1 25 26 package org.objectweb.jonas.jtests.clients.entity; 27 28 import javax.naming.NamingException ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import junit.framework.Test; 32 import junit.framework.TestSuite; 33 34 import org.objectweb.jonas.jtests.beans.annuaire.Personne; 35 import org.objectweb.jonas.jtests.beans.annuaire.PersonneHome; 36 import org.objectweb.jonas.jtests.util.JTestCase; 37 38 43 public class F_IsModified extends JTestCase { 44 45 private static String BEAN_HOME = "annuairePersonneECHome"; 46 protected static PersonneHome ehome = null; 47 String mynum = "63800"; 48 String myname = "Max"; 49 50 public F_IsModified(String name) { 51 super(name); 52 } 53 54 protected void setUp() { 55 super.setUp(); 56 if (ehome == null) { 57 useBeans("annuaire", true); 58 try { 59 ehome = (PersonneHome) PortableRemoteObject.narrow(ictx.lookup(BEAN_HOME), PersonneHome.class); 60 } catch (NamingException e) { 61 fail("Cannot get bean home"); 62 } 63 } 64 } 65 66 69 public void testNotModified() throws Exception { 70 71 Personne acc = ehome.create(myname, mynum); 72 73 acc.reset(); 75 utx.begin(); 76 acc.getNom(); 77 assertTrue(! acc.isDirty()); 78 utx.commit(); 79 assertTrue(! acc.ejbStoreCalled()); 80 assertTrue(acc.isModifiedCalled()); 81 82 acc.remove(); 83 } 84 85 88 public void testModified() throws Exception { 89 90 Personne acc = ehome.create(myname, mynum); 91 String os = "100"; 92 93 acc.reset(); 95 utx.begin(); 96 acc.setNumero(os); 97 assertTrue(acc.isDirty()); 98 utx.commit(); 99 assertTrue(acc.ejbStoreCalled()); 100 assertTrue(acc.isModifiedCalled()); 101 102 String ns = acc.getNumero(); 103 assertTrue(ns.equals(os)); 104 assertTrue(! acc.isDirty()); 105 106 acc.remove(); 107 } 108 109 public static Test suite() { 110 return new TestSuite(F_IsModified.class); 111 } 112 113 public static void main (String args[]) { 114 String testtorun = null; 115 for (int argn = 0; argn < args.length; argn++) { 117 String s_arg = args[argn]; 118 Integer i_arg; 119 if (s_arg.equals("-n")) { 120 testtorun = args[++argn]; 121 } 122 } 123 if (testtorun == null) { 124 junit.textui.TestRunner.run(suite()); 125 } else { 126 junit.textui.TestRunner.run(new F_IsModified(testtorun)); 127 } 128 } 129 } 130 | Popular Tags |