Search in sources :

Example 31 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testJolokiaAccessViaAPI.

@Test
public void testJolokiaAccessViaAPI() throws Exception {
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccess(access -> {
        access.host("1.1.1.1");
    }));
    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().map(String::trim).collect(Collectors.toList());
        assertThat(lines).isNotEmpty();
        assertThat(lines).contains("<host>1.1.1.1</host>");
    }
}
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) Test(org.junit.Test)

Example 32 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testPreferConfigValueURL_vs_FractionSetting.

@Test
public void testPreferConfigValueURL_vs_FractionSetting() throws Exception {
    URL resource = getClass().getClassLoader().getResource("my-jolokia-access2.xml");
    URL fractionResource = getClass().getClassLoader().getResource("my-jolokia-access3.xml");
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccessXml(fractionResource));
    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 33 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testJolokiaAccessViaFileOnFraction.

@Test
public void testJolokiaAccessViaFileOnFraction() throws Exception {
    URL resource = getClass().getClassLoader().getResource("my-jolokia-access2.xml");
    String path = resource.getPath();
    File file = new File(path);
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccessXml(file));
    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-access2.xml");
    }
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) InputStreamReader(java.io.InputStreamReader) Node(org.jboss.shrinkwrap.api.Node) BufferedReader(java.io.BufferedReader) File(java.io.File) JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) URL(java.net.URL) Test(org.junit.Test)

Example 34 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class JolokiaWarDeploymentProducerTest method testPreferConfigValueFile_vs_API.

@Test
public void testPreferConfigValueFile_vs_API() throws Exception {
    URL resource = getClass().getClassLoader().getResource("my-jolokia-access2.xml");
    String path = resource.getPath();
    File file = new File(path);
    JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
    producer.fraction = new JolokiaFraction().prepareJolokiaWar(JolokiaFraction.jolokiaAccess(access -> {
        access.host("1.1.1.1");
    }));
    producer.lookup = new MockArtifactLookup();
    producer.jolokiaAccessXML = file.getAbsolutePath();
    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) File(java.io.File) JolokiaFraction(org.wildfly.swarm.jolokia.JolokiaFraction) URL(java.net.URL) Test(org.junit.Test)

Example 35 with Archive

use of org.jboss.shrinkwrap.api.Archive in project ceylon by eclipse.

the class ModulesTest method testArchive.

protected void testArchive(Archive module, String run, Archive... libs) throws Throwable {
    File tmpdir = Files.createTempDirectory("ceylon-runtimetests-").toFile();
    try {
        List<File> files = new ArrayList<File>();
        files.add(createModuleFile(tmpdir, module));
        for (Archive lib : libs) {
            files.add(createModuleFile(tmpdir, lib));
        }
        String name;
        String version;
        String fullName = module.getName();
        final boolean isDefault = (Constants.DEFAULT + ".car").equals(fullName);
        if (isDefault) {
            name = Constants.DEFAULT.toString();
            version = null;
        } else {
            int p = fullName.indexOf("-");
            if (p < 0)
                throw new IllegalArgumentException("No name and version split: " + fullName);
            name = fullName.substring(0, p);
            version = fullName.substring(p + 1, fullName.lastIndexOf("."));
        }
        Map<String, String> args = new LinkedHashMap<String, String>();
        args.put(Constants.CEYLON_ARGUMENT_PREFIX + Argument.SYSTEM_REPOSITORY.toString(), getDistRepo());
        args.put(Constants.CEYLON_ARGUMENT_PREFIX + Argument.REPOSITORY.toString(), tmpdir.toString());
        if (run != null)
            args.put(Constants.CEYLON_ARGUMENT_PREFIX + Argument.RUN.toString(), run);
        execute(version != null ? name + "/" + version : name, args);
    } finally {
        FileUtil.deleteQuietly(tmpdir);
    }
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) ArrayList(java.util.ArrayList) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Archive (org.jboss.shrinkwrap.api.Archive)37 Node (org.jboss.shrinkwrap.api.Node)17 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)12 Test (org.junit.Test)12 File (java.io.File)11 URL (java.net.URL)10 ArrayList (java.util.ArrayList)9 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)8 JolokiaFraction (org.wildfly.swarm.jolokia.JolokiaFraction)8 BufferedReader (java.io.BufferedReader)7 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)6 List (java.util.List)5 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)5 DeploymentContext (org.wildfly.swarm.container.runtime.cdi.DeploymentContext)5 JARArchive (org.wildfly.swarm.spi.api.JARArchive)5 Path (java.nio.file.Path)4