Examples of MessageBundle


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

    assertNull(bundle.getMessages().get(MSG_3_NAME));
  }

  @Test
  public void getCountryBundle() throws Exception {
    MessageBundle bundle = bundleFactory.getBundle(gadgetSpec, COUNTRY_LOCALE, true);

    assertEquals(MSG_0_COUNTRY_VALUE, bundle.getMessages().get(MSG_0_NAME));
    assertNull(bundle.getMessages().get(MSG_1_NAME));
    assertNull(bundle.getMessages().get(MSG_2_NAME));
    assertEquals(MSG_3_VALUE, bundle.getMessages().get(MSG_3_NAME));
  }
View Full Code Here

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

    assertEquals(MSG_3_VALUE, bundle.getMessages().get(MSG_3_NAME));
  }

  @Test
  public void getAllAllBundle() throws Exception {
    MessageBundle bundle = bundleFactory.getBundle(gadgetSpec, new Locale("all", "ALL"), true);
    assertEquals(MSG_0_ALL_VALUE, bundle.getMessages().get(MSG_0_NAME));
    assertNull(bundle.getMessages().get(MSG_1_NAME));
    assertNull(bundle.getMessages().get(MSG_2_NAME));
    assertNull(bundle.getMessages().get(MSG_3_NAME));
  }
View Full Code Here

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

    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(countryResponse);
    HttpResponse allAllResponse = new HttpResponse(ALL_ALL_BUNDLE);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(allAllResponse);

    replay(pipeline);
    MessageBundle bundle = bundleFactory.getBundle(externalSpec, LOCALE, true);
    verify(pipeline);

    assertEquals("true", bundle.getMessages().get("lang"));
    assertEquals("true", bundle.getMessages().get("country"));
    assertEquals("true", bundle.getMessages().get("all"));
    assertEquals(MSG_0_VALUE, bundle.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(langResponse);
    HttpResponse allAllResponse = new HttpResponse(ALL_ALL_BUNDLE);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(allAllResponse);

    replay(pipeline);
    MessageBundle bundle = bundleFactory.getBundle(externalSpec, LANG_LOCALE, true);
    verify(pipeline);

    assertEquals("true", bundle.getMessages().get("lang"));
    assertEquals("true", bundle.getMessages().get("all"));
    assertEquals(MSG_0_LANG_VALUE, bundle.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(countryResponse);
    HttpResponse allAllResponse = new HttpResponse(ALL_ALL_BUNDLE);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(allAllResponse);

    replay(pipeline);
    MessageBundle bundle = bundleFactory.getBundle(externalSpec, COUNTRY_LOCALE, true);
    verify(pipeline);

    assertEquals("true", bundle.getMessages().get("country"));
    assertEquals("true", bundle.getMessages().get("all"));
    assertEquals(MSG_0_COUNTRY_VALUE, bundle.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

  public void getAllAllExternal() throws Exception {
    HttpResponse allAllResponse = new HttpResponse(ALL_ALL_BUNDLE);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(allAllResponse);

    replay(pipeline);
    MessageBundle bundle = bundleFactory.getBundle(externalSpec, new Locale("all", "ALL"), true);
    verify(pipeline);

    assertEquals("true", bundle.getMessages().get("all"));
    assertEquals(MSG_0_ALL_VALUE, bundle.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

  public void getBundleFromCache() throws Exception {
    HttpResponse response = new HttpResponse(BASIC_BUNDLE);
    expect(pipeline.execute(isA(HttpRequest.class))).andReturn(response).once();
    replay(pipeline);

    MessageBundle bundle0 = bundleFactory.getBundle(gadgetSpec, LOCALE, false);
    MessageBundle bundle1 = bundleFactory.getBundle(gadgetSpec, LOCALE, false);

    verify(pipeline);

    assertEquals(bundle0.getMessages().get(MSG_0_NAME), bundle1.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

      }
    });

    time.set(System.currentTimeMillis());

    MessageBundle bundle0 = bundleFactory.getBundle(gadgetSpec, LOCALE, false);

    time.set(time.get() + MAX_AGE + 1);

    MessageBundle bundle1 = bundleFactory.getBundle(gadgetSpec, LOCALE, false);

    verify(pipeline);

    assertEquals(bundle0.getMessages().get(MSG_0_NAME), bundle1.getMessages().get(MSG_0_NAME));
  }
View Full Code Here

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

    return cacheProvider.createCache(CACHE_NAME);
  }

  @Override
  protected MessageBundle parse(String content, Query query) throws GadgetException {
    return new MessageBundle(((LocaleQuery) query).locale, content);
  }
View Full Code Here

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

    return new MessageBundle(((LocaleQuery) query).locale, content);
  }

  public MessageBundle getBundle(GadgetSpec spec, Locale locale, boolean ignoreCache, String container, String view)
      throws GadgetException {
    MessageBundle exact = getBundleFor(spec, locale, ignoreCache, container, view);

    // We don't want to fetch the same bundle multiple times, so we verify that the exact match
    // has not already been fetched.
    MessageBundle lang, country, all;

    boolean isAllLanguage = locale.getLanguage().equalsIgnoreCase("all");
    boolean isAllCountry = locale.getCountry().equalsIgnoreCase("ALL");

    if (isAllCountry) {
      lang = MessageBundle.EMPTY;
    } else {
      lang = getBundleFor(spec, new Locale(locale.getLanguage(), "ALL"), ignoreCache, container, view);
    }

    if (isAllLanguage) {
      country = MessageBundle.EMPTY;
    } else {
      country = getBundleFor(spec, new Locale("all", locale.getCountry()), ignoreCache, container, view);
    }

    if (isAllCountry || isAllLanguage) {
      // If either of these is true, we already picked up both anyway.
      all = MessageBundle.EMPTY;
    } else {
      all = getBundleFor(spec, ALL_ALL, ignoreCache, container, view);
    }

    return new MessageBundle(all, country, lang, exact);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.