[jboss-cvs] JBossAS SVN: r66223 - in trunk/testsuite: src/main/org/jboss/test/cluster/defaultcfg/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 17 14:09:38 EDT 2007
Author: galder.zamarreno at jboss.com
Date: 2007-10-17 14:09:37 -0400 (Wed, 17 Oct 2007)
New Revision: 66223
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonControllerBeanUnitTestCase.java
trunk/testsuite/src/resources/cluster/hasingleton/ha-singleton-beans.xml
Modified:
trunk/testsuite/imports/sections/cluster.xml
Log:
[JBAS-4180] Created a bean descriptor file containing definition of an HA singleton pojo and corresponding HASingletonController bean without JMX annotation. Also created a unit test case to test the deployment of a singleton pojo.
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2007-10-17 18:07:20 UTC (rev 66222)
+++ trunk/testsuite/imports/sections/cluster.xml 2007-10-17 18:09:37 UTC (rev 66223)
@@ -81,6 +81,11 @@
<copy todir="${build.lib}"
file="${build.resources}/cluster/hasingleton/electionpolicy/ha-electionpolicy-beans.xml"
overwrite="true"/>
+
+ <!--beans for testing HASingletonControllerBeanUnitTestCase -->
+ <copy todir="${build.lib}"
+ file="${build.resources}/cluster/hasingleton/ha-singleton-beans.xml"
+ overwrite="true"/>
<!-- ha-invoker adaptor sar -->
<jar destfile="${build.lib}/ha-invoker.sar">
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonControllerBeanUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonControllerBeanUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonControllerBeanUnitTestCase.java 2007-10-17 18:09:37 UTC (rev 66223)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.cluster.defaultcfg.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.ha.singleton.examples.HASingletonPojoExample;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * HASingletonControllerBeanUnitTestCase.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class HASingletonControllerBeanUnitTestCase extends JBossClusteredTestCase
+{
+ public HASingletonControllerBeanUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(HASingletonControllerBeanUnitTestCase.class, "ha-singleton-beans.xml");
+ }
+
+ public void testBeanDeployment() throws Exception
+ {
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+
+ String[] namingUrls = getNamingURLs();
+
+ String namingUrl = namingUrls[0];
+ env.setProperty(Context.PROVIDER_URL, namingUrl);
+ Context ctx = new InitialContext(env);
+ HASingletonPojoExample pojo = (HASingletonPojoExample)ctx.lookup("test/cluster/hasingleton/simplepojo");
+
+ assertTrue("Pojo in " + namingUrl + " should be deployed as HA singleton", pojo.isMasterNode());
+
+ namingUrl = namingUrls[1];
+ env.setProperty(Context.PROVIDER_URL, namingUrl);
+ ctx = new InitialContext(env);
+ try
+ {
+ pojo = (HASingletonPojoExample)ctx.lookup("test/cluster/hasingleton/simplepojo");
+ fail("Should have thrown a NamingException indicating 'test not bound'");
+ }
+ catch(NamingException ne)
+ {
+ }
+ }
+
+}
Added: trunk/testsuite/src/resources/cluster/hasingleton/ha-singleton-beans.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/hasingleton/ha-singleton-beans.xml (rev 0)
+++ trunk/testsuite/src/resources/cluster/hasingleton/ha-singleton-beans.xml 2007-10-17 18:09:37 UTC (rev 66223)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean class="org.jboss.ha.singleton.examples.HASingletonPojoExample"
+ name="SimpleHaSingletonPojo">
+
+ <constructor><parameter>test/cluster/hasingleton/simplepojo</parameter></constructor>
+
+ </bean>
+
+ <bean class="org.jboss.ha.singleton.HASingletonController"
+ name="SimpleHaSingletonController">
+
+ <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ <property name="target"><inject bean="SimpleHaSingletonPojo"/></property>
+ <property name="targetStartMethod">startSingleton</property>
+ <property name="targetStopMethod">stopSingleton</property>
+
+ </bean>
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list