1 22 package org.jboss.ejb3.test.lob.unit; 23 24 import java.io.ByteArrayInputStream ; 25 import java.io.ObjectInputStream ; 26 import java.util.HashMap ; 27 import java.util.Map ; 28 import org.jboss.ejb3.test.lob.BlobEntity2; 29 import org.jboss.ejb3.test.lob.LobTester; 30 import org.jboss.test.JBossTestCase; 31 import junit.framework.Test; 32 33 39 40 public class BlobUnitTestCase 41 extends JBossTestCase 42 { 43 org.jboss.logging.Logger log = getLog(); 44 45 static boolean deployed = false; 46 static int test = 0; 47 48 public BlobUnitTestCase(String name) 49 { 50 51 super(name); 52 53 } 54 55 public void testBlob() throws Exception 56 { 57 LobTester test = (LobTester) this.getInitialContext().lookup("LobTesterBean/remote"); 58 long blobId = test.create(); 59 HashMap map = test.findBlob(blobId); 60 assertEquals("world", map.get("hello")); 61 String str = test.findClob(blobId); 62 assertTrue(str.startsWith("This is a very long string")); 63 } 64 65 public void testBlob2() throws Exception 66 { 67 LobTester test = (LobTester) this.getInitialContext().lookup("LobTesterBean/remote"); 68 long blobId = test.create2(); 69 BlobEntity2 blob = test.findBlob2(blobId); 70 ObjectInputStream ois = new ObjectInputStream (new ByteArrayInputStream (blob.getBlobby())); 71 Map map = (HashMap ) ois.readObject(); 72 73 assertEquals("world", map.get("hello")); 74 assertTrue(blob.getClobby().startsWith("This is a very long string")); 75 } 76 77 public static Test suite() throws Exception 78 { 79 return getDeploySetup(BlobUnitTestCase.class, "lob-test.jar"); 80 } 81 82 } 83 | Popular Tags |