001 package org.apache.tapestry.pages; 002 003 import org.apache.tapestry.BaseComponentTestCase; 004 import org.apache.tapestry.INamespace; 005 import org.apache.tapestry.engine.ISpecificationSource; 006 import org.testng.annotations.Test; 007 import org.testng.annotations.DataProvider; 008 import static org.easymock.EasyMock.*; 009 010 @Test 011 public class TestException extends BaseComponentTestCase { 012 013 @Test(dataProvider = "packages") 014 public void test_getPackages(String pages, String comps, String[] expected) { 015 016 ISpecificationSource source = newMock(ISpecificationSource.class); 017 INamespace namespace = newMock(INamespace.class); 018 expect(source.getApplicationNamespace()).andReturn(namespace); 019 expect(namespace.getPropertyValue("page-prop")).andReturn(pages); 020 expect(namespace.getPropertyValue("comp-prop")).andReturn(comps); 021 022 replay(); 023 024 Exception exceptionPage = newInstance(Exception.class, 025 "specificationSource", source, 026 "pagePackages", "page-prop", 027 "componentPackages", "comp-prop"); 028 029 String[] packages = exceptionPage.getPackages(); 030 assertListEquals(packages, expected); 031 032 verify(); 033 034 } 035 036 @DataProvider(name="packages") 037 public Object[][] createPackages() { 038 return new Object[][] { 039 {null, null, new String[0]}, 040 {"pages", "components", 041 new String[]{"pages", "components"} }, 042 {"ajax", null, new String[]{"ajax"} }, 043 {null, "ajax", new String[]{"ajax"} } 044 045 }; 046 } 047 048 }