1 22 package org.jboss.test.entity.test; 23 24 import junit.framework.Test; 25 26 import org.jboss.test.JBossTestCase; 27 28 import org.jboss.test.entity.interfaces.TestEntity; 29 import org.jboss.test.entity.interfaces.TestEntityHome; 30 import org.jboss.test.entity.interfaces.TestEntityUtil; 31 import org.jboss.test.entity.interfaces.TestEntityValue; 32 33 39 public class EntityUnitTestCase 40 extends JBossTestCase 41 { 42 public EntityUnitTestCase(String name) 43 { 44 super(name); 45 } 46 47 public static Test suite() 48 throws Exception 49 { 50 return getDeploySetup(EntityUnitTestCase.class, "jboss-test-entity.jar"); 51 } 52 53 public void testExternalRemoveAfterCreateThenRecreate() 54 throws Exception 55 { 56 getLog().debug("Retrieving home"); 57 TestEntityHome home = TestEntityUtil.getHome(); 58 59 getLog().debug("Creating entity"); 60 TestEntityValue value = new TestEntityValue("key1", null); 61 home.create(value); 62 63 getLog().debug("Removing entity externally"); 64 home.removeExternal("key1"); 65 66 getLog().debug("Recreating the entity"); 67 home.create(value); 68 } 69 70 public void testInternalHomeRemoveAfterCreateThenRecreate() 71 throws Exception 72 { 73 getLog().debug("Retrieving home"); 74 TestEntityHome home = TestEntityUtil.getHome(); 75 76 getLog().debug("Creating entity"); 77 TestEntityValue value = new TestEntityValue("key2", null); 78 home.create(value); 79 80 getLog().debug("Removing entity internally"); 81 home.remove("key2"); 82 83 getLog().debug("Recreating the entity"); 84 home.create(value); 85 } 86 87 public void testInternalBeanRemoveAfterCreateThenRecreate() 88 throws Exception 89 { 90 getLog().debug("Retrieving home"); 91 TestEntityHome home = TestEntityUtil.getHome(); 92 93 getLog().debug("Creating entity"); 94 TestEntityValue value = new TestEntityValue("key3", null); 95 TestEntity bean = home.create(value); 96 97 getLog().debug("Removing entity internally"); 98 bean.remove(); 99 100 getLog().debug("Recreating the entity"); 101 home.create(value); 102 } 103 104 public void testChangeReadOnlyField() 105 throws Exception 106 { 107 getLog().debug("Retrieving home"); 108 TestEntityHome home = TestEntityUtil.getHome(); 109 110 getLog().debug("Creating entity"); 111 TestEntityValue value = new TestEntityValue("key4", "original"); 112 TestEntity bean = home.create(value); 113 114 getLog().debug("Access the value"); 115 assertEquals("original", bean.getValue1()); 116 117 getLog().debug("Change the value"); 118 home.changeValue1("key4", "changed"); 119 assertEquals("changed", bean.getValue1()); 120 } 121 } 122 | Popular Tags |