org.jboss.shrinkwrap.api.spec.JavaArchive Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.spec.JavaArchive. 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: OptimisticEventStoreServiceTest.java    From JEEventStore with MIT License 6 votes vote down vote up
@Deployment
public static Archive<?> deployment() {
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
            .addAsModule(ShrinkWrap.create(JavaArchive.class, "ejb.jar")
                    .addAsManifestResource(new File("src/test/resources/META-INF/beans.xml"))
                    .addAsManifestResource(new File(
                            "src/test/resources/META-INF/ejb-jar-OptimisticEventStoreServiceTest.xml"),
                            "ejb-jar.xml")
                    .addPackage(ChangeSet.class.getPackage())
                    .addPackage(EventStoreCommitNotifier.class.getPackage())
                    .addPackage(OptimisticEventStoreService.class.getPackage())
                    .addPackage(SyncEventStoreCommitNotifier.class.getPackage())
                    .addClass(IteratorUtils.class)
                    .addClass(MockPersistence.class)
                    .addClass(EventStorePersistence.class)
            );
    return ear;
}
 
Example #2
Source File: JWTOrFormAuthenticationFilterTest.java    From shiro-jwt with MIT License 6 votes vote down vote up
@Deployment
public static Archive<?> deployment() {

    File[] filesCompile = Maven.resolver().loadPomFromFile("pom.xml").importDependencies(ScopeType.COMPILE).resolve().withTransitivity().asFile();
    File[] filestest = Maven.resolver().loadPomFromFile("pom.xml")
            .resolve("com.fasterxml.jackson.core:jackson-annotations", "com.fasterxml.jackson.core:jackson-databind", "com.fasterxml.jackson.core:jackson-core").withTransitivity().asFile();

    JavaArchive jar = ShrinkWrap.create(MavenImporter.class)
            .loadPomFromFile("pom.xml")
            .importBuildOutput()
            .as(JavaArchive.class);

    WebArchive war = ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(filestest)
            .addAsLibraries(jar)
            .addAsLibraries(filesCompile)
            .addClasses(UserDefaultExample.class, UserRepositoryExample.class)
            .addClasses(JAXRSConfigurationExample.class, ObjectMapperProviderExample.class, ResourceExample.class)
            .addAsWebInfResource("WEB-INF/test.shiro.ini", "shiro.ini")
            .addAsWebInfResource("WEB-INF/web.xml", "web.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

    System.out.println(war.toString(true));

    return war;
}
 
Example #3
Source File: DisableAnnotationOnClassTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy() {
   Asset config = new DisableConfigAsset()
           .disable(DisableAnnotationClient.class, Retry.class)
           .disable(DisableAnnotationClient.class, CircuitBreaker.class)
           .disable(DisableAnnotationClient.class, Timeout.class)
           .disable(DisableAnnotationClient.class, Asynchronous.class)
           .disable(DisableAnnotationClient.class, Fallback.class)
           .disable(DisableAnnotationClient.class, Bulkhead.class);
    
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "ftDisableClass.jar")
        .addClasses(DisableAnnotationClient.class)
        .addPackage(Packages.UTILS)
        .addAsManifestResource(config, "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
        .create(WebArchive.class, "ftDisableClass.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #4
Source File: DisableAnnotationGloballyTest.java    From microprofile-fault-tolerance with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy() {
    
    Asset config = new DisableConfigAsset()
            .disable(Retry.class)
            .disable(CircuitBreaker.class)
            .disable(Timeout.class)
            .disable(Asynchronous.class)
            .disable(Fallback.class)
            .disable(Bulkhead.class);
    
    JavaArchive testJar = ShrinkWrap
        .create(JavaArchive.class, "ftDisableGlobally.jar")
        .addClasses(DisableAnnotationClient.class)
        .addPackage(Packages.UTILS)
        .addAsManifestResource(config, "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
        .as(JavaArchive.class);

    WebArchive war = ShrinkWrap
        .create(WebArchive.class, "ftDisableGlobally.war")
        .addAsLibrary(testJar);
    return war;
}
 
Example #5
Source File: JdkModuleDependencyTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JavaArchive prepareTestDeployment(String dependency) throws Exception {
    final String deploymentName = dependency + DEPLOYMENT_NAME_SUFFIX;
    final Properties properties = new Properties();
    properties.put(deploymentName + "Service", "isNew");
    final JavaArchive archive = ServiceActivatorDeploymentUtil.createServiceActivatorDeploymentArchive(deploymentName,
            properties);
    archive.delete("META-INF/permissions.xml");
    archive.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
            new PropertyPermission("test.deployment.trivial.prop", "write"),
            new PropertyPermission(deploymentName + "Service", "write"),
            new PropertyPermission("service", "write")
    ), "permissions.xml");
    archive.addAsResource(new StringAsset(prepareJBossDeploymentStructure(dependency)),
            "META-INF/jboss-deployment-structure.xml");
    return archive;
}
 
Example #6
Source File: StartSuspendedTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Before
public void startContainer() throws Exception {
    // Start the server
    container.startSuspended();
    managementClient = container.getClient();

    //ServerDeploymentHelper helper = new ServerDeploymentHelper(managementClient.getControllerClient());
    JavaArchive war = ShrinkWrap.create(JavaArchive.class, WEB_SUSPEND_JAR);
    war.addPackage(SuspendResumeHandler.class.getPackage());
    war.addAsServiceProvider(ServiceActivator.class, TestSuspendServiceActivator.class);
    war.addAsResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller, io.undertow.core, org.jboss.as.server,org.wildfly.extension.request-controller, org.jboss.as.network\n"), "META-INF/MANIFEST.MF");
    war.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(
        new RuntimePermission("createXnioWorker"),
        new SocketPermission(TestSuiteEnvironment.getServerAddress() + ":8080", "listen,resolve"),
        new SocketPermission("*", "accept,resolve")
    ), "permissions.xml");
    //helper.deploy(WEB_SUSPEND_JAR, war.as(ZipExporter.class).exportAsInputStream());
    serverController.deploy(war, WEB_SUSPEND_JAR);
}
 
Example #7
Source File: PubcompInterceptorHandlerTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
@NotNull
private PubcompInboundInterceptor getInboundInterceptor(@NotNull final String name) throws Exception {

    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class)
            .addClass("com.hivemq.extensions.handler.PubcompInterceptorHandlerTest$" + name);

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

    //This classloader contains the classes from the jar file
    final IsolatedPluginClassloader
            cl =
            new IsolatedPluginClassloader(new URL[]{jarFile.toURI().toURL()}, this.getClass().getClassLoader());

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

    return (PubcompInboundInterceptor) interceptorClass.newInstance();
}
 
