jboynes     2005/07/31 15:32:24

  Modified:    modules/itests/src/itest/org/openejb/test/entity/cmp2
                        StorageTests.java
  Log:

  Add tests for byte[] cmp fields; require tranql 1.1
  
  Revision  Changes    Path
  1.2       +27 -18    
openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/StorageTests.java
  
  Index: StorageTests.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/itests/src/itest/org/openejb/test/entity/cmp2/StorageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StorageTests.java 29 Jul 2005 22:29:44 -0000      1.1
  +++ StorageTests.java 31 Jul 2005 19:32:23 -0000      1.2
  @@ -48,7 +48,7 @@
   package org.openejb.test.entity.cmp2;
   
   import java.util.Properties;
  -
  +import java.util.Arrays;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   
  @@ -64,27 +64,30 @@
   public class StorageTests extends NamedTestCase {
       private InitialContext initialContext;
       private StorageHome ejbHome;
  +    private StorageRemote storage;
  +    private byte[] testdata;
   
       public StorageTests() {
           super("StorageTests.");
       }
   
  -    public void testStorageBlob() {
  -        try {
  -            byte[] blob = "this is a test".getBytes();
  -            
  -            ejbHome = (StorageHome) 
javax.rmi.PortableRemoteObject.narrow(initialContext.lookup("cmp2/Storage"), 
StorageHome.class);
  -            StorageRemote storage = ejbHome.create(new Integer(1));
  -            storage.setBlob(blob);
  -
  -            byte[] readBlob = storage.getBlob();
  -            assertEquals(blob.length, readBlob.length);
  -            for (int i = 0; i < readBlob.length; i++) {
  -                assertEquals(blob[i], readBlob[i]);
  -            }
  -        } catch (Exception e) {
  -            fail("Received Exception " + e.getClass() + " : " + 
e.getMessage());
  -        }
  +    public void testStorageBlob() throws Exception {
  +
  +        storage.setBlob(testdata);
  +        byte[] readBlob = storage.getBlob();
  +        assertTrue(Arrays.equals(testdata, readBlob));
  +    }
  +
  +    public void testReadBlob() throws Exception {
  +        storage.setBlob(testdata);
  +        byte[] readbytes = storage.getBytes();
  +        assertTrue(Arrays.equals(testdata, readbytes));
  +    }
  +
  +    public void testWriteBlob() throws Exception {
  +        storage.setBytes(testdata);
  +        byte[] readblob = storage.getBlob();
  +        assertTrue(Arrays.equals(testdata, readblob));
       }
   
       protected void setUp() throws Exception {
  @@ -93,8 +96,14 @@
           properties.put(Context.SECURITY_CREDENTIALS, "ENTITY_TEST_CLIENT");
   
           initialContext = new InitialContext(properties);
  +
  +        ejbHome = (StorageHome) 
javax.rmi.PortableRemoteObject.narrow(initialContext.lookup("cmp2/Storage"), 
StorageHome.class);
  +        storage = ejbHome.create(new Integer(1));
  +
  +        testdata = "this is a test".getBytes();
       }
   
       protected void tearDown() throws Exception {
  +        storage.remove();
       }
   }
  
  
  

Reply via email to