### Question:
DefaultResourceLocator implements ResourceLocator { public String getRelativePath(String path) throws Exception { java.util.List<java.io.File> p1=new java.util.Vector<java.io.File>(); java.util.List<java.io.File> p2=new java.util.Vector<java.io.File>(); java.io.File f=new java.io.File(path); while (f != null) { p1.add(0, f); f = f.getParentFile(); } f = _baseDir; while (f != null) { p2.add(0, f); f = f.getParentFile(); } while (p1.size() > 0 && p2.size() > 0 && p1.get(0).equals(p2.get(0))) { p1.remove(0); p2.remove(0); } String ret=""; for (int i=0; i < p2.size(); i++) { ret += ".."+java.io.File.separator; } for (int i=0; i < p1.size(); i++) { ret += p1.get(i).getName(); if (p1.get(i).isDirectory()) { ret += java.io.File.separator; } } return (ret); } DefaultResourceLocator(java.io.File baseDir); java.net.URI getResourceURI(String uri); String getRelativePath(String path);  }### Answer:
@Test public void testGetRelativePath() { try { java.net.URL url1=ClassLoader.getSystemResource("project/requirements/SuccessfulPolicyQuote.scn"); java.io.File base=new java.io.File(url1.getFile()); DefaultResourceLocator locator=new DefaultResourceLocator(base.getParentFile()); java.net.URL url2=ClassLoader.getSystemResource("project/requirements/sample-data/CreditCheckRequest.xml"); java.io.File dataFile=new java.io.File(url2.getFile()); java.io.File targetFile=new java.io.File(dataFile.getParentFile(), "../../schema/creditCheck.xsd"); String path=locator.getRelativePath(targetFile.getCanonicalPath()); if (!path.equals("../schema/creditCheck.xsd")) { fail("Expecting path '../schema/creditCheck.xsd', but got: "+path); } } catch (Exception e) { fail("Failed: "+e); } }