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

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


  }

  private JsUri mockJsUri(String container, RenderingContext context, boolean debug,
      boolean jsload, boolean nocache, String onload, int refresh, UriStatus status,
      String... libs) {
    JsUri result = mock(JsUri.class);
    expect(result.getContainer()).andReturn(container).anyTimes();
    expect(result.getContext()).andReturn(context).anyTimes();
    expect(result.getOnload()).andReturn(onload).anyTimes();
    expect(result.getRefresh()).andReturn(refresh).anyTimes();
    expect(result.isDebug()).andReturn(debug).anyTimes();
    expect(result.isNoCache()).andReturn(nocache).anyTimes();
    expect(result.isJsload()).andReturn(jsload).anyTimes();
    expect(result.getStatus()).andReturn(status).anyTimes();
    if (libs != null) {
      expect(result.getLibs()).andReturn(Lists.newArrayList(libs)).anyTimes();
    }
    return result;
  }
View Full Code Here


  }

  @Test
  public void testWithIfModifiedSinceHeaderPresentAndVersionReturnsNotModified() throws Exception {
    setUp(0);
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, false, false, false,
        null, REFRESH_INTERVAL_SEC, UriStatus.VALID_VERSIONED);
    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(request.getHeader("If-Modified-Since")).andReturn("12345");
    replay();
View Full Code Here

  }

  @Test
  public void testWithIfModifiedSinceHeaderPresentButNoVersionActsNormal() throws Exception {
    setUp(0);
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, false, false, false,
        null, REFRESH_INTERVAL_SEC, UriStatus.VALID_UNVERSIONED);
    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(request.getHeader("If-Modified-Since")).andReturn("12345");
    final JsResponse response = new JsResponseBuilder().appendJs(EXAMPLE_JS_CODE, "js").build();
    expect(request.getHeader("Host")).andReturn("localhost");
View Full Code Here

  @Test
  public void testDoJsloadNormal() throws Exception {
    setUp(0);
    String url = "http://localhost/gadgets/js/feature.js?v=abc&nocache=0&onload=" + ONLOAD_PARAM;
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, true, true, false,
        ONLOAD_PARAM, REFRESH_INTERVAL_SEC, UriStatus.VALID_VERSIONED);

    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(jsUriManagerMock.makeExternJsUri(isA(JsUri.class)))
        .andReturn(Uri.parse(url));
View Full Code Here

  @Test
  public void testDoJsloadWithJsLoadTimeout() throws Exception {
    setUp(TIMEOUT_SEC); // Enable JS load timeout.

    String url = "http://localhost/gadgets/js/feature.js?v=abc&nocache=0&onload=" + ONLOAD_PARAM;
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, true, true,
        false, ONLOAD_PARAM, -1, UriStatus.VALID_VERSIONED); // Disable refresh interval.

    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(jsUriManagerMock.makeExternJsUri(isA(JsUri.class)))
        .andReturn(Uri.parse(url));
View Full Code Here

  }

  @Test
  public void testDoJsloadNoOnload() throws Exception {
    setUp(0);
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, true, true, false,
        null, // lacks &onload=
        REFRESH_INTERVAL_SEC, UriStatus.VALID_VERSIONED);
    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    replay();
View Full Code Here

  @Test
  public void testDoJsloadNoCache() throws Exception {
    setUp(0);
    String url = "http://localhost/gadgets/js/feature.js?v=abc&nocache=1&onload=" + ONLOAD_PARAM;
    JsUri jsUri = mockJsUri(CONTAINER_PARAM, RenderingContext.CONTAINER, true, true,
        true, // Set to no cache.
        ONLOAD_PARAM, REFRESH_INTERVAL_SEC, UriStatus.VALID_VERSIONED);

    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andReturn(jsUri);
    expect(jsUriManagerMock.makeExternJsUri(isA(JsUri.class)))
View Full Code Here

      Gadget gadget, Node headTag, Node firstHeadChild, String extraContent)
      throws GadgetException {

    GadgetContext context = gadget.getContext();
    // Gadget is not specified in request in order to support better caching
    JsUri jsUri = new JsUri(null, context.getDebug(), false, context.getContainer(), null,
        libs, loaded, null, false, false, RenderingContext.getDefault(), null,
        getFeatureRepositoryId(gadget));
    jsUri.setCajoleContent(gadget.requiresCaja());

    String content = "";
    if (!inline) {
      String jsUrl = new UriBuilder(jsUriManager.makeExternJsUri(jsUri))
          // Avoid jsload by adding jsload=0
View Full Code Here

    String targetHost = "target-host.org";
    ContainerConfig config = mockConfig("http://" + targetHost, "/gadgets/js");
    TestDefaultJsUriManager manager = makeManager(config, null);
    Uri testUri = Uri.parse("http://other-host.org/gadgets/js/feature" + JS_SUFFIX + "?" +
        Param.CONTAINER.getKey() + "=" + CONTAINER);
    JsUri jsUri = manager.processExternJsUri(testUri);
    assertTrue(manager.hadError());
    assertEquals(jsUri.getStatus(), UriStatus.BAD_URI);
    assertSame(DefaultJsUriManager.INVALID_URI, jsUri);
  }
View Full Code Here

    String targetHost = "target-host.org";
    ContainerConfig config = mockConfig("http://" + targetHost, "/gadgets/js");
    TestDefaultJsUriManager manager = makeManager(config, null);
    Uri testUri = Uri.parse("http://target-host.org/gadgets/other-js/feature" + JS_SUFFIX + "?" +
        Param.CONTAINER.getKey() + "=" + CONTAINER);
    JsUri jsUri = manager.processExternJsUri(testUri);
    assertTrue(manager.hadError());
    assertEquals(jsUri.getStatus(), UriStatus.BAD_URI);
    assertSame(DefaultJsUriManager.INVALID_URI, 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.