-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2743 from mkouba/mp-config-tck-fix
MP Config TCK - fix a regression caused by #2629
- Loading branch information
Showing
5 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...profile-config/src/test/java/io/quarkus/tck/config/ConfigApplicationArchiveProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.tck.config; | ||
|
||
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.ArchivePath; | ||
import org.jboss.shrinkwrap.api.ArchivePaths; | ||
import org.jboss.shrinkwrap.api.Node; | ||
import org.jboss.shrinkwrap.api.asset.ArchiveAsset; | ||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
|
||
/** | ||
* Arquillian automatically adds the test class to a test deployment. However, some MP Config tests do add the test class to a | ||
* library jar too. As a result, we get ambiguous dependency when trying to instantiate the test class. Unfortunately, we can't | ||
* use an ApplicationArchiveProcessor to remove the test class added by Arquillian because it's applied | ||
* before the test class is added. Therefore, we deciced to remove the test class from any library jar. | ||
*/ | ||
public class ConfigApplicationArchiveProcessor implements ApplicationArchiveProcessor { | ||
|
||
private static final ArchivePath PATH_LIBRARY = ArchivePaths.create("WEB-INF/lib"); | ||
|
||
@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()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
tcks/microprofile-config/src/test/java/io/quarkus/tck/config/ConfigExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.quarkus.tck.config; | ||
|
||
import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; | ||
import org.jboss.arquillian.core.spi.LoadableExtension; | ||
|
||
public class ConfigExtension implements LoadableExtension { | ||
|
||
@Override | ||
public void register(ExtensionBuilder builder) { | ||
builder.service(ApplicationArchiveProcessor.class, ConfigApplicationArchiveProcessor.class); | ||
} | ||
|
||
} |
6 changes: 0 additions & 6 deletions
6
tcks/microprofile-config/src/test/java/io/quarkus/tck/config/Dummy.java
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...nfig/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
io.quarkus.tck.config.ConfigExtension |