Java Code Examples for org.jboss.shrinkwrap.api.ShrinkWrap

The following examples show how to use org.jboss.shrinkwrap.api.ShrinkWrap. These examples are extracted from open source projects. 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
@Deployment
public static WebArchive deploy()
{
    String simpleName = GroupedConversationSubGroupTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(GroupedConversationSubGroupTest.class.getPackage())
            .addPackage(TestBaseBean.class.getPackage())
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example 2
Source Project: thorntail   Source File: SWARM_513Test.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment(testable = true)
public static Archive createDeployment() throws Exception {
    URL url = Thread.currentThread().getContextClassLoader().getResource("project-test-defaults-path.yml");
    assertThat(url).isNotNull();
    File projectDefaults = new File(url.toURI());
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "myapp.war");
    deployment.addResource(TicketEndpoint.class);
    deployment.addClass(Ticket.class);
    deployment.addClass(Tickets.class);
    deployment.addClass(TicketDTO.class);

    deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", SWARM_513Test.class.getClassLoader()), "classes/META-INF/persistence.xml");
    deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/import.sql", SWARM_513Test.class.getClassLoader()), "classes/META-INF/import.sql");

    deployment.addAsResource(projectDefaults, "/project-defaults.yml");
    return deployment;
}
 
Example 3
@Deployment
@AddonDependencies({
            @AddonDependency(name = "org.jboss.windup.ui:windup-ui"),
            @AddonDependency(name = "org.jboss.windup.exec:windup-exec"),
            @AddonDependency(name = "org.jboss.windup.graph:windup-graph"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java"),
            @AddonDependency(name = "org.jboss.windup.utils:windup-utils"),
            @AddonDependency(name = "org.jboss.forge.furnace.container:cdi"),
            @AddonDependency(name = "org.jboss.forge.addon:maven"),
            @AddonDependency(name = "org.jboss.forge.addon:ui-test-harness"),
})
public static AddonArchive getDeployment()
{
    AddonArchive archive = ShrinkWrap
                .create(AddonArchive.class)
                .addBeansXML()
                .addAsResource(WindupCommandTest.class.getResource(TEST_OLD_WINDUP), TEST_OLD_WINDUP);
    return archive;
}
 
Example 4
Source Project: tomee   Source File: DataSourceDefinitionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class)
            .version(WebAppVersionType._3_0)
            .createServlet()
            .servletName(SERVLET_NAME)
            .servletClass(DataSourceServlet.class.getName()).up()
            .createServletMapping()
            .servletName(SERVLET_NAME)
            .urlPattern("/" + TEST_NAME).up();

    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war")
            .addClass(DataSourceDefinitionTest.class)
            .addClass(DataSourceServlet.class)
            .addClass(DataSourceBean.class)
            .addClass(DataSourcePojo.class)
            .addClass(Runner.class)
            .addAsLibraries(JarLocation.jarLocation(Test.class))
            .addAsWebInfResource(new ClassLoaderAsset(CONTENT_LOCATION_EJB_JAR_XML), RESOURCE_EJB_JAR_XML)
            .setWebXML(new StringAsset(descriptor.exportAsString()));

    return archive;
}
 
Example 5
private SubackOutboundInterceptor getIsolatedOutboundInterceptor(final @NotNull String name) throws Exception {
    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class)
            .addClass("com.hivemq.extensions.handler.SubackOutboundInterceptorHandlerTest$" + name);

    final File jarFile = temporaryFolder.newFile();
    javaArchive.as(ZipExporter.class).exportTo(jarFile, true);

    final IsolatedPluginClassloader
            cl =
            new IsolatedPluginClassloader(new URL[]{jarFile.toURI().toURL()}, this.getClass().getClassLoader());

    final Class<?> interceptorClass =
            cl.loadClass("com.hivemq.extensions.handler.SubackOutboundInterceptorHandlerTest$" + name);

    return (SubackOutboundInterceptor) interceptorClass.newInstance();
}
 