Example #8
Source File: PingInterceptorHandlerTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
private @NotNull PingReqInboundInterceptor getIsolatedInboundInterceptor(final @NotNull String name) throws Exception {
    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class)
            .addClass("com.hivemq.extensions.handler.PingInterceptorHandlerTest$" + 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.PingInterceptorHandlerTest$" + name);

    final PingReqInboundInterceptor interceptor =
            (PingReqInboundInterceptor) interceptorClass.newInstance();

    return interceptor;
}
 
Example #9
Source File: PluginLoaderImplTest.java    From hivemq-community-edition with Apache License 2.0 6 votes vote down vote up
/*******************************
 * loadSinglePlugin(...) Tests *
 *******************************/

@Test(timeout = 5000)
public void test_load_single_plugin_load_and_instantiate_enabled() throws Throwable {

    final File pluginFolder1 = temporaryFolder.newFolder("extension", "plugin1");
    FileUtils.writeStringToFile(pluginFolder1.toPath().resolve("hivemq-extension.xml").toFile(),
            validPluginXML1,
            Charset.defaultCharset());
    final File file = new File(pluginFolder1, "extension.jar");
    final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class).
            addAsServiceProviderAndClasses(ExtensionMain.class, TestExtensionMainImpl.class);
    javaArchive.as(ZipExporter.class).exportTo(file);

    final HiveMQExtension hiveMQExtension = realPluginLoader.loadSinglePlugin(
            pluginFolder1.toPath(),
            HiveMQPluginXMLReader.getPluginEntityFromXML(pluginFolder1.toPath(), true).get(),
            ExtensionMain.class);

    assertNotNull(hiveMQExtension);
    hiveMQExtension.start(super.getTestPluginStartInput(), super.getTestPluginStartOutput());
    assertTrue(hiveMQExtension.isEnabled());
}
 
