1b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamspackage org.robolectric.internal; 2b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 3851f2a9519be23c73a9e2929128179b405e2e7a6Christian Williamsimport static org.assertj.core.api.Assertions.assertThat; 4851f2a9519be23c73a9e2929128179b405e2e7a6Christian Williams 5b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamsimport org.junit.Before; 6b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamsimport org.junit.Test; 7879371277af60d57148eefb24fd046a6a30e4683christianwimport org.junit.runner.RunWith; 8879371277af60d57148eefb24fd046a6a30e4683christianwimport org.junit.runners.JUnit4; 9b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamsimport org.robolectric.annotation.Config; 10b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamsimport org.robolectric.res.FileFsFile; 11b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamsimport org.robolectric.res.FsFile; 12b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 13879371277af60d57148eefb24fd046a6a30e4683christianw@RunWith(JUnit4.class) 14b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williamspublic class MavenManifestFactoryTest { 15b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 16b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams private Config.Builder configBuilder; 17b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams private MyMavenManifestFactory myMavenManifestFactory; 18b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 19b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams @Before 20b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams public void setUp() throws Exception { 21405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams configBuilder = Config.Builder.defaults().setManifest("DifferentManifest.xml"); 22b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams myMavenManifestFactory = new MyMavenManifestFactory(); 23b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 24b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 25b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams @Test public void identify() throws Exception { 26b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build()); 27b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getManifestFile()) 28405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/DifferentManifest.xml")); 29b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getResDir()) 30b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/res")); 31b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 32b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 33b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams @Test public void withDotSlashManifest_identify() throws Exception { 34405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams configBuilder.setManifest("./DifferentManifest.xml"); 35b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 36b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build()); 37b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getManifestFile()) 38405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/DifferentManifest.xml")); 39b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getResDir()) 40b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/res")); 41b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 42b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 43b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams @Test public void withDotDotSlashManifest_identify() throws Exception { 44405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams configBuilder.setManifest("../DifferentManifest.xml"); 45b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 46b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build()); 47b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getManifestFile()) 48405e6f33c257017336665c9327b6ff5a01cae4c3Christian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/../DifferentManifest.xml")); 49b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams assertThat(manifestIdentifier.getResDir()) 50b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams .isEqualTo(FileFsFile.from(":fakefs:path/to/../res")); 51b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 52b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams 53b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams private static class MyMavenManifestFactory extends MavenManifestFactory { 54b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams @Override 55b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams FsFile getBaseDir() { 56b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams return FileFsFile.from(":fakefs:path/to"); 57b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 58b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams } 59b4d0e3b1d6313b7f37852f42a2b8b54cc57af17eChristian Williams}