Skip to content

Commit

Permalink
Microprofile tests crashed; error was logged, but ignored.
Browse files Browse the repository at this point in the history
- Now using project's pom.xml

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Feb 27, 2023
1 parent e8de62c commit 216a8ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 4 additions & 0 deletions appserver/tests/tck/microprofile/config/pom.xml
Expand Up @@ -43,6 +43,10 @@
<artifactId>microprofile-config-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
@@ -1,16 +1,15 @@
package org.glassfish.microprofile.config.tck.client;

import java.io.File;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;

import java.io.File;
import java.util.logging.Logger;

import static java.util.logging.Level.SEVERE;

/**
* This extension adds certain libraries to deployed Arquillian apps.
*
Expand All @@ -19,26 +18,23 @@
*/
public class LibraryIncluder implements ApplicationArchiveProcessor {

private static final Logger LOGGER = Logger.getLogger(LibraryIncluder.class.getName());
private static final Logger LOG = System.getLogger(LibraryIncluder.class.getName());

@Override
public void process(Archive<?> archive, TestClass testClass) {

// Only process web archives
if (!(archive instanceof WebArchive)) return;
final var webArchive = (WebArchive) archive;

try {
// Add Hamcrest
webArchive.addAsLibraries(resolveDependency("org.hamcrest:hamcrest:2.2"));
} catch (Exception e) {
LOGGER.log(SEVERE, "Error adding dependencies", e);
if (!(archive instanceof WebArchive)) {
return;
}
final var webArchive = (WebArchive) archive;
webArchive.addAsLibraries(resolveDependency("org.hamcrest:hamcrest"));
LOG.log(Level.INFO, () -> "webArchive:\n" + webArchive.toString(true));
}

private static File[] resolveDependency(String coordinates) {
return Maven.resolver()
.resolve(coordinates)
.withoutTransitivity().asFile();
return Maven.configureResolver().workOffline().loadPomFromFile("pom.xml")
.resolve(coordinates).withoutTransitivity()
.asFile();
}
}

0 comments on commit 216a8ec

Please sign in to comment.