Author: julien(a)jboss.com
Date: 2007-01-10 17:37:23 -0500 (Wed, 10 Jan 2007)
New Revision: 5985
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java
Modified:
trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml
trunk/portlet/build.xml
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java
trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml
trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java
trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java
trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java
Log:
- ported portlet session replication changes test from 2.4 to trunk
- make the multi server tests work in trunk (was disabled after the test framework
refactorings)
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml 2007-01-10 20:01:45
UTC (rev 5984)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/jboss-web.xml 2007-01-10 22:37:23
UTC (rev 5985)
@@ -26,7 +26,7 @@
<security-domain>java:jaas/portal</security-domain>
<context-root>@portal.web.context-root(a)</context-root>
<replication-config>
- <replication-trigger>SET_AND_GET</replication-trigger>
+ <replication-trigger>SET</replication-trigger>
</replication-config>
<resource-ref>
<res-ref-name>jdbc/PortalDS</res-ref-name>
Modified: trunk/portlet/build.xml
===================================================================
--- trunk/portlet/build.xml 2007-01-10 20:01:45 UTC (rev 5984)
+++ trunk/portlet/build.xml 2007-01-10 22:37:23 UTC (rev 5985)
@@ -345,6 +345,7 @@
<fileset dir="${build.resources}/test/ha/test-session-war"/>
<fileset dir="${build.classes}"
includes="org/jboss/portal/test/portlet/ha/session/**"/>
<fileset dir="${build.classes}"
includes="org/jboss/portal/test/framework/portlet/**"/>
+ <fileset dir="${build.classes}"
includes="org/jboss/portal/test/portlet/framework/**"/>
</jar>
<!-- JSR 168 test case packaging -->
@@ -579,6 +580,35 @@
</execute-tests>
</target>
+ <target name="test-ha" depends="init">
+ <execute-tests>
+ <x-sysproperty>
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
+ <sysproperty key="test.root"
value="${build.lib}"/>
+ <sysproperty key="test.uri"
value="/test/redirect/"/>
+ </x-sysproperty>
+ <x-test>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.portlet.ha.session.SessionTestCase"/>
+ </x-test>
+ <x-classpath>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="jboss.remoting.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <pathelement location="${source.java}"/>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+
<target name="test2" depends="init">
<execute-tests>
<x-sysproperty>
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/MutableValue.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.portlet.ha.session;
import java.io.Serializable;
+import java.io.IOException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -61,4 +62,21 @@
}
return false;
}
+
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException
+ {
+ out.writeUTF(string);
+ System.out.print("Serializing " + string);
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws IOException,
ClassNotFoundException
+ {
+ string = in.readUTF();
+ System.out.print("Unserializing " + string);
+ }
+
+ public String toString()
+ {
+ return "MutableValue[" + string + "]";
+ }
}
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionSequenceBuilder.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -25,6 +25,7 @@
import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
import org.jboss.portal.common.test.driver.DriverResponse;
import org.jboss.portal.common.test.driver.response.EndTestResponse;
+import org.jboss.portal.common.util.Tools;
import org.jboss.portal.test.framework.portlet.Sequence;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
@@ -41,6 +42,7 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import java.io.IOException;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -51,7 +53,7 @@
public void createTestReplicateImmutableValue(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+ registry.addSequence("TestReplicateImmutableValue", seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new
PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException,
PortletSecurityException, IOException
@@ -80,7 +82,7 @@
public void createTestReplicateMutableValue(SequenceRegistry registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+ registry.addSequence("TestReplicateMutableValue", seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new
PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws IOException
@@ -111,7 +113,7 @@
public void
createTestModifyExistingAttributeWithoutExplicitSetDoesNotReplicate(SequenceRegistry
registry)
{
Sequence seq = new Sequence();
- registry.addSequence("ABC", seq);
+
registry.addSequence("TestModifyExistingAttributeWithoutExplicitSetDoesNotReplicate",
seq);
seq.addAction(0, NodeId.PORTS_01, UTP1.RENDER_JOINPOINT, new
PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws IOException
@@ -119,6 +121,7 @@
assertNull(request.getPortletSession(false));
PortletSession session = request.getPortletSession();
assertNotNull(session);
+ assertEquals(Collections.EMPTY_LIST,
Tools.toList(session.getAttributeNames()));
MutableValue value = new MutableValue("abcdef");
session.setAttribute("mutable", value);
PortletURL portletURL = response.createRenderURL();
@@ -131,6 +134,7 @@
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws IOException
{
PortletSession session = request.getPortletSession();
+ assertEquals(Collections.singletonList("mutable"),
Tools.toList(session.getAttributeNames()));
Object o = session.getAttribute("mutable");
assertNotNull(o);
assertEquals(MutableValue.class, o.getClass());
@@ -147,6 +151,7 @@
{
PortletSession session = request.getPortletSession();
assertNotNull(session);
+ assertEquals(Collections.singletonList("mutable"),
Tools.toList(session.getAttributeNames()));
assertEquals(new MutableValue("abcdef"),
session.getAttribute("mutable"));
return new EndTestResponse();
}
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/ha/session/SessionTestCase.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.portlet.ha.session;
+
+import org.jboss.portal.test.framework.server.runner.ServerTestRunner;
+import org.jboss.portal.test.framework.server.NodeId;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SessionTestCase extends ServerTestRunner
+{
+ public SessionTestCase()
+ {
+ super("test-ha-session.war", new
NodeId[]{NodeId.PORTS_01,NodeId.PORTS_02});
+ }
+}
Modified: trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml 2007-01-10 20:01:45 UTC
(rev 5984)
+++ trunk/portlet/src/resources/test-war/WEB-INF/jboss-web.xml 2007-01-10 22:37:23 UTC
(rev 5985)
@@ -27,6 +27,5 @@
<security-domain>java:/jaas/other</security-domain>
<replication-config>
<replication-trigger>SET</replication-trigger>
- <replication-type>SYNC</replication-type>
</replication-config>
</jboss-web>
Modified:
trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/server/src/main/org/jboss/portal/test/framework/server/runner/ServerTestRunner.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -24,14 +24,12 @@
import org.jboss.portal.test.framework.runner.BaseRunner;
import org.jboss.portal.test.framework.server.NodeId;
-import org.jboss.portal.common.test.TestParameterValue;
import org.jboss.portal.common.test.TestParametrization;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import junit.framework.AssertionFailedError;
import java.io.File;
import java.net.MalformedURLException;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -40,25 +38,49 @@
public class ServerTestRunner extends BaseRunner
{
+ /** . */
+ private String archiveName;
+
public ServerTestRunner()
{
- TestParametrization abc = JUnitAdapter.getParametrization();
- archiveName = (String)abc.getParameterValue("archive").get();
+ init(null);
}
+ public ServerTestRunner(NodeId[] nodeIds)
+ {
+ super(nodeIds);
+ init(null);
+ }
+
public ServerTestRunner(String archiveName)
{
- this.archiveName = archiveName;
+ init(archiveName);
}
- /** . */
- private String archiveName;
+ public ServerTestRunner(String archiveName, NodeId[] nodeIds)
+ {
+ super(nodeIds);
+ init(archiveName);
+ }
+ private void init(String archiveName)
+ {
+ if (archiveName == null)
+ {
+ TestParametrization abc = JUnitAdapter.getParametrization();
+ this.archiveName = (String)abc.getParameterValue("archive").get();
+ }
+ else
+ {
+ this.archiveName = archiveName;
+ }
+ }
+
public void startRunner() throws Exception
{
File root = new File(getArchivePath());
File f = new File(root, archiveName);
- getDeployer().deploy(f.toURL(), getNodeManager().getNode(NodeId.DEFAULT));
+ deploy(f.toURL());
}
public void stopRunner()
@@ -67,7 +89,7 @@
{
File root = new File(getArchivePath());
File f = new File(root, archiveName);
- getDeployer().undeploy(f.toURL());
+ undeploy(f.toURL());
}
catch (MalformedURLException e)
{
Modified: trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployer.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -29,8 +29,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -88,15 +86,15 @@
public void deploy(String url, Node node) throws Exception
{
- deploy(url, Collections.singleton(node));
+ deploy(url, new Node[]{node});
}
public void deploy(URL url, Node node) throws Exception
{
- deploy(url, Collections.singleton(node));
+ deploy(url, new Node[]{node});
}
- public void deploy(URL url, Collection nodes) throws Exception
+ public void deploy(URL url, Node[] nodes) throws Exception
{
Deployment deployment = new Deployment(nodes, url);
deployment.deploy(testAgentLookup);
@@ -112,7 +110,7 @@
}
}
- public void deploy(String url, Collection nodes) throws Exception
+ public void deploy(String url, Node[] nodes) throws Exception
{
this.deploy(getArchiveURL(url), nodes);
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/test/src/main/org/jboss/portal/test/framework/deployment/Deployment.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -32,8 +32,6 @@
import java.io.IOException;
import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
/**
* A deployment in the portlet container.
@@ -47,7 +45,7 @@
private static final Logger log = Logger.getLogger(Deployment.class);
/** The nodes we must deploy to. */
- private final Collection nodes;
+ private final Node[] nodes;
/** The local url of the deployment to make. */
private URL url;
@@ -55,7 +53,7 @@
/** . */
private boolean deployed;
- public Deployment(Collection nodes, URL url)
+ public Deployment(Node[] nodes, URL url)
{
if (nodes == null)
{
@@ -89,9 +87,9 @@
//
try
{
- for (Iterator i = nodes.iterator(); i.hasNext();)
+ for (int i = 0;i < nodes.length;i++)
{
- Node node = (Node)i.next();
+ Node node = nodes[i];
TestAgent agent = (TestAgent)testAgentLookup.getService(node);
agent.deploy(url);
}
@@ -121,11 +119,11 @@
this.url = null;
//
- for (Iterator i = nodes.iterator(); i.hasNext();)
+ for (int i = 0;i < nodes.length;i++)
{
try
{
- Node node = (Node)i.next();
+ Node node = nodes[i];
TestAgent agent = (TestAgent)testAgentLookup.getService(node);
agent.undeploy(url);
}
Modified:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java 2007-01-10
20:01:45 UTC (rev 5984)
+++
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverClient.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -133,15 +133,15 @@
this.serverLookup = serverLookup;
}
- private HttpTestDriverServer getServer()
+ private HttpTestDriverServer getServer(Node node)
{
- Node node = nodeManager.getNode(initialNodeId);
return (HttpTestDriverServer)serverLookup.getService(node);
}
public TestItemInfo getInfo()
{
- HttpTestDriverServer server = getServer();
+ Node node = nodeManager.getNode(initialNodeId);
+ HttpTestDriverServer server = getServer(node);
return server.getInfo();
}
@@ -340,14 +340,14 @@
{
requestCount = -1;
pushContext();
- DriverResponse response = getServer().invoke(testId, cmd);
+ DriverResponse response = getServer(node).invoke(testId, cmd);
requestCount = 0;
return new HttpDriverResponseContext(response);
}
else if (cmd instanceof SendResponseCommand)
{
pushContext();
- DriverResponse response = getServer().invoke(testId, cmd);
+ DriverResponse response = getServer(node).invoke(testId, cmd);
requestCount++;
return new HttpDriverResponseContext(response);
}
@@ -459,13 +459,13 @@
HttpTestContext ctx = new HttpTestContext(testId, requestCount, archivePath);
log.info("# Updating test case context of : " + node + " : "
+ ctx);
- HttpTestDriverServer agent = getServer();
+ HttpTestDriverServer agent = getServer(node);
agent.pushContext(testId, ctx);
}
private HttpTestContext popContext()
{
- HttpTestDriverServer agent = getServer();
+ HttpTestDriverServer agent = getServer(node);
return agent.popContext(testId);
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java 2007-01-10
20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/runner/BaseRunner.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -38,6 +38,8 @@
import junit.framework.TestResult;
import junit.framework.TestCase;
+import java.net.URL;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -65,9 +67,6 @@
/** . */
private TestRuntimeContext runtimeContext;
- /** The node id list used for this test suite. */
- private NodeId[] nodeIds;
-
/** . */
private String archivePath;
@@ -86,6 +85,9 @@
/** . */
private ServiceLookup testAgentLookup;
+ /** The node id list used for this test suite. */
+ private NodeId[] nodeIds;
+
public Deployer getDeployer()
{
return deployer;
@@ -128,7 +130,7 @@
public BaseRunner()
{
- this("org/jboss/portal/test/framework/container/jboss-beans.xml");
+ this("org/jboss/portal/test/framework/container/jboss-beans.xml", new
NodeId[]{NodeId.DEFAULT});
}
public BaseRunner(String beansDescriptorLocation)
@@ -136,16 +138,20 @@
this(beansDescriptorLocation, new NodeId[]{NodeId.DEFAULT});
}
+ public BaseRunner(NodeId[] nodeIds)
+ {
+ this("org/jboss/portal/test/framework/container/jboss-beans.xml",
nodeIds);
+ }
+
public BaseRunner(String beansDescriptorLocation, NodeId[] nodeIds)
{
this.runtimeContext = new TestRuntimeContext(beansDescriptorLocation);
this.runtimeContext.addBean("TestBean", this);
- this.nodeIds = (NodeId[])nodeIds.clone();
this.archivePath = System.getProperty("test.root");
this.state = STOPPED;
+ this.nodeIds = nodeIds;
}
-
public String getArchivePath()
{
return archivePath;
@@ -171,10 +177,10 @@
//
HttpTestDriverClient driver = new HttpTestDriverClient();
+ driver.setInitialNodeId(nodeIds[0]);
driver.setArchivePath(archivePath);
driver.setNodeManager(nodeManager);
driver.setServerLookup(httpTestDriverServerLookup);
- driver.setInitialNodeId(NodeId.DEFAULT);
//
adapter = new JUnitAdapter(driver);
@@ -295,4 +301,14 @@
public final void destroy()
{
}
+
+ protected void deploy(URL url) throws Exception
+ {
+ getDeployer().deploy(url, getNodeManager().getNodes(nodeIds));
+ }
+
+ protected void undeploy(URL url)
+ {
+ getDeployer().undeploy(url);
+ }
}
Modified: trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java 2007-01-10
20:01:45 UTC (rev 5984)
+++ trunk/test/src/main/org/jboss/portal/test/framework/server/NodeManager.java 2007-01-10
22:37:23 UTC (rev 5985)
@@ -51,6 +51,17 @@
return nodeMap.values();
}
+ public Node[] getNodes(NodeId[] nodeIds)
+ {
+ Node[] nodes = new Node[nodeIds.length];
+ for (int i = 0;i < nodeIds.length;i++)
+ {
+ NodeId nodeId = nodeIds[i];
+ nodes[i] = getNode(nodeId);
+ }
+ return nodes;
+ }
+
public Node getNode(NodeId nodeId)
{
return (Node)nodeMap.get(nodeId);