Author: julien(a)jboss.com
Date: 2007-03-16 22:51:03 -0400 (Fri, 16 Mar 2007)
New Revision: 6721
Added:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverServer.java
Removed:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverService.java
Log:
fixed not commited class because of SVN failure
Added:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverServer.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverServer.java
(rev 0)
+++
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverServer.java 2007-03-17
02:51:03 UTC (rev 6721)
@@ -0,0 +1,179 @@
+/******************************************************************************
+ * 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.driver.http;
+
+import org.jboss.portal.common.test.driver.DriverResponse;
+import org.jboss.portal.common.test.driver.TestDriverException;
+import org.jboss.portal.common.test.driver.TestDriver;
+import org.jboss.portal.common.test.driver.DriverCommand;
+import org.jboss.portal.common.test.driver.TestDriverRegistry;
+import org.jboss.portal.common.test.info.TestItemInfo;
+import org.jboss.portal.common.test.info.TestContainerInfo;
+import org.jboss.portal.test.framework.driver.AbstractTestDriverServer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5636 $
+ */
+public class HttpTestDriverServer extends AbstractTestDriverServer implements
HttpTestDriver, TestDriverRegistry
+{
+
+ /** . */
+ protected final Map _entries;
+
+ /** . */
+ protected final TestContainerInfo _container;
+
+ public HttpTestDriverServer()
+ {
+ _entries = new HashMap();
+ _container = new TestContainerInfo("Main");
+ }
+
+ public void pushContext(String testId, HttpTestContext ctx)
+ {
+ TestDriver driver = getDriver(testId);
+ if (driver instanceof HttpTestDriver)
+ {
+ HttpTestDriver httpDriver = (HttpTestDriver)driver;
+ TestItemInfo item = _container.findItem(testId);
+ String newId = item.getId(httpDriver.getInfo());
+ HttpTestContext ctx2 = new HttpTestContext(newId, ctx.getRequestCount(),
ctx.getArchivePath());
+ ctx2.setTestAgent(getAgent());
+ httpDriver.pushContext(newId, ctx2);
+ }
+ }
+
+ public HttpTestContext popContext(String testId)
+ {
+ TestDriver tmp = getDriver(testId);
+ HttpTestDriver driver = (HttpTestDriver)tmp;
+ TestItemInfo item = _container.findItem(testId);
+ String newId = item.getId(driver.getInfo());
+ HttpTestContext context = driver.popContext(newId);
+ context = new HttpTestContext(context);
+ context.setTestAgent(null);
+ return context;
+ }
+
+ public synchronized void registerTestDriver(TestDriver test) throws
IllegalArgumentException
+ {
+ if (test == null)
+ {
+ throw new IllegalArgumentException("Cannot add null test");
+ }
+ TestItemInfo itemInfo = test.getInfo();
+ String entryKey = itemInfo.getName();
+ if (_entries.containsKey(entryKey))
+ {
+ throw new IllegalArgumentException("Cannot have two tests with the same id
" + entryKey);
+ }
+
+ //
+ _container.addChild(itemInfo);
+ _entries.put(entryKey, test);
+ }
+
+ public synchronized void unregisterTestDriver(TestDriver test) throws
IllegalArgumentException
+ {
+ if (test == null)
+ {
+ throw new IllegalArgumentException("Cannot add null test");
+ }
+ String entryKey = test.getInfo().getName();
+ if (!_entries.containsKey(entryKey))
+ {
+ throw new IllegalArgumentException("Cannot remove test that was not added
previously " + entryKey);
+ }
+
+ //
+ _entries.remove(entryKey);
+ _container.removeChild(entryKey);
+ }
+
+ public synchronized void register(TestDriver driver)
+ {
+ registerTestDriver(driver);
+ }
+
+ public synchronized void unregister(TestDriver driver)
+ {
+ unregisterTestDriver(driver);
+ }
+
+ public TestDriver getDriver(String itemId)
+ {
+ TestItemInfo itemInfo = _container.findItem(itemId);
+ if (itemInfo == null)
+ {
+ return null;
+ }
+
+ // Find original parent
+ TestItemInfo currentInfo = itemInfo;
+ while (true)
+ {
+ TestContainerInfo parentInfo = currentInfo.getParent();
+ if (parentInfo == null)
+ {
+ //
+ return null;
+ }
+ else if (parentInfo == _container)
+ {
+ break;
+ }
+ else
+ {
+ currentInfo = parentInfo;
+ }
+ }
+
+ //
+ return (TestDriver)_entries.get(currentInfo.getName());
+ }
+
+ public DriverResponse invoke(String testId, DriverCommand cmd) throws
TestDriverException
+ {
+ TestItemInfo item = _container.findItem(testId);
+ if (item == null)
+ {
+ throw new TestDriverException("Driver not found for " + testId);
+ }
+
+ // Get associated test driver
+ TestDriver driver = getDriver(testId);
+
+ // Route the command to the target driver
+ String newTestId = item.getId(driver.getInfo());
+ return driver.invoke(newTestId, cmd);
+ }
+
+ public TestItemInfo getInfo()
+ {
+ return _container;
+ }
+}
Property changes on:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverServer.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted:
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverService.java
===================================================================
---
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverService.java 2007-03-17
02:37:08 UTC (rev 6720)
+++
trunk/test/src/main/org/jboss/portal/test/framework/driver/http/HttpTestDriverService.java 2007-03-17
02:51:03 UTC (rev 6721)
@@ -1,180 +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.server.driver;
-
-import org.jboss.portal.test.framework.driver.http.AbstractHttpTestDriverServerService;
-import org.jboss.portal.test.framework.driver.http.HttpTestContext;
-import org.jboss.portal.test.framework.driver.http.HttpTestDriverServer;
-import org.jboss.portal.common.test.driver.DriverResponse;
-import org.jboss.portal.common.test.driver.TestDriverException;
-import org.jboss.portal.common.test.driver.TestDriver;
-import org.jboss.portal.common.test.driver.DriverCommand;
-import org.jboss.portal.common.test.info.TestItemInfo;
-import org.jboss.portal.common.test.info.TestContainerInfo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class HttpTestDriverRegistryService extends AbstractHttpTestDriverServerService
implements HttpTestDriverRegistry
-{
-
- /** . */
- private Map _entries;
-
- /** . */
- private TestContainerInfo _container;
-
- public HttpTestDriverRegistryService()
- {
- _entries = new HashMap();
- _container = new TestContainerInfo("Main");
- }
-
- public synchronized void registerTestDriver(TestDriver test) throws
IllegalArgumentException
- {
- if (test == null)
- {
- throw new IllegalArgumentException("Cannot add null test");
- }
- TestItemInfo itemInfo = test.getInfo();
- String entryKey = itemInfo.getName();
- if (_entries.containsKey(entryKey))
- {
- throw new IllegalArgumentException("Cannot have two tests with the same id
" + entryKey);
- }
-
- //
- _container.addChild(itemInfo);
- _entries.put(entryKey, test);
- }
-
- public synchronized void unregisterTestDriver(TestDriver test) throws
IllegalArgumentException
- {
- if (test == null)
- {
- throw new IllegalArgumentException("Cannot add null test");
- }
- String entryKey = test.getInfo().getName();
- if (!_entries.containsKey(entryKey))
- {
- throw new IllegalArgumentException("Cannot remove test that was not added
previously " + entryKey);
- }
-
- //
- _entries.remove(entryKey);
- _container.removeChild(entryKey);
- }
-
- public synchronized void register(TestDriver driver)
- {
- registerTestDriver(driver);
- }
-
- public synchronized void unregister(TestDriver driver)
- {
- unregisterTestDriver(driver);
- }
-
- public TestDriver getDriver(String itemId)
- {
- TestItemInfo itemInfo = _container.findItem(itemId);
- if (itemInfo == null)
- {
- return null;
- }
-
- // Find original parent
- TestItemInfo currentInfo = itemInfo;
- while (true)
- {
- TestContainerInfo parentInfo = currentInfo.getParent();
- if (parentInfo == null)
- {
- //
- return null;
- }
- else if (parentInfo == _container)
- {
- break;
- }
- else
- {
- currentInfo = parentInfo;
- }
- }
-
- //
- return (TestDriver)_entries.get(currentInfo.getName());
- }
-
- public DriverResponse invoke(String testId, DriverCommand cmd) throws
TestDriverException
- {
- TestItemInfo item = _container.findItem(testId);
- if (item == null)
- {
- throw new TestDriverException("Driver not found for " + testId);
- }
-
- // Get associated test driver
- TestDriver driver = getDriver(testId);
-
- // Route the command to the target driver
- String newTestId = item.getId(driver.getInfo());
- return driver.invoke(newTestId, cmd);
- }
-
- public TestItemInfo getInfo()
- {
- return _container;
- }
-
- public void pushContext(String testId, HttpTestContext ctx)
- {
- TestDriver driver = getDriver(testId);
- if (driver instanceof HttpTestDriverServer)
- {
- HttpTestDriverServer httpDriver = (HttpTestDriverServer)driver;
- TestItemInfo item = _container.findItem(testId);
- String newId = item.getId(httpDriver.getInfo());
- HttpTestContext ctx2 = new HttpTestContext(newId, ctx.getRequestCount(),
ctx.getArchivePath());
- ctx2.setTestAgent(getAgent());
- httpDriver.pushContext(newId, ctx2);
- }
- }
-
- public HttpTestContext popContext(String testId)
- {
- TestDriver tmp = getDriver(testId);
- HttpTestDriverServer driver = (HttpTestDriverServer)tmp;
- TestItemInfo item = _container.findItem(testId);
- String newId = item.getId(driver.getInfo());
- HttpTestContext context = driver.popContext(newId);
- context = new HttpTestContext(context);
- context.setTestAgent(null);
- return context;
- }
-}