Java Code Examples for org.jboss.shrinkwrap.api.Archive#get()
The following examples show how to use
org.jboss.shrinkwrap.api.Archive#get() .
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: DeploymentArchiveProcessor.java From keycloak with Apache License 2.0 | 6 votes |
public void addFilterDependencies(Archive<?> archive, TestClass testClass) { TestContext testContext = testContextProducer.get(); if (testContext.getAppServerInfo().isUndertow()) { return; } Node jbossDeploymentStructureXml = archive.get(JBOSS_DEPLOYMENT_XML_PATH); if (jbossDeploymentStructureXml == null) { log.debug("Archive doesn't contain " + JBOSS_DEPLOYMENT_XML_PATH); return; } log.info("Adding filter dependencies to " + archive.getName()); String dependency = testClass.getAnnotation(UseServletFilter.class).filterDependency(); ((WebArchive) archive).addAsLibraries(KeycloakDependenciesResolver.resolveDependencies((dependency + ":" + System.getProperty("project.version")))); Document jbossXmlDoc = loadXML(jbossDeploymentStructureXml.getAsset().openStream()); removeNodeByAttributeValue(jbossXmlDoc, "dependencies", "module", "name", "org.keycloak.keycloak-saml-core"); removeNodeByAttributeValue(jbossXmlDoc, "dependencies", "module", "name", "org.keycloak.keycloak-adapter-spi"); archive.add(new StringAsset((documentToString(jbossXmlDoc))), JBOSS_DEPLOYMENT_XML_PATH); }
Example 2
Source File: JolokiaWarDeploymentProducerTest.java From thorntail with Apache License 2.0 | 6 votes |
@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"); } }
Example 3
Source File: OpenEJBArchiveProcessor.java From tomee with Apache License 2.0 | 6 votes |
private static void addEnvEntries(final Archive<?> archive, final String prefix, final AppModule appModule, final EjbModule ejbModule) { final Node envEntriesProperties = archive.get(prefix.concat(ENV_ENTRIES_PROPERTIES)); if (envEntriesProperties != null) { InputStream is = null; final Properties properties = new Properties(); try { is = envEntriesProperties.getAsset().openStream(); properties.load(is); ejbModule.getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); // do it for test class too appModule.getEjbModules().iterator().next().getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); } catch (final Exception e) { LOGGER.log(Level.SEVERE, "can't read env-entries.properties", e); } finally { IO.close(is); } } }
Example 4
Source File: OpenEJBArchiveProcessor.java From tomee with Apache License 2.0 | 6 votes |
private static WebApp createWebApp(final Archive<?> archive) { WebApp webApp; final Node webXml = archive.get(WEB_INF + "web.xml"); if (webXml == null) { webApp = new WebApp(); } else { InputStream inputStream = null; try { inputStream = webXml.getAsset().openStream(); webApp = Sxc.unmarshalJavaee(new WebApp$JAXB(), inputStream); } catch (final Exception e) { webApp = new WebApp(); } finally { IO.close(inputStream); } } return webApp; }
Example 5
Source File: AbstractJolokiaAccessPreparer.java From thorntail with Apache License 2.0 | 5 votes |
public void accept(Archive archive) { Node node = archive.get("WEB-INF/classes/jolokia-access.xml"); if (node == null) { Asset asset = getJolokiaAccessXmlAsset(); if (asset != null) { archive.as(WARArchive.class).add(asset, "WEB-INF/classes/jolokia-access.xml"); } } }
Example 6
Source File: SwaggerWebAppFractionTest.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Test public void testAddWebContentFromDirectory() { SwaggerWebAppFraction fraction = new SwaggerWebAppFraction(); fraction.addWebContent("./sut"); Archive<?> archive = assertArchive(fraction); // make sure nested files are where they should be Node node = archive.get("/js/test.js"); assertThat(node).isNotNull(); node = archive.get("/js/lib/some-lib.js"); assertThat(node).isNotNull(); }
Example 7
Source File: SWClassLoader.java From tomee with Apache License 2.0 | 5 votes |
public LinkedList<Archive<?>> findNodes(final String name) { final LinkedList<Archive<?>> items = new LinkedList<>(); for (final Archive<?> a : archives) { final boolean isWar = WebArchive.class.isInstance(a); final Node node = a.get(ArchivePaths.create((isWar ? "/WEB-INF/classes/" : "") + name)); if (node != null) { items.add(a); } } return items; }
Example 8
Source File: SwaggerWebAppFractionTest.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
private Archive<?> assertArchive(SwaggerWebAppFraction fraction) { Archive<?> archive = fraction.getWebContent(); assertThat(archive).isNotNull(); Node node = archive.get("/index.html"); assertThat(node).isNotNull(); return archive; }
Example 9
Source File: ManagedSEDeployableContainer.java From camel-spring-boot with Apache License 2.0 | 5 votes |
private Properties getSystemProperties(final Archive<?> archive) throws DeploymentException { Node systemPropertiesNode = archive.get(ClassPath.SYSTEM_PROPERTIES_ARCHIVE_PATH); if (systemPropertiesNode != null) { try (InputStream in = systemPropertiesNode.getAsset().openStream()) { Properties systemProperties = new Properties(); systemProperties.load(in); return systemProperties; } catch (IOException e) { throw new DeploymentException("Could not load system properties", e); } } return null; }
Example 10
Source File: SecuredArchivePreparer.java From thorntail with Apache License 2.0 | 5 votes |
private static Node getKeycloakJsonNodeFromWebInf(Archive<?> tmpArchive, String resourceName, boolean useForwardSlash) { String webInfPath = useForwardSlash ? "/WEB-INF" : "WEB-INF"; if (!resourceName.startsWith("/")) { resourceName = "/" + resourceName; } Node jsonNode = tmpArchive.get(webInfPath + resourceName); if (jsonNode == null) { jsonNode = tmpArchive.get(webInfPath + "/classes" + resourceName); } return jsonNode; }
Example 11
Source File: DefaultApplicationDeploymentProcessor.java From thorntail with Apache License 2.0 | 5 votes |
private static boolean hasApplicationServletMapping(Archive<?> archive) { Node webXmlNode = archive.get(PATH_WEB_XML); if (webXmlNode != null) { return hasApplicationServletMapping(webXmlNode.getAsset()); } return false; }
Example 12
Source File: SwaggerWebAppFractionTest.java From thorntail with Apache License 2.0 | 5 votes |
private Archive<?> assertArchive(SwaggerWebAppFraction fraction) { Archive<?> archive = fraction.getWebContent(); assertThat(archive).isNotNull(); Node node = archive.get("/index.html"); assertThat(node).isNotNull(); return archive; }
Example 13
Source File: SwaggerWebAppFractionTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test public void testAddWebContentFromDirectory() { SwaggerWebAppFraction fraction = new SwaggerWebAppFraction(); fraction.addWebContent("./src/test/user-content"); Archive<?> archive = assertArchive(fraction); // make sure nested files are where they should be Node node = archive.get("/js/test.js"); assertThat(node).isNotNull(); node = archive.get("/js/lib/some-lib.js"); assertThat(node).isNotNull(); }
Example 14
Source File: OpenEJBArchiveProcessor.java From tomee with Apache License 2.0 | 5 votes |
private static Node findBeansXml(final Archive<?> archive, final String prefix) { Node beansXml = archive.get(prefix.concat(BEANS_XML)); if (beansXml == null && WEB_INF.equals(prefix)) { beansXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(BEANS_XML)); } return beansXml; }
Example 15
Source File: FaultToleranceApplicationArchiveProcessor.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
private ByteArrayOutputStream readCurrentConfig(Archive<?> appArchive) { try { Node node = appArchive.get(MP_CONFIG_PATH); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); IOUtil.copy(node.getAsset().openStream(), outputStream); return outputStream; } catch (IOException e) { throw new RuntimeException("Failed to prepare microprofile-config.properties"); } }
Example 16
Source File: ShrinkWrapResource.java From piranha with BSD 3-Clause "New" or "Revised" License | 4 votes |
private Node getNode(Archive<?> archiveToGetFrom, String location) { return archiveToGetFrom.get( ArchivePaths.create( location)); }
Example 17
Source File: JolokiaWarDeploymentProducerTest.java From thorntail with Apache License 2.0 | 3 votes |
@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"); } }
Example 18
Source File: JolokiaWarDeploymentProducerTest.java From thorntail with Apache License 2.0 | 3 votes |
@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"); } }
Example 19
Source File: JolokiaWarDeploymentProducerTest.java From thorntail with Apache License 2.0 | 3 votes |
public void testPreferConfigValueFile_vs_FractionSetting() throws Exception { URL resource = getClass().getClassLoader().getResource("my-jolokia-access2.xml"); URL fractionResource = getClass().getClassLoader().getResource("my-jolokia-access3.xml"); String path = resource.getPath(); File file = new File(path); JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer(); producer.fraction = new JolokiaFraction() .prepareJolokiaWar(JolokiaFraction.jolokiaAccessXml(fractionResource)); 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"); } }
Example 20
Source File: JolokiaWarDeploymentProducerTest.java From thorntail with Apache License 2.0 | 3 votes |
@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"); } }