package org.purl.wf4ever.robundle.fs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.nio.file.Path;

import org.junit.Test;
import org.purl.wf4ever.robundle.Bundle;
import org.purl.wf4ever.robundle.Bundles;

public class TestBundlePaths {
	@Test
	public void endsWith() throws Exception {
		Bundle bundle = Bundles.createBundle();
		bundle.getRoot();
		Path fred = bundle.getRoot();
		Path barBazAbs = fred.resolve("bar/baz");
		System.out.println(barBazAbs);
		Path barBaz = fred.relativize(barBazAbs);
		assertEquals("bar/baz", barBaz.toString());
		assertTrue(barBaz.endsWith("bar/baz"));
		assertFalse(barBaz.endsWith("bar/../bar/baz"));
		Path climber = barBaz.resolve("../baz");
		assertEquals("bar/baz/../baz", climber.toString());
		assertTrue(climber.endsWith("../baz"));
		assertFalse(climber.endsWith("bar/baz"));
		Path climberNorm = climber.normalize();
		assertFalse(climberNorm.endsWith("../baz"));
		assertTrue(climberNorm.endsWith("bar/baz"));
		
	}
}

@@ -32,16 +32,50 @@
 le.fs;%0A%0A
+import static org.junit.Assert.*;%0A
 import s
@@ -427,90 +427,112 @@
 ndle
- bundle = Bundles.createBundle();%0A%09%09bundle.getRoot();%0A%09%09Path fred = bundle.getRoot
+FileSystem fs = BundleFileSystemProvider.newFileSystemFromTemporary();%0A%09%09Path root = fs.getRootDirectory
 ();%0A
@@ -550,20 +550,20 @@
 azAbs = 
-fred
+root
 .resolve
@@ -628,12 +628,12 @@
 z = 
-fred
+root
 .rel
@@ -1112,13 +1112,215 @@
 %22));
-%0A
 %09%09%0A%09%7D%0A
+%09%0A%09@Test%0A%09public void parent() throws Exception %7B%0A%09%09BundleFileSystem fs = BundleFileSystemProvider.newFileSystemFromTemporary();%0A%09%09Path root = fs.getRootDirectory();%0A%09%09assertNull(root.getParent());%0A%09%7D%0A%09%0A
 %7D%0A

Check parent is null