Search in sources :

Example 1 with JolokiaFraction

use of org.wildfly.swarm.jolokia.JolokiaFraction in project wildfly-swarm by wildfly-swarm.

the class JolokiaKeycloakCustomizerTest method testWithoutRole.

@Test
public void testWithoutRole() {
    JolokiaFraction jolokia = new JolokiaFraction();
    JolokiaKeycloakCustomizer customizer = new JolokiaKeycloakCustomizer();
    customizer.jolokia = jolokia;
    customizer.customize();
    assertThat(jolokia.jolokiaWarPreparer()).isNull();
}
Also used : JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) Test(org.junit.Test)

Example 2 with JolokiaFraction

use of org.wildfly.swarm.jolokia.JolokiaFraction in project wildfly-swarm by wildfly-swarm.

the class JolokiaKeycloakCustomizerTest method testWithRole.

@Test
public void testWithRole() {
    JolokiaFraction jolokia = new JolokiaFraction();
    JolokiaKeycloakCustomizer customizer = new JolokiaKeycloakCustomizer();
    customizer.jolokia = jolokia;
    customizer.role = "admin";
    customizer.customize();
    assertThat(jolokia.jolokiaWarPreparer()).isNotNull();
}
Also used : JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) Test(org.junit.Test)

Example 3 with JolokiaFraction

use of org.wildfly.swarm.jolokia.JolokiaFraction in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testPreferConfigValueURL_vs_API.

@Test
public void testPreferConfigValueURL_vs_API() throws Exception {
    URL resource = getClass().getClassLoader().getResource("my-jolokia-access2.xml");
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccess(access -> {
        access.host("1.1.1.1");
    }));
    producer.lookup = new MockArtifactLookup();
    producer.jolokiaAccessXML = resource.toExternalForm();
    Archive war = producer.jolokiaWar();
    Node xml = war.get("WEB-INF/classes/jolokia-access.xml");
    assertThat(xml).isNotNull();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(xml.getAsset().openStream()))) {
        List<String> lines = reader.lines().collect(Collectors.toList());
        assertThat(lines).isNotEmpty();
        assertThat(lines.get(0)).contains("This is my-jolokia-access2.xml");
    }
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) InputStreamReader(java.io.InputStreamReader) Node(org.jboss.shrinkwrap.api.Node) BufferedReader(java.io.BufferedReader) JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) URL(java.net.URL) Test(org.junit.Test)

Example 4 with JolokiaFraction

use of org.wildfly.swarm.jolokia.JolokiaFraction in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testNoJolokiaAccessAtAll.

@Test
public void testNoJolokiaAccessAtAll() throws Exception {
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction();
    producer.lookup = new MockArtifactLookup();
    Archive war = producer.jolokiaWar();
    Node xml = war.get("WEB-INF/classes/jolokia-access.xml");
    assertThat(xml).isNull();
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) Node(org.jboss.shrinkwrap.api.Node) JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) Test(org.junit.Test)

Example 5 with JolokiaFraction

use of org.wildfly.swarm.jolokia.JolokiaFraction in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testJolokiaAccessViaUrlOnFraction.

@Test
public void testJolokiaAccessViaUrlOnFraction() throws Exception {
    URL resource = getClass().getClassLoader().getResource("my-jolokia-access.xml");
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccessXml(resource));
    producer.lookup = new MockArtifactLookup();
    Archive war = producer.jolokiaWar();
    Node xml = war.get("WEB-INF/classes/jolokia-access.xml");
    assertThat(xml).isNotNull();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(xml.getAsset().openStream()))) {
        List<String> lines = reader.lines().collect(Collectors.toList());
        assertThat(lines).isNotEmpty();
        assertThat(lines.get(0)).contains("This is my-jolokia-access.xml");
    }
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) InputStreamReader(java.io.InputStreamReader) Node(org.jboss.shrinkwrap.api.Node) BufferedReader(java.io.BufferedReader) JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) URL(java.net.URL) Test(org.junit.Test)

Aggregations

JolokiaFraction (org.wildfly.swarm.jolokia.JolokiaFraction)10 Test (org.junit.Test)9 Archive (org.jboss.shrinkwrap.api.Archive)8 Node (org.jboss.shrinkwrap.api.Node)8 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7 URL (java.net.URL)6 File (java.io.File)3