Author: julien(a)jboss.com
Date: 2007-08-22 19:03:16 -0400 (Wed, 22 Aug 2007)
New Revision: 8042
Removed:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/TestDriverRegistryAccess.java
Modified:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTest.java
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestDriver.java
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java
modules/portlet/trunk/test/build.xml
modules/portlet/trunk/test/src/resources/portlet-test-war/WEB-INF/jboss-beans.xml
Log:
improve singleton access to RemoteTestDriverServer
Modified:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTest.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTest.java 2007-08-22
21:35:19 UTC (rev 8041)
+++
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTest.java 2007-08-22
23:03:16 UTC (rev 8042)
@@ -46,8 +46,8 @@
public PortletTest()
{
- actionMap = new HashMap();
- parameters = new HashSet();
+ this.actionMap = new HashMap();
+ this.parameters = new HashSet();
}
public void addParameter(String parameterName)
@@ -142,4 +142,7 @@
return result;
}
}
+
+ //
+
}
Modified:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestDriver.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestDriver.java 2007-08-22
21:35:19 UTC (rev 8041)
+++
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestDriver.java 2007-08-22
23:03:16 UTC (rev 8042)
@@ -23,19 +23,18 @@
package org.jboss.portal.test.framework.portlet;
import org.jboss.portal.test.framework.info.TestInfo;
-import org.jboss.portal.test.framework.info.TestContainerInfo;
import org.jboss.portal.test.framework.info.TestItemInfo;
import org.jboss.portal.test.framework.info.TestParameterInfo;
import org.jboss.portal.test.framework.driver.DriverResponse;
import org.jboss.portal.test.framework.driver.DriverCommand;
import org.jboss.portal.test.framework.driver.TestDriverException;
+import org.jboss.portal.test.framework.driver.TestSuite;
+import org.jboss.portal.test.framework.driver.TestDriver;
import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
-import org.jboss.portal.test.framework.driver.http.HTTPTestDriver;
import org.jboss.portal.test.framework.driver.remote.TestContext;
+import org.jboss.portal.test.framework.driver.remote.RemoteTestDriver;
+import org.jboss.portal.test.framework.driver.remote.RemoteTestDriverServer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Collections;
import java.util.Iterator;
/**
@@ -44,24 +43,42 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision: 6720 $
*/
-public class PortletTestDriver implements HTTPTestDriver
+public class PortletTestDriver implements RemoteTestDriver
{
/** . */
- private final Map entries;
+ private static PortletTestContext context;
/** . */
- protected final TestContainerInfo container;
+ private final RemoteTestDriverServer server = new RemoteTestDriverServer();
/** . */
- private static PortletTestContext context;
+ private TestSuite suite;
+ /** . */
+ private String path;
+
public PortletTestDriver(String name)
{
- entries = Collections.synchronizedMap(new HashMap());
- container = new TestContainerInfo(name);
+ this(name, "/test");
}
+ public PortletTestDriver(String name, String path)
+ {
+ this.suite = new TestSuite(name);
+ this.path = path;
+ }
+
+ public void start()
+ {
+ server.addDriver(this);
+ }
+
+ public void stop()
+ {
+ server.removeDriver(this);
+ }
+
/**
* Adding sequence to registry. Sequence can be null as this will clear the binding
*
@@ -78,27 +95,22 @@
{
throw new IllegalArgumentException("Portlet test can't be null");
}
- if (entries.containsKey(testName))
+ if (getSequence(testName) != null)
{
throw new IllegalArgumentException("Portlet test cannot be bound
twice");
}
//
- TestInfo test = new TestInfo(testName);
- for (Iterator i = portletTest.parameters.iterator();i.hasNext();)
- {
- String parameterName = (String)i.next();
- test.addParameter(new TestParameterInfo(parameterName));
- }
+ Sequence sequence = new Sequence(testName, portletTest);
//
- entries.put(testName, portletTest);
- container.addChild(test);
+ suite.addDriver(sequence);
}
public void removeSequence(String testName)
{
- container.removeChild(testName);
+ TestDriver a = suite.getDriver(testName);
+ suite.removeDriver(a);
}
public PortletTest getSequence(String testName)
@@ -107,18 +119,18 @@
{
throw new IllegalArgumentException("Test name can't be null");
}
- return (PortletTest)entries.get(testName);
+ Sequence sequence = (Sequence)suite.getDriver(testName);
+ return sequence != null ? sequence.test : null;
}
public TestItemInfo getInfo()
{
- return container;
+ return suite.getInfo();
}
public DriverResponse invoke(String testId, DriverCommand command) throws
TestDriverException
{
- TestInfo info = (TestInfo)getInfo().findItem(testId);
- return new InvokeGetResponse("/test/" + info.getName());
+ return suite.invoke(testId, command);
}
public void pushContext(String testId, TestContext testContext)
@@ -140,4 +152,42 @@
{
return context;
}
+
+ private class Sequence implements TestDriver
+ {
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final PortletTest test;
+
+ /** . */
+ private final TestItemInfo info;
+
+ public Sequence(String name, PortletTest test)
+ {
+ TestInfo info = new TestInfo(name);
+ for (Iterator i = info.getParameterNames().iterator();i.hasNext();)
+ {
+ String parameterName = (String)i.next();
+ info.addParameter(new TestParameterInfo(parameterName));
+ }
+
+ //
+ this.name = name;
+ this.test = test;
+ this.info = info;
+ }
+
+ public TestItemInfo getInfo()
+ {
+ return info;
+ }
+
+ public DriverResponse invoke(String string, DriverCommand driverCommand) throws
TestDriverException
+ {
+ return new InvokeGetResponse(path + "/" + name);
+ }
+ }
}
Modified:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java 2007-08-22
21:35:19 UTC (rev 8041)
+++
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/PortletTestSuite.java 2007-08-22
23:03:16 UTC (rev 8042)
@@ -93,13 +93,13 @@
//
sce.getServletContext().setAttribute("SequenceRegistry", driver);
- TestDriverRegistryAccess.getTestDriverRegistry().addDriver(driver);
+ driver.start();
}
public void contextDestroyed(ServletContextEvent sce)
{
+ driver.stop();
sce.getServletContext().removeAttribute("SequenceRegistry");
- TestDriverRegistryAccess.getTestDriverRegistry().removeDriver(driver);
}
/**
Deleted:
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/TestDriverRegistryAccess.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/TestDriverRegistryAccess.java 2007-08-22
21:35:19 UTC (rev 8041)
+++
modules/portlet/trunk/portlet/src/main/org/jboss/portal/test/framework/portlet/TestDriverRegistryAccess.java 2007-08-22
23:03:16 UTC (rev 8042)
@@ -1,42 +0,0 @@
-/******************************************************************************
- * 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.framework.portlet;
-
-import org.jboss.portal.test.framework.driver.TestDriverContainer;
-import org.jboss.portal.test.framework.driver.remote.RemoteTestDriverServer;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestDriverRegistryAccess
-{
-
- /** . */
- private static TestDriverContainer testDriverContainer = new
RemoteTestDriverServer();
-
- public static TestDriverContainer getTestDriverRegistry()
- {
- return testDriverContainer;
- }
-}
Modified: modules/portlet/trunk/test/build.xml
===================================================================
--- modules/portlet/trunk/test/build.xml 2007-08-22 21:35:19 UTC (rev 8041)
+++ modules/portlet/trunk/test/build.xml 2007-08-22 23:03:16 UTC (rev 8042)
@@ -240,7 +240,11 @@
</x-test>
<x-sysproperty>
<sysproperty key="test.root"
value="${jboss.portal-portlet.root}/lib"/>
- <sysproperty key="test.uri"
value="/test/redirect/"/>
+ <sysproperty key="test.uri"
value="/portlet-test/"/>
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
</x-sysproperty>
<x-classpath>
<path refid="oswego.concurrent.classpath"/>
Modified:
modules/portlet/trunk/test/src/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
---
modules/portlet/trunk/test/src/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2007-08-22
21:35:19 UTC (rev 8041)
+++
modules/portlet/trunk/test/src/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2007-08-22
23:03:16 UTC (rev 8042)
@@ -4,15 +4,9 @@
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
-
-
<bean name="TestDriverServer"
class="org.jboss.portal.test.framework.driver.remote.RemoteTestDriverServer">
-<!--
- <depends
- optional-attribute-name="Agent"
- proxy-type="attribute">portal.test:service=Agent</depends>
--->
</bean>
+
<bean name="TestDriverServerExporter"
class="org.jboss.portal.test.framework.impl.generic.server.GenericServiceExporter">
<constructor>
<parameter>socket://localhost:5400</parameter>
@@ -21,10 +15,6 @@
</constructor>
</bean>
- <bean name="PortletTestDriver"
class="org.jboss.portal.test.framework.portlet.TestDriverRegistryAccess">
- <property name="testDriverRegistry"><inject
bean="TestDriverServer"/></property>
- </bean>
-
<!-- An application registry mainly for listeners -->
<bean name="PortletApplicationRegistry"
class="org.jboss.portal.portlet.impl.container.PortletApplicationRegistryImpl">
</bean>