lundi 19 mars 2018

Arquillian and Configuration

How can I set programatically environment variables to be used in Wildfly Swarm container?

I'm instantiate a server in @BeforeClass and this server endpoint should be passed to the Microprofile Config as EnviromentVariable.

All my code:

@CreateSwarm
public static Swarm newContainer() throws Exception {
    return new Swarm().fraction(new JAXRSFraction());
}

@Deployment(testable = false)
public static Archive<JAXRSArchive> createDeployment() throws Exception {
    return ShrinkWrap.create(JAXRSArchive.class, "myapp.war").addClass(MyConfigSource.class)
            .addClass(TestEndpoint.class).staticContent().setContextRoot("rest").addAllDependencies();
}

@Test
@RunAsClient
public void testSwarmServer() {
    browser.navigate().to("http://127.0.0.1:8080/rest/config");
    assertThat(browser.getPageSource()).contains("TEST_DATA");
} 

My problem is that the Wildfly container is up before @BeforeClass. How can I set this value?

Aucun commentaire:

Enregistrer un commentaire