[jboss-cvs] JBossAS SVN: r87443 - trunk/testsuite/imports/sections and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 16 12:42:53 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-04-16 12:42:53 -0400 (Thu, 16 Apr 2009)
New Revision: 87443
Added:
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/TruthfulResponseFilterUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/
trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/Echo.java
trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/EchoMBean.java
trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java
trunk/testsuite/src/resources/cluster/rspfilter/
trunk/testsuite/src/resources/cluster/rspfilter/META-INF/
trunk/testsuite/src/resources/cluster/rspfilter/META-INF/jboss-service.xml
trunk/testsuite/src/resources/ejb/proxy/META-INF/
trunk/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml
trunk/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml
Removed:
branches/JBPAPP_4_3_0_GA_CP03_JBPAPP-1686/testsuite/src/main/org/jboss/test/ejb/proxy/beans/
Modified:
trunk/testsuite/imports/sections/cluster.xml
Log:
[JBAS-5703] Added standalone lookup response filter unit test and in server, call on cluster with response filter test.
Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml 2009-04-16 16:31:31 UTC (rev 87442)
+++ trunk/testsuite/imports/sections/cluster.xml 2009-04-16 16:42:53 UTC (rev 87443)
@@ -807,6 +807,13 @@
<include name="org/jboss/test/cluster/ejb2/ustxsticky/*"/>
</fileset>
</zip>
+
+ <zip destfile="${build.lib}/rspfilter.sar">
+ <zipfileset dir="${build.resources}/cluster/rspfilter"/>
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/cluster/rspfilter/*"/>
+ </fileset>
+ </zip>
</target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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 junit.framework.TestCase;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+import org.jboss.ha.framework.server.ClusterNodeImpl;
+import org.jboss.ha.framework.server.ClusterPartition;
+import org.jboss.ha.framework.server.RspFilterAdapter;
+import org.jboss.ha.jndi.LookupSucceededFilter;
+import org.jgroups.Address;
+import org.jgroups.blocks.RspFilter;
+import org.jgroups.stack.IpAddress;
+
+/**
+ * LookupSucceededFilterUnitTestCase.
+ *
+ * @author Galder Zamarreño
+ */
+public class LookupSucceededFilterUnitTestCase extends TestCase
+{
+ public void testFilterLogic()
+ {
+ ResponseFilter filter = new LookupSucceededFilter();
+ ClusterNode sender = new ClusterNodeImpl(new IpAddress(12345));
+ exerciseFilterLogic(filter, sender);
+ }
+
+ public void testFilterLogicViaAdapter()
+ {
+ ResponseFilter filter = new LookupSucceededFilter();
+ Address sender = new IpAddress(12345);
+ RspFilterAdapter adapter = new RspFilterAdapter(filter);
+ exerciseFilterLogic(adapter, sender);
+ }
+
+ private void exerciseFilterLogic(ResponseFilter filter, ClusterNode sender)
+ {
+ filter.isAcceptable(null, sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new Exception(), sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new ClusterPartition.NoHandlerForRPC(), sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new String(), sender);
+ assertFalse(filter.needMoreResponses());
+ }
+
+ private void exerciseFilterLogic(RspFilter filter, Address sender)
+ {
+ filter.isAcceptable(null, sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new Exception(), sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new ClusterPartition.NoHandlerForRPC(), sender);
+ assertTrue(filter.needMoreResponses());
+
+ filter.isAcceptable(new String(), sender);
+ assertFalse(filter.needMoreResponses());
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/TruthfulResponseFilterUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/TruthfulResponseFilterUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/TruthfulResponseFilterUnitTestCase.java 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.rspfilter.TruthfulResponseFilter;
+
+/**
+ * TruthfulResponseFilterUnitTestCase.
+ *
+ * @author Galder Zamarreño
+ */
+public class TruthfulResponseFilterUnitTestCase extends JBossClusteredTestCase
+{
+ public TruthfulResponseFilterUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(TruthfulResponseFilterUnitTestCase.class, "rspfilter.sar");
+ }
+
+ public void testTrueEcho() throws Exception
+ {
+ MBeanServerConnection[] adaptors = this.getAdaptors();
+ ObjectName on = new ObjectName("cluster.rspfilter:service=Echo");
+ ResponseFilter filter = new TruthfulResponseFilter();
+ Object[] args = new Object[] {true, false, filter};
+ String[] signature = new String[] {boolean.class.getName(), boolean.class.getName(),ResponseFilter.class.getName()};
+ List resps = (List) adaptors[0].invoke(on, "callEchoOnCluster", args, signature);
+ log.debug("Response list: " + resps);
+ assertEquals(1, resps.size());
+
+ if (resps.get(0) instanceof Exception)
+ {
+ throw (Exception)resps.get(0);
+ }
+
+ assertTrue(((Boolean)resps.get(0)).booleanValue());
+ }
+
+// Commented from the time being since it results of call timing out since there'd be no responses
+// and this will force 1 minute wait. testTrueEcho() is enough to give us an indication of
+// response filter being in action.
+//
+// public void testFalseEcho() throws Exception
+// {
+// MBeanServerConnection[] adaptors = this.getAdaptors();
+// ObjectName on = new ObjectName("cluster.rspfilter:service=Echo");
+// ResponseFilter filter = new TruthfulResponseFilter();
+// Object[] args = new Object[] {false, false, filter};
+// String[] signature = new String[] {boolean.class.getName(), boolean.class.getName(),ResponseFilter.class.getName()};
+// List resps = (List) adaptors[0].invoke(on, "callEchoOnCluster", args, signature);
+// log.debug("Response list: " + resps);
+// assertEquals(0, resps.size());
+// }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/Echo.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/Echo.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/Echo.java 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.rspfilter;
+
+import java.util.List;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+import org.jboss.logging.Logger;
+
+/**
+ * Echo.
+ *
+ * @author Galder Zamarreño
+ */
+public class Echo implements EchoMBean
+{
+ private static final Logger log = Logger.getLogger(Echo.class);
+ private static final String NAME = "cluster.rspfilter:service=Echo";
+ private HAPartition partition;
+
+ public boolean echo(boolean echo, ClusterNode sender)
+ {
+ // Only reply echo if I'm *not* the node that send it.
+ if (!sender.equals(partition.getClusterNode()))
+ {
+ return echo;
+ }
+ return false;
+ }
+
+ public void setHAPartition(HAPartition partition)
+ {
+ log.debug("Set partition: " + partition);
+ this.partition = partition;
+ }
+
+ public List callEchoOnCluster(boolean echo, boolean excludeSelf, ResponseFilter filter) throws Exception
+ {
+ log.debug("callEchoOnCluster(" + echo+ ", " + excludeSelf + ", " + filter+ ")");
+ return partition.callMethodOnCluster(NAME, "echo", new Object[] {echo, partition.getClusterNode()},
+ new Class[] {boolean.class, ClusterNode.class}, excludeSelf, filter);
+ }
+
+ public void start() throws Exception
+ {
+ log.debug("Register rpc handler " + this + " with " + NAME);
+ partition.registerRPCHandler(NAME, this);
+ }
+
+ public void stop() throws Exception
+ {
+ log.debug("Unregister rpc handler " + this + " with " + NAME);
+ partition.unregisterRPCHandler(NAME, this);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/EchoMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/EchoMBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/EchoMBean.java 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.rspfilter;
+
+import java.util.List;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+
+/**
+ * EchoMBean.
+ *
+ * @author Galder Zamarreño
+ */
+public interface EchoMBean
+{
+ boolean echo(boolean echo, ClusterNode sender);
+ void start() throws Exception;
+ void stop() throws Exception;
+ void setHAPartition(HAPartition clusterPartition);
+ List callEchoOnCluster(boolean echo, boolean excludeSelf, ResponseFilter filter) throws Exception;
+}
Added: trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.rspfilter;
+
+import java.io.Serializable;
+
+import org.jboss.ha.framework.interfaces.ClusterNode;
+import org.jboss.ha.framework.interfaces.ResponseFilter;
+import org.jboss.ha.framework.server.ClusterPartition.NoHandlerForRPC;
+import org.jboss.logging.Logger;
+
+/**
+ * TruthfulResponseFilter.
+ *
+ * @author Galder Zamarreño
+ */
+public class TruthfulResponseFilter implements ResponseFilter, Serializable
+{
+ private static final long serialVersionUID = 2223820538160300865L;
+ private static final Logger log = Logger.getLogger(TruthfulResponseFilter.class);
+ private boolean lookupSucceeded;
+
+ public boolean isAcceptable(Object response, ClusterNode sender)
+ {
+ log.debug("isAcceptable (" + response + ") from " + sender);
+
+ if (response != null && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC))
+ {
+ lookupSucceeded = (Boolean)response;
+ }
+
+ if (lookupSucceeded)
+ {
+ log.debug("Lookup succeded from " + sender);
+ }
+
+ return lookupSucceeded;
+ }
+
+ public boolean needMoreResponses()
+ {
+ log.debug("needMoreResponses? " + !(lookupSucceeded));
+ return !(lookupSucceeded);
+ }
+
+}
Added: trunk/testsuite/src/resources/cluster/rspfilter/META-INF/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/cluster/rspfilter/META-INF/jboss-service.xml (rev 0)
+++ trunk/testsuite/src/resources/cluster/rspfilter/META-INF/jboss-service.xml 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+ <mbean code="org.jboss.test.cluster.rspfilter.Echo" name="cluster.rspfilter:service=Echo">
+ <attribute name="HAPartition"><inject bean="HAPartition"/></attribute>
+ </mbean>
+</server>
Added: trunk/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml
===================================================================
--- trunk/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml (rev 0)
+++ trunk/testsuite/src/resources/ejb/proxy/META-INF/ejb-jar.xml 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ version="2.1">
+ <enterprise-beans>
+ <session>
+ <ejb-name>StatefulCounterEjb</ejb-name>
+ <home>org.jboss.test.ejb.proxy.beans.StatefulCounterHome</home>
+ <remote>org.jboss.test.ejb.proxy.beans.StatefulCounter</remote>
+ <ejb-class>org.jboss.test.ejb.proxy.beans.StatefulCounterBean</ejb-class>
+ <session-type>Stateful</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
\ No newline at end of file
Added: trunk/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml
===================================================================
--- trunk/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml (rev 0)
+++ trunk/testsuite/src/resources/ejb/proxy/META-INF/jboss.xml 2009-04-16 16:42:53 UTC (rev 87443)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+<jboss>
+ <enterprise-beans>
+ <session>
+ <ejb-name>StatefulCounterEjb</ejb-name>
+ <jndi-name>ejb/StatefulCounterEjb</jndi-name>
+ <configuration-name>Mock Standard Stateful SessionBean</configuration-name>
+ </session>
+ </enterprise-beans>
+
+ <invoker-proxy-bindings>
+ <invoker-proxy-binding>
+ <name>mock-stateful-unified-invoker</name>
+ <invoker-mbean>jboss:service=invoker,type=unified</invoker-mbean>
+ <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
+ <proxy-factory-config>
+ <client-interceptors>
+ <home>
+ <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
+ <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
+ </home>
+ <bean>
+ <interceptor>org.jboss.test.ejb.proxy.beans.HandleRetrievalStatefulSessionInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
+ <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
+ <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
+ </bean>
+ </client-interceptors>
+ </proxy-factory-config>
+ </invoker-proxy-binding>
+ </invoker-proxy-bindings>
+
+ <container-configurations>
+ <container-configuration extends="Standard Stateful SessionBean">
+ <container-name>Mock Standard Stateful SessionBean</container-name>
+ <invoker-proxy-binding-name>mock-stateful-unified-invoker</invoker-proxy-binding-name>
+ </container-configuration>
+ </container-configurations>
+</jboss>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list