Package org.apache.shindig.gadgets.uri.JsUriManager

Examples of org.apache.shindig.gadgets.uri.JsUriManager.JsUri


  public void processValidVersioned() throws GadgetException {
    String targetHost = "target-host.org";
    ContainerConfig config = mockConfig("http://" + targetHost, "/gadgets/js");
    List<String> extern = Lists.newArrayList("feature", "another");
    String version = "verstring";
    JsUri ctx = mockGadgetContext(false, false, extern);
    Versioner versioner = mockVersioner(ctx, version, version);
    TestDefaultJsUriManager manager = makeManager(config, versioner);
    Uri testUri = Uri.parse("http://target-host.org/gadgets/js/" + addJsLibs(extern) +
        JS_SUFFIX + '?' + Param.CONTAINER.getKey() + '=' + CONTAINER + '&' +
        Param.VERSION.getKey() + '=' + version);
    JsUri jsUri = manager.processExternJsUri(testUri);
    assertFalse(manager.hadError());
    assertEquals(jsUri.getStatus(), UriStatus.VALID_VERSIONED);
    assertCollectionEquals(jsUri.getLibs(), extern);
  }
View Full Code Here


  @Test
  public void makeAndProcessSymmetric() throws GadgetException {
    // Make...
    ContainerConfig config = mockConfig("http://www.js.org", "/gadgets/js");
    List<String> extern = Lists.newArrayList("feature1", "feature2", "feature3");
    JsUri ctx = mockGadgetContext(false, false, extern);
    String version = "verstring";
    Versioner versioner = mockVersioner(ctx, version, version);
    TestDefaultJsUriManager manager = makeManager(config, versioner);
    Uri jsUri = manager.makeExternJsUri(ctx);
    assertFalse(manager.hadError());
    assertEquals("http", jsUri.getScheme());
    assertEquals("www.js.org", jsUri.getAuthority());
    assertEquals("/gadgets/js/" + addJsLibs(extern) + JS_SUFFIX, jsUri.getPath());
    assertEquals(CONTAINER, jsUri.getQueryParameter(Param.CONTAINER.getKey()));
    assertEquals(version, jsUri.getQueryParameter(Param.VERSION.getKey()));
    assertEquals("0", jsUri.getQueryParameter(Param.NO_CACHE.getKey()));
    assertEquals("0", jsUri.getQueryParameter(Param.DEBUG.getKey()));

    // ...and process
    JsUri processed = manager.processExternJsUri(jsUri);
    assertEquals(UriStatus.VALID_VERSIONED, processed.getStatus());
    assertCollectionEquals(extern, processed.getLibs());
  }
View Full Code Here

  private JsUri mockGadgetContext(boolean nocache, boolean debug,
      List<String> extern, List<String> loaded,
      boolean isContainer, Map<String, String> params,
      JsCompileMode compileMode, String repository) {
    JsUri context = createMock(JsUri.class);
    expect(context.getContainer()).andStubReturn(CONTAINER);
    expect(context.isNoCache()).andStubReturn(nocache);
    expect(context.isDebug()).andStubReturn(debug);
    expect(context.getGadget()).andStubReturn(GADGET_URI);
    expect(context.getContext()).andStubReturn(
        isContainer ? RenderingContext.CONTAINER : RenderingContext.GADGET);
    expect(context.getLibs()).andStubReturn(extern);
    expect(context.getLoadedLibs()).andStubReturn(
        loaded == null ? ImmutableList.<String>of() : loaded);
    expect(context.getOnload()).andStubReturn(null);
    expect(context.isJsload()).andStubReturn(false);
    expect(context.isNohint()).andStubReturn(false);
    expect(context.getExtensionParams()).andStubReturn(params);
    expect(context.getOrigUri()).andStubReturn(null);
    expect(context.getCompileMode()).andStubReturn(compileMode);
    expect(context.cajoleContent()).andStubReturn(false);
    expect(context.getRepository()).andStubReturn(repository);
    replay(context);
    return context;
  }
View Full Code Here

    compiler = new DefaultJsCompiler();
  }

  @Test
  public void testGetJsContentWithDeb() throws Exception {
    JsUri jsUri = mockJsUri(true); // debug
    FeatureResource extRes = mockResource(true, RESOURCE_URL_DEB, RESOURCE_URL_OPT);
    FeatureResource intRes = mockResource(false, RESOURCE_CONTENT_DEB, RESOURCE_CONTENT_OPT);
    FeatureBundle bundle = mockBundle(Lists.newArrayList(extRes, intRes));
    Iterable<JsContent> actual = compiler.getJsContent(jsUri, bundle);
    assertEquals(
View Full Code Here

        getContent(actual));
  }

  @Test
  public void testGetJsContentWithOpt() throws Exception {
    JsUri jsUri = mockJsUri(false); // optimized
    FeatureResource extRes = mockResource(true, RESOURCE_URL_DEB, RESOURCE_URL_OPT);
    FeatureResource intRes = mockResource(false, RESOURCE_CONTENT_DEB, RESOURCE_CONTENT_OPT);
    FeatureBundle bundle = mockBundle(Lists.newArrayList(extRes, intRes));
    Iterable<JsContent> actual = compiler.getJsContent(jsUri, bundle);
    assertEquals(
View Full Code Here

    assertEquals(COMPILE_CONTENT, actual.toJsString());
    assertEquals(0, actual.getErrors().size());
  }

  private JsUri mockJsUri(boolean debug) {
    JsUri result = createMock(JsUri.class);
    expect(result.isDebug()).andReturn(debug).anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void noCajoleRequest() throws Exception {
    JsUri uri = mockJsUri(false);
    JsRequest request = mockJsRequest(uri);

    control.replay();
    boolean actualReturn = processor.process(request, builder);
    JsResponse actualResponse = builder.build();
View Full Code Here

    assertEquals(Strings.repeat(NORMAL_CONTENT_JS, 3), actualResponse.toJsString());
  }

  @Test
  public void cajoleRequest() throws Exception {
    JsUri uri = mockJsUri(true);
    JsRequest request = mockJsRequest(uri);

    control.replay();
    boolean actualReturn = processor.process(request, builder);
    JsResponse actualResponse = builder.build();
View Full Code Here

    expect(result.getAttribs()).andReturn(map).anyTimes();
    return result;
  }

  private JsUri mockJsUri(boolean cajole) {
    JsUri uri = control.createMock(JsUri.class);
    expect(uri.cajoleContent()).andReturn(cajole).anyTimes();
    return uri;
  }
View Full Code Here

    control.verify();
  }


  private void setJsUri(String uri) {
    jsUri = new JsUri(UriStatus.VALID_UNVERSIONED, Uri.parse(uri), LIBS, null);
    EasyMock.expect(request.getJsUri()).andReturn(jsUri);
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.uri.JsUriManager.JsUri

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.