private Set<String> getClientLibraryUrls(
     DefDescriptor<? extends BaseComponentDef> desc, Type libraryType) throws Exception {
   AuraContext context = Aura.getContextService().getCurrentContext();
   context.setApplicationDescriptor(desc);
   // TODO: Why this extra step, should the Client Library service take care of loading the appDesc
   // def and
   // returning the urls?
   Aura.getDefinitionService().updateLoaded(desc);
   Set<String> urls = clientLibraryService.getUrls(context, libraryType);
   return urls;
 }
  public void testWriteResourcesJS() throws Exception {
    AuraContext context = Aura.getContextService().getCurrentContext();
    DefDescriptor<ApplicationDef> appDesc =
        Aura.getDefinitionService()
            .getDefDescriptor("clientLibraryTest:clientLibraryTest", ApplicationDef.class);
    context.setApplicationDescriptor(appDesc);
    Aura.getDefinitionService().updateLoaded(appDesc);
    StringBuilder sb = new StringBuilder();

    clientLibraryService.writeJs(context, sb);
    String libraryContent = sb.toString();
    assertTrue("Missing resource JS", libraryContent.contains("clientLibraryTest"));

    try {
      clientLibraryService.writeJs(context, null);
      fail("Should not be able to write to null stream");
    } catch (Exception e) {
      checkExceptionFull(e, AuraRuntimeException.class, "Output cannot be null");
    }
  }
  public void testContextPath() throws Exception {
    AuraContext context = Aura.getContextService().getCurrentContext();
    DefDescriptor<ApplicationDef> appDesc =
        Aura.getDefinitionService()
            .getDefDescriptor("clientLibraryTest:clientLibraryTest", ApplicationDef.class);
    context.setApplicationDescriptor(appDesc);
    String coolContext = "/cool";
    context.setContextPath(coolContext);
    Aura.getDefinitionService().updateLoaded(appDesc);

    Set<String> urlSet = clientLibraryService.getUrls(context, Type.JS);
    Pattern pattern = Pattern.compile("/auraFW|/l/");
    for (String url : urlSet) {
      Matcher matcher = pattern.matcher(url);
      while (matcher.find()) {
        int start = matcher.start();
        String cool = url.substring(start - 5, start);
        if (!cool.equals(coolContext)) {
          fail("Context path was not prepended to Aura urls");
        }
      }
    }
  }