org.jboss.shrinkwrap.api.ShrinkWrap Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.ShrinkWrap. 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: GroupedConversationSubGroupTest.java    From deltaspike with Apache License 2.0 7 votes vote down vote up
@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 File: SWARM_513Test.java    From thorntail with 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
Source File: SubackOutboundInterceptorHandlerTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: DataSourceDefinitionTest.java    From tomee with 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
Source File: ToolingModeTest.java    From windup with 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 #6
Source File: WindupUpdateRulesetCommandTest.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@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 #7
Source File: CdiOptionalInjectionTest.java    From microprofile-config with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: CXFWSSecurityIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: CdiProcessApplicationEventSupportTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: DeploymentOverlayScenario.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #11
Source File: TimeoutConfigTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: TicketServiceTest.java    From packt-java-ee-7-code-samples with GNU General Public License v2.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
            .addPackage(SeatType.class.getPackage())
            .addPackage(TicketService.class.getPackage())
            .addPackage(LoggerProducer.class.getPackage())
            .addAsResource("META-INF/persistence.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #13
Source File: CoapIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class, "camel-coap-tests.jar")
        .addClass(AvailablePortFinder.class)
        .setManifest(() -> {
            ManifestBuilder builder = new ManifestBuilder();
            builder.addManifestHeader("Dependencies", "org.eclipse.californium");
            return builder.openStream();
        });
}
 
Example #14
Source File: DeployedScriptPolicyTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Deployment(name = SCRIPT_DEPLOYMENT_NAME, managed = false, testable = false)
@TargetsContainer(AUTH_SERVER_CURRENT)
public static JavaArchive deploy() throws IOException {
    ScriptProviderDescriptor representation = new ScriptProviderDescriptor();

    representation.addPolicy("Grant Policy", "policy-grant.js");
    representation.addPolicy("Deny Policy", "policy-deny.js");

    return ShrinkWrap.create(JavaArchive.class, SCRIPT_DEPLOYMENT_NAME)
            .addAsManifestResource(new StringAsset(JsonSerialization.writeValueAsPrettyString(representation)),
                    "keycloak-scripts.json")
            .addAsResource(new StringAsset("$evaluation.grant();"), "policy-grant.js")
            .addAsResource(new StringAsset("$evaluation.deny();"), "policy-deny.js");
}
 
Example #15
Source File: TimedTagMethodBeanTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Deployment
static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
        // Test bean
        .addClass(TimedTagMethodBean.class)
        // Bean archive deployment descriptor
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #16
Source File: TodoTest.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@Deployment(name = "test")
public static Archive<?> createDeployment() {

    JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
            .addPackage(Todo.class.getPackage())
            //.addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
            //.addAsResource("persons.json", "persons.json")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    // System.out.println(archive.toString(true));
    return archive;
}
 
Example #17
Source File: SourceModeTest.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
@Deployment
@AddonDependencies({
            @AddonDependency(name = "org.jboss.windup.config:windup-config"),
            @AddonDependency(name = "org.jboss.windup.exec:windup-exec"),
            @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")
})
public static AddonArchive getDeployment()
{
    return ShrinkWrap.create(AddonArchive.class).addBeansXML();
}
 
Example #18
Source File: ClassLevelInterceptorTest.java    From deltaspike with 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 #19
Source File: ResourceAdapterFactory.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create the work.rar
 *
 * @return The resource adapter archive
 */
public static ResourceAdapterArchive createWorkRarMCFNoHashCode()
{
   org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor raXml = Descriptors
         .create(org.jboss.shrinkwrap.descriptor.api.connector16.ConnectorDescriptor.class, "ra.xml").version("1.6");

   org.jboss.shrinkwrap.descriptor.api.connector16.ResourceadapterType rt = raXml.getOrCreateResourceadapter()
         .resourceadapterClass(WorkResourceAdapter.class.getName());
   org.jboss.shrinkwrap.descriptor.api.connector16.OutboundResourceadapterType ort = rt
         .getOrCreateOutboundResourceadapter().transactionSupport("NoTransaction").reauthenticationSupport(false);
   org.jboss.shrinkwrap.descriptor.api.connector16.ConnectionDefinitionType cdt = ort.createConnectionDefinition()
         .managedconnectionfactoryClass(WorkManagedConnectionFactoryNoHashCode.class.getName())
         .connectionfactoryInterface(WorkConnectionFactory.class.getName())
         .connectionfactoryImplClass(WorkConnectionFactoryImpl.class.getName())
         .connectionInterface(WorkConnection.class.getName())
         .connectionImplClass(WorkConnectionImpl.class.getName());

   ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, "work.rar");

   JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "work.jar");
   ja.addPackages(true, WorkConnection.class.getPackage());

   raa.addAsLibrary(ja);
   raa.addAsManifestResource(new StringAsset(raXml.exportAsString()), "ra.xml");

   return raa;
}
 
