### Question:
DatasetUrl { public static DatasetUrl findDatasetUrl(String orgLocation) throws IOException { ServiceType serviceType = null; String location = StringUtil2.replace(orgLocation.trim(), '\\', "/"); List<String> allProtocols = getProtocols(location); String trueUrl = location; String leadProtocol; if (allProtocols.isEmpty()) { leadProtocol = "file"; } else { leadProtocol = allProtocols.get(0); } String fragment = null; int pos = trueUrl.lastIndexOf('#'); if (pos >= 0) { fragment = trueUrl.substring(pos + 1); trueUrl = trueUrl.substring(0, pos); } pos = location.lastIndexOf('?'); String query = null; if (pos >= 0) { query = trueUrl.substring(pos + 1); trueUrl = trueUrl.substring(0, pos); } if (fragment != null) { serviceType = searchFragment(fragment); } if (serviceType == null) { serviceType = decodeLeadProtocol(leadProtocol); } if (serviceType == null) { serviceType = searchPath(trueUrl); } if (serviceType == null) { if (leadProtocol.equals("file")) { serviceType = decodePathExtension(trueUrl); if (serviceType == null && checkIfNcml(new File(location))) { serviceType = ServiceType.NCML; } } else { serviceType = disambiguateHttp(trueUrl); if ((serviceType == null || serviceType == ServiceType.HTTPServer)) { if (checkIfRemoteNcml(trueUrl)) { serviceType = ServiceType.NCML; } } } } if (serviceType == ServiceType.NCML) { trueUrl = (allProtocols.isEmpty() ? "file:" + trueUrl : location); } if (query != null || fragment != null) { StringBuilder buf = new StringBuilder(trueUrl); if (query != null) { buf.append('?'); buf.append(query); } if (fragment != null) { buf.append('#'); buf.append(fragment); } trueUrl = buf.toString(); } return DatasetUrl.create(serviceType, trueUrl); } private  DatasetUrl(ServiceType serviceType, String trueurl); static DatasetUrl findDatasetUrl(String orgLocation); static DatasetUrl create(@Nullable ServiceType serviceType, String trueurl); @Override boolean equals(Object o); @Override int hashCode(); ServiceType getServiceType(); String getTrueurl();  }### Answer:
@Test public void testFindDatasetUrl() throws IOException { testFind("dods: testFind("dap4: testFind("dap4:https: testFind("file: testFind("file: testFind("file:c:/x/y/z", null); testFind("file:/blah/blah/some_file_2014-04-13_16:00:00.nc.dds", ServiceType.OPENDAP); testFind("/blah/blah/some_file_2014-04-13_16:00:00.nc.dds", ServiceType.OPENDAP); testFind("c:/x/y/z", null); testFind("x::a/y/z", null); testFind("x::/y/z", null); testFind("::/y/z", null); testFind("dap4:&/y/z", null); testFind("file:x/z::a", null); testFind("x/z::a", null); testFind("thredds:http: testFind("thredds:file:c:/dev/netcdf-java-2.2/test/data/catalog/addeStationDataset.xml#AddeSurfaceData", ServiceType.THREDDS); testFind("thredds:resolve:http: ServiceType.THREDDS); testFind("cdmremote:http: testFind( "dap4:http: ServiceType.DAP4); testFind( "dynamic:http: null); }