[jboss-cvs] JBossAS SVN: r64671 - branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 17 15:55:01 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-08-17 15:55:01 -0400 (Fri, 17 Aug 2007)
New Revision: 64671
Added:
branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
Log:
[JBAS-4574] Test naming restart
Added: branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java (rev 0)
+++ branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java 2007-08-17 19:55:01 UTC (rev 64671)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.naming.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.naming.restart.ObjectBinder;
+
+/**
+ * A NamingRestartUnitTestCase.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class NamingRestartUnitTestCase extends JBossTestCase
+{
+ private static final String namingPort = "19099";
+ private static final String haNamingPort = "19100";
+
+ private static boolean deployed = true;
+
+ public NamingRestartUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(NamingRestartUnitTestCase.class, "naming-restart.sar");
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ if (!deployed)
+ deploy("naming-restart.sar");
+ }
+
+ public void testLookupAfterHANamingRestart() throws Exception
+ {
+ log.info("Running testLookupAfterHANamingRestart");
+
+ namingRestartTest(haNamingPort);
+ }
+
+ public void testLookupAfterNamingRestart() throws Exception
+ {
+ log.info("Running testLookupAfterNamingRestart");
+
+ namingRestartTest(namingPort);
+ }
+
+ private void namingRestartTest(String port) throws Exception
+ {
+ String namingURL = getServerHost() + ":" + port;
+ Properties env = new Properties();
+ env.setProperty("java.naming.provider.url", namingURL);
+ env.setProperty("jnp.disableDiscovery", "true");
+
+ Context ctx1 = new InitialContext(env);
+ assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
+
+ // HOLD ONTO REF to ctx1 so the ref to it does not get gc'ed from
+ // static map in org.jnp.interfaces.NamingContext.
+
+ // Redeploy the naming service
+ deployed = false;
+ redeploy("naming-restart.sar");
+ deployed = true;
+
+ Context ctx2 = new InitialContext(env);
+ NamingException ne = null;
+ try
+ {
+ assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
+ }
+ catch (NamingException e)
+ {
+ // Cache the exception to fail the test later, after
+ // we check that we can recover
+ log.error("Caught NamingException", e);
+ ne = e;
+ }
+
+ // We recover from failure
+ if (ne != null)
+ {
+ try
+ {
+ assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to reacquire server");
+ }
+ // Now fail due to the earlier failure
+ fail(ne.getMessage());
+ }
+
+
+ }
+
+}
Property changes on: branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list