Example 6
Source Project: windup   Source File: ToolingModeTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Deployment
@AddonDependencies({
            @AddonDependency(name = "org.jboss.windup:windup-tooling"),
            @AddonDependency(name = "org.jboss.windup.config:windup-config"),
            @AddonDependency(name = "org.jboss.windup.config:windup-config-xml"),
            @AddonDependency(name = "org.jboss.windup.exec:windup-exec"),
            @AddonDependency(name = "org.jboss.windup.reporting:windup-reporting"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java-ee"),
            @AddonDependency(name = "org.jboss.windup.rules.apps:windup-rules-java-project"),
            @AddonDependency(name = "org.jboss.windup.utils:windup-utils"),
            @AddonDependency(name = "org.jboss.forge.furnace.container:cdi"),
})
public static AddonArchive getDeployment()
{
    return ShrinkWrap
                .create(AddonArchive.class)
                .addBeansXML();
}
 
Example 7
private File createDeployment(Class<? extends ServiceActivator> clazz) throws Exception{
    File tmpRoot = new File(System.getProperty("java.io.tmpdir"));
    File tmpDir = new File(tmpRoot, this.getClass().getSimpleName() + System.currentTimeMillis());
    Files.createDirectory(tmpDir.toPath());
    tmpDirs.add(tmpDir);
    String deploymentName = DEPLOYMENT_NAME;
    File deployment = new File(tmpDir, deploymentName);
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, deploymentName);
    archive.addClasses(clazz, ServiceActivatorBaseDeployment.class);
    archive.addAsServiceProvider(ServiceActivator.class, clazz);
    archive.addAsManifestResource(new StringAsset("Dependencies: org.jboss.msc\n"), "MANIFEST.MF");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.broken.fail", "read"),
            new PropertyPermission("test.deployment.prop.one", "write"),
            new PropertyPermission("test.deployment.prop.two", "write"),
            new PropertyPermission("test.deployment.prop.three", "write"),
            new PropertyPermission("test.deployment.prop.four", "write"),
            new PropertyPermission("test.overlay.prop.one", "write"),
            new PropertyPermission("test.overlay.prop.two", "write"),
            new PropertyPermission("test.overlay.prop.three", "write"),
            new PropertyPermission("test.overlay.prop.four", "write")
    ), "permissions.xml");
    archive.as(ZipExporter.class).exportTo(deployment);
    return deployment;
}
 
Example 8
@Deployment
public static WebArchive createDeployment() {
  WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war")
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
      .addAsLibraries(DeploymentHelper.getEngineCdi())
      .addAsResource("META-INF/processes.xml", "META-INF/processes.xml")
      .addClass(AbstractFoxPlatformIntegrationTest.class)
      .addClass(CdiEventSupportProcessApplication.class)
      .addClass(EventObserverCdiBean.class)
      .addAsResource("org/camunda/bpm/integrationtest/functional/event/ProcessApplicationEventSupportTest.testExecutionListener.bpmn20.xml");

  TestContainer.addContainerSpecificResourcesForNonPa(archive);

  return archive;

}
 
