From portal-commits at lists.jboss.org Thu Oct 18 11:05:32 2007 Content-Type: multipart/mixed; boundary="===============5064835456680284368==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r8689 - modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver. Date: Thu, 18 Oct 2007 11:05:32 -0400 Message-ID: --===============5064835456680284368== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-10-18 11:05:31 -0400 (Thu, 18 Oct 2007) New Revision: 8689 Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/Composit= eRemoteTestDriver.java Modified: modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTe= stDriverServer.java Log: improve the remote test driver server by using a more flexible delegation m= odel Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/Comp= ositeRemoteTestDriver.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/Composi= teRemoteTestDriver.java (rev 0) +++ modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/Composi= teRemoteTestDriver.java 2007-10-18 15:05:31 UTC (rev 8689) @@ -0,0 +1,79 @@ +/*************************************************************************= ***** + * 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.unit.remote.driver; + +import org.jboss.unit.Failure; +import org.jboss.unit.TestId; +import org.jboss.unit.driver.TestDriver; +import org.jboss.unit.driver.response.FailureResponse; +import org.jboss.unit.driver.impl.composite.CompositeTestDriver; +import org.jboss.unit.remote.RequestContext; +import org.jboss.unit.remote.ResponseContext; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * @author Julien Viet + * @version $Revision: 1.1 $ + */ +public class CompositeRemoteTestDriver extends CompositeTestDriver impleme= nts RemoteTestDriver +{ + + public void pushContext(TestId testId, RequestContext requestContext) + { + String name =3D testId.getName(0); + + // + TestDriver driver =3D drivers.get(name); + + // + if (driver instanceof RemoteTestDriver) + { + RemoteTestDriver remoteDriver =3D (RemoteTestDriver)driver; + + // + remoteDriver.pushContext(testId.range(1), requestContext); + } + } + + public ResponseContext popContext(TestId testId) + { + String name =3D testId.getName(0); + + // + TestDriver driver =3D drivers.get(name); + + // + if (driver instanceof RemoteTestDriver) + { + RemoteTestDriver remoteDriver =3D (RemoteTestDriver)driver; + + // + return remoteDriver.popContext(testId.range(1)); + } + + // + return new ResponseContext(new FailureResponse(Failure.createErrorFa= ilure("No test found for " + testId)), new HashMap()); + } +} Modified: modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/R= emoteTestDriverServer.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteT= estDriverServer.java 2007-10-18 10:31:49 UTC (rev 8688) +++ modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteT= estDriverServer.java 2007-10-18 15:05:31 UTC (rev 8689) @@ -31,10 +31,12 @@ import org.jboss.unit.driver.DriverResponse; import org.jboss.unit.driver.DriverCommand; import org.jboss.unit.driver.response.FailureResponse; -import org.jboss.unit.driver.impl.composite.CompositeTestDriver; import org.jboss.unit.remote.RequestContext; import org.jboss.unit.remote.ResponseContext; = +import java.io.Serializable; +import java.util.HashMap; + /** * @author Julien Viet * @version $Revision: 5636 $ @@ -43,14 +45,14 @@ { = /** . */ - private CompositeTestDriver drivers =3D new CompositeTestDriver(); + private RemoteTestDriver drivers; = - public CompositeTestDriver getDrivers() + public TestDriver getDrivers() { return drivers; } = - public void setDrivers(CompositeTestDriver drivers) + public void setDrivers(RemoteTestDriver drivers) { this.drivers =3D drivers; } @@ -89,19 +91,7 @@ { if (drivers !=3D null) { - String name =3D testId.getName(0); - - // - TestDriver driver =3D drivers.get(name); - - // - if (driver instanceof RemoteTestDriver) - { - RemoteTestDriver remoteDriver =3D (RemoteTestDriver)driver; - - // - remoteDriver.pushContext(testId.range(1), requestContext); - } + drivers.pushContext(testId, requestContext); } } = @@ -109,49 +99,10 @@ { if (drivers !=3D null) { - String name =3D testId.getName(0); - - // - TestDriver driver =3D drivers.get(name); - - // - if (driver instanceof RemoteTestDriver) - { - RemoteTestDriver remoteDriver =3D (RemoteTestDriver)driver; - - // - return remoteDriver.popContext(testId.range(1)); - } + return drivers.popContext(testId); } = // - return null; + return new ResponseContext(new FailureResponse(Failure.createErrorFa= ilure("No test found for " + testId)), new HashMap()); } - - -// /** . */ -// private String initialPath =3D "/test"; -// -// public String getInitialPath() -// { -// return initialPath; -// } -// -// public void setInitialPath(String initialPath) -// { -// this.initialPath =3D initialPath; -// } -// -// public void pushContext(String testId, TestContext testContext) -// { -// if (testContext instanceof HTTPTestContext) -// { -// HTTPTestContext httpTestContext =3D (HTTPTestContext)testContex= t; -// httpTestContext.initialPath =3D initialPath; -// } -// -// // -// super.pushContext(testId, testContext); -// } - } --===============5064835456680284368==--