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 Project: microprofile-rest-client   Author: eclipse   File: HasConversationScopeTest.java    License: 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 #2
@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 #3
Source Project: microprofile-jwt-auth   Author: eclipse   File: ClaimValueInjectionTest.java    License: 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 #4
Source Project: microprofile-jwt-auth   Author: eclipse   File: ServletTest.java    License: 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 #5
Source Project: microprofile-jwt-auth   Author: eclipse   File: JsonValueInjectionTest.java    License: 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 #6
Source Project: microprofile-rest-client   Author: eclipse   File: HasAppScopeTest.java    License: 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 #7
Source Project: microprofile-jwt-auth   Author: eclipse   File: InvalidTokenTest.java    License: 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 #8
Source Project: microprofile-rest-client   Author: eclipse   File: ConfigKeyTest.java    License: 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 #9
Source Project: microprofile-jwt-auth   Author: eclipse   File: ProviderInjectionTest.java    License: 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 #10
Source Project: ConfigJSR   Author: eclipse   File: CDIPropertyNameMatchingTest.java    License: 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 #11
Source Project: microprofile-jwt-auth   Author: eclipse   File: PrimitiveInjectionTest.java    License: 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 #12
Source Project: microprofile-rest-client   Author: eclipse   File: CDIInterceptorTest.java    License: 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 #13
Source Project: microprofile-context-propagation   Author: eclipse   File: MPConfigTest.java    License: 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 #14
Source Project: microprofile-rest-client   Author: eclipse   File: CDIFollowRedirectsTest.java    License: 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 #15
Source Project: microprofile-jwt-auth   Author: eclipse   File: ApplicationScopedInjectionTest.java    License: 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 #16
Source Project: microprofile-jwt-auth   Author: eclipse   File: PublicKeyAsPEMTest.java    License: 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 #17
@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 #18
Source Project: microprofile-fault-tolerance   Author: eclipse   File: CircuitBreakerConfigOnMethodTest.java    License: 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 #19
Source Project: microprofile-jwt-auth   Author: eclipse   File: ECPublicKeyAsPEMTest.java    License: 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 #20
Source Project: microprofile-jwt-auth   Author: eclipse   File: RolesAllowedSignEncryptTest.java    License: 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 #21
Source Project: microprofile-jwt-auth   Author: eclipse   File: TokenAsCookieTest.java    License: 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 #22
Source Project: microprofile-jwt-auth   Author: eclipse   File: ECPublicKeyAsJWKLocationTest.java    License: 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 #23
Source Project: microprofile-jwt-auth   Author: eclipse   File: RequiredClaimsTest.java    License: 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 #24
@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 #25
Source Project: microprofile-jwt-auth   Author: eclipse   File: TokenAsCookieIgnoredTest.java    License: 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 #26
Source Project: camel-quarkus   Author: apache   File: CamelDevModeTest.java    License: Apache License 2.0 5 votes vote down vote up
public static Asset applicationProperties() {
    Writer writer = new StringWriter();

    Properties props = new Properties();
    props.setProperty("quarkus.banner.enabled", "false");
    props.setProperty("camel.main.xml-routes", "file:" + BASE.toAbsolutePath().toString() + "/routes.xml");

    try {
        props.store(writer, "");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new StringAsset(writer.toString());
}
 
Example #27
Source Project: camel-quarkus   Author: apache   File: CamelMainAutoConfigurationTest.java    License: Apache License 2.0 5 votes vote down vote up
public static Asset applicationProperties() {
    Writer writer = new StringWriter();

    Properties props = new Properties();
    props.setProperty("quarkus.banner.enabled", "false");
    props.setProperty("quarkus.arc.remove-unused-beans", "false");

    try {
        props.store(writer, "");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new StringAsset(writer.toString());
}
 
Example #28
Source Project: camel-quarkus   Author: apache   File: CamelMainRoutesDiscoveryTest.java    License: Apache License 2.0 5 votes vote down vote up
public static Asset applicationProperties() {
    Writer writer = new StringWriter();

    Properties props = new Properties();
    props.setProperty("quarkus.banner.enabled", "false");
    props.setProperty("quarkus.camel.routes-discovery.enabled", "false");

    try {
        props.store(writer, "");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new StringAsset(writer.toString());
}
 
Example #29
Source Project: camel-quarkus   Author: apache   File: CamelMainInjectTest.java    License: Apache License 2.0 5 votes vote down vote up
public static Asset applicationProperties() {
    Writer writer = new StringWriter();

    Properties props = new Properties();
    props.setProperty("quarkus.banner.enabled", "false");
    props.setProperty("quarkus.arc.remove-unused-beans", "false");

    try {
        props.store(writer, "");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new StringAsset(writer.toString());
}
 
Example #30
Source Project: camel-quarkus   Author: apache   File: CamelConfigurationTest.java    License: Apache License 2.0 5 votes vote down vote up
public static Asset applicationProperties() {
    Writer writer = new StringWriter();

    Properties props = new Properties();
    props.setProperty("quarkus.arc.remove-unused-beans", "false");
    props.setProperty("quarkus.banner.enabled", "false");

    try {
        props.store(writer, "");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new StringAsset(writer.toString());
}