tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andy...@apache.org
Subject svn commit: r581896 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/pages/ test/org/apache/tapestry/html/ test/org/apache/tapestry/pages/
Date Thu, 04 Oct 2007 13:39:31 GMT
Author: andyhot
Date: Thu Oct  4 06:39:31 2007
New Revision: 581896

URL: http://svn.apache.org/viewvc?rev=581896&view=rev
Log:
TAPESTRY-1787: tests

Added:
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/TestExceptionDisplay.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/TestException.java
Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pages/Exception.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pages/Exception.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pages/Exception.java?rev=581896&r1=581895&r2=581896&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pages/Exception.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/pages/Exception.java
Thu Oct  4 06:39:31 2007
@@ -16,6 +16,7 @@
 
 import org.apache.tapestry.INamespace;
 import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.engine.ISpecificationSource;
 import org.apache.tapestry.event.PageDetachListener;
 import org.apache.tapestry.html.BasePage;
 import org.apache.tapestry.util.exception.ExceptionAnalyzer;
@@ -33,6 +34,8 @@
     public abstract String getPagePackages();
     /** @since 4.1.4 */
     public abstract String getComponentPackages();
+    /** @since 4.1.4 */
+    public abstract ISpecificationSource getSpecificationSource();
 
     /** Transient property. */
     public abstract void setExceptions(ExceptionDescription[] exceptions);
@@ -51,15 +54,22 @@
         return getRequestCycle().getResponseBuilder().isDynamic();
     }
     
-    public String[] getPackages() {
-        INamespace namespace = getRequestCycle().getInfrastructure().getSpecificationSource().getApplicationNamespace();
+    public String[] getPackages()
+    {
+        INamespace namespace = getSpecificationSource().getApplicationNamespace();
         String pages = namespace.getPropertyValue(getPagePackages());
         String comps = namespace.getPropertyValue(getComponentPackages());
+        
         StringBuffer sb = new StringBuffer();
-        if (pages!=null) 
+        if (pages!=null)
+        {
             sb.append(pages);
+            if (comps!=null)
+                sb.append(",");
+        }
         if (comps!=null)
-            sb.append(",").append(comps);
+            sb.append(comps);
+
         return TapestryUtils.split(sb.toString(), ',');
     }
 }

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/TestExceptionDisplay.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/TestExceptionDisplay.java?rev=581896&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/TestExceptionDisplay.java
(added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/TestExceptionDisplay.java
Thu Oct  4 06:39:31 2007
@@ -0,0 +1,31 @@
+package org.apache.tapestry.html;
+
+import org.apache.tapestry.BaseComponentTestCase;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Test
+public class TestExceptionDisplay extends BaseComponentTestCase {
+
+    @Test(dataProvider = "traces")
+    public void test_isInPackage(List packages, String trace, boolean expected) {
+        ExceptionDisplay display = newInstance(ExceptionDisplay.class,
+                "packages", packages,
+                "trace", trace);
+        assertTrue(display.isInPackage() == expected);
+    }
+
+    @DataProvider(name="traces")
+    public Object[][] createTraces() {
+        return new Object[][] {
+          { Arrays.asList("org.apache.tapestry"), "org.apache", false},
+          { Arrays.asList("org.apache.tapestry.pages", "org.apache.tapestry.components"),
+                  "org.apache.tapestry.components", true},
+          { Arrays.asList(), "org.apache", false},
+          { null, "org.apache", false}
+        };
+    }
+}

Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/TestException.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/TestException.java?rev=581896&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/TestException.java
(added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/pages/TestException.java
Thu Oct  4 06:39:31 2007
@@ -0,0 +1,48 @@
+package org.apache.tapestry.pages;
+
+import org.apache.tapestry.BaseComponentTestCase;
+import org.apache.tapestry.INamespace;
+import org.apache.tapestry.engine.ISpecificationSource;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import static org.easymock.EasyMock.*;
+
+@Test
+public class TestException extends BaseComponentTestCase {
+
+    @Test(dataProvider = "packages")
+    public void test_getPackages(String pages, String comps, String[] expected) {
+
+        ISpecificationSource source = newMock(ISpecificationSource.class);
+        INamespace namespace = newMock(INamespace.class);
+        expect(source.getApplicationNamespace()).andReturn(namespace);
+        expect(namespace.getPropertyValue("page-prop")).andReturn(pages);
+        expect(namespace.getPropertyValue("comp-prop")).andReturn(comps);
+
+        replay();
+
+        Exception exceptionPage = newInstance(Exception.class,
+                "specificationSource", source,
+                "pagePackages", "page-prop",
+                "componentPackages", "comp-prop");
+
+        String[] packages = exceptionPage.getPackages();
+        assertListEquals(packages, expected);
+
+        verify();
+
+    }
+
+    @DataProvider(name="packages")
+    public Object[][] createPackages() {
+        return new Object[][] {
+                {null, null, new String[0]},
+                {"pages", "components",
+                        new String[]{"pages", "components"} },
+                {"ajax", null, new String[]{"ajax"} },
+                {null, "ajax", new String[]{"ajax"} }
+
+        };
+    }
+
+}



Mime
View raw message