Example #10
Source File: CustomSchedulerWarFileTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    String simpleName = CustomSchedulerWarFileTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "customSchedulerTest.jar")
            .addPackage(CustomSchedulerWarFileTest.class.getPackage().getName())
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsResource(new StringAsset(MockedScheduler.class.getName()),
                    "META-INF/services/" + Scheduler.class.getName())
            .addAsResource(new StringAsset(CustomConfigSource.class.getName()),
                    "META-INF/services/" + ConfigSource.class.getName());

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndSchedulerArchive())
            .addAsLibraries(ArchiveUtils.getContextControlForDeployment())
            .addAsLibraries(Maven.resolver().loadPomFromFile("pom.xml").resolve(
                    "org.quartz-scheduler:quartz")
                    .withTransitivity()
                    .asFile())
            .addAsLibraries(testJar)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #11
Source File: FallbackConfigTest.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();
    config.set(FallbackConfigBean.class, "applyOnMethod", Fallback.class, "applyOn", TestConfigExceptionA.class.getCanonicalName());
    config.set(FallbackConfigBean.class, "skipOnMethod", Fallback.class, "skipOn", TestConfigExceptionA.class.getCanonicalName());
    config.set(FallbackConfigBean.class, "fallbackMethodConfig", Fallback.class, "fallbackMethod", "anotherFallback");
    config.set(FallbackConfigBean.class, "fallbackHandlerConfig", Fallback.class, "value", FallbackHandlerB.class.getName());
    
    JavaArchive jar = ShrinkWrap
            .create(JavaArchive.class, "ftFallbackConfigTest.jar")
            .addPackage(FallbackConfigTest.class.getPackage())
            .addPackage(Packages.UTILS)
            .addAsManifestResource(config, "microprofile-config.properties")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    
    WebArchive war = ShrinkWrap
            .create(WebArchive.class, "ftFallbackConfigTest.war")
            .addAsLibraries(jar);
    return war;
}
 
Example #12
Source File: ConcreteExtendedTimedBeanTest.java    From metrics-cdi with Apache License 2.0 5 votes vote down vote up
@Deployment
static Archive<?> createTestArchive() {
    return ShrinkWrap.create(JavaArchive.class)
        // Test bean
        .addClass(ConcreteExtendedTimedBean.class)
        // Metrics CDI extension
        .addPackage(MetricsExtension.class.getPackage())
        // Bean archive deployment descriptor
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #13
Source File: AbstractTest.java    From ConfigJSR with Apache License 2.0 5 votes vote down vote up
public static void addFile(JavaArchive archive, String originalPath) {
    String resName = "internal/" + originalPath;
    URL resource = Thread.currentThread().getContextClassLoader().getResource(resName);
    if (resource == null) {
        throw new IllegalStateException("could not load test resource " + resName);
    }
    archive.addAsResource(new UrlAsset(resource),
            originalPath);
}
 
Example #14
Source File: EclipseLinkTest.java    From hammock with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClasses(Employee.class, EmployeeService.class, EclipseLinkTest.class, SimpleEmployeeService.class)
       .addAsServiceProviderAndClasses(Extension.class, DataSourceExtension.class, JPAExtension.class)
            .addPackage(EntityManagerProducer.class.getPackage())
            .addAsManifestResource("META-INF/beans.xml", "beans.xml")
            .addAsManifestResource("META-INF/load.sql")
            .addAsManifestResource("META-INF/persistence.xml");
}
 
Example #15
Source File: CompositeFunctionsTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    
    return ShrinkWrap
                    .create(JavaArchive.class)
                    .addPackages(true, "org.apache.deltaspike", "io.astefanutti.metrics.cdi", "datawave.query", "org.jboss.logging",
                                    "datawave.webservice.query.result.event")
                    .deleteClass(DefaultEdgeEventQueryLogic.class)
                    .deleteClass(RemoteEdgeDictionary.class)
                    .deleteClass(datawave.query.metrics.QueryMetricQueryLogic.class)
                    .deleteClass(datawave.query.metrics.ShardTableQueryMetricHandler.class)
                    .addAsManifestResource(
                                    new StringAsset("<alternatives>" + "<stereotype>datawave.query.tables.edge.MockAlternative</stereotype>"
                                                    + "</alternatives>"), "beans.xml");
}
 
