1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.businessobjects.environment.persistence;
16
17 import org.figure8.join.util.SpringTestCase;
18 import org.figure8.join.businessobjects.environment.Machine;
19 /**
20 * JUnit test case for testing MachineDao implementation.
21 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
22 * @version $Revision: 1.1 $
23 */
24 public class MachineDaoTest extends SpringTestCase{
25
26
27
28 /** Spring configuration files */
29 private String[] configLocations = new String[]{"classpath:/org/figure8/join/businessobjects/environment/persistence/spring.xml"};
30
31
32
33
34 /** The MachineDao implementation to test */
35 protected MachineDao dao = null;
36
37
38
39
40 /** Retrieve MachineDao implementation after having initialized context */
41 public void setUp(){
42 super.setUp();
43
44 dao = (MachineDao)context.getBean("machineDao");
45 }
46
47
48
49
50 /** Test the creation of a machine */
51 public void testMachineCreation(){
52
53 Machine machine = new Machine("creation.myorg.org", "127.0.0.1");
54 int size = getMachineListSize();
55 dao.save(machine);
56
57 assertEquals("Machine is successfully created", size + 1, dao.findAll().size());
58 }
59
60 /** Test the getMachine() method with name as parameter */
61
62
63 /** Test the removal of a machine */
64
65
66
67
68
69 /** Test the findAll on Machine */
70 protected int getMachineListSize(){
71 return dao.findAll().size();
72 }
73
74
75
76
77 /** @return An array of locations from Spring configuration files. */
78 public String[] getConfigLocations(){
79 return configLocations;
80 }
81 }