1 19 20 package org.netbeans.modules.projectimport.eclipse; 21 22 import java.io.ByteArrayInputStream ; 23 import java.io.IOException ; 24 import org.netbeans.junit.NbTestCase; 25 26 29 public final class WorkspaceParserTest extends NbTestCase { 30 31 public WorkspaceParserTest(String testName) { 32 super(testName); 33 } 34 35 public void testGetLocation() throws Exception { 36 assertRightPath("/some/path", "/some/path"); 37 assertRightPath("URI//file:/some/path", "/some/path"); 38 assertRightPath("URI//whatever:/some/path", "/some/path"); 39 } 40 41 private void assertRightPath(final String rawPath, final String expectedPath) throws IOException { 42 byte[] pathB = rawPath.getBytes(); 43 byte[] locationContent = new byte[18 + pathB.length]; 44 locationContent[17] = (byte) pathB.length; 45 System.arraycopy(pathB, 0, locationContent, 18, pathB.length); 46 ByteArrayInputStream bis = new ByteArrayInputStream (locationContent); 47 assertEquals("right path", expectedPath, WorkspaceParser.getLocation(bis).getAbsolutePath()); 48 } 49 50 } 51 | Popular Tags |