001 package org.apache.tapestry.engine; 002 003 import org.apache.tapestry.INamespace; 004 import org.apache.tapestry.TestBase; 005 import org.apache.tapestry.spec.ILibrarySpecification; 006 import org.apache.tapestry.spec.LibrarySpecification; 007 import org.testng.annotations.Test; 008 009 /** 010 * Tests property value getting logic of {@link Namespace}. 011 */ 012 @Test 013 public class TestNamespaceProperties extends TestBase { 014 015 public void test_Simple_Get_Property() 016 { 017 ILibrarySpecification spec = new LibrarySpecification(); 018 INamespace ns = new Namespace("test", null, spec, null); 019 020 spec.setProperty("key", "value"); 021 022 assertEquals(ns.getPropertyValue("key"), "value"); 023 } 024 025 public void test_Get_Immediate_Property() 026 { 027 ILibrarySpecification parentSpec = new LibrarySpecification(); 028 INamespace parentNs = new Namespace("parent", null, parentSpec, null); 029 030 ILibrarySpecification spec = new LibrarySpecification(); 031 INamespace ns = new Namespace("test", parentNs, spec, null); 032 033 parentSpec.setProperty("barney", "rubble"); 034 spec.setProperty("barney", "bam bam"); 035 036 assertEquals(ns.getPropertyValue("barney"), "bam bam"); 037 } 038 039 public void test_Get_Parent_Property() 040 { 041 ILibrarySpecification parentSpec = new LibrarySpecification(); 042 INamespace parentNs = new Namespace("parent", null, parentSpec, null); 043 044 ILibrarySpecification spec = new LibrarySpecification(); 045 INamespace ns = new Namespace("test", parentNs, spec, null); 046 047 parentSpec.setProperty("barney", "rubble"); 048 049 assertEquals(ns.getPropertyValue("barney"), "rubble"); 050 assert ns.getPropertyValue("nothere") == null; 051 } 052 }