org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem Java Examples

The following examples show how to use org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Deployments.java    From launchpad-missioncontrol with Apache License 2.0 5 votes vote down vote up
/**
 * Test hooks so we can do some cleanupCreatedProject
 *
 * @return
 */
static WebArchive getTestDeployment() {
    final WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war")
            .addPackages(
                    true,
                    OpenShiftServiceSpi.class.getPackage(),
                    OpenShiftProjectImpl.class.getPackage(),
                    OpenShiftServiceFactory.class.getPackage(),
                    GitHubServiceSpi.class.getPackage(),
                    KohsukeGitHubServiceImpl.class.getPackage(),
                    GitHubServiceFactory.class.getPackage())
            .addPackage(TestSupport.class.getPackage());
    final File[] depsOpenshift = Resolvers.use(MavenResolverSystem.class).
            loadPomFromFile("../services/openshift-service-impl/pom.xml").
            importRuntimeAndTestDependencies().
            resolve().
            withTransitivity().
            asFile();
    final File[] depsGithub = Resolvers.use(MavenResolverSystem.class).
            loadPomFromFile("../services/github-service-impl/pom.xml").
            importRuntimeAndTestDependencies().
            resolve().
            withTransitivity().
            asFile();

    final File[] ourTestDeps = Resolvers.use(MavenResolverSystem.class).
            loadPomFromFile("pom.xml").
            importTestDependencies().
            resolve().
            withTransitivity().
            asFile();
    archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    archive.addAsLibraries(depsOpenshift);
    archive.addAsLibraries(depsGithub);
    archive.addAsLibraries(ourTestDeps);
    return archive;
}
 
Example #2
Source File: OverridedClientTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> war() {
    final MavenResolverSystem resolver = Maven.resolver();
    final String jerseyVersion = "2.17";
    final String hkApi = "2.4.0-b16";
    return ShrinkWrap.create(WebArchive.class, "OverridedClientTest.war")
            .addAsServiceProvider(ClientBuilder.class.getName(), "org.glassfish.jersey.client.JerseyClientBuilder") // missing in jersey
            .addAsLibraries(resolver.resolve("org.glassfish.jersey.core:jersey-common:" + jerseyVersion).withoutTransitivity().asFile())
            .addAsLibraries(resolver.resolve("org.glassfish.jersey.core:jersey-client:" + jerseyVersion).withoutTransitivity().asFile())
            .addAsLibraries(resolver.resolve("org.glassfish.hk2:hk2-api:" + hkApi).withoutTransitivity().asFile())
            .addAsLibraries(resolver.resolve("org.glassfish.hk2:hk2-core:" + hkApi).withoutTransitivity().asFile())
            .addAsLibraries(resolver.resolve("org.glassfish.jersey.bundles.repackaged:jersey-guava:" + jerseyVersion).withoutTransitivity().asFile());
}
 
Example #3
Source File: DeploymentArchiveProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void process(Archive<?> archive, TestClass testClass) {
    // Ignore run on server classes
    if (archive.getName().equals("run-on-server-classes.war")) {
        return;
    }

    // Ignore archives modifed in specific DeploymentArchiveProcessors, see e.g. 
    // org.keycloak.testsuite.arquillian.wildfly.container.WildflyDeploymentArchiveProcessor
    if (isWLSAppServer() || isWASAppServer()) {

        log.info("Processing archive " + archive.getName());
        modifyAdapterConfigs(archive, testClass);
        modifyWebXml(archive, testClass);

        MavenResolverSystem resolver = Maven.resolver();
        MavenFormatStage dependencies = resolver
                .loadPomFromFile("pom.xml")
                .importTestDependencies()
                .resolve("org.apache.httpcomponents:httpclient")
                .withTransitivity();

        ((WebArchive) archive)
                .addAsLibraries(dependencies.asFile())
                .addClass(org.keycloak.testsuite.arquillian.annotation.AppServerContainer.class)
                .addClass(org.keycloak.testsuite.utils.annotation.UseServletFilter.class);
    }
}
 
Example #4
Source File: ServerFrontendWebAppBuilder.java    From ldp4j with Apache License 2.0 4 votes vote down vote up
public WebArchive build(JavaArchive... archives) {
	if(LOGGER.isDebugEnabled() &&
		Boolean.parseBoolean(System.getProperty("org.ldp4j.testing.logging.setup"))) {
		LOGGER.debug("Creating testing web application archive:");
		LOGGER.debug("- Maven configuration:");
		LOGGER.debug("  + Setting: "+getSettings());
		LOGGER.debug("  + POM....: "+getPom());
		LOGGER.debug("- Web application configuration:");
		LOGGER.debug("  + Descriptor.....: "+getWebXml());
		LOGGER.debug("  + Deployable name: "+getDeployableName());
		LOGGER.debug("  + Control phrase.: "+getControlPhrase());
		if(archives.length>0) {
			LOGGER.debug("- Custom libraries:");
			for(JavaArchive archive:archives) {
				LOGGER.debug("  + "+archive);
				if(LOGGER.isTraceEnabled() &&
					Boolean.parseBoolean(System.getProperty("org.ldp4j.testing.logging.setup")) &&
					Boolean.parseBoolean(System.getProperty("org.ldp4j.testing.logging.archive"))) {
					LOGGER.trace(archive.toString(true));
				}
			}
		}
	}

	MavenResolverSystem resolver = Maven.
		configureResolver().fromClassloaderResource(getSettings());
	PomEquippedResolveStage mavenResolver=
		resolver.loadPomFromClassLoaderResource(getPom());

	WebArchive war=
		ShrinkWrap.
			create(WebArchive.class, getDeployableName()).
			addAsLibraries(
				mavenResolver.
					importRuntimeDependencies().asFile()).
			addAsLibraries(archives).
			addAsWebResource(
				new StringAsset(getControlPhrase()),"index.html");

	updateWebInf(war);

	if(LOGGER.isTraceEnabled() &&
		Boolean.parseBoolean(System.getProperty("org.ldp4j.testing.logging.setup")) &&
		Boolean.parseBoolean(System.getProperty("org.ldp4j.testing.logging.archive"))) {
		LOGGER.trace(String.format("Testing web application archive: \n%s",war.toString(true)));
	}

	return war;
}