[JBoss JIRA] (SHRINKWRAP-364) API Signature nconsistency for .addAsManifestResource() and .addAsWebResource()
by Hanspeter Gisler (Created) (JIRA)
API Signature nconsistency for .addAsManifestResource() and .addAsWebResource()
-------------------------------------------------------------------------------
Key: SHRINKWRAP-364
URL: https://issues.jboss.org/browse/SHRINKWRAP-364
Project: ShrinkWrap
Issue Type: Enhancement
Components: api
Affects Versions: 1.0.0-beta-6
Environment: Windows 64bit, Netbeans 7.07, Glassfish 3.1.1, Maven 3.03, testng 6.3, arquillian resolver 1.1.0-alpha-1
Reporter: Hanspeter Gisler
If adding for example a bean.xml to a Java-Archives META-INF directory, I have to write:
{code}
...
.addAsManifestResource(beansFile, ArchivePaths.create("beans.xml"))
...
{code}
If I want to add the beans.xml to a Web-Archives WEB-INF directory, I have to write:
{code}
...
.addAsWebResource(beansFile, ArchivePaths.create("WEB-INF/beans.xml"))
...
{code}
This is error prone, as I have to remember, that addAsManifestResource puts the file into META-INF on its own, addAsWebResource on the otherhand puts it into root.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years
[JBoss JIRA] (SHRINKWRAP-388) Adding an Asset to already existing ArchivePath is silently ignored
by Karel Piwko (JIRA)
Karel Piwko created SHRINKWRAP-388:
--------------------------------------
Summary: Adding an Asset to already existing ArchivePath is silently ignored
Key: SHRINKWRAP-388
URL: https://issues.jboss.org/browse/SHRINKWRAP-388
Project: ShrinkWrap
Issue Type: Bug
Components: impl-base
Affects Versions: 1.0.0-cr-3
Reporter: Karel Piwko
Priority: Critical
When trying to include a Asset to already existing Archive path simply does nothing. Also if user does merge of two archives, it makes the operation order dependent.
Solutions:
1. Trying to include an Asset to already existing path should fail. For merge, there might be an optional override property
2. Override and make this behavior documented. Probably log a warning.
Test case:
{code}
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import junit.framework.Assert;
import org.apache.commons.io.IOUtils;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
public class SimpleTest {
@Test
// fails
public void simple() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
.add(new StringAsset("foo"), ArchivePaths.create("resources/foo"))
.add(new StringAsset("bar"), ArchivePaths.create("resources/foo"));
// here it should either fail fast before or contain bar
Assert.assertEquals("Expecting bar", "bar", getContent(jar, ArchivePaths.create("resources/foo")));
}
@Test
// fails
public void mergeJar1Jar2() throws Exception {
JavaArchive jar1 = ShrinkWrap.create(JavaArchive.class).add(new StringAsset("foo"),
ArchivePaths.create("resources/foo"));
JavaArchive jar2 = ShrinkWrap.create(JavaArchive.class).add(new StringAsset("bar"),
ArchivePaths.create("resources/foo"));
JavaArchive jar = jar1.merge(jar2);
// here it should either fail or contain bar
Assert.assertEquals("Expecting bar", "bar", getContent(jar, ArchivePaths.create("resources/foo")));
}
@Test
// passes
public void mergeJar2Jar1() throws Exception {
JavaArchive jar1 = ShrinkWrap.create(JavaArchive.class).add(new StringAsset("foo"),
ArchivePaths.create("resources/foo"));
JavaArchive jar2 = ShrinkWrap.create(JavaArchive.class).add(new StringAsset("bar"),
ArchivePaths.create("resources/foo"));
JavaArchive jar = jar2.merge(jar1);
// here it should either fail or contain bar
Assert.assertEquals("Expecting bar", "bar", getContent(jar, ArchivePaths.create("resources/foo")));
}
private String getContent(Archive<?> archive, ArchivePath path) throws IOException {
InputStream is = archive.get(path).getAsset().openStream();
StringWriter w = new StringWriter();
IOUtils.copy(is, w);
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(w);
return w.toString();
}
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months