Example #16
Source File: Libraries.java    From microprofile1.4-samples with MIT License 5 votes vote down vote up
public static JavaArchive[] awaitability() {
    return Maven.resolver()
            .loadPomFromFile("pom.xml")
            .resolve("com.jayway.awaitility:awaitility")
            .withTransitivity()
            .as(JavaArchive.class);
}
 
Example #17
Source File: TMSRulesJUnitTest.java    From drools-workshop with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
            .addPackages(true, "org.drools.workshop.clinical.model")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    //System.out.println(jar.toString(true));
    return jar;
}
 
Example #18
Source File: BusinessScopedRulesJUnitTest.java    From drools-workshop with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
            .addPackages(true, "org.drools.workshop")
            .addAsServiceProvider(BusinessScopeExtension.class, BusinessScopeContext.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    System.out.println(jar.toString(true));
    return jar;
}
 
Example #19
Source File: ExtensionSetup.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static StreamExporter createResourceRoot(Class<? extends Extension> extension, Package... additionalPackages) throws IOException {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    archive.addPackage(extension.getPackage());
    if (additionalPackages != null) {
        for (Package pkg : additionalPackages) {
            archive.addPackage(pkg);
        }
    }
    archive.addAsServiceProvider(Extension.class, extension);
    return archive.as(ZipExporter.class);
}
 
Example #20
Source File: ZookeeperMasterIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive deployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "zookeeper-master-tests");
    archive.addClasses(CuratorFactoryBean.class, ZKServerFactoryBean.class);
    archive.addAsResource("zookeepermaster/zkmaster-camel-context.xml");
    return archive;
}
 
Example #21
Source File: ServiceFileCombinationImpl.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private static Map<ArchivePath, Node> getMatchingFilesFromJar(List<String> patterns, JavaArchive archive) {
    return archive.getContent(path -> {
                for (String pattern : patterns) {
                    if (SelectorUtils.match(pattern, path.get())) {
                        return true;
                    }
                }
                return false;
            });
}
 
Example #22
Source File: DeploymentHelper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static JavaArchive[] getEngineSpring() {
  if(CACHED_SPRING_ASSETS != null) {
    return CACHED_SPRING_ASSETS;
  } else {

    JavaArchive[] resolvedArchives = Maven.configureResolver()
        .workOffline()
        .loadPomFromFile("pom.xml")
        .addDependencies(
            MavenDependencies.createDependency("org.camunda.bpm:camunda-engine-spring", ScopeType.COMPILE, false,
                MavenDependencies.createExclusion("org.camunda.bpm:camunda-engine")),
                MavenDependencies.createDependency("org.springframework:spring-context", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-jdbc", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-tx", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-orm", ScopeType.COMPILE, false),
                MavenDependencies.createDependency("org.springframework:spring-web", ScopeType.COMPILE, false))
        .resolve()
        .withTransitivity()
        .as(JavaArchive.class);

    if(resolvedArchives.length == 0) {
      throw new RuntimeException("could not resolve org.camunda.bpm:camunda-engine-spring");
    } else {
      CACHED_SPRING_ASSETS = resolvedArchives;
      return CACHED_SPRING_ASSETS;
    }
  }

}
 
Example #23
Source File: MyTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    final JavaArchive  archive = ShrinkWrap.create(JavaArchive.class, "camel-tests.jar");
    archive.addPackage(MyBean.class.getPackage());
    archive.addAsResource(new File("src/main/webapp/META-INF/jboss-camel-context.xml"), "jboss-camel-context.xml");
    return archive;
}
 
Example #24
Source File: CounterFieldBeanTest.java    From metrics-cdi with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(JavaArchive.class)
        // Test bean
        .addClass(CounterFieldBean.class)
        // Metrics CDI extension
        .addPackage(MetricsExtension.class.getPackage())
        // Bean archive deployment descriptor
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #25
Source File: TestDatawaveUserServiceTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() throws Exception {
    System.setProperty("cdi.bean.context", "testAuthServiceBeanRefContext.xml");
    System.setProperty("dw.security.use.testuserservice", "false");
    return ShrinkWrap
                    .create(JavaArchive.class)
                    .addPackages(true, "org.apache.deltaspike", "io.astefanutti.metrics.cdi")
                    .addClasses(TestDatawaveUserService.class, DatawaveUserService1.class, AltDatawaveUserService1.class, AltDatawaveUserService2.class)
                    .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #26
Source File: ProgrammaticPUTest.java    From hammock with Apache License 2.0 5 votes vote down vote up
@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class)
            .addClasses(AnotherEmployeeService.class, ProgrammaticPUTest.class, PUConfiguration.class)
            .addAsServiceProviderAndClasses(Extension.class, DataSourceExtension.class, JPAExtension.class)
            .addPackage(EntityManagerProducer.class.getPackage())
            .addAsManifestResource("META-INF/beans.xml", "beans.xml");
}
 
