Java Code Examples for org.jboss.shrinkwrap.api.Archive#as()
The following examples show how to use
org.jboss.shrinkwrap.api.Archive#as() .
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: ConfigApplicationArchiveProcessor.java From quarkus with Apache License 2.0 | 6 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { if (applicationArchive instanceof WebArchive) { WebArchive war = applicationArchive.as(WebArchive.class); Node libNode = war.get(PATH_LIBRARY); if (libNode != null) { for (Node child : libNode.getChildren()) { Asset childAsset = child.getAsset(); if (childAsset instanceof ArchiveAsset) { ArchiveAsset archiveAsset = (ArchiveAsset) childAsset; if (archiveAsset.getArchive() instanceof JavaArchive) { JavaArchive libArchive = (JavaArchive) archiveAsset.getArchive(); libArchive.deleteClass(testClass.getName()); } } } } } }
Example 2
Source File: RestClientArchiveProcessor.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void process(Archive<?> appArchive, TestClass testClass) { if (!(appArchive instanceof WebArchive)) { return; } log.info("Preparing archive: " + appArchive); WARArchive war = appArchive.as(WARArchive.class); PomEquippedResolveStage pom = Maven.resolver().loadPomFromFile("pom.xml"); // Wiremock classes that need to be present File[] wiremockDeps = pom .resolve("com.github.tomakehurst:wiremock") .withTransitivity() .asFile(); war.addAsLibraries(wiremockDeps); // TCK Classes that need to present war.addPackages(true, "org.eclipse.microprofile.rest.client.tck.ext"); log.fine("Augmented war: \n" + war.toString(true)); }
Example 3
Source File: RestClientProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@Override public void process(Archive<?> applicationArchive, TestClass testClass) { // Only apply the processor to SSL tests if (testClass.getName().contains("SslHostnameVerifierTest") || testClass.getName().contains("SslMutualTest") || testClass.getName().contains("SslTrustStoreTest") || testClass.getName().contains("SslContextTest")) { if (!(applicationArchive instanceof WebArchive)) { return; } WebArchive war = applicationArchive.as(WebArchive.class); war.addAsResource(new StringAsset("quarkus.ssl.native=true"), "application.properties"); } // Make sure the test class and all of its superclasses are added to the test deployment // This ensures that all the classes from the hierarchy are loaded by the RuntimeClassLoader if (ClassContainer.class.isInstance(applicationArchive) && testClass.getJavaClass().getSuperclass() != null) { ClassContainer<?> classContainer = ClassContainer.class.cast(applicationArchive); Class<?> clazz = testClass.getJavaClass().getSuperclass(); while (clazz != Object.class && clazz != null) { classContainer.addClass(clazz); clazz = clazz.getSuperclass(); } } }
Example 4
Source File: AdvertisingMetadataProcessor.java From thorntail with Apache License 2.0 | 5 votes |
private void advertise(Archive<?> archive, AnnotationInstance anno) { String serviceName = anno.value().asString(); List<String> tags = Optional.ofNullable(anno.value(Advertise.TAGS_ATTRIBUTE_NAME)) .map(AnnotationValue::asStringArray) .map(Arrays::asList) .orElse(Collections.emptyList()); TopologyArchive topologyArchive = archive.as(TopologyArchive.class); topologyArchive.advertise(serviceName, tags); }