@Test public void baseElementNotInsertedWhenConfigDoesNotAllowIt() throws Exception { Gadget gadget = makeDefaultGadget(); config.data.put(INSERT_BASE_ELEMENT_KEY, false); String rewritten = rewrite(gadget, BODY_CONTENT); assertFalse("Base element injected incorrectly.", rewritten.contains("<base")); }
@Test public void doesRewriteWhenSanitizeEquals0() throws Exception { Gadget gadget = makeDefaultGadget(); context.params.put("sanitize", "0"); assertFalse("Didn't rewrite when sanitize was '0'.", BODY_CONTENT.equals(rewrite(gadget, BODY_CONTENT))); }
@Test public void doesRewriteWhenSanitizeEquals0() throws Exception { Gadget gadget = makeDefaultGadget(); context.params.put("sanitize", "0"); assertFalse("Didn't rewrite when sanitize was '0'.", BODY_CONTENT.equals(rewrite(gadget, BODY_CONTENT))); }
@Test public void baseElementNotInsertedWhenConfigDoesNotAllowIt() throws Exception { Gadget gadget = makeDefaultGadget(); config.data.put(INSERT_BASE_ELEMENT_KEY, false); String rewritten = rewrite(gadget, BODY_CONTENT); assertFalse("Base element injected incorrectly.", rewritten.contains("<base")); }
@Test public void featuresNotInjectedWhenRemoved() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; Gadget gadget = makeGadgetWithSpec(gadgetXml); gadget.removeFeature("foo"); expectFeatureCalls(gadget, ImmutableList.<FeatureResource>of(), ImmutableSet.<String>of(), ImmutableList.<FeatureResource>of()); String rewritten = rewrite(gadget, ""); assertFalse("Removed script still inlined.", rewritten.contains("foo_content();")); }
@Test public void featuresNotInjectedWhenRemoved() throws Exception { String gadgetXml = "<Module><ModulePrefs title=''>" + " <Require feature='foo'/>" + "</ModulePrefs>" + "<Content type='html'/>" + "</Module>"; Gadget gadget = makeGadgetWithSpec(gadgetXml); gadget.removeFeature("foo"); expectFeatureCalls(gadget, ImmutableList.<FeatureResource>of(), ImmutableSet.<String>of(), ImmutableList.<FeatureResource>of()); String rewritten = rewrite(gadget, ""); assertFalse("Removed script still inlined.", rewritten.contains("foo_content();")); }
assertTrue("Forced javascript not included.", matcher.group(HEAD_GROUP).contains("<script src=\"/js/foo?jsload=0\">")); assertFalse("Default styling was injected when a doctype was specified.", matcher.group(HEAD_GROUP).contains(DEFAULT_CSS)); assertTrue("Custom body attributes missing.",
assertTrue("Forced javascript not included.", matcher.group(HEAD_GROUP).contains("<script src=\"/js/foo?jsload=0\">")); assertFalse("Default styling was injected when a doctype was specified.", matcher.group(HEAD_GROUP).contains(DEFAULT_CSS)); assertTrue("Custom body attributes missing.",
@Test public void xhrWrapperConfigurationNotInjectedIfUnnecessary() throws Exception { String gadgetXml = "<Module><ModulePrefs title='' />" + "<Content type='html' href='http://foo.com/bar/baz.html' />" + "</Module>"; Gadget gadget = makeGadgetWithSpec(gadgetXml); gadget.setCurrentView(gadget.getSpec().getView("default")); String rewritten = rewrite(gadget, BODY_CONTENT); boolean containsConfig = rewritten.contains("\"shindig.xhrwrapper\""); assertFalse("shindig.xhrwrapper configuration present in rewritten HTML.", containsConfig); }
@Test public void xhrWrapperConfigurationNotInjectedIfUnnecessary() throws Exception { String gadgetXml = "<Module><ModulePrefs title='' />" + "<Content type='html' href='http://foo.com/bar/baz.html' />" + "</Module>"; Gadget gadget = makeGadgetWithSpec(gadgetXml); gadget.setCurrentView(gadget.getSpec().getView("default")); String rewritten = rewrite(gadget, BODY_CONTENT); boolean containsConfig = rewritten.contains("\"shindig.xhrwrapper\""); assertFalse("shindig.xhrwrapper configuration present in rewritten HTML.", containsConfig); }
assertFalse(actual.contains("hello")); assertEquals(expected, actual); assertFalse(json.getJSONObject("core.util").has("hello"));
assertFalse(actual.contains("hello")); assertEquals(expected, actual); assertFalse(json.getJSONObject("core.util").has("hello"));