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/11 20:11:09 UTC
svn commit: r506098 - in /incubator/tuscany/java/sca/runtime/itest:
plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/
smoketest/src/test/resources/
Author: jboynes
Date: Sun Feb 11 11:11:08 2007
New Revision: 506098
URL: http://svn.apache.org/viewvc?view=rev&rev=506098
Log:
attempt to deploy test harness scdl
currently fails because the AutowireResolver is not being injected into the system Deployer
Added:
incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/
incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl (with props)
Modified:
incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java
Modified: incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java?view=diff&rev=506098&r1=506097&r2=506098
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java (original)
+++ incubator/tuscany/java/sca/runtime/itest/plugin/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java Sun Feb 11 11:11:08 2007
@@ -18,10 +18,23 @@
*/
package org.apache.tuscany.sca.plugin.itest;
+import java.io.File;
+import java.net.URI;
+
import org.apache.tuscany.core.runtime.AbstractRuntime;
import org.apache.tuscany.host.runtime.InitializationException;
import org.apache.tuscany.spi.component.RegistrationException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.component.ComponentException;
import org.apache.tuscany.spi.services.artifact.ArtifactRepository;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.resolver.ResolutionException;
/**
* @version $Rev$ $Date$
@@ -48,4 +61,26 @@
this.artifactRepository = artifactRepository;
}
+ public void deployTestScdl(File testScdl, ClassLoader testClassLoader) throws Exception {
+ Deployer deployer = getDeployer();
+
+ URI name = URI.create("itest://testDomain/");
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(testScdl.toURI().toURL());
+ impl.setClassLoader(testClassLoader);
+
+ ComponentDefinition<CompositeImplementation> definition =
+ new ComponentDefinition<CompositeImplementation>(name, impl);
+ Component testComponent = deployer.deploy(null, definition);
+ }
+
+ protected Deployer getDeployer() {
+ try {
+ URI uri = URI.create("sca://root.system/main/deployer");
+ AtomicComponent component = (AtomicComponent) getComponentManager().getComponent(uri);
+ return (Deployer) component.getTargetInstance();
+ } catch (TargetResolutionException e) {
+ throw new AssertionError(e);
+ }
+ }
}
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=506098&r1=506097&r2=506098
==============================================================================
--- 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 11:11:08 2007
@@ -22,16 +22,28 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.Iterator;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
import org.apache.maven.surefire.junit.JUnitDirectoryTestSuite;
import org.apache.maven.surefire.report.BriefFileReporter;
import org.apache.maven.surefire.report.ReporterException;
import org.apache.maven.surefire.report.ReporterManager;
import org.apache.maven.surefire.suite.SurefireTestSuite;
import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+
+import org.apache.tuscany.host.runtime.InitializationException;
+import org.apache.tuscany.api.TuscanyRuntimeException;
/**
* @version $Rev$ $Date$
@@ -42,7 +54,7 @@
/**
* @parameter expression="${project.build.directory}/surefire-reports"
*/
- private File reportsDirectory;
+ public File reportsDirectory;
/**
* Whether to trim the stack trace in the reports to just the lines within
@@ -50,7 +62,7 @@
*
* @parameter expression="${trimStackTrace}" default-value="true"
*/
- private boolean trimStackTrace;
+ public boolean trimStackTrace;
/**
* The directory containing generated test classes of the project being
@@ -59,25 +71,114 @@
* @parameter expression="${project.build.testOutputDirectory}"
* @required
*/
- private File testClassesDirectory;
+ public File testClassesDirectory;
+
+ /**
+ * @parameter expression="${project.testClasspathElements}"
+ * @required
+ * @readonly
+ */
+ public List testClassPath;
/**
* @parameter
*/
- private List includes = new ArrayList();
+ public List includes = new ArrayList();
/**
* @parameter
*/
- private List excludes = new ArrayList();
+ public List excludes = new ArrayList();
- public void execute() throws MojoExecutionException, MojoFailureException {
- getLog().info("Executing tests...");
+ /**
+ * @parameter expression="${project.build.testOutputDirectory}/itest.scdl"
+ */
+ public File testScdl;
+
+ /**
+ * @parameter
+ */
+ public URL systemScdl;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
+ * @required
+ * @readonly
+ */
+ public ArtifactResolver resolver;
- boolean success = runSurefire();
- if (!success) {
- String msg = "There were test failures";
- throw new MojoFailureException(msg);
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.metadata.ArtifactMetadataSource}"
+ * @required
+ * @readonly
+ */
+ public ArtifactMetadataSource metadataSource;
+
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ */
+ public ArtifactRepository localRepository;
+
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ public List remoteRepositories;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
+ * @required
+ * @readonly
+ */
+ public ArtifactFactory artifactFactory;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Log log = getLog();
+ log.info("Starting Tuscany...");
+ MavenEmbeddedRuntime runtime = createRuntime();
+ try {
+ runtime.initialize();
+ } catch (InitializationException e) {
+ throw new MojoExecutionException("Error initializing Tuscany runtime", e);
+ }
+ try {
+ log.debug("Deploying test SCDL from " + testScdl);
+ try {
+ // fixme this should probably be an isolated classloader
+ ClassLoader testClassLoader = createTestClassLoader(getClass().getClassLoader());
+ runtime.deployTestScdl(testScdl, testClassLoader);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error deploying test component " + testScdl, e);
+ }
+/*
+ log.info("Executing tests...");
+
+ boolean success = runSurefire();
+ if (!success) {
+ String msg = "There were test failures";
+ throw new MojoFailureException(msg);
+ }
+*/
+ } finally {
+ log.info("Stopping Tuscany...");
+ try {
+ runtime.destroy();
+ } catch (TuscanyRuntimeException e) {
+ log.error("Error stopping Tuscany runtime", e);
+ }
}
}
@@ -128,4 +229,41 @@
return reporterManager.getNumErrors() == 0 && reporterManager.getNumFailures() == 0;
}
+ protected MavenEmbeddedRuntime createRuntime() throws MojoExecutionException {
+ ClassLoader hostClassLoader = getClass().getClassLoader();
+ if (systemScdl == null) {
+ systemScdl = hostClassLoader.getResource("META-INF/tuscany/embeddedMaven.scdl");
+ }
+
+ MavenRuntimeInfo runtimeInfo = new MavenRuntimeInfo();
+ MavenEmbeddedArtifactRepository artifactRepository = new MavenEmbeddedArtifactRepository(artifactFactory,
+ resolver,
+ metadataSource,
+ localRepository,
+ remoteRepositories);
+ MavenEmbeddedRuntime runtime = new MavenEmbeddedRuntime();
+ runtime.setRuntimeInfo(runtimeInfo);
+ runtime.setSystemScdl(systemScdl);
+ runtime.setHostClassLoader(hostClassLoader);
+ runtime.setArtifactRepository(artifactRepository);
+ return runtime;
+ }
+
+ public ClassLoader createTestClassLoader(ClassLoader parent) {
+ URL[] urls = new URL[testClassPath.size()];
+ int idx = 0;
+ for (Iterator i = testClassPath.iterator(); i.hasNext();) {
+ File pathElement = new File((String) i.next());
+ try {
+ URL url = pathElement.toURI().toURL();
+ getLog().debug("Adding application URL: " + url);
+ urls[idx++] = url;
+ } catch (MalformedURLException e) {
+ // toURI should have encoded the URL
+ throw new AssertionError();
+ }
+
+ }
+ return new URLClassLoader(urls, parent);
+ }
}
Added: 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=auto&rev=506098
==============================================================================
--- incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl (added)
+++ incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl Sun Feb 11 11:11:08 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="TestHarnessComposite">
+
+ <include name="ITestSmoketestComposite" scdlResource="META-INF/sca/default.scdl"/>
+</composite>
Propchange: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/runtime/itest/smoketest/src/test/resources/itest.scdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org