001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.test.wsrp;
023:
024: import org.jboss.logging.Logger;
025: import org.jboss.portal.jems.as.system.AbstractJBossService;
026: import org.jboss.portal.test.framework.driver.DriverCommand;
027: import org.jboss.portal.test.framework.driver.DriverResponse;
028: import org.jboss.portal.test.framework.driver.TestDriverContainer;
029: import org.jboss.portal.test.framework.driver.TestDriverException;
030: import org.jboss.portal.test.framework.driver.remote.RemoteTestDriver;
031: import org.jboss.portal.test.framework.driver.remote.TestContext;
032: import org.jboss.portal.test.framework.info.TestItemInfo;
033: import org.jboss.portal.test.framework.junit.POJOJUnitTest;
034:
035: /**
036: * Base Class for all WSRP Test Cases
037: *
038: * @author <a href="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
039: * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
040: * @author <a href="mailto:Boleslaw.Dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
041: * @since 2.4 (Feb 20, 2006)
042: */
043: public abstract class WSRPBaseTest extends AbstractJBossService
044: implements RemoteTestDriver {
045:
046: Logger log = Logger.getLogger(WSRPBaseTest.class);
047:
048: /** . */
049: private POJOJUnitTest test;
050:
051: /** . */
052: private TestDriverContainer testDriverContainer;
053:
054: /** . */
055: private TestContext context;
056:
057: protected WSRPBaseTest(String name) throws Exception {
058: // log("Instantiated test named '" + name + "'");
059: }
060:
061: protected WSRPBaseTest() {
062: }
063:
064: protected void log(String message) {
065: log.debug(getClass().getName() + ": " + message);
066: }
067:
068: public TestDriverContainer getTestDriverRegistry() {
069: return testDriverContainer;
070: }
071:
072: public void setTestDriverRegistry(
073: TestDriverContainer testDriverContainer) {
074: this .testDriverContainer = testDriverContainer;
075: }
076:
077: protected void startService() throws Exception {
078: test = new POJOJUnitTest(this );
079: testDriverContainer.addDriver(this );
080: }
081:
082: protected void stopService() throws Exception {
083: testDriverContainer.removeDriver(this );
084: }
085:
086: /** Make it accessible from outter packages. */
087: public void setUp() throws Exception {
088: }
089:
090: /** Make it accessible from outter packages. */
091: public void tearDown() throws Exception {
092: }
093:
094: protected void deploy(String archiveId) throws Exception {
095: context.deploy(archiveId);
096: }
097:
098: protected void undeploy(String archiveId) throws Exception {
099: context.undeploy(archiveId);
100: }
101:
102: public TestItemInfo getInfo() {
103: return test.getInfo();
104: }
105:
106: public DriverResponse invoke(String testId, DriverCommand command)
107: throws TestDriverException {
108: return test.invoke(testId, command);
109: }
110:
111: public void pushContext(String testId, TestContext testContext) {
112: this .context = testContext;
113: }
114:
115: public TestContext popContext(String testId) {
116: return context;
117: }
118: }
|