tiles-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r939465 - /tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/
Date Thu, 29 Apr 2010 19:19:14 GMT
Author: apetrelli
Date: Thu Apr 29 19:19:14 2010
New Revision: 939465

URL: http://svn.apache.org/viewvc?rev=939465&view=rev
Log:
TILESSB-31
Added tests for servlet extractor.

Added:
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
  (with props)
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
  (with props)
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
  (with props)
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
  (with props)
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
  (with props)
    tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
  (with props)

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,86 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link ApplicationScopeExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ApplicationScopeExtractorTest {
+
+    private ServletContext context;
+
+    private ApplicationScopeExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        context = createMock(ServletContext.class);
+        extractor = new ApplicationScopeExtractor(context);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ApplicationScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+     */
+    @Test
+    public void testSetValue() {
+        context.setAttribute("attribute", "value");
+
+        replay(context);
+        extractor.setValue("attribute", "value");
+        verify(context);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ApplicationScopeExtractor#removeValue(java.lang.String)}.
+     */
+    @Test
+    public void testRemoveValue() {
+        context.removeAttribute("attribute");
+
+        replay(context);
+        extractor.removeValue("attribute");
+        verify(context);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ApplicationScopeExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+        expect(context.getAttributeNames()).andReturn(keys);
+
+        replay(context, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(context, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ApplicationScopeExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(context.getAttribute("attribute")).andReturn("value");
+
+        replay(context);
+        assertEquals("value", extractor.getValue("attribute"));
+        verify(context);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ApplicationScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,94 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link HeaderExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeaderExtractorTest {
+
+    private HttpServletRequest request;
+
+    private HttpServletResponse response;
+
+    private HeaderExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        request = createMock(HttpServletRequest.class);
+        response = createMock(HttpServletResponse.class);
+        extractor = new HeaderExtractor(request, response);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.HeaderExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(request.getHeaderNames()).andReturn(keys);
+
+        replay(request, response, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(request, response, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.HeaderExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(request.getHeader("name")).andReturn("value");
+
+        replay(request, response);
+        assertEquals("value", extractor.getValue("name"));
+        verify(request, response);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.HeaderExtractor#getValues(java.lang.String)}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetValues() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(request.getHeaders("name")).andReturn(keys);
+
+        replay(request, response, keys);
+        assertEquals(keys, extractor.getValues("name"));
+        verify(request, response, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.HeaderExtractor#setValue(java.lang.String,
java.lang.String)}.
+     */
+    @Test
+    public void testSetValue() {
+        response.setHeader("name", "value");
+
+        replay(request, response);
+        extractor.setValue("name", "value");
+        verify(request, response);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/HeaderExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link InitParameterExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InitParameterExtractorTest {
+
+    private ServletContext context;
+
+    private InitParameterExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        context = createMock(ServletContext.class);
+        extractor = new InitParameterExtractor(context);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.InitParameterExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(context.getInitParameterNames()).andReturn(keys);
+
+        replay(context, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(context, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.InitParameterExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(context.getInitParameter("name")).andReturn("value");
+
+        replay(context);
+        assertEquals("value", extractor.getValue("name"));
+        verify(context);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/InitParameterExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link ParameterExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ParameterExtractorTest {
+
+    private HttpServletRequest request;
+
+    private ParameterExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        request = createMock(HttpServletRequest.class);
+        extractor = new ParameterExtractor(request);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ParameterExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(request.getParameterNames()).andReturn(keys);
+
+        replay(request, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(request, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.ParameterExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(request.getParameter("name")).andReturn("value");
+
+        replay(request);
+        assertEquals("value", extractor.getValue("name"));
+        verify(request);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/ParameterExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link RequestScopeExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeExtractorTest {
+
+    private HttpServletRequest request;
+
+    private RequestScopeExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        request = createMock(HttpServletRequest.class);
+        extractor = new RequestScopeExtractor(request);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.RequestScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+     */
+    @Test
+    public void testSetValue() {
+        request.setAttribute("name", "value");
+
+        replay(request);
+        extractor.setValue("name", "value");
+        verify(request);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.RequestScopeExtractor#removeValue(java.lang.String)}.
+     */
+    @Test
+    public void testRemoveValue() {
+        request.removeAttribute("name");
+
+        replay(request);
+        extractor.removeValue("name");
+        verify(request);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.RequestScopeExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(request.getAttributeNames()).andReturn(keys);
+
+        replay(request, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(request, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.RequestScopeExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(request.getAttribute("name")).andReturn("value");
+
+        replay(request);
+        assertEquals("value", extractor.getValue("name"));
+        verify(request);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/RequestScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java?rev=939465&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
Thu Apr 29 19:19:14 2010
@@ -0,0 +1,120 @@
+/**
+ *
+ */
+package org.apache.tiles.request.servlet.extractor;
+
+import static org.easymock.EasyMock.*;
+import static org.easymock.classextension.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests {@link SessionScopeExtractor}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionScopeExtractorTest {
+
+    private HttpServletRequest request;
+
+    private HttpSession session;
+
+    private SessionScopeExtractor extractor;
+
+    /**
+     * Sets up the test.
+     */
+    @Before
+    public void setUp() {
+        request = createMock(HttpServletRequest.class);
+        session = createMock(HttpSession.class);
+        extractor = new SessionScopeExtractor(request);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#setValue(java.lang.String,
java.lang.Object)}.
+     */
+    @Test
+    public void testSetValue() {
+        expect(request.getSession()).andReturn(session);
+        session.setAttribute("name", "value");
+
+        replay(request, session);
+        extractor.setValue("name", "value");
+        verify(request, session);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#removeValue(java.lang.String)}.
+     */
+    @Test
+    public void testRemoveValue() {
+        expect(request.getSession(false)).andReturn(session);
+        session.removeAttribute("name");
+
+        replay(request, session);
+        extractor.removeValue("name");
+        verify(request, session);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#getKeys()}.
+     */
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testGetKeys() {
+        Enumeration<String> keys = createMock(Enumeration.class);
+
+        expect(request.getSession(false)).andReturn(session);
+        expect(session.getAttributeNames()).andReturn(keys);
+
+        replay(request, session, keys);
+        assertEquals(keys, extractor.getKeys());
+        verify(request, session, keys);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#getKeys()}.
+     */
+    @Test
+    public void testGetKeysNoSession() {
+        expect(request.getSession(false)).andReturn(null);
+
+        replay(request, session);
+        assertNull(extractor.getKeys());
+        verify(request, session);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValue() {
+        expect(request.getSession(false)).andReturn(session);
+        expect(session.getAttribute("name")).andReturn("value");
+
+        replay(request, session);
+        assertEquals("value", extractor.getValue("name"));
+        verify(request, session);
+    }
+
+    /**
+     * Test method for {@link org.apache.tiles.request.servlet.extractor.SessionScopeExtractor#getValue(java.lang.String)}.
+     */
+    @Test
+    public void testGetValueNoSession() {
+        expect(request.getSession(false)).andReturn(null);
+
+        replay(request, session);
+        assertNull(extractor.getValue("name"));
+        verify(request, session);
+    }
+
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/test/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message