KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > ReplicatedNonSerializableTest


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.cache.pojo;
9
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestSuite;
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15
16 import javax.naming.Context JavaDoc;
17 import java.util.Properties JavaDoc;
18
19 /**
20  * New NewReplicatedAopTest that doesn't use TreeCacheAopTester.
21  *
22  * @author Ben Wang
23  */

24
25 public class ReplicatedNonSerializableTest extends TestCase
26 {
27    Log log_ = LogFactory.getLog(ReplicatedNonSerializableTest.class);
28    PojoCache cache_;
29    PojoCache cache1_;
30
31    public ReplicatedNonSerializableTest(String JavaDoc name)
32    {
33       super(name);
34    }
35
36    protected void setUp() throws Exception JavaDoc
37    {
38       super.setUp();
39       Properties JavaDoc prop = new Properties JavaDoc();
40       prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
41       boolean toStart = false;
42       cache_ = PojoCacheFactory.createCache("META-INF/replSync-service.xml", toStart);
43       cache1_ = PojoCacheFactory.createCache("META-INF/replSync-service.xml", toStart);
44       cache_.start();
45       cache1_.start();
46    }
47
48    protected void tearDown() throws Exception JavaDoc
49    {
50       super.tearDown();
51       cache_.stop();
52       cache1_.stop();
53    }
54
55    public void testDummy()
56    {
57    }
58
59    /* JBCACHE-770
60    public void testNonSeriazable1() throws Exception
61    {
62       log_.info("testNonSerializable1() ....");
63       // First the flag is set to false
64       NonSerializableObject nso = new NonSerializableObject();
65       nso.setId("2");
66       try {
67          cache_.attach("/test", nso);
68          fail("should fail becuase vo is not Serializable");
69       }
70       catch (RuntimeException e) {
71       }
72
73       // Then we set the flag
74       cache_.setMarshallNonSerializable(true);
75       cache1_.setMarshallNonSerializable(true);
76       cache_.attach("/test", nso);
77       NonSerializableObject nso1 = (NonSerializableObject)cache1_.find("/test");
78       assertNotNull("nso on remote cache should not be null", nso1);
79       assertEquals("VO should be the same", nso, nso1);
80
81    }
82
83    public void testNonSeriazable2() throws Exception
84    {
85       log_.info("testNonSerializable2() ....");
86       // First the flag is set to false
87       NonSerializableObject nso = new NonSerializableObject();
88       nso.setId("2");
89
90       // Then we set the flag
91       cache_.setMarshallNonSerializable(true);
92       cache1_.setMarshallNonSerializable(true);
93       cache_.attach("/test", nso);
94       NonSerializableObject nso1 = (NonSerializableObject)cache1_.find("/test");
95       assertNotNull("nso on remote cache should not be null", nso1);
96       assertEquals("VO should be the same", nso, nso1);
97
98       nso1 = new NonSerializableObject();
99       nso1.setId("4");
100       cache1_.attach("/test", nso1);
101       nso = (NonSerializableObject)cache_.find("/test");
102       assertNotNull("nso on remote cache should not be null", nso);
103       assertEquals("VO should be the same", nso, nso1);
104
105    }
106
107 */

108
109    public static Test suite() throws Exception JavaDoc
110    {
111       return new TestSuite(ReplicatedNonSerializableTest.class);
112    }
113
114
115    public static void main(String JavaDoc[] args) throws Exception JavaDoc
116    {
117       junit.textui.TestRunner.run(ReplicatedNonSerializableTest.suite());
118    }
119
120 }
121
Popular Tags