01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.ejbthree921.unit;
23:
24: import java.util.Properties;
25:
26: import javax.naming.Context;
27: import javax.naming.InitialContext;
28:
29: import junit.framework.Test;
30:
31: import org.jboss.ejb3.test.ejbthree921.MyStateful;
32: import org.jboss.ejb3.test.ejbthree921.Person;
33: import org.jboss.test.JBossTestCase;
34:
35: import org.jboss.test.JBossClusteredTestCase;
36:
37: /**
38: * Comment
39: *
40: * @author <a href="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
41: * @version $Revision: $
42: */
43: public class PersistenceContextReplicationTestCase extends
44: JBossClusteredTestCase {
45:
46: public PersistenceContextReplicationTestCase(String name) {
47: super (name);
48: }
49:
50: protected InitialContext getInitialContext(int node)
51: throws Exception {
52: // Connect to the server0 JNDI
53: String[] urls = getNamingURLs();
54: Properties env1 = new Properties();
55: env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
56: "org.jnp.interfaces.NamingContextFactory");
57: env1.setProperty(Context.PROVIDER_URL, urls[node]);
58: return new InitialContext(env1);
59: }
60:
61: public void test1() throws Exception {
62: MyStateful stateful = (MyStateful) getInitialContext(0).lookup(
63: "MyStatefulBean/remote");
64: Person p = new Person("Brian");
65: stateful.save(p);
66: String expected = "Changing SFSB state";
67: stateful.setDescription(expected);
68: stateful.setUpFailover("once");
69: try {
70: String actual = stateful.getDescription();
71: assertEquals(expected, actual);
72: } catch (Exception e) {
73: Throwable cause = e;
74: while (cause.getCause() != null)
75: cause = cause.getCause();
76: throw (Exception) cause;
77: }
78: stateful.remove(p);
79: stateful.done();
80: }
81:
82: public static Test suite() throws Exception {
83: return getDeploySetup(
84: PersistenceContextReplicationTestCase.class,
85: "ejbthree921.jar");
86: }
87:
88: }
|