문제

How to build Arquillian ShrinkWrap deployment that will execute Maven resource filtering? Which version of ShrinkWrap should I use?

도움이 되었습니까?

해결책

According to information from ShrinkWrap developers https://community.jboss.org/message/781880#781880 this is not yet implemented.

The ticket for this feature https://issues.jboss.org/browse/SHRINKRES-100

다른 팁

After trying to "fix" it, it turns out the answer is quite simple...

    webArchive.addAsResource("test.properties");

... will use a classpath resource that maven has already filtered.

EDIT: see my other answer, this is actually implemented and simple to use ;-)

Grzegorz is correct, this isn't implemented in Arquillian.

As a workaround, I ended up with this in @Deployment:

Properties testProperties = new Properties();
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
InputStream testPropertiesInputStream = contextClassLoader.getResourceAsStream("test.properties");
testProperties.load(testPropertiesInputStream);

File testPropertiesTargetFile = File.createTempFile("arquillian_test_", ".properties");
try (Writer testPropertiesWriter = Files.newBufferedWriter(testPropertiesTargetFile.toPath())) {
    testProperties.store(testPropertiesWriter, null);
}
webArchive.addAsResource(testPropertiesTargetFile, "test.properties");

And this in @Setup:

private Properties testProperties;

@Before
public void setUp() throws IOException {
    testProperties = new Properties();
    InputStream testPropertiesInputStream = this.getClass().getResourceAsStream("/test.properties");
    testProperties.load(testPropertiesInputStream);
}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top