tiles-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r933760 - in /tiles/sandbox/trunk/tiles-request/tiles-request-api/src: main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java
Date Tue, 13 Apr 2010 19:37:05 GMT
Author: apetrelli
Date: Tue Apr 13 19:37:05 2010
New Revision: 933760

URL: http://svn.apache.org/viewvc?rev=933760&view=rev
Log:
TILESSB-11
The code coverage in tiles-request-api is maximum possible.

Modified:
    tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
    tiles/sandbox/trunk/tiles-request/tiles-request-api/src/test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java

Modified: tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java?rev=933760&r1=933759&r2=933760&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
(original)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-api/src/main/java/org/apache/tiles/request/scope/ReflectionContextResolver.java
Tue Apr 13 19:37:05 2010
@@ -33,6 +33,7 @@ public class ReflectionContextResolver i
         try {
             return (Map<String, Object>) method.invoke(request);
         } catch (IllegalAccessException e) {
+            // Should not ever happen, since method is public.
             throw new NoSuchScopeException("No accessible method for '" + scope
                     + "' scope.", e);
         } catch (InvocationTargetException e) {

Modified: tiles/sandbox/trunk/tiles-request/tiles-request-api/src/test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-api/src/test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java?rev=933760&r1=933759&r2=933760&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-api/src/test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java
(original)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-api/src/test/java/org/apache/tiles/request/scope/ReflectionContextResolverTest.java
Tue Apr 13 19:37:05 2010
@@ -14,6 +14,7 @@ import java.util.Map;
 
 import org.apache.tiles.request.ApplicationContext;
 import org.apache.tiles.request.Request;
+import org.apache.tiles.request.util.RequestWrapper;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -60,6 +61,43 @@ public class ReflectionContextResolverTe
     }
 
     /**
+     * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getContext(org.apache.tiles.request.Request,
java.lang.String)}.
+     */
+    @Test
+    public void testGetContextWrapped() {
+        replay(oneScope, twoScope, threeScope);
+        RequestWrapper wrapper = new RequestWrapper(request);
+        assertEquals(oneScope, resolver.getContext(wrapper, "one"));
+        assertEquals(twoScope, resolver.getContext(wrapper, "two"));
+        assertEquals(threeScope, resolver.getContext(wrapper, "three"));
+        verify(oneScope, twoScope, threeScope);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getContext(org.apache.tiles.request.Request,
java.lang.String)}.
+     */
+    @Test(expected=NoSuchScopeException.class)
+    public void testGetContextException() {
+        resolver.getContext(request, "none");
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getContext(org.apache.tiles.request.Request,
java.lang.String)}.
+     */
+    @Test(expected=NoSuchScopeException.class)
+    public void testGetContextException2() {
+        resolver.getContext(request, "private");
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getContext(org.apache.tiles.request.Request,
java.lang.String)}.
+     */
+    @Test(expected=NoSuchScopeException.class)
+    public void testGetContextException3() {
+        resolver.getContext(request, "unavailable");
+    }
+
+    /**
      * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getAvailableScopes(org.apache.tiles.request.Request)}.
      */
     @Test
@@ -69,6 +107,17 @@ public class ReflectionContextResolverTe
         verify(oneScope, twoScope, threeScope);
     }
 
+    /**
+     * Test method for {@link org.apache.tiles.request.scope.ReflectionContextResolver#getAvailableScopes(org.apache.tiles.request.Request)}.
+     */
+    @Test
+    public void testGetAvailableScopesWrapped() {
+        replay(oneScope, twoScope, threeScope);
+        RequestWrapper wrapper = new RequestWrapper(request);
+        assertArrayEquals(SCOPES, resolver.getAvailableScopes(wrapper));
+        verify(oneScope, twoScope, threeScope);
+    }
+
     public static class SampleRequest implements Request {
 
         private static final String [] SCOPES = new String[] {"one", "two", "three"};
@@ -104,6 +153,14 @@ public class ReflectionContextResolverTe
             return threeScope;
         }
 
+        private Map<String, Object> getPrivateScope() {
+            return null;
+        }
+
+        public Map<String, Object> getUnavailableScope() {
+            throw new UnsupportedOperationException("No way!");
+        }
+
         @Override
         public void dispatch(String path) {
             // Does nothing.



Mime
View raw message