Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("baz"); assertEquals(expected, actual);
@Test public void mixedExternalAndInline() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSet.of("bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Join.join(":", libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); expectFeatureCalls(gadget, ImmutableList.of(inline("foo_content();", "foo_content_debug();")), libs, ImmutableList.of(inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("bar", "baz"); assertEquals(expected, actual); assertTrue("Requested scripts not inlined.", rewritten.contains("foo_content();")); }
Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("baz"); assertEquals(expected, actual);
@Test public void mixedExternalAndInline() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSet.of("bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Joiner.on(':').join(libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); expectFeatureCalls(gadget, ImmutableList.of(inline("foo_content();", "foo_content_debug();")), libs, ImmutableList.of(inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("bar", "baz"); assertEquals(expected, actual); assertTrue("Requested scripts not inlined.", rewritten.contains("foo_content();")); }
Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("baz"); assertEquals(expected, actual);
@Test public void mixedExternalAndInline() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSet.of("bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Joiner.on(':').join(libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); expectFeatureCalls(gadget, ImmutableList.of(inline("foo_content();", "foo_content_debug();")), libs, ImmutableList.of(inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("bar", "baz"); assertEquals(expected, actual); assertTrue("Requested scripts not inlined.", rewritten.contains("foo_content();")); }
JSONObject json = getConfigJson(rewritten); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("core.util", "foo", "bar", "baz"); assertFalse(actual.contains("hello"));
JSONObject json = getConfigJson(rewritten); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("core.util", "foo", "bar", "baz"); assertFalse(actual.contains("hello"));
@Test public void forcedFeaturesInjectedExternal() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSortedSet.of("foo", "bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Joiner.on(':').join(libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); FeatureResource fooResource = inline("foo-content", "foo-debug"); expectFeatureCalls(gadget, ImmutableList.of(fooResource), libs, ImmutableList.of(fooResource, inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("foo", "bar", "baz"); assertEquals(expected, actual); }
@Test public void forcedFeaturesInjectedExternal() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSortedSet.of("foo", "bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Join.join(":", libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); FeatureResource fooResource = inline("foo-content", "foo-debug"); expectFeatureCalls(gadget, ImmutableList.of(fooResource), libs, ImmutableList.of(fooResource, inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("foo", "bar", "baz"); assertEquals(expected, actual); }
@Test public void forcedFeaturesInjectedExternal() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; final Set<String> libs = ImmutableSortedSet.of("foo", "bar", "baz"); GadgetContext context = new GadgetContext() { @Override public String getParameter(String name) { if (name.equals("libs")) { return Joiner.on(':').join(libs); } return null; } }; Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context); FeatureResource fooResource = inline("foo-content", "foo-debug"); expectFeatureCalls(gadget, ImmutableList.of(fooResource), libs, ImmutableList.of(fooResource, inline("bar-c", "bar-d"), inline("baz-c", "baz-d"))); String rewritten = rewrite(gadget, ""); Set<String> actual = getInjectedScript(rewritten); Set<String> expected = ImmutableSortedSet.of("foo", "bar", "baz"); assertEquals(expected, actual); }