[jboss-cvs] JBossAS SVN: r95824 - in projects/jboss-osgi/projects/bundles/husky/trunk: harness/src/main/java/org/jboss/osgi/husky and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 30 09:05:43 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-30 09:05:42 -0400 (Fri, 30 Oct 2009)
New Revision: 95824
Added:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/Bridge.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/BridgeFactory.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/HuskyCapability.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/ProvideContext.java
Removed:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Bridge.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/HuskyCapability.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/annotation/
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Context.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicBridge.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicContext.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/Util.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/context/context-basic.bnd
Log:
WIP
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/pom.xml 2009-10-30 13:05:42 UTC (rev 95824)
@@ -67,13 +67,13 @@
<Bundle-Activator>org.jboss.osgi.husky.runtime.osgi.HuskyActivator</Bundle-Activator>
<Export-Package>
org.jboss.osgi.husky;version=${version},
- org.jboss.osgi.husky.annotation;version=${version},
org.jboss.osgi.testing;version=${version},
</Export-Package>
<Import-Package>
javax.management,
javax.naming,
org.jboss.osgi.deployment.interceptor;version="[1.0,1.1)",
+ org.jboss.osgi.spi;version="[1.0,1.1)",
org.jboss.osgi.spi.capability;version="[1.0,1.1)",
org.jboss.osgi.spi.management;version="[1.0,1.1)",
org.jboss.osgi.spi.util;version="[1.0,1.1)",
Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Bridge.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Bridge.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Bridge.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -1,122 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.osgi.husky;
-
-
-
-// $Id$
-
-/**
- * A Bridge intercepts a test and delegates the execution
- * to the same (or another) test in and isolated test environment.
- *
- * An isolated test environment is one that does not have the same
- * class loading space as the test itself. Isolated test environments
- * are for example
- *
- * <ul>
- * <li>Remote container environment</li>
- * <li>Embedded OSGi Framework</li>
- * </ul>
- *
- * Details on test method mapping is given with the individual
- * run methods.
- *
- * The test {@link Request} is fieled through an {@link Invoker}
- * that that returns a {@link Response} for the given test run.
- *
- * Invokers may be arbitarily complex. Local 'in proccess' invokers are
- * possible just as well as remote invokers.
- *
- * <pre>
- * void testMethod
- * {
- * if(isNotInContainer())
- * {
- * BridgeFactory.getBridge().run();
- * return;
- * }
- * else
- * {
- * // in container test logic
- * ...
- * }
- * }
- * </pre>
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-May-2009
- */
-public interface Bridge
-{
- /**
- * Get the caller's class
- */
- Class<?> getCallerClass();
-
- /**
- * Get the caller's method
- */
- String getCallerMethod();
-
- /**
- * Get the caller's concatination of class name and method.
- */
- String getCallerFrame();
-
- /**
- * Intercepts a test and delegates the execution to the
- * same test in the same test class.
- *
- * The main use case is that of the same test class beeing deployed
- * in the isolated test environment as well as run from the client test runner.
- */
- void run();
-
- /**
- * Intercepts a test and delegates the execution to the
- * same test in a different test class.
- *
- * The main use case is that of one client side test class with the same
- * set of test methods as another test class that runs in the isolated test environment.
- */
- void run(Class<?> testClass);
-
- /**
- * Intercepts a test and delegates the execution to another test
- * in a different test class.
- *
- * The main use case is that of free mapping between client side tests and tests
- * that run in the isolated test environment.
- */
- void run(Class<?> testClass, String testMethod);
-
- /**
- * Get the invoker that is associated with this bridge.
- */
- Invoker getInvoker();
-
- /**
- * Set the invoker that is associated with this bridge.
- */
- void setInvoker(Invoker invoker);
-}
Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.osgi.husky;
-
-// $Id$
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.osgi.husky.internal.BasicBridge;
-import org.jboss.osgi.husky.internal.Util;
-
-/**
- * Loads the configured {@link Bridge} instance.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-May-2009
- */
-public abstract class BridgeFactory
-{
- private static Map<Object, Bridge> bridgeCache = new HashMap<Object, Bridge>();
-
- /**
- * Loads the bridge class that is configed through the system property {@link Bridge}.
- * If there is no such property, it returns an instance of {@link BasicBridge}.
- */
- public static Bridge getBridge()
- {
- Properties props = System.getProperties();
- return getBridgeInternal(null, props);
- }
-
- /**
- * Get the cached instance of the bridge class that is configed through the system property {@link Bridge}.
- * If there is no cached instance it creates a new instance.
- */
- public static Bridge getBridge(Object key)
- {
- Properties props = System.getProperties();
- return getBridgeInternal(key, props);
- }
-
- /**
- * Loads the bridge class that is configed through the property {@link Bridge}.
- *
- * If the loaded bridge has a constructor that takes a {@link Properties} parameter,
- * that constructor is used. Otherwise the bridge will be instanciated with the default constructor
- *
- * @param props bridge properties
- */
- public static Bridge getBridge(Object key, Properties props)
- {
- String className = props.getProperty(Bridge.class.getName());
- if (className == null)
- throw new IllegalStateException("Cannot find property: " + Bridge.class.getName());
-
- return getBridgeInternal(key, props);
- }
-
- private static Bridge getBridgeInternal(Object key, Properties props)
- {
- Bridge bridge = bridgeCache.get(key);
- if (bridge == null)
- {
- String className = props.getProperty(Bridge.class.getName(), BasicBridge.class.getName());
- bridge = (Bridge)Util.loadInstance(className, props);
-
- if (key != null)
- bridgeCache.put(key, bridge);
- }
- return bridge;
- }
-}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Context.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Context.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Context.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -23,7 +23,7 @@
// $Id$
-import java.util.Collection;
+import org.jboss.osgi.spi.Attachments;
/**
* The Context is a bucket of typed/named attachemnts.
@@ -31,130 +31,6 @@
* @author Thomas.Diesler at jboss.com
* @since 20-Apr-2007
*/
-public interface Context
+public interface Context extends Attachments
{
- /** Get attachment keys */
- Collection<Key> getAttachmentKeys();
-
- /** Add arbitrary attachment */
- <T> T addAttachment(Class<T> clazz, Object value);
-
- /** Add arbitrary attachment with name */
- <T> T addAttachment(Class<T> clazz, String name, Object value);
-
- /** Add arbitrary attachment with name */
- Object addAttachment(String name, Object value);
-
- /** Get an arbitrary attachment */
- <T> T getAttachment(Class<T> clazz);
-
- /** Get an arbitrary attachment */
- <T> T getAttachment(Class<T> clazz, String name);
-
- /** Get an arbitrary attachment */
- Object getAttachment(String name);
-
- /** Remove arbitrary attachments */
- <T> T removeAttachment(Class<T> clazz);
-
- /** Remove arbitrary attachments */
- <T> T removeAttachment(Class<T> clazz, String name);
-
- /** Remove arbitrary attachments */
- Object removeAttachment(String name);
-
- /**
- * A key for attachements
- */
- static class Key
- {
- private Class<?> clazz;
- private String name;
-
- /**
- * Construct the key with optional class and name
- */
- public Key(Class<?> clazz, String name)
- {
- this.clazz = clazz;
- this.name = name;
- }
-
- public static Key valueOf(String key)
- {
- int index = key.indexOf(",");
- if (key.startsWith("[") && key.endsWith("]") && index > 0)
- {
- Class<?> classPart = null;
- String className = key.substring(1, index);
- String namePart = key.substring(index + 1, key.length() - 1);
- if (className.length() > 0 && !className.equals("null"))
- {
- try
- {
- classPart = Class.forName(className);
- }
- catch (ClassNotFoundException ex)
- {
- throw new IllegalArgumentException("Cannot find class '" + className + "' in: " + key);
- }
- }
- return new Key(classPart, namePart);
- }
- return null;
- }
-
- /**
- * Get the class part for this key
- *
- * @return maybe null
- */
- public Class<?> getClassPart()
- {
- return clazz;
- }
-
- /**
- * Get the name part for this key
- *
- * @return maybe null
- */
- public String getNamePart()
- {
- return name;
- }
-
- /**
- * Two keys are equal if their {@link #toString()} is equal
- */
- public boolean equals(Object obj)
- {
- if (!(obj instanceof Key))
- return false;
- if (obj == this)
- return true;
- return obj.toString().equals(toString());
- }
-
- /**
- * Two keys have the same hashCode if their {@link #toString()} is equal
- */
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- /**
- * Returns the String repesentation of this Key.
- * <p/>
- *
- * <pre>
- * "[" + clazz + "," + name + "]"
- * </pre>
- */
- public String toString()
- {
- return "[" + clazz + "," + name + "]";
- }
- }
}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/HuskyCapability.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/HuskyCapability.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.osgi.husky;
-
-import org.jboss.osgi.husky.runtime.Connector;
-import org.jboss.osgi.spi.capability.Capability;
-
-
-
-//$Id$
-
-
-/**
- * Adds the Husky testing capability to the {@link OSGiRuntime}
- * under test.
- *
- * It is ignored if a Husky connector is already registered.
- *
- * Installed bundles: jboss-osgi-husky.jar
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public class HuskyCapability extends Capability
-{
- public HuskyCapability()
- {
- super(Connector.class.getName());
-
- addBundle("bundles/jboss-osgi-husky.jar");
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -32,9 +32,10 @@
import junit.framework.AssertionFailedError;
-import org.jboss.osgi.husky.Bridge;
import org.jboss.osgi.husky.Failure;
+import org.jboss.osgi.husky.Invoker;
import org.jboss.osgi.husky.Response;
+import org.jboss.osgi.testing.Bridge;
/**
* An abstract {@link Bridge} implementation.
@@ -124,7 +125,8 @@
line = br.readLine().trim();
String bridgePackage = Bridge.class.getPackage().getName();
- while (line.startsWith("at " + bridgePackage))
+ String invokerPackage = Invoker.class.getPackage().getName();
+ while (line.startsWith("at " + bridgePackage) || line.startsWith("at " + invokerPackage))
{
line = br.readLine().trim();
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractConnector.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -110,7 +110,7 @@
{
try
{
- Thread.currentThread().wait(200);
+ Thread.sleep(200);
}
catch (InterruptedException e)
{
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicBridge.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicBridge.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicBridge.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -25,8 +25,8 @@
import java.util.Properties;
-import org.jboss.osgi.husky.Bridge;
import org.jboss.osgi.husky.Invoker;
+import org.jboss.osgi.testing.Bridge;
/**
* A basic {@link Bridge} implementation that can be associated
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicContext.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicContext.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/BasicContext.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -23,11 +23,8 @@
// $Id$
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
import org.jboss.osgi.husky.Context;
+import org.jboss.osgi.spi.util.AttachmentSupport;
/**
* The Context is a bucket of typed/named attachemnts.
@@ -35,87 +32,6 @@
* @author Thomas.Diesler at jboss.com
* @since 20-Apr-2007
*/
-public class BasicContext implements Context
+public class BasicContext extends AttachmentSupport implements Context
{
- private Map<Key, Object> attachments = new HashMap<Key, Object>();
-
- /** Construct the execution context with no attachments */
- public BasicContext()
- {
-
- }
-
- /** Construct the execution context with given attachments */
- public BasicContext(Context att)
- {
- if (att != null)
- {
- for (Key key : att.getAttachmentKeys())
- {
- Object value = att.getAttachment(key.getClassPart(), key.getNamePart());
- this.attachments.put(key, value);
- }
- }
- }
-
- public Collection<Key> getAttachmentKeys()
- {
- return attachments.keySet();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz)
- {
- return (T)attachments.get(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.get(new Key(clazz, name));
- }
-
- public Object getAttachment(String name)
- {
- return attachments.get(new Key(null, name));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, Object obj)
- {
- return (T)attachments.put(new Key(clazz, null), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(Class<T> clazz, String name, Object obj)
- {
- return (T)attachments.put(new Key(clazz, name), obj);
- }
-
- public Object addAttachment(String name, Object obj)
- {
- return attachments.put(new Key(null, name), obj);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz)
- {
- return (T)attachments.remove(new Key(clazz, null));
- }
-
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(Class<T> clazz, String name)
- {
- return (T)attachments.remove(new Key(clazz, name));
- }
-
- public Object removeAttachment(String name)
- {
- return attachments.remove(new Key(null, name));
- }
-
- public String toString()
- {
- return attachments.toString();
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/Util.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/Util.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/Util.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -29,7 +29,7 @@
import java.lang.reflect.Constructor;
import java.util.Properties;
-import org.jboss.osgi.husky.Bridge;
+import org.jboss.osgi.testing.Bridge;
/**
* Loads the configured test {@link Bridge} instance.
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -25,8 +25,8 @@
import org.jboss.osgi.husky.Context;
import org.jboss.osgi.husky.Response;
-import org.jboss.osgi.husky.annotation.ProvideContext;
import org.jboss.osgi.husky.runtime.junit.JUnitRunner;
+import org.jboss.osgi.testing.ProvideContext;
/**
* An abstraction of a test runner that executes the given
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -30,8 +30,8 @@
import org.jboss.osgi.husky.Context;
import org.jboss.osgi.husky.Response;
-import org.jboss.osgi.husky.annotation.ProvideContext;
import org.jboss.osgi.husky.runtime.Runner;
+import org.jboss.osgi.testing.ProvideContext;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/Bridge.java (from rev 95821, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/Bridge.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/Bridge.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/Bridge.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.osgi.testing;
+
+import org.jboss.osgi.husky.Invoker;
+import org.jboss.osgi.husky.Request;
+import org.jboss.osgi.husky.Response;
+
+
+
+// $Id$
+
+/**
+ * A Bridge intercepts a test and delegates the execution
+ * to the same (or another) test in and isolated test environment.
+ *
+ * An isolated test environment is one that does not have the same
+ * class loading space as the test itself. Isolated test environments
+ * are for example
+ *
+ * <ul>
+ * <li>Remote container environment</li>
+ * <li>Embedded OSGi Framework</li>
+ * </ul>
+ *
+ * Details on test method mapping is given with the individual
+ * run methods.
+ *
+ * The test {@link Request} is fieled through an {@link Invoker}
+ * that that returns a {@link Response} for the given test run.
+ *
+ * Invokers may be arbitarily complex. Local 'in proccess' invokers are
+ * possible just as well as remote invokers.
+ *
+ * <pre>
+ * void testMethod
+ * {
+ * if(isNotInContainer())
+ * {
+ * BridgeFactory.getBridge().run();
+ * return;
+ * }
+ * else
+ * {
+ * // in container test logic
+ * ...
+ * }
+ * }
+ * </pre>
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-May-2009
+ */
+public interface Bridge
+{
+ /**
+ * Get the caller's class
+ */
+ Class<?> getCallerClass();
+
+ /**
+ * Get the caller's method
+ */
+ String getCallerMethod();
+
+ /**
+ * Get the caller's concatination of class name and method.
+ */
+ String getCallerFrame();
+
+ /**
+ * Intercepts a test and delegates the execution to the
+ * same test in the same test class.
+ *
+ * The main use case is that of the same test class beeing deployed
+ * in the isolated test environment as well as run from the client test runner.
+ */
+ void run();
+
+ /**
+ * Intercepts a test and delegates the execution to the
+ * same test in a different test class.
+ *
+ * The main use case is that of one client side test class with the same
+ * set of test methods as another test class that runs in the isolated test environment.
+ */
+ void run(Class<?> testClass);
+
+ /**
+ * Intercepts a test and delegates the execution to another test
+ * in a different test class.
+ *
+ * The main use case is that of free mapping between client side tests and tests
+ * that run in the isolated test environment.
+ */
+ void run(Class<?> testClass, String testMethod);
+
+ /**
+ * Get the invoker that is associated with this bridge.
+ */
+ Invoker getInvoker();
+
+ /**
+ * Set the invoker that is associated with this bridge.
+ */
+ void setInvoker(Invoker invoker);
+}
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/BridgeFactory.java (from rev 95821, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/BridgeFactory.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/BridgeFactory.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.osgi.testing;
+
+// $Id$
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.osgi.husky.internal.BasicBridge;
+import org.jboss.osgi.husky.internal.Util;
+
+/**
+ * Loads the configured {@link Bridge} instance.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-May-2009
+ */
+public abstract class BridgeFactory
+{
+ private static Map<Object, Bridge> bridgeCache = new HashMap<Object, Bridge>();
+
+ /**
+ * Loads the bridge class that is configed through the system property {@link Bridge}.
+ * If there is no such property, it returns an instance of {@link BasicBridge}.
+ */
+ public static Bridge getBridge()
+ {
+ Properties props = System.getProperties();
+ return getBridgeInternal(null, props);
+ }
+
+ /**
+ * Get the cached instance of the bridge class that is configed through the system property {@link Bridge}.
+ * If there is no cached instance it creates a new instance.
+ */
+ public static Bridge getBridge(Object key)
+ {
+ Properties props = System.getProperties();
+ return getBridgeInternal(key, props);
+ }
+
+ /**
+ * Loads the bridge class that is configed through the property {@link Bridge}.
+ *
+ * If the loaded bridge has a constructor that takes a {@link Properties} parameter,
+ * that constructor is used. Otherwise the bridge will be instanciated with the default constructor
+ *
+ * @param props bridge properties
+ */
+ public static Bridge getBridge(Object key, Properties props)
+ {
+ String className = props.getProperty(Bridge.class.getName());
+ if (className == null)
+ throw new IllegalStateException("Cannot find property: " + Bridge.class.getName());
+
+ return getBridgeInternal(key, props);
+ }
+
+ private static Bridge getBridgeInternal(Object key, Properties props)
+ {
+ Bridge bridge = bridgeCache.get(key);
+ if (bridge == null)
+ {
+ String className = props.getProperty(Bridge.class.getName(), BasicBridge.class.getName());
+ bridge = (Bridge)Util.loadInstance(className, props);
+
+ if (key != null)
+ bridgeCache.put(key, bridge);
+ }
+ return bridge;
+ }
+}
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/HuskyCapability.java (from rev 95821, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/HuskyCapability.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/HuskyCapability.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/HuskyCapability.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.osgi.testing;
+
+//$Id$
+
+import org.jboss.osgi.husky.runtime.Connector;
+import org.jboss.osgi.spi.capability.Capability;
+
+/**
+ * Adds the Husky testing capability to the {@link OSGiRuntime}
+ * under test.
+ *
+ * It is ignored if a Husky connector is already registered.
+ *
+ * Installed bundles: jboss-osgi-husky.jar
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class HuskyCapability extends Capability
+{
+ public HuskyCapability()
+ {
+ super(Connector.class.getName());
+
+ addBundle("bundles/jboss-osgi-husky.jar");
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/ProvideContext.java (from rev 95821, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/annotation/ProvideContext.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/ProvideContext.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/ProvideContext.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.osgi.testing;
+
+// $Id$
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.osgi.husky.Context;
+import org.jboss.osgi.husky.runtime.Runner;
+
+/**
+ * An annotation that instructs the {@link Runner} to inject
+ * the {@link Context} into the marked field or method on the
+ * test case instance prior to the execution of any test method.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-May-2009
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.FIELD})
+public @interface ProvideContext
+{
+
+}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -26,12 +26,12 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeNotNull;
-import org.jboss.osgi.husky.BridgeFactory;
-import org.jboss.osgi.husky.HuskyCapability;
-import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.testing.BridgeFactory;
+import org.jboss.osgi.testing.HuskyCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.ProvideContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -26,12 +26,12 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeNotNull;
-import org.jboss.osgi.husky.BridgeFactory;
-import org.jboss.osgi.husky.HuskyCapability;
-import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.testing.BridgeFactory;
+import org.jboss.osgi.testing.HuskyCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.ProvideContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java 2009-10-30 13:05:42 UTC (rev 95824)
@@ -26,12 +26,12 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeNotNull;
-import org.jboss.osgi.husky.BridgeFactory;
-import org.jboss.osgi.husky.HuskyCapability;
-import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.testing.BridgeFactory;
+import org.jboss.osgi.testing.HuskyCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.ProvideContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/context/context-basic.bnd
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/context/context-basic.bnd 2009-10-30 12:29:02 UTC (rev 95823)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/context/context-basic.bnd 2009-10-30 13:05:42 UTC (rev 95824)
@@ -5,8 +5,6 @@
Export-Package: org.jboss.test.osgi.husky.context
Import-Package: \
- org.jboss.osgi.husky, \
- org.jboss.osgi.husky.annotation, \
org.jboss.osgi.spi.capability, \
org.jboss.osgi.testing, \
org.junit, \
More information about the jboss-cvs-commits
mailing list