Example 9
@Deployment
public static WebArchive create() {
    ConfigAnnotationAsset config = new ConfigAnnotationAsset()
        .set(TimeoutConfigBean.class, "serviceValue", Timeout.class, "value",
            TCKConfig.getConfig().getTimeoutInStr(1000))
        // only changing value here to scale the original, not for the purpose of this test
        .set(TimeoutConfigBean.class, "serviceUnit", Timeout.class, "value",
            TCKConfig.getConfig().getTimeoutInStr(1000))
        .set(TimeoutConfigBean.class, "serviceUnit", Timeout.class, "unit", "MILLIS")
        .set(TimeoutConfigBean.class, "serviceBoth", Timeout.class, "value",
            TCKConfig.getConfig().getTimeoutInStr(1000))
        .set(TimeoutConfigBean.class, "serviceBoth", Timeout.class, "unit", "MILLIS");

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ftTimeoutConfig.jar")
        .addClasses(TimeoutConfigBean.class, CompletableFutureHelper.class)
        .addPackage(Packages.UTILS)
        .addAsManifestResource(config, "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    return ShrinkWrap.create(WebArchive.class, "ftTimeoutConfig.war")
        .addAsLibrary(jar);
}
 
Example 10
@Deployment
public static Archive<?> deployment() {
    final WebArchive archive = ShrinkWrap.create(WebArchive.class, APP_NAME + ".war")
            .addClasses(Endpoint.class, UsernameTokenEndpointImpl.class, POJOEndpointAuthorizationInterceptor.class)
            .addAsWebInfResource("cxf/ws-security/EndpointService-with-username-token-policy.wsdl",
                    "EndpointService.wsdl")
            .addAsManifestResource(new StringAsset("Dependencies: org.apache.cxf\n"), "MANIFEST.MF")
            .addAsWebInfResource("cxf/ws-security/jaxws-endpoint-config.xml", "jaxws-endpoint-config.xml")
            .addAsWebInfResource(
                    new StringAsset(
                            "<jboss-web><security-domain>cxf-security-domain</security-domain></jboss-web>"),
                    "jboss-web.xml")
            .addAsResource("cxf/secure/cxf-roles.properties", "cxf-roles.properties")
            .addAsResource("cxf/secure/cxf-users.properties", "cxf-users.properties");
    return archive;
}
 
Example 11
@Deployment
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap
            .create(JavaArchive.class, "cdiOptionalInjectionTest.jar")
            .addClasses(CdiOptionalInjectionTest.class, OptionalValuesBean.class)
            .addAsManifestResource(
                new StringAsset(
                    "my.optional.int.property=1234\n" +
                    "my.optional.long.property=1234\n" +
                    "my.optional.double.property=1234.5\n" +
                    "my.optional.string.property=hello"),
                    "microprofile-config.properties")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
            .create(WebArchive.class, "cdiOptionalInjectionTest.war")
            .addAsLibrary(testJar);
    return war;
}
 
Example 12
@Deployment(order=1)
public static WebArchive delegateDeployment() {
  WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "service.war")
    .addAsLibraries(DeploymentHelper.getEjbClient())
    .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
    .addClass(AbstractFoxPlatformIntegrationTest.class)
    .addClass(RemoteSFSBean.class) // the EJB
    .addClass(BusinessInterface.class); // the business interface

  TestContainer.addContainerSpecificResourcesForNonPa(webArchive);

  return webArchive;
}
 
Example 13
Source Project: wildfly-camel   Source File: SpringContextDeploymentTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-deployment-tests");
    archive.addAsResource("spring/transform6-camel-context.xml", "some-other-name.xml");
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            ManifestBuilder builder = new ManifestBuilder();
            builder.addManifestHeader("Dependencies", "org.jboss.as.controller-client");
            return builder.openStream();
        }
    });
    return archive;
}
 
Example 14
Source Project: JEEventStore   Source File: SyncEventStoreCommitNotifierTest.java    License: MIT License 5 votes vote down vote up
@Deployment
public static Archive<?> deployment() {
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
            .addAsModule(ShrinkWrap.create(JavaArchive.class, "ejb.jar")
                    .addAsManifestResource(new File("src/test/resources/META-INF/beans.xml"))
                    .addAsManifestResource(
                            new File("src/test/resources/META-INF/ejb-jar-SyncEventStoreCommitNotifierTest.xml"),
                            "ejb-jar.xml")
                    .addPackage(AsyncEventStoreCommitNotifier.class.getPackage())
                    .addPackage(ChangeSet.class.getPackage())
                    .addClass(TestChangeSet.class)
            );

    return ear;
}
 
Example 15
Source Project: wildfly-camel   Source File: JCacheMBeansTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "jcache-mbeans-tests");
    archive.addAsResource("jcache/jcache-camel-context.xml", "some-other-name.xml");
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            ManifestBuilder builder = new ManifestBuilder();
            builder.addManifestHeader("Dependencies", "org.jboss.as.controller-client");
            return builder.openStream();
        }
    });
    return archive;
}
 
