You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/02/12 00:43:04 UTC

svn commit: r506179 - in /incubator/tuscany/java/sca/runtime/itest: plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/ plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/ plugin/src/main/resources/META-INF/tuscany/ smo...

Author: jboynes
Date: Sun Feb 11 15:43:03 2007
New Revision: 506179

URL: http://svn.apache.org/viewvc?view=rev&rev=506179
Log:
add a ComponentType loader for JUnit components
add a simple test component to the harness

Added:
    incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java   (with props)
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java   (with props)
Modified:
    incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java
    incubator/tuscany/java/sca/runtime/itest/plugin/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
    incubator/tuscany/java/sca/runtime/itest/smoketest/pom.xml
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/main/java/org/apache/tuscany/sca/runtime/itest/smoketest/HelloServiceImpl.java
    incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl

Modified: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java?view=diff&rev=506179&r1=506178&r2=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java (original)
+++ incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java Sun Feb 11 15:43:03 2007
@@ -156,7 +156,7 @@
             throw new MojoExecutionException("Error initializing Tuscany runtime", e);
         }
         try {
-            log.debug("Deploying test SCDL from " + testScdl);
+            log.info("Deploying test SCDL from " + testScdl);
             try {
                 // fixme this should probably be an isolated classloader
                 ClassLoader testClassLoader = createTestClassLoader(getClass().getClassLoader());

Added: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java?view=auto&rev=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java (added)
+++ incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java Sun Feb 11 15:43:03 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.plugin.itest.implementation.junit;
+
+import java.net.URL;
+
+import org.osoa.sca.annotations.Constructor;
+
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.implementation.java.IntrospectionRegistry;
+import org.apache.tuscany.spi.implementation.java.Introspector;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JUnitComponentTypeLoader extends ComponentTypeLoaderExtension<ImplementationJUnit> {
+    private Introspector introspector;
+
+    @Constructor({"registry", "introspector"})
+    public JUnitComponentTypeLoader(@Autowire LoaderRegistry loaderRegistry,
+                                    @Autowire IntrospectionRegistry introspector) {
+        super(loaderRegistry);
+        this.introspector = introspector;
+    }
+
+    @Override
+    protected Class<ImplementationJUnit> getImplementationClass() {
+        return ImplementationJUnit.class;
+    }
+
+    public void load(CompositeComponent parent,
+                     ImplementationJUnit implementation,
+                     DeploymentContext deploymentContext) throws LoaderException {
+        String className = implementation.getClassName();
+        Class<?> implClass;
+        try {
+            implClass = deploymentContext.getClassLoader().loadClass(className);
+        } catch (ClassNotFoundException e) {
+            throw new MissingResourceException(className, e);
+        }
+        URL resource = implClass.getResource(JavaIntrospectionHelper.getBaseName(implClass) + ".componentType");
+        PojoComponentType componentType;
+        if (resource == null) {
+            componentType = loadByIntrospection(parent, implementation, deploymentContext, implClass);
+        } else {
+            componentType = loadFromSidefile(parent, resource, deploymentContext);
+        }
+        implementation.setComponentType(componentType);
+    }
+
+    protected PojoComponentType loadByIntrospection(CompositeComponent parent,
+                                                    ImplementationJUnit implementation,
+                                                    DeploymentContext deploymentContext,
+                                                    Class<?> implClass) throws ProcessingException {
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        introspector.introspect(parent, implClass, componentType, deploymentContext);
+        return componentType;
+    }
+
+    protected PojoComponentType loadFromSidefile(CompositeComponent parent,
+                                                 URL url,
+                                                 DeploymentContext deploymentContext) throws LoaderException {
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> componentType =
+            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        return loaderRegistry.load(parent, componentType, url, PojoComponentType.class, deploymentContext);
+    }
+}

Propchange: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/implementation/junit/JUnitComponentTypeLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/plugin/src/main/resources/META-INF/tuscany/embeddedMaven.scdl?view=diff&rev=506179&r1=506178&r2=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/plugin/src/main/resources/META-INF/tuscany/embeddedMaven.scdl (original)
+++ incubator/tuscany/java/sca/runtime/itest/plugin/src/main/resources/META-INF/tuscany/embeddedMaven.scdl Sun Feb 11 15:43:03 2007
@@ -148,5 +148,13 @@
         <system:implementation.system class="org.apache.tuscany.sca.plugin.itest.implementation.junit.ImplementationJUnitLoader"/>
     </component>
 
+    <component name="org.apache.tuscany.sca.plugin.itest.implementation.junit.JUnitComponentTypeLoader">
+        <system:implementation.system class="org.apache.tuscany.sca.plugin.itest.implementation.junit.JUnitComponentTypeLoader"/>
+    </component>
+
+    <component name="org.apache.tuscany.sca.plugin.itest.implementation.junit.JUnitComponentBuilder">
+        <system:implementation.system class="org.apache.tuscany.sca.plugin.itest.implementation.junit.JUnitComponentBuilder"/>
+    </component>
+
 
 </composite>

Modified: incubator/tuscany/java/sca/runtime/itest/smoketest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/smoketest/pom.xml?view=diff&rev=506179&r1=506178&r2=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/smoketest/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/itest/smoketest/pom.xml Sun Feb 11 15:43:03 2007
@@ -31,6 +31,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.osoa</groupId>
+            <artifactId>sca-api-r1.0</artifactId>
+            <version>1.0-incubator-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>

Modified: incubator/tuscany/java/sca/runtime/itest/smoketest/src/main/java/org/apache/tuscany/sca/runtime/itest/smoketest/HelloServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/smoketest/src/main/java/org/apache/tuscany/sca/runtime/itest/smoketest/HelloServiceImpl.java?view=diff&rev=506179&r1=506178&r2=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/smoketest/src/main/java/org/apache/tuscany/sca/runtime/itest/smoketest/HelloServiceImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/itest/smoketest/src/main/java/org/apache/tuscany/sca/runtime/itest/smoketest/HelloServiceImpl.java Sun Feb 11 15:43:03 2007
@@ -29,6 +29,6 @@
     }
 
     public String getGreeting() {
-        return greeting;
+        return "Hello World";
     }
 }

Added: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java?view=auto&rev=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java (added)
+++ incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java Sun Feb 11 15:43:03 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.runtime.itest.smoketest;
+
+import junit.framework.TestCase;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicTestComponent extends TestCase {
+    @Reference
+    public HelloService hello;
+
+    public void testGreeting() {
+        assertEquals("Hello World", hello.getGreeting());
+    }
+}

Propchange: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/java/org/apache/tuscany/sca/runtime/itest/smoketest/BasicTestComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl?view=diff&rev=506179&r1=506178&r2=506179
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl (original)
+++ incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl Sun Feb 11 15:43:03 2007
@@ -18,7 +18,12 @@
  * under the License.
 -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
            name="TestHarnessComposite">
 
     <include name="ITestSmoketestComposite" scdlResource="META-INF/sca/default.scdl"/>
+
+    <component name="testComponent">
+        <tuscany:junit class="org.apache.tuscany.sca.runtime.itest.smoketest.BasicTestComponent"/>
+    </component>
 </composite>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org