Example #20
Source File: DuplicateTypeValueTest.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
@Deployment
@AddonDependencies({
            @AddonDependency(name = "org.jboss.windup.graph:windup-graph"),
            @AddonDependency(name = "org.jboss.forge.furnace.container:cdi")
})
public static AddonArchive getDeployment()
{
    return ShrinkWrap.create(AddonArchive.class)
                .addBeansXML()
                .addClasses(TestSimpleModel.class, TestSimple2Model.class);
}
 
Example #21
Source File: CounterFieldBeanTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
        // Test bean
        .addClass(CounterFieldBean.class)
        // Bean archive deployment descriptor
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #22
Source File: ZeroRetryJitterTest.java    From microprofile-fault-tolerance with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftZeroTestJitter.jar")
                                    .addClasses(RetryClientForZeroJitter.class)
                                    .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
                                    .as(JavaArchive.class);

    return ShrinkWrap.create(WebArchive.class, "ftZeroTestJitter.war").addAsLibrary(testJar);
}
 
Example #23
Source File: EESecurityTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive createDeployment() throws Exception {
    WARArchive deployment = ShrinkWrap.create(WARArchive.class);
    deployment.addClass(EESecurityServlet.class);
    deployment.addClass(SimpleAuthenticationMechanism.class);
    deployment.addClass(SimpleIdentityStore.class);
    deployment.addAsWebInfResource("jboss-web.xml");
    return deployment;
}
 
Example #24
Source File: TimerFieldBeanTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Deployment
static Archive<?> createTestArchive() {
    return ShrinkWrap.create(WebArchive.class)
        // Test bean
        .addClasses(TimerFieldBean.class, MetricsUtil.class)
        // Bean archive deployment descriptor
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #25
Source File: SESIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive deployment() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "aws-ses-tests.jar");
    archive.addClasses(SESClientProducer.class, SESUtils.class, BasicCredentialsProvider.class);
    archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return archive;
}
 
Example #26
Source File: JoseCompactJwkAcceptTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> createDeployment() throws Exception {
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.addResource(MyResource.class);
    deployment.addResource(SecuredApplication.class);
    deployment.addResource(Jose4jJoseFactory.class);
    deployment.addResource(Jose4jJoseImpl.class);  
    deployment.addAllDependencies();
    deployment.addAsResource("jwk.keys");
    deployment.addAsResource("project-jwk-store-accept.yml", "project-defaults.yml");
    deployment.addAsServiceProvider(JoseFactory.class, Jose4jJoseFactory.class);
    return deployment;
}
 
Example #27
Source File: MissingValueOnInstanceInjectionTest.java    From ConfigJSR with Apache License 2.0 5 votes vote down vote up
@ShouldThrowException(DeploymentException.class)
@Deployment
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap
            .create(JavaArchive.class, "missingValueOnInstanceInjectionTest.jar")
            .addClass(ConfigOwner.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
            .create(WebArchive.class, "missingValueOnInstanceInjectionTest.war")
            .addAsLibrary(testJar);
    return war;
}
 
Example #28
Source File: InvalidConfigurationTest.java    From microprofile-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Deployment(managed = false, name = "invalid-publisher-method")
@ShouldThrowException(value = DeploymentException.class, testable = true)
public static Archive<JavaArchive> invalidPublisherMethod() {
  JavaArchive archive = ShrinkWrap.create(JavaArchive.class)
    .addClasses(BeanWithBadOutgoingSignature.class, ArchiveExtender.class)
    .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

  ServiceLoader.load(ArchiveExtender.class).iterator().forEachRemaining(ext -> ext.extend(archive));
  return archive;
}
 
Example #29
Source File: DisableTest.java    From microprofile-fault-tolerance with 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;
}
 
Example #30
Source File: PublicKeyAsBase64JWKTest.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}