/** * A script should fail to parse if it declares tags that don't exist. */ public void testNonexistentTags() throws Exception { setUp("nonexistentTags1.jelly"); try { Script script = jelly.compileScript(); fail("Scripts should throw JellyException when it declares a nonexistent tag."); } catch (JellyException e) { } }
public void testNamespaceNotDefined() throws Exception { Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should not have set 'usedDefaultNamespace' variable", context.getVariable("usedDefaultNamespace") == null); } }
public void testInnermost() throws Exception { // performs no includes setUp("c.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); }
public void testMiddle() throws Exception { // performs one include setUp("b.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); assertTrue("should have set 'b' variable to 'true'", context.getVariable("b").equals("true")); }
public void testOutputGood() throws Exception { setUpScript("outputGood.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); assertEquals("<html></html>x",bos.toString()); }
public void testOutputBad() throws Exception { setUpScript("outputBad.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); assertEquals("<html></html>",bos.toString()); }
public void testOutermost() throws Exception { // performs one nested include setUp("a.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); assertTrue("should have set 'b' variable to 'true'", context.getVariable("b").equals("true")); assertTrue("should have set 'a' variable to 'true'", context.getVariable("a").equals("true")); }
public void testNamespaceDefined() throws Exception { jelly.setDefaultNamespaceURI("jelly:core"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'usedDefaultNamespace' variable", context.getVariable("usedDefaultNamespace") != null); }
public void testOutputBadGood() throws Exception { setUpScript("outputBad.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutput ouput = XMLOutput.createXMLOutput(bos); script.run(getJellyContext(),ouput); ouput.flush(); assertEquals("<html></html>",bos.toString()); }
public void testMultipleDefaults() throws Exception { setUpScript("testSwitchTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("multiple.defaults",new Boolean(true)); try { script.run(getJellyContext(),getXMLOutput()); fail("Expected JellyException"); } catch(JellyException e) { // expected } }
public void testCaseWithoutValue() throws Exception { setUpScript("testSwitchTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("case.without.value",new Boolean(true)); try { script.run(getJellyContext(),getXMLOutput()); fail("Expected MissingAttributeException"); } catch(MissingAttributeException e) { // expected } }
/** * Gets the System property 'java.runtime.version' and compares it with, * well, the same system property */ public void testSimpleSystemInvoke() throws Exception { setUpScript( "testInvokeStaticTag.jelly" ); Script script = getJelly().compileScript(); getJellyContext().setVariable( "test.simpleSystemInvoke",Boolean.TRUE ); getJellyContext().setVariable( "propertyName", "java.runtime.version" ); script.run( getJellyContext(),getXMLOutput() ); assertTrue( System.getProperty( "java.runtime.version" ).equals( getJellyContext().getVariable("propertyName" ) ) ); }
public void testSimpleFileTag() throws Exception { setUpScript("testFileTag.jelly"); Script script = getJelly().compileScript(); script.run(getJellyContext(), getXMLOutput()); String data = (String)getJellyContext().getVariable("testFileTag"); //FIXME This doesn't take into account attribute ordering assertEquals("fully qualified attributes not passed", "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"></html>", data); }
public void testSimpleBreakTag() throws Exception { setUpScript("testBreakTag.jelly"); Script script = getJelly().compileScript(); script.run(getJellyContext(), getXMLOutput()); String simpleResult = (String) getJellyContext().getVariable("simpleResult"); assertEquals("simpleResult", "12345", simpleResult); }
public void testConditionalBreakTag() throws Exception { setUpScript("testBreakTag.jelly"); Script script = getJelly().compileScript(); script.run(getJellyContext(), getXMLOutput()); String simpleResult = (String) getJellyContext().getVariable("conditionalResult"); assertEquals("conditionalResult", "12345", simpleResult); }
public void testVarNoBreakTag() throws Exception { setUpScript("testBreakTag.jelly"); Script script = getJelly().compileScript(); script.run(getJellyContext(), getXMLOutput()); String varNotBroken = (String) getJellyContext().getVariable("varNotBroken"); assertEquals("varNotBroken", "false", varNotBroken); }
public void testSimpleFileTag() throws Exception { setUpScript("testChooseTag.jelly"); Script script = getJelly().compileScript(); script.run(getJellyContext(), getXMLOutput()); String resultTrue = (String) getJellyContext().getVariable("result.true"); String resultFalse = (String) getJellyContext().getVariable("result.false"); assertEquals("result.true", "AC", resultTrue); assertEquals("result.false", "BC", resultFalse); }
public void testNewWithNullArg() throws Exception { setUpScript("testNewTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.newWithNullArg",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); assertNotNull(getJellyContext().getVariable("foo")); assertTrue(getJellyContext().getVariable("foo") instanceof Customer); Customer customer = (Customer)(getJellyContext().getVariable("foo")); assertNull(customer.getName()); }
public void testInvokeWithReturnedValueAsArg() throws Exception { setUpScript("testInvokeTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.invokeWithReturnedValueAsArg",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); assertNotNull(getJellyContext().getVariable("customer")); assertTrue(getJellyContext().getVariable("customer") instanceof Customer); Customer customer = (Customer)(getJellyContext().getVariable("customer")); assertEquals("Jane Doe",customer.getName()); assertEquals("Chicago",customer.getCity()); }
public void testNewWithUseBeanArg() throws Exception { setUpScript("testNewTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.newWithUseBeanArg",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); assertNotNull(getJellyContext().getVariable("foo")); assertTrue(getJellyContext().getVariable("foo") instanceof Customer); Customer customer = (Customer)(getJellyContext().getVariable("foo")); assertEquals("Jane Doe",customer.getName()); assertEquals("Chicago",customer.getCity()); assertEquals("Location",customer.getLocation()); } }