Example 16
@Deployment
@ShouldThrowException(value = FaultToleranceDefinitionException.class)
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "ftInvalidAsnycClass.jar")
        .addClasses(AsynchronousClientForValidationClass.class)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    return ShrinkWrap
        .create(WebArchive.class, "ftInvalidAsnycClass.war")
        .addAsLibrary(testJar);
}
 
Example 17
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws IOException {
    URL publicKey = ExpClaimAllowMissingExpValidationTest.class.getResource("/publicKey4k.pem");

    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    //configProps.setProperty(Names.REQUIRE_ISS, "true");
    configProps.setProperty(Names.ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty("mp.jwt.tomee.allow.no-exp", "true");

    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssValidationTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "ExpClaimValidationTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey4k.pem")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(configAsset, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 18
@Deployment
static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
            // Test bean
            .addClasses(SimplyTimedClassBean.class, MetricsUtil.class)
            // Bean archive deployment descriptor
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example 19
@Test
public void testWithSingleAnnotation() throws IOException {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);

    archive.addClass(MyClass.class);

    AdvertisingMetadataProcessor processor = new AdvertisingMetadataProcessor(archive, createIndex(archive));
    processor.process();

    List<String> advertisements = archive.as(TopologyArchive.class).advertisements();

    assertThat(advertisements).hasSize(1);
    assertThat(advertisements).contains("foo");
}
 
Example 20
@Produces
public Archive managementConsoleWar() throws Exception {
    // Load the management-ui webjars.
    WARArchive war = ShrinkWrap.create(WARArchive.class, "management-console-ui.war");
    Module module = Module.getBootModuleLoader().loadModule("org.jboss.as.console");
    Iterator<Resource> resources = module.globResources("*");
    while (resources.hasNext()) {
        Resource each = resources.next();
        war.add(new UrlAsset(each.getURL()), each.getName());
    }
    war.setContextRoot(this.fraction.contextRoot());
    return war;
}
 
Example 21
Source Project: ARCHIVE-wildfly-swarm   Source File: SwaggerArchiveTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSwaggerArchive() {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, "myapp.jar");
    SwaggerArchive swaggerArchive = archive.as(SwaggerArchive.class);

    // we need to set at least one configuration option for the swagger configuration to activate
    swaggerArchive.setHost("localhost");

    Asset asset = archive.get(SwaggerArchive.SWAGGER_CONFIGURATION_PATH).getAsset();
    assertThat(asset).isNotNull();
    assertThat(asset).isInstanceOf(SwaggerConfigurationAsset.class);

    assertThat(archive.as(ServiceActivatorArchive.class).containsServiceActivator(SwaggerArchiveImpl.SERVICE_ACTIVATOR_CLASS_NAME)).isTrue();
}
 
Example 22
@Deployment
public static JavaArchive createDeployment() {

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
            .addPackages(true, "org.drools.workshop.misc.model")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    //System.out.println(jar.toString(true));
    return jar;
}
 
Example 23
@Deployment(order = 3)
public static AddonArchive getDeployment()
{
    AddonArchive archive = ShrinkWrap.create(AddonArchive.class)
            .addBeansXML()
            .addClasses(JavaUtilLoggingFactory.class)
            .addAsLocalServices(ClassLoaderAdapterJavaUtilLoggingTest.class);

    return archive;
}
 
