Пример #1
0
  @Test
  public void shouldExtractPluginFromKey() {
    Map<String, ClassLoader> bundleToClassLoaders = Maps.newHashMap();
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "core", getClass().getClassLoader());
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "checkstyle", getClass().getClassLoader());
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "sqale", getClass().getClassLoader());
    I18nManager i18n = new I18nManager(bundleToClassLoaders, coreClassLoader);
    i18n.start();

    assertThat(i18n.extractBundleFromKey("by"), Is.is(BUNDLE_PACKAGE + "core"));
    assertThat(
        i18n.extractBundleFromKey("violations_drilldown.page"), Is.is(BUNDLE_PACKAGE + "core"));
    assertThat(
        i18n.extractBundleFromKey("checkstyle.rule1.name"), Is.is(BUNDLE_PACKAGE + "checkstyle"));
    assertThat(i18n.extractBundleFromKey("sqale.console.page"), Is.is(BUNDLE_PACKAGE + "sqale"));
  }
Пример #2
0
  @Before
  public void init() {
    Map<String, ClassLoader> bundleToClassLoaders = Maps.newHashMap();
    // following represents the English language pack + a core plugin : they use the same
    // classloader
    coreClassLoader = newCoreClassLoader();
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "core", coreClassLoader);
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "checkstyle", coreClassLoader);
    // following represents a commercial plugin that must embed all its bundles, whatever the
    // language
    sqaleClassLoader = newSqaleClassLoader();
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "sqale", sqaleClassLoader);
    // following represents a forge plugin that embeds only the english bundle, and lets the
    // language
    // packs embed all the bundles for the other languages
    forgeClassLoader = newForgeClassLoader();
    bundleToClassLoaders.put(BUNDLE_PACKAGE + "forge", forgeClassLoader);

    manager = new I18nManager(bundleToClassLoaders, coreClassLoader);
    manager.start();
  }