|
|
@@ -19,9 +19,7 @@ import net.ranides.assira.trace.ExceptionUtils;
|
|
|
*/
|
|
|
public class CJarHandlerTest {
|
|
|
|
|
|
- private static URIHandle resolve(URI uri) throws IOException {
|
|
|
- return new CJarHandler().resolve(uri);
|
|
|
- }
|
|
|
+ private final URIResolver re = new URIResolver().register(CJarHandler.class);
|
|
|
|
|
|
private static URI uri(String scheme, String file) {
|
|
|
return new URIBuilder(ContractTesters.JAR_TEST.toURI() + "!/" + file).scheme(scheme).build();
|
|
|
@@ -37,9 +35,9 @@ public class CJarHandlerTest {
|
|
|
URI uri2 = uri("jar", "text/info.txt");
|
|
|
URI uri3 = uri("jar:file", "text/info.txt");
|
|
|
|
|
|
- URIHandle handle1 = resolve(uri1);
|
|
|
- URIHandle handle2 = resolve(uri2);
|
|
|
- URIHandle handle3 = resolve(uri3);
|
|
|
+ URIHandle handle1 = re.resolve(uri1);
|
|
|
+ URIHandle handle2 = re.resolve(uri2);
|
|
|
+ URIHandle handle3 = re.resolve(uri3);
|
|
|
|
|
|
assertNotNull(handle1.time(URITime.MODIFIED));
|
|
|
assertNotNull(handle2.time(URITime.MODIFIED));
|
|
|
@@ -73,7 +71,7 @@ public class CJarHandlerTest {
|
|
|
|
|
|
@Test
|
|
|
public void testParent() throws IOException {
|
|
|
- URIHandle handle = resolve(uri("jar", "text/info.txt"));
|
|
|
+ URIHandle handle = re.resolve(uri("jar", "text/info.txt"));
|
|
|
|
|
|
assertTrue(handle.uri().toString().endsWith("!/text/info.txt"));
|
|
|
assertTrue(handle.parent().uri().toString().endsWith("!/text"));
|
|
|
@@ -83,6 +81,20 @@ public class CJarHandlerTest {
|
|
|
handle.close();
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testSize() throws URISyntaxException, IOException {
|
|
|
+ try(URIHandle handle = re.resolve(uri("jar","text/info.txt"))) {
|
|
|
+ assertEquals(11, handle.size());
|
|
|
+ }
|
|
|
+ try(URIHandle handle = re.resolve(uri("jar","text"))) {
|
|
|
+ assertEquals(1, handle.size());
|
|
|
+ }
|
|
|
+ try(URIHandle handle = re.resolve(uri("jar","net/ranides/assira/test"))) {
|
|
|
+ assertEquals(7, handle.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testBasic() throws URISyntaxException, IOException {
|
|
|
|
|
|
@@ -93,12 +105,12 @@ public class CJarHandlerTest {
|
|
|
URI uri5 = uri("jar", "not-found");
|
|
|
URI uri6 = uri("jar", "text/info.txt", "UTF-8");
|
|
|
|
|
|
- URIHandle handle1 = resolve(uri1);
|
|
|
- URIHandle handle2 = resolve(uri2);
|
|
|
- URIHandle handle3 = resolve(uri3);
|
|
|
- URIHandle handle4 = resolve(uri4);
|
|
|
- URIHandle handle5 = resolve(uri5);
|
|
|
- URIHandle handle6 = resolve(uri6);
|
|
|
+ URIHandle handle1 = re.resolve(uri1);
|
|
|
+ URIHandle handle2 = re.resolve(uri2);
|
|
|
+ URIHandle handle3 = re.resolve(uri3);
|
|
|
+ URIHandle handle4 = re.resolve(uri4);
|
|
|
+ URIHandle handle5 = re.resolve(uri5);
|
|
|
+ URIHandle handle6 = re.resolve(uri6);
|
|
|
|
|
|
assertEquals(11, handle3.size());
|
|
|
assertEquals(URIFlags.collect(URIFlags.READABLE, URIFlags.FILE, URIFlags.BINARY, URIFlags.SIZE), handle3.flags());
|
|
|
@@ -117,7 +129,7 @@ public class CJarHandlerTest {
|
|
|
assertEquals(7, handle4.scan().map(f-> asName(f)).size());
|
|
|
|
|
|
assertEquals(URIFlags.collect(URIFlags.DIR), handle2.flags());
|
|
|
- assertEquals(0, handle2.size());
|
|
|
+ assertEquals(1, handle2.size());
|
|
|
assertTrue(handle2.exists());
|
|
|
|
|
|
assertEquals(URIFlags.collect(), handle5.flags());
|