Example 24
Source Project: joynr   Source File: JoynrJeeMessageContextTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> getDeployment() {
    return ShrinkWrap.create(JavaArchive.class)
                     .addClasses(JoynrJeeMessageScoped.class,
                                 JoynrJeeMessageContext.class,
                                 TestResult.class,
                                 MessageScopedBean.class)
                     .addAsManifestResource(new File("src/main/resources/META-INF/beans.xml"))
                     .addAsManifestResource(new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"));
}
 
Example 25
Source Project: ee8-sandbox   Source File: GreeterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment(name = "test")
public static Archive<?> createDeployment() {

    JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
            .addClasses(
                    Greeter.class,
                    Resources.class
            )
            .addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
            //.addAsResource("persons.json", "persons.json")
            .addAsManifestResource("META-INF/test-beans.xml", "beans.xml");
    // System.out.println(archive.toString(true));
    return archive;
}
 
Example 26
@Override
public Archive<?> createAuxiliaryArchive() {
    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, "arquillian-tomee-archive-appender.jar")
            .addClasses(RemoteTomEEObserver.class, RemoteTomEERemoteExtension.class)
            .addClasses(OpenEJBEnricher.class, TomEEInjectionEnricher.class, MockitoEnricher.class)
            .addAsServiceProvider(RemoteLoadableExtension.class, RemoteTomEERemoteExtension.class);
    try {
        javaArchive.addClass(Thread.currentThread().getContextClassLoader().loadClass("org.apache.openejb.arquillian.transaction.OpenEJBTransactionProvider"));
    } catch (final Throwable t) {
        // skip, not mandatory
    }
    return javaArchive;
}
 
Example 27
Source Project: deltaspike   Source File: ClassLevelInterceptorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive war()
{
    Asset beansXml = new StringAsset(
        "<beans><interceptors><class>" +
                CustomInterceptorImpl.class.getName() +
        "</class></interceptors></beans>"
    );

    String simpleName = ClassLevelInterceptorTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    //don't create a completely empty web-archive
    if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
    {
        return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
    }

    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(ClassLevelInterceptorTest.class.getPackage())
            .addPackage(TestPartialBeanBinding.class.getPackage())
            .addAsManifestResource(beansXml, "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(beansXml, "beans.xml");
}
 
Example 28
private static WebArchive app(String war, Class<?> routeBuilder, Map<String, String> pathRoleMap) {
    final WebArchive archive = ShrinkWrap.create(WebArchive.class, war)
            .addClasses(BasicSecurityDomainASetup.class, CXFRSSecureUtils.class, TestClient.class, routeBuilder, AbstractUndertowSecureRestDslClientTest.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    SecurityUtils.enhanceArchive(archive, BasicSecurityDomainASetup.SECURITY_DOMAIN,
            BasicSecurityDomainASetup.AUTH_METHOD, pathRoleMap);
    return archive;
}
 
Example 29
/**
 * Create a CDI aware base web application archive that includes an embedded JWKS public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /jwks
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(name = "jwk")
public static WebArchive createDeploymentJWK() throws IOException {
    // Read in the JWKS
    URL publicKey = PublicKeyAsBase64JWKTest.class.getResource("/signer-key4k.jwk");
    StringWriter jwksContents = new StringWriter();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(publicKey.openStream()))) {
        String line = reader.readLine();
        while (line != null) {
            jwksContents.write(line);
            line = reader.readLine();
        }
    }
    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    System.out.printf("jwk: %s\n", jwksContents.toString());
    String base64Contents = Base64.getEncoder().encodeToString(jwksContents.toString().getBytes());
    configProps.setProperty(VERIFIER_PUBLIC_KEY, base64Contents);
    configProps.setProperty(ISSUER, TCKConstants.TEST_ISSUER);
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "PublicKeyAsBase64JWKTest JWK microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "PublicKeyAsBase64JWKTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addClass(PublicKeyEndpoint.class)
        .addClass(JwksApplication.class)
        .addClass(SimpleTokenUtils.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(configAsset, "microprofile-config.properties")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 30
Source Project: microprofile-fault-tolerance   Source File: DisableTest.java    License: Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap
            .create(JavaArchive.class, "ftDisableAllButFallback.jar")
            .addClasses(DisableClient.class, StringFallbackHandler.class)
            .addAsManifestResource(new StringAsset("MP_Fault_Tolerance_NonFallback_Enabled=false"),
                "microprofile-config.properties")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
            .create(WebArchive.class, "ftDisableAllButFallback.war")
            .addAsLibrary(testJar);
    return war;
}