org.jboss.shrinkwrap.api.asset.StringAsset Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.asset.StringAsset. 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: CDIFollowRedirectsTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    String urlProperty1 = SimpleGetApi.class.getName() + "/mp-rest/uri=" + getStringURL();
    String urlProperty2 = "myConfigKey/mp-rest/uri=" + getStringURL();
    String redirectProperty = "myConfigKey/mp-rest/followRedirects=true";
    String simpleName = CDIFollowRedirectsTest.class.getSimpleName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, simpleName + ".jar")
        .addClasses(SimpleGetApi.class, SimpleGetApiWithConfigKey.class, 
                    FollowRedirectsTest.class, WiremockArquillianTest.class)
        .addAsManifestResource(new StringAsset(String.format(redirectProperty + "%n" + urlProperty1 + "%n" + urlProperty2)),
                                               "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return ShrinkWrap.create(WebArchive.class, simpleName + ".war")
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #2
Source File: FaultToleranceInterceptorEnableByXmlTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class)
        .getOrCreateInterceptors()
        .clazz("org.eclipse.microprofile.fault.tolerance.tck.interceptor.xmlInterceptorEnabling.EarlyFtInterceptor").up()
        .getOrCreateInterceptors()
        .clazz("org.eclipse.microprofile.fault.tolerance.tck.interceptor.xmlInterceptorEnabling.LateFtInterceptor").up();

    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "interceptorFtXml.jar")
        .addClasses(InterceptorComponent.class, EarlyFtInterceptor.class, LateFtInterceptor.class, OrderQueueProducer.class)
         .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml")
        .as(JavaArchive.class);

    return ShrinkWrap.create(WebArchive.class, "interceptorFtXml.war")
        .addAsLibrary(testJar);
}
 
Example #3
Source File: HasConversationScopeTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    String url = SimpleGetApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String url2 = MyConversationScopedApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String scope = SimpleGetApi.class.getName() + "/mp-rest/scope=" + ConversationScoped.class.getName();
    String configKeyScope = "myConfigKey/mp-rest/scope=" + ConversationScoped.class.getName();
    String simpleName = HasConversationScopeTest.class.getSimpleName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, simpleName + ".jar")
        .addClasses(SimpleGetApi.class, MyConversationScopedApi.class, ConfigKeyClient.class)
        .addAsManifestResource(new StringAsset(url + "\n" + scope + "\n" + url2 + "\n" + configKeyScope),
                               "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return ShrinkWrap.create(WebArchive.class, simpleName + ".war")
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #4
Source File: JsonValueInjectionTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = JsonValueInjectionTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = JsonValueInjectionTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "JsonValueInjectionTest.war")
            .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey.pem")
            .addClass(JsonValuejectionEndpoint.class)
            .addClass(TCKApplication.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #5
Source File: ECPublicKeyAsJWKLocationTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key that
 * is referenced via the mp.jwt.verify.publickey.location as an embedded resource property.
 * The root url is /jwks
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createLocationDeployment() throws IOException {
    URL publicKey = ECPublicKeyAsJWKLocationTest.class.getResource("/ecPublicKey.jwk");
    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    // Location points to the JWKS bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/ecPublicKey.jwk");
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_ALGORITHM, SignatureAlgorithm.ES256.getAlgorithm());
    configProps.setProperty(Names.ISSUER, TCKConstants.TEST_ISSUER);
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "ECPublicKeyAsJWKLocationTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());
    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "ECPublicKeyAsJWKLocationTest.war")
            .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/ecPublicKey.jwk")
            .addClass(PublicKeyEndpoint.class)
            .addClass(JwksApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(configAsset, "microprofile-config.properties");
    return webArchive;
}
 