Example #27
Source File: UncatchedFlushExceptionTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "autoInjectionUncatchedFlushExceptionTest.jar")
            .addPackage(ArchiveUtils.SHARED_PACKAGE)
            .addPackage(UncatchedFlushExceptionTest.class.getPackage().getName())
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    return ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
            .addAsLibraries(testJar)
            .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
            .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
}
 
Example #28
Source File: ExceptionMeteredMethodBeanTest.java    From metrics-cdi with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> createTestArchive() {
    return ShrinkWrap.create(JavaArchive.class)
        // Test bean
        .addClass(ExceptionMeteredMethodBean.class)
        // Metrics CDI extension
        .addPackage(MetricsExtension.class.getPackage())
        // Bean archive deployment descriptor
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #29
Source File: CircuitBreakerConfigTest.java    From microprofile-fault-tolerance with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive create() {
    ConfigAnnotationAsset config = new ConfigAnnotationAsset()
        .set(CircuitBreakerConfigBean.class, "skipOnMethod", CircuitBreaker.class,
            "skipOn", TestConfigExceptionA.class.getName())
        .set(CircuitBreakerConfigBean.class, "failOnMethod", CircuitBreaker.class,
            "failOn", TestConfigExceptionA.class.getName())
        .set(CircuitBreakerConfigBean.class, "delayMethod", CircuitBreaker.class,
            "delay", TCKConfig.getConfig().getTimeoutInStr(1000))
        .set(CircuitBreakerConfigBean.class, "delayMethod", CircuitBreaker.class,
            "delayUnit", "MILLIS")
        .set(CircuitBreakerConfigBean.class, "requestVolumeThresholdMethod", CircuitBreaker.class,
            "requestVolumeThreshold", "4")
        .set(CircuitBreakerConfigBean.class, "failureRatioMethod", CircuitBreaker.class,
            "failureRatio","0.8")
        .set(CircuitBreakerConfigBean.class, "successThresholdMethod", CircuitBreaker.class,
            "successThreshold", "2")
        // only changing value here to scale the original, not for the purpose of this test
        .set(CircuitBreakerConfigBean.class, "successThresholdMethod", CircuitBreaker.class,
            "delay", TCKConfig.getConfig().getTimeoutInStr(1000));

    JavaArchive jar = ShrinkWrap
            .create(JavaArchive.class, "ftCircuitBreakerConfig.jar")
            .addClasses(CircuitBreakerConfigBean.class, TestConfigExceptionA.class, TestConfigExceptionB.class)
            .addPackage(Packages.UTILS)
            .addAsManifestResource(config, "microprofile-config.properties")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    return ShrinkWrap
            .create(WebArchive.class, "ftCircuitBreakerConfig.war")
            .addAsLibraries(jar);
}
 
Example #30
Source File: DeploymentOverlayTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    testSupport = CLITestSuite.createSupport(
            DeploymentOverlayTestCase.class.getSimpleName());
    cli = CLITestUtil.getCommandContext(testSupport);
    cli.connectController();

    properties.clear();
    properties.put("service", "is new");

    properties2.clear();
    properties2.put("service", "is overwritten");

    JavaArchive archive = ServiceActivatorDeploymentUtil.createServiceActivatorDeploymentArchive(name, properties);
    archiveFile = new File(TestSuiteEnvironment.getTmpDir(), name);
    archiveFile.createNewFile();
    archiveFile.deleteOnExit();
    archive.as(ZipExporter.class).exportTo(archiveFile, true);
    deployContent();
    // overlay content
    overlayContent = new File(TestSuiteEnvironment.getTmpDir(), "test-properties-content.properties");
    overlayContent.createNewFile();
    overlayContent.deleteOnExit();
    try (FileWriter writer = new FileWriter(overlayContent)) {
        properties2.store(writer, "Overlay Content");
    }
}