public Object get(Object key) { return context.getVariable( (String) key ); }
public RenderOnDemandClosure(JellyContext context, String attributesToCapture) { List<Script> bodyStack = new ArrayList<Script>(); for (JellyContext c = context; c!=null; c=c.getParent()) { Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) bodyStack.add(script); } this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]); assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand> Map<String,Object> variables = new HashMap<String, Object>(); for (String v : Util.fixNull(attributesToCapture).split(",")) variables.put(v.intern(),context.getVariable(v)); // capture the current base of context for descriptors currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl(); this.variables = PackedMap.of(variables); Set<String> _adjuncts = AdjunctsInPage.get().getIncluded(); this.adjuncts = new String[_adjuncts.size()]; int i = 0; for (String adjunct : _adjuncts) { this.adjuncts[i++] = adjunct.intern(); } }
public Object getVariableValue( String namespaceURI, String prefix, String localName) { Object value = context.getVariable(localName); //log.debug( "Looking up XPath variable of name: " + localName + " value is: " + value ); return value; }
public Object getVariableValue( String namespaceURI, String prefix, String localName) { Object value = context.getVariable(localName); //log.debug( "Looking up XPath variable of name: " + localName + " value is: " + value ); return value; }
public Object getVariableValue( String namespaceURI, String prefix, String localName) { Object value = context.getVariable(localName); //log.debug( "Looking up XPath variable of name: " + localName + " value is: " + value ); return value; }
public WerkzProject getProject() { return (WerkzProject) getContext().getVariable( MavenConstants.WERKZ_PROJECT ); } }
/** * @return the value of the given variable name in the given variable scope * @param name is the name of the variable * @param scopeName is the optional scope name such as 'parent'. For servlet environments * this could be 'application', 'session' or 'request'. */ public Object getVariable(String name, String scopeName) { JellyContext scope = getScope(scopeName); if ( scope != null ) { return scope.getVariable(name); } return null; }
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 testSetVariablesAndRetainContextEntry() { final JellyContext jc = new JellyContext(); assertNotNull( "Initial variable of context", jc.getVariable( "context" ) ); jc.setVariables( new HashMap() ); assertNotNull( "Value after setVariables()", jc.getVariable( "context" ) ); } }
/** * Strategy method to find the corrent TestSuite to add a new Test case to */ protected TestSuite getSuite() { SuiteTag tag = (SuiteTag) findAncestorWithClass( SuiteTag.class ); if ( tag != null ) { return tag.getSuite(); } return (TestSuite) context.getVariable( "org.apache.commons.jelly.junit.suite" ); }
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 testNamespaceNotDefined() throws Exception { Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should not have set 'usedDefaultNamespace' variable", context.getVariable("usedDefaultNamespace") == null); } }
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 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 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 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()); }
/** * 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); }