diff options
Diffstat (limited to 'sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin')
6 files changed, 764 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/Dependency.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/Dependency.java new file mode 100644 index 0000000000..8f8934488a --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/Dependency.java @@ -0,0 +1,82 @@ +/* + * 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; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; + + +/** + * Represents a configured tuscany dependency for boot and extension libraries. + * + * @version $Rev$ $Date$ + */ +public class Dependency { + + /** + * JAR type artifact. + */ + private static final String TYPE_JAR = "jar"; + + /** + * Group Id that is injected in from configuration. + */ + private String groupId; + + /** + * Artifact Id that is injected in from configuration. + */ + private String artifactId; + + /** + * Version that is injected in from configuration. + */ + private String version; + + /** + * Default constructor. + */ + public Dependency() { + } + + /** + * Initializes the field. + * + * @param groupId Group id. + * @param artifactId Artifact id. + * @param version Artifact version. + */ + public Dependency(String groupId, String artifactId, String version) { + super(); + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + } + + /** + * Gets the artifact using the specified artifact factory. + * + * @param artifactFactory Artifact factory to use. + * @return Artifact identified by the dependency. + */ + public Artifact getArtifact(ArtifactFactory artifactFactory) { + return artifactFactory.createArtifact(groupId, artifactId, version, Artifact.SCOPE_RUNTIME, TYPE_JAR); + } + +} diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java new file mode 100644 index 0000000000..fda97c8a64 --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenEmbeddedRuntime.java @@ -0,0 +1,139 @@ +/* + * 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; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.osoa.sca.CompositeContext; + +import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation; +import org.apache.tuscany.core.launcher.CompositeContextImpl; +import org.apache.tuscany.core.runtime.AbstractRuntime; +import org.apache.tuscany.host.runtime.InitializationException; +import org.apache.tuscany.sca.plugin.itest.TuscanyStartMojo.MavenEmbeddedArtifactRepository; +import org.apache.tuscany.spi.builder.BuilderException; +import org.apache.tuscany.spi.component.Component; +import org.apache.tuscany.spi.component.ComponentException; +import org.apache.tuscany.spi.component.ComponentRegistrationException; +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.component.TargetResolutionException; +import org.apache.tuscany.spi.deployer.CompositeClassLoader; +import org.apache.tuscany.spi.deployer.Deployer; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.model.ComponentDefinition; +import org.apache.tuscany.spi.services.artifact.ArtifactRepository; + +/** + * @version $Rev$ $Date$ + */ +public class MavenEmbeddedRuntime extends AbstractRuntime { + private CompositeContextImpl context; + private CompositeComponent application; + + private ArtifactRepository artifactRepository; + // leave untyped b/c of QDox error + private Map extensions = new HashMap(); + + public void addExtension(String extensionName, URL extentionSCDL) { + extensions.put(extensionName, extentionSCDL); + } + + protected void registerSystemComponents() throws InitializationException { + super.registerSystemComponents(); + try { + getSystemComponent().registerJavaObject(MavenRuntimeInfo.COMPONENT_NAME, + MavenRuntimeInfo.class, + (MavenRuntimeInfo) getRuntimeInfo()); + + getSystemComponent().registerJavaObject(MavenEmbeddedArtifactRepository.COMPONENT_NAME, + ArtifactRepository.class, + artifactRepository); + } catch (ComponentRegistrationException e) { + throw new InitializationException(e); + } + } + + public void initialize() throws InitializationException { + super.initialize(); + + try { + for (Object extensionName : extensions.keySet()) { + deployExtension(getTuscanySystem(), getDeployer(), (String) extensionName, (URL) extensions.get(extensionName)); + } + + application = deployApplicationScdl(getDeployer(), + getRuntime().getRootComponent(), + getApplicationName(), + getApplicationScdl(), + getApplicationClassLoader()); + application.start(); + + context = new CompositeContextImpl(application, getWireService()); + } catch (LoaderException e) { + throw new InitializationException(e); + } catch (BuilderException e) { + throw new InitializationException(e); + } catch (TargetResolutionException e) { + throw new InitializationException(e); + } catch (ComponentException e) { + throw new InitializationException(e); + } + } + + protected void deployExtension(CompositeComponent composite, Deployer deployer, String extensionName, URL url) + throws LoaderException, BuilderException, ComponentException { + SystemCompositeImplementation implementation = new SystemCompositeImplementation(); + URL scdlLocation; + try { + scdlLocation = new URL("jar:" + url.toExternalForm() + "!/META-INF/sca/default.scdl"); + } catch (MalformedURLException e) { + throw new IllegalArgumentException(e); + } + + implementation.setScdlLocation(scdlLocation); + implementation.setClassLoader(new CompositeClassLoader(new URL[]{url}, getClass().getClassLoader())); + + ComponentDefinition<SystemCompositeImplementation> definition = + new ComponentDefinition<SystemCompositeImplementation>(extensionName, implementation); + + Component component = deployer.deploy(composite, definition); + component.start(); + } + + public void destroy() { + context = null; + if (application != null) { + application.stop(); + application = null; + } + super.destroy(); + } + + public CompositeContext getContext() { + return context; + } + + public void setArtifactRepository(ArtifactRepository artifactRepository) { + this.artifactRepository = artifactRepository; + } + +} diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java new file mode 100644 index 0000000000..60dfeb604d --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/MavenRuntimeInfo.java @@ -0,0 +1,56 @@ +/* + * 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; + +import java.io.File; +import java.net.URL; +import java.net.URI; + +import org.apache.tuscany.host.RuntimeInfo; + +/** + * @version $Rev$ $Date$ + */ +public class MavenRuntimeInfo implements RuntimeInfo { + public static final String COMPONENT_NAME = "MavenRuntimeInfo"; + + public File getInstallDirectory() { + throw new UnsupportedOperationException(); + } + + public File getApplicationRootDirectory() { + throw new UnsupportedOperationException(); + } + + public URL getBaseURL() { + throw new UnsupportedOperationException(); + } + + public boolean isOnline() { + throw new UnsupportedOperationException(); + } + + public URI getDomain() { + throw new UnsupportedOperationException(); + } + + public String getRuntimeId() { + throw new UnsupportedOperationException(); + } +} diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java new file mode 100644 index 0000000000..935dd95d2f --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java @@ -0,0 +1,130 @@ +/* + * 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; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +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; + +/** + * @version $Rev$ $Date$ + * @goal test + * @phase integration-test + */ +public class TuscanyITestMojo extends AbstractMojo { + /** + * @parameter expression="${project.build.directory}/surefire-reports" + */ + private File reportsDirectory; + + /** + * Whether to trim the stack trace in the reports to just the lines within + * the test, or show the full trace. + * + * @parameter expression="${trimStackTrace}" default-value="true" + */ + private boolean trimStackTrace; + + /** + * The directory containing generated test classes of the project being + * tested. + * + * @parameter expression="${project.build.testOutputDirectory}" + * @required + */ + private File testClassesDirectory; + + /** + * @parameter + */ + private List includes = new ArrayList(); + + /** + * @parameter + */ + private List excludes = new ArrayList(); + + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().info("Executing tests..."); + + boolean success = runSurefire(); + if (!success) { + String msg = "There were test failures"; + throw new MojoFailureException(msg); + } + } + + public boolean runSurefire() throws MojoExecutionException { + ClassLoader testsClassLoader = TuscanyStartMojo.foo.get(); + try { + Properties status = new Properties(); + boolean success = run(testsClassLoader, status); + getLog().info("Test results: "+status); + return success; + } catch (ReporterException e) { + throw new MojoExecutionException(e.getMessage(), e); + } catch (TestSetFailedException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } + + public boolean run(ClassLoader testsClassLoader, Properties status) throws ReporterException, + TestSetFailedException { + List reports = new ArrayList(); + reports.add(new BriefFileReporter(reportsDirectory, trimStackTrace)); + ReporterManager reporterManager = new ReporterManager(reports); + reporterManager.initResultsFromProperties(status); + + List suites = new ArrayList(); + + int totalTests = 0; + SurefireTestSuite suite = + new JUnitDirectoryTestSuite(testClassesDirectory, (ArrayList)includes, (ArrayList)excludes); + suite.locateTestSets(testsClassLoader); + + int testCount = suite.getNumTests(); + if (testCount > 0) { + suites.add(suite); + totalTests += testCount; + } + reporterManager.runStarting(totalTests); + + if (totalTests == 0) { + reporterManager.writeMessage("There are no tests to run."); + } else { + suite.execute(reporterManager, testsClassLoader); + } + + reporterManager.runCompleted(); + reporterManager.updateResultsProperties(status); + return reporterManager.getNumErrors() == 0 && reporterManager.getNumFailures() == 0; + } + +} diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java new file mode 100644 index 0000000000..178561b870 --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java @@ -0,0 +1,323 @@ +/* + * 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; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.metadata.ResolutionGroup; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.tuscany.host.runtime.InitializationException; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * @version $Rev$ $Date$ + * @goal start + * @phase pre-integration-test + */ +public class TuscanyStartMojo extends AbstractMojo { + + public class MavenEmbeddedArtifactRepository implements org.apache.tuscany.spi.services.artifact.ArtifactRepository { + public static final String COMPONENT_NAME = "MavenEmbeddedArtifactRepository"; + + public void resolve(org.apache.tuscany.spi.services.artifact.Artifact artifact) { + resolveTransitively(artifact); + } + + public void resolve(Collection artifacts) { + for (Object a : artifacts) { + resolve((Artifact)a); + } + } + + /** + * Resolves the dependencies transitively. + * + * @param rootArtifact Artifact whose dependencies need to be resolved. + */ + public boolean resolveTransitively(org.apache.tuscany.spi.services.artifact.Artifact rootArtifact) { + + org.apache.maven.artifact.Artifact mavenRootArtifact = + artifactFactory.createArtifact(rootArtifact.getGroup(), rootArtifact.getName(), rootArtifact + .getVersion(), org.apache.maven.artifact.Artifact.SCOPE_RUNTIME, rootArtifact.getType()); + + try { + + if (resolve(mavenRootArtifact)) { + rootArtifact.setUrl(mavenRootArtifact.getFile().toURL()); + if (resolveDependencies(rootArtifact, mavenRootArtifact)) { + return true; + } else { + return false; + } + } else { + return false; + } + } catch (MalformedURLException ex) { + throw new IllegalArgumentException(ex); + } + + } + + /* + * Resolves the artifact. + */ + private boolean resolve(org.apache.maven.artifact.Artifact mavenRootArtifact) { + + try { + resolver.resolve(mavenRootArtifact, remoteRepositories, localRepository); + return true; + } catch (ArtifactResolutionException ex) { + return false; + } catch (ArtifactNotFoundException ex) { + return false; + } + + } + + /* + * Resolves transitive dependencies. + */ + private boolean resolveDependencies(org.apache.tuscany.spi.services.artifact.Artifact rootArtifact, + org.apache.maven.artifact.Artifact mavenRootArtifact) { + + try { + + ResolutionGroup resolutionGroup = null; + ArtifactResolutionResult result = null; + + resolutionGroup = metadataSource.retrieve(mavenRootArtifact, localRepository, remoteRepositories); + result = + resolver.resolveTransitively(resolutionGroup.getArtifacts(), + mavenRootArtifact, + remoteRepositories, + localRepository, + metadataSource); + + // Add the artifacts to the deployment unit + for (Object obj : result.getArtifacts()) { + org.apache.maven.artifact.Artifact depArtifact = (org.apache.maven.artifact.Artifact)obj; + org.apache.tuscany.spi.services.artifact.Artifact artifact = + new org.apache.tuscany.spi.services.artifact.Artifact(); + artifact.setName(depArtifact.getArtifactId()); + artifact.setGroup(depArtifact.getGroupId()); + artifact.setType(depArtifact.getType()); + artifact.setClassifier(depArtifact.getClassifier()); + artifact.setUrl(depArtifact.getFile().toURL()); + artifact.setVersion(depArtifact.getVersion()); + rootArtifact.addDependency(artifact); + } + + } catch (ArtifactMetadataRetrievalException ex) { + return false; + } catch (MalformedURLException ex) { + throw new IllegalArgumentException(ex); + } catch (ArtifactResolutionException ex) { + return false; + } catch (ArtifactNotFoundException ex) { + return false; + } + + return true; + + } + + } + + /** + * @parameter + */ + private URL systemScdl; + + /** + * @parameter + */ + private URL applicationScdl; + + /** + * @parameter expression="${project.testClasspathElements}" + * @required + * @readonly + */ + private List testClassPath; + + /** + * Extensions + * + * @parameter + */ + private Dependency[] extensions = new Dependency[0]; + + /** + * Used to look up Artifacts in the remote repository. + * + * @parameter expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}" + * @required + * @readonly + */ + private ArtifactResolver resolver; + + /** + * Used to look up Artifacts in the remote repository. + * + * @parameter expression="${component.org.apache.maven.artifact.metadata.ArtifactMetadataSource}" + * @required + * @readonly + */ + private ArtifactMetadataSource metadataSource; + + /** + * Location of the local repository. + * + * @parameter expression="${localRepository}" + * @readonly + * @required + */ + private ArtifactRepository localRepository; + + /** + * List of Remote Repositories used by the resolver + * + * @parameter expression="${project.remoteArtifactRepositories}" + * @readonly + * @required + */ + private List remoteRepositories; + + /** + * Used to look up Artifacts in the remote repository. + * + * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}" + * @required + * @readonly + */ + private ArtifactFactory artifactFactory; + + static ThreadLocal<ClassLoader> foo = new ThreadLocal<ClassLoader>(); + + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().info("Starting Tuscany..."); + + ClassLoader hostClassLoader = getClass().getClassLoader(); + if (systemScdl == null) { + systemScdl = hostClassLoader.getResource("META-INF/tuscany/embeddedMaven.scdl"); + } + + MavenRuntimeInfo runtimeInfo = new MavenRuntimeInfo(); + MavenEmbeddedRuntime runtime = new MavenEmbeddedRuntime(); + runtime.setArtifactRepository(new MavenEmbeddedArtifactRepository()); + + for (Dependency d : extensions) { + try { + Artifact artifact = d.getArtifact(artifactFactory); + resolver.resolve(artifact, remoteRepositories, localRepository); + URL url = artifact.getFile().toURL(); + getLog().info(url.toString()); + runtime.addExtension(artifact.getGroupId() + ":" + artifact.getArtifactId(), url); + } catch (Exception e) { + throw new MojoExecutionException("Fail to resolve an extension", e); + } + } + + runtime.setSystemScdl(systemScdl); + runtime.setHostClassLoader(hostClassLoader); + + ClassLoader applicationClassLoader = createApplicationClassLoader(hostClassLoader); + if (applicationScdl == null) { + Enumeration resources; + try { + resources = applicationClassLoader.getResources("META-INF/sca/default.scdl"); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + if (!resources.hasMoreElements()) { + throw new MojoExecutionException("No SCDL found on test classpath"); + } + applicationScdl = (URL)resources.nextElement(); + if (resources.hasMoreElements()) { + StringBuffer msg = new StringBuffer(); + msg.append("Multiple SCDL files found on test classpath:\n"); + msg.append(" ").append(applicationScdl).append('\n'); + do { + msg.append(" ").append(resources.nextElement()).append('\n'); + } while (resources.hasMoreElements()); + throw new MojoExecutionException(msg.toString()); + } + } else { + if (applicationScdl.getProtocol() == null) { + String resource = applicationScdl.getPath(); + applicationScdl = applicationClassLoader.getResource(resource); + if (applicationScdl == null) { + throw new MojoExecutionException("Application SCDL cannot be resolved: " + resource); + } + } + } + runtime.setApplicationName("application"); + runtime.setApplicationScdl(applicationScdl); + runtime.setApplicationClassLoader(applicationClassLoader); + runtime.setRuntimeInfo(runtimeInfo); + try { + runtime.initialize(); + } catch (InitializationException e) { + throw new MojoExecutionException("Error initializing", e); + } + CompositeContext context = runtime.getContext(); + CurrentCompositeContext.setContext(context); + + foo.set(applicationClassLoader); + } + + public ClassLoader createApplicationClassLoader(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); + } +} diff --git a/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java new file mode 100644 index 0000000000..46bde33d5a --- /dev/null +++ b/sca-java-1.x/branches/pre-spec-changes/services/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java @@ -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.plugin.itest; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +/** + * @goal stop + * @phase post-integration-test + * @version $Rev$ $Date$ + */ +public class TuscanyStopMojo extends AbstractMojo { + public void execute() throws MojoExecutionException, MojoFailureException { + getLog().info("Stopping Tuscany..."); + } +} |