Code example for URI

Methods: getPathgetSchemegetSchemeSpecificPart

0
   * specific part is not <code>null</code>. 
   *  
   * @return the scheme specific path. 
   */ 
  private static String getPath(URI uri) {
    if (uri.getPath() != null && uri.getPath().length() != 0){
      return uri.getPath();
    } 
    return uri.getSchemeSpecificPart();
  } 
 
  PackageLibraryManager packageLibraryManager = new PackageLibraryManager();
  
 
  public void testExpand1() throws Exception { 
    URI shortUri = new URI("dart:core");
    URI fullUri = packageLibraryManager.expandRelativeDartUri(shortUri);
    assertNotNull(fullUri);
    assertEquals("dart", fullUri.getScheme());
    assertEquals("core", fullUri.getHost());
    assertTrue(getPath(fullUri).endsWith("/core.dart"));
  } 
 
  public void testExpand2() throws Exception { 
    URI shortUri = new URI("dart:doesnotexist");
    URI fullUri = packageLibraryManager.expandRelativeDartUri(shortUri);
    assertNull(fullUri);
  } 
 
  public void testTranslate1() throws Exception { 
    URI shortUri = new URI("dart:core");
    URI fullUri = packageLibraryManager.expandRelativeDartUri(shortUri);
    URI translatedURI = packageLibraryManager.resolveDartUri(fullUri);
    assertNotNull(translatedURI);
    String scheme = translatedURI.getScheme();
    assertTrue(scheme.equals("file"));
    assertTrue(getPath(translatedURI).endsWith("/core.dart"));
  } 
 
  public void testTranslate2() throws Exception { 
Experience pair programming with AI  Get Codota for Java