Package org.apache.shindig.gadgets.spec

Examples of org.apache.shindig.gadgets.spec.GadgetSpec


  /**
   * Verify that social preloads where the request doesn't contain a token
   * serve up 403s for the preloaded data, instead of failing the whole request.
   */
  public void testSocialPreloadWithoutToken() throws Exception {
    GadgetSpec spec = new GadgetSpec(GADGET_URL, XML);
   
    RecordingRequestPipeline pipeline = new RecordingRequestPipeline("");
    PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
    view = "profile";
    // But don't set the security token

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("profile"));
    PipelinedData.Batch batch = getBatch(gadget);
    Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
        context, batch);
    PreloadedData data = tasks.iterator().next().call();
    JSONObject resultWithKeyA = new JSONObject(
View Full Code Here


  /**
   * Run an HTTP Preload test, returning the String result.
   */
  private String executeHttpPreload(HttpResponse response, String xml) throws Exception {
    GadgetSpec spec = new GadgetSpec(GADGET_URL, xml);

    RecordingRequestPipeline pipeline = new RecordingRequestPipeline(response);
    PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
    view = "profile";

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("profile"));

    PipelinedData.Batch batch = getBatch(gadget);
    Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
        context, batch);
    assertEquals(1, tasks.size());
View Full Code Here

    return result.iterator().next().toString();
  }

  @Test
  public void testHttpPreloadWithPostParams() throws Exception {
    GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_WITH_HTTP_REQUEST_AND_PARAMS);

    String httpResult = "{foo: 'bar'}";
    RecordingRequestPipeline pipeline = new RecordingRequestPipeline(httpResult);
    PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
    view = "profile";

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("profile"));
    PipelinedData.Batch batch = getBatch(gadget);
    Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
        context, batch);
    tasks.iterator().next().call();
View Full Code Here

    assertEquals(PARAMS, request.getPostBodyAsString());
  }

  @Test
  public void testHttpPreloadWithGetParams() throws Exception {
    GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_WITH_HTTP_REQUEST_AND_GET_PARAMS);

    String httpResult = "{foo: 'bar'}";
    RecordingRequestPipeline pipeline = new RecordingRequestPipeline(httpResult);
    PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
    view = "profile";

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("profile"));
    PipelinedData.Batch batch = getBatch(gadget);
    Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
        context, batch);
    tasks.iterator().next().call();
View Full Code Here

   * Verify that social preloads pay attention to view resolution by
   * using gadget.getCurrentView().
   */
  @Test
  public void testSocialPreloadViewResolution() throws Exception {
    GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_IN_DEFAULT_CONTAINER);

    String socialResult = "[{id:'p', data:1}, {id:'a', data:2}]";
    RecordingRequestPipeline pipeline = new RecordingRequestPipeline(socialResult);
    PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);

    view = "profile";
    contextParams.put("st", "token");

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        // Assume view resolution has behaved correctly
        .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW));

    PipelinedData.Batch batch = getBatch(gadget);
    Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
        context, batch);
    assertEquals(1, tasks.size());
View Full Code Here

      = new DefaultMessageBundleFactory(pipeline, cacheProvider, MAX_AGE);
  private final GadgetSpec gadgetSpec;

  public DefaultMessageBundleFactoryTest() {
    try {
      gadgetSpec = new GadgetSpec(SPEC_URI, BASIC_SPEC);
    } catch (GadgetException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

        = "<Module>" +
          " <ModulePrefs title='test'/>" +
          " <Content type='html'/>" +
          " <UserPref name='" + UP_NAME + "' datatype='string'/>" +
          "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse(SPEC_URL), xml);
    replay();

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("default"));

    Uri iframeUrl = Uri.parse(urlGenerator.getIframeUrl(gadget));

    assertEquals(IFR_BASE, iframeUrl.getPath());
    assertEquals(CONTAINER, iframeUrl.getQueryParameter("container"));
View Full Code Here

        = "<Module>" +
          " <ModulePrefs title='test'/>" +
          " <Content type='html'/>" +
          " <UserPref name='" + UP_NAME + "' datatype='string'/>" +
          "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse(SPEC_URL), xml);

    expect(lockedDomainService.getLockedDomainForGadget(isA(Gadget.class), eq(CONTAINER)))
        .andReturn("locked.example.org");
    replay();

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("default"));

    Uri iframeUrl = Uri.parse(urlGenerator.getIframeUrl(gadget));

    assertEquals("locked.example.org", iframeUrl.getAuthority());
    assertEquals(IFR_BASE, iframeUrl.getPath());
View Full Code Here

        = "<Module>" +
          " <ModulePrefs title='test'/>" +
          " <Content type='url' href='" + StringEscapeUtils.escapeHtml(TYPE_URL_HREF) + "'/>" +
          " <UserPref name='" + UP_NAME + "' datatype='string'/>" +
          "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse(SPEC_URL), xml);
    replay();

    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(spec)
        .setCurrentView(spec.getView("default"));

    URI iframeUrl = URI.create(urlGenerator.getIframeUrl(gadget));

    assertEquals(TYPE_URL_HREF_HOST, iframeUrl.getAuthority());
    assertEquals(TYPE_URL_HREF_PATH, iframeUrl.getPath());
View Full Code Here

public class VariableSubstituterTest {
  private final FakeMessageBundleFactory messageBundleFactory = new FakeMessageBundleFactory();
  private final VariableSubstituter substituter = new VariableSubstituter(messageBundleFactory);

  private GadgetSpec substitute(String xml) throws Exception {
    return substituter.substitute(new GadgetContext(), new GadgetSpec(Uri.parse("#"), xml));
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.spec.GadgetSpec

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.