KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > lob > unit > BlobUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.lob.unit;
23
24 import java.io.ByteArrayInputStream JavaDoc;
25 import java.io.ObjectInputStream JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
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 /**
34  * Sample client for the jboss container.
35  *
36  * @author <a HREF="mailto:bill@burkecentral.com">Bill Burke</a>
37  * @version $Id: BlobUnitTestCase.java 58110 2006-11-04 08:34:21Z scott.stark@jboss.org $
38  */

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 JavaDoc name)
49    {
50
51       super(name);
52
53    }
54
55    public void testBlob() throws Exception JavaDoc
56    {
57       LobTester test = (LobTester) this.getInitialContext().lookup("LobTesterBean/remote");
58       long blobId = test.create();
59       HashMap JavaDoc map = test.findBlob(blobId);
60       assertEquals("world", map.get("hello"));
61       String JavaDoc str = test.findClob(blobId);
62       assertTrue(str.startsWith("This is a very long string"));
63    }
64
65    public void testBlob2() throws Exception JavaDoc
66    {
67       LobTester test = (LobTester) this.getInitialContext().lookup("LobTesterBean/remote");
68       long blobId = test.create2();
69       BlobEntity2 blob = test.findBlob2(blobId);
70       ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(new ByteArrayInputStream JavaDoc(blob.getBlobby()));
71       Map JavaDoc map = (HashMap JavaDoc) 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 JavaDoc
78    {
79       return getDeploySetup(BlobUnitTestCase.class, "lob-test.jar");
80    }
81
82 }
83
Popular Tags