Example #6
Source File: ServletTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL publicKey = ServletTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "ServletTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(EjbEndpoint.class)
        .addClass(ServiceServlet.class)
        .addClass(IService.class)
        .addClass(ServiceEJB.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #7
Source File: RequiredClaimsTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable = true)
public static WebArchive createDeployment() throws IOException {
    URL config = RequiredClaimsTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = RequiredClaimsTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "RequiredClaimsTest.war")
            .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey.pem")
            .addClass(RequiredClaimsEndpoint.class)
            .addClass(TCKApplication.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #8
Source File: RolesAllowedSignEncryptTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = RolesAllowedSignEncryptTest.class.getResource("/META-INF/microprofile-config-verify-decrypt.properties");
    URL verifyKey = RolesAllowedSignEncryptTest.class.getResource("/publicKey4k.pem");
    URL decryptKey = RolesAllowedSignEncryptTest.class.getResource("/privateKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "RolesAllowedSignEncryptTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(decryptKey, "/privateKey.pem")
        .addAsResource(verifyKey, "/publicKey4k.pem")
        .addClass(RolesEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    return webArchive;
}
 
Example #9
Source File: ClaimValueInjectionTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = ClaimValueInjectionTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = ClaimValueInjectionTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "ClaimValueInjectionTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(ClaimValueInjectionEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #10
Source File: ConfigPropertyOnClassAndMethodTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deployAnotherApp() {
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "ftConfig.jar")
        .addClasses(BeanWithRetry.class)
        .addAsManifestResource(new StringAsset(
                                   "org.eclipse.microprofile.fault.tolerance.tck.config.BeanWithRetry/Retry/maxRetries=5" +
                                       "\norg.eclipse.microprofile.fault.tolerance.tck.config.BeanWithRetry/triggerException/Retry/maxRetries=6"),
                               "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
        .create(WebArchive.class, "ftConfigTest.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #11
Source File: TokenAsCookieTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() throws IOException {
    Properties configProps = new Properties();
    configProps.setProperty(VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey.pem");
    configProps.setProperty(ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty(TOKEN_HEADER, "Cookie");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "PublicKeyAsJWKTest JWK microprofile-config.properties");
    StringAsset config = new StringAsset(configSW.toString());

    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    return ShrinkWrap
        .create(WebArchive.class, "TokenAsCookie.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(TCKApplication.class)
        .addClass(RolesEndpoint.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
}
 
Example #12
Source File: HasAppScopeTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    String url = SimpleGetApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String url2 = MyAppScopedApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String scope = SimpleGetApi.class.getName() + "/mp-rest/scope=" + ApplicationScoped.class.getName();
    String configKeyScope = "myConfigKey/mp-rest/scope=" + ApplicationScoped.class.getName();
    String simpleName = HasAppScopeTest.class.getSimpleName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, simpleName + ".jar")
        .addClasses(SimpleGetApi.class, MyAppScopedApi.class, ConfigKeyClient.class)
        .addAsManifestResource(new StringAsset(url + "\n" + scope + "\n"+ url2 + "\n" + configKeyScope),
                               "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return ShrinkWrap.create(WebArchive.class, simpleName + ".war")
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #13
Source File: InvalidTokenTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = InvalidTokenTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "InvalidTokenTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(RolesEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #14
Source File: CircuitBreakerConfigOnMethodTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreaker.jar")
        .addClasses(CircuitBreakerClientDefaultSuccessThreshold.class,
                    Misc.class)
        .addAsManifestResource(new StringAsset(
                                   "org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker" +
                                       ".clientserver.CircuitBreakerClientDefaultSuccessThreshold/serviceA/CircuitBreaker/delay=200")
            , "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap.create(WebArchive.class, "ftCircuitBreaker.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #15
Source File: TokenAsCookieIgnoredTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() throws IOException {
    Properties configProps = new Properties();
    configProps.setProperty(VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey.pem");
    configProps.setProperty(ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty(TOKEN_COOKIE, "Authorization");
    configProps.setProperty(TOKEN_COOKIE, "jwt");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "PublicKeyAsJWKTest JWK microprofile-config.properties");
    StringAsset config = new StringAsset(configSW.toString());

    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    return ShrinkWrap
        .create(WebArchive.class, "TokenAsCookie.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(TCKApplication.class)
        .addClass(RolesEndpoint.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
}
 
Example #16
Source File: MPConfigTest.java    From microprofile-context-propagation with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    // build a JAR that provides three fake context types: 'Buffer', 'Label', and 'ThreadPriority'
    JavaArchive fakeContextProviders = ShrinkWrap.create(JavaArchive.class, "fakeContextTypes.jar")
            .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.buffer")
            .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.label")
            .addPackage("org.eclipse.microprofile.context.tck.contexts.priority.spi")
            .addAsServiceProvider(ThreadContextProvider.class,
                    BufferContextProvider.class, LabelContextProvider.class, ThreadPriorityContextProvider.class);

    return ShrinkWrap.create(WebArchive.class, MPConfigTest.class.getSimpleName() + ".war")
            .addClass(MPConfigBean.class)
            .addClass(MPConfigTest.class)
            .addClass(ProducerBean.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsWebInfResource(new StringAsset(
                            "mp.context.ManagedExecutor.maxAsync=1\n" +
                                    "mp.context.ManagedExecutor.maxQueued=4\n" +
                                    "mp.context.ManagedExecutor.propagated=Label,ThreadPriority\n" +
                                    "mp.context.ManagedExecutor.cleared=Remaining\n" +
                                    "mp.context.ThreadContext.cleared=Buffer\n" +
                                    "mp.context.ThreadContext.propagated=\n" +
                                    "mp.context.ThreadContext.unchanged=Remaining"),
                    "classes/META-INF/microprofile-config.properties")
            .addAsLibraries(fakeContextProviders);
}
 
Example #17
Source File: CDIInterceptorTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    String simpleName = CDIInterceptorTest.class.getSimpleName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, simpleName + ".jar")
        .addClasses(ClientWithURIAndInterceptor.class,
                    Loggable.class,
                    LoggableInterceptor.class,
                    ReturnWithURLRequestFilter.class)
        .addAsManifestResource(new StringAsset(
            "<beans xmlns=\"http://java.sun.com/xml/ns/javaee\"" +
            "       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
            "       xsi:schemaLocation=\"" +
            "          http://java.sun.com/xml/ns/javaee" +
            "          http://java.sun.com/xml/ns/javaee/beans_1_0.xsd\">" +
            "       <interceptors>" +
            "           <class>org.eclipse.microprofile.rest.client.tck.interfaces.LoggableInterceptor</class>" +
            "       </interceptors>" +
            "</beans>"),
            "beans.xml");
    return ShrinkWrap.create(WebArchive.class, simpleName + ".war")
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #18
Source File: PrimitiveInjectionTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = PrimitiveInjectionTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = PrimitiveInjectionTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "PrimitiveInjectionTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(PrimitiveInjectionEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #19
Source File: CDIPropertyNameMatchingTest.java    From ConfigJSR with Apache License 2.0 6 votes vote down vote up
@Deployment
public static Archive deployment() {
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "CDIPropertyNameMatchingTest.jar")
        .addClasses(CDIPropertyNameMatchingTest.class, SimpleValuesBean.class)
        .addAsManifestResource(new StringAsset(
                "envconfig.my.int/property=3"+
                    "\nenvconfig.my.string/property=fake"),
            "javaconfig.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
        .create(WebArchive.class, "CDIPropertyNameMatchingTest.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #20
Source File: ApplicationScopedInjectionTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = ApplicationScopedInjectionTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = ApplicationScopedInjectionTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "ClaimValueInjectionTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(ApplicationScopedEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #21
Source File: ProviderInjectionTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = ProviderInjectionTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = ProviderInjectionTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "ProviderInjectionTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(ProviderInjectionEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #22
Source File: PublicKeyAsPEMTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * 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 = PublicKeyAsPEMTest.class.getResource("/publicKey4k.pem");
    // This mp.jwt.verify.publickey value is an embedded PEM key
    URL config = PublicKeyAsPEMTest.class.getResource("/META-INF/microprofile-config-publickey.properties");

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "PublicKeyAsPEMTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey.pem")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example #23
Source File: ConfigPropertyGlobalVsClassVsMethodTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deployAnotherApp() {
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "ftConfig.jar")
        .addClasses(BeanWithRetry.class)
        .addAsManifestResource(new StringAsset(
            "org.eclipse.microprofile.fault.tolerance.tck.config.BeanWithRetry/Retry/maxRetries=5" +
                "\norg.eclipse.microprofile.fault.tolerance.tck.config.BeanWithRetry/triggerException/Retry/maxRetries=6" +
                "\nRetry/maxRetries=7"), "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
        .create(WebArchive.class, "ftConfigTest.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #24
Source File: ConfigKeyTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    String uriPropertyName = "myConfigKey/mp-rest/uri";
    String uriValue = "http://localhost:1234/configKeyUri";
    String overridePropName = ConfigKeyClient2.class.getName()+"/mp-rest/uri";
    String overridePropValue = "http://localhost:5678/FQCNUri";
    String simpleName = ConfigKeyTest.class.getSimpleName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, simpleName + ".jar")
        .addClasses(ConfigKeyClient.class,
                    ConfigKeyClient2.class,
                    ReturnWithURLRequestFilter.class)
        .addAsManifestResource(new StringAsset(
            String.format(uriPropertyName+"="+uriValue+"%n"+
                          overridePropName+"="+overridePropValue)),
            "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return ShrinkWrap.create(WebArchive.class, simpleName + ".war")
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #25
Source File: ECPublicKeyAsPEMTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive that includes an embedded PEM EC 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 {
    // This mp.jwt.verify.publickey value is an embedded PEM key
    URL config = ECPublicKeyAsPEMTest.class.getResource("/META-INF/microprofile-config-ecpublickey.properties");

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "PublicKeyAsPEMTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    return webArchive;
}
 
Example #26
Source File: CombinedFormBasicAuthTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public JavaArchive get() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClasses(TestIdentityProvider.class, TestTrustedIdentityProvider.class, TestIdentityController.class,
                    PathHandler.class)
            .addAsResource(new StringAsset(APP_PROPS), "application.properties");
}
 
Example #27
Source File: AgroalDevModeTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public JavaArchive get() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClass(DevModeResource.class)
            .add(new StringAsset("quarkus.datasource.db-kind=h2\n" +
                    "quarkus.datasource.username=USERNAME-NAMED\n" +
                    "quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:testing\n" +
                    "quarkus.datasource.jdbc.driver=org.h2.Driver\n"), "application.properties");
}
 
Example #28
Source File: DefaultOverflowStrategyOverflowWithoutBufferSizeTest.java    From microprofile-reactive-messaging with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<JavaArchive> deployment() {
    return getBaseArchive()
        .addClasses(BeanUsingBufferOverflowWithoutBufferSizeStrategy.class)
        .addAsManifestResource(new StringAsset(
            "mp.messaging.emitter.default-buffer-size=5"),
                "microprofile-config.properties");
}
 
Example #29
Source File: FormAuthTestCase.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public JavaArchive get() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClasses(TestIdentityProvider.class, TestTrustedIdentityProvider.class, TestIdentityController.class,
                    PathHandler.class)
            .addAsResource(new StringAsset(APP_PROPS), "application.properties");
}
 
Example #30
Source File: EmptyTokenTest.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    URL config = InvalidTokenTest.class.getResource("/META-INF/microprofile-config-publickey-location.properties");
    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    return ShrinkWrap
        .create(WebArchive.class, "EmptyTokenTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(TCKApplication.class)
        .addClass(EmptyTokenEndpoint.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
}