1 package org.smartcomps.twister.engine.core;
2
3 import junit.framework.TestCase;
4
5 import org.smartcomps.twister.engine.priv.core.definition.PropertyFactory;
6 import org.smartcomps.twister.engine.priv.core.definition.Property;
7 import org.smartcomps.twister.common.transaction.TransactionManager;
8 import org.smartcomps.twister.common.lifecycle.LifecycleManager;
9
10 import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
11 import net.sf.hibernate.cfg.Configuration;
12
13 /***
14 * Simple test class for the PropertyFactory, basically tests the most
15 * simple create / find / update case.
16 */
17 public class TestProperty extends TestCase {
18
19 private PropertyFactory factory = new PropertyFactory();
20
21 protected void setUp() throws Exception {
22 LifecycleManager.getLifecycleManager().createResources();
23 LifecycleManager.getLifecycleManager().startResources();
24
25 SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
26 schemaExport.create(true, true);
27
28 TransactionManager.beginTransaction();
29 }
30
31 protected void tearDown() throws Exception {
32 TransactionManager.commitTransaction();
33
34 LifecycleManager.getLifecycleManager().stopResources();
35 LifecycleManager.getLifecycleManager().destroyResources();
36 }
37
38 public void testCreate() throws Exception {
39 Property prop = factory.createProperty("test", "xsd:string");
40 }
41
42 public void testUpdate() throws Exception {
43 factory.createProperty("testUpdate", "xsd:integer");
44
45 Property prop = factory.getByName("testUpdate");
46 prop.setType("xsd:long");
47
48 Property prop2 = factory.getByName("testUpdate");
49 assertEquals("Updated property type and found one are different !", "xsd:long", prop2.getType());
50 }
51
52 public void testGetByName() throws Exception {
53 factory.createProperty("testGetByName", "xsd:integer");
54
55 Property prop = factory.getByName("testGetByName");
56 assertEquals("Created property type and found one are different !", "xsd:integer", prop.getType());
57 }
58 }
This page was automatically generated by Maven