FileDocCategorySizeDatePackage
TestAbstractGdataServlet.javaAPI DocApache Lucene 2.1.011040Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.servlet

TestAbstractGdataServlet

public class TestAbstractGdataServlet extends TestCase
author
Simon Willnauer

Fields Summary
private static final String
METHOD_DELETE
private static final String
METHOD_GET
private static final String
METHOD_POST
private static final String
METHOD_PUT
private static final String
METHOD_HEADER_NAME
private HttpServletRequest
mockRequest
private HttpServletResponse
mockResponse
private AbstractGdataServlet
servletInstance
private org.easymock.MockControl
requestMockControl
private org.easymock.MockControl
responseMockControl
Constructors Summary
Methods Summary
protected voidsetUp()

 
 
          
        this.requestMockControl = MockControl 
                .createControl(HttpServletRequest.class); 
        this.responseMockControl = MockControl 
                .createControl(HttpServletResponse.class); 
        this.mockRequest = (HttpServletRequest) this.requestMockControl 
                .getMock(); 
        this.mockResponse = (HttpServletResponse) this.responseMockControl 
                .getMock(); 
        this.servletInstance = new StubGDataServlet(); 
    
public voidtestServiceHttpServletRequestHttpServletResponseDelete()
Test method for 'org.apache.lucene.gdata.servlet.AbstractGdataServlet.service(HttpServletRequest, HttpServletResponse)'

 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_DELETE); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_DELETE); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
        this.requestMockControl.reset(); 
 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_POST); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_DELETE); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
    
public voidtestServiceHttpServletRequestHttpServletResponseGET()
Test method for 'org.apache.lucene.gdata.servlet.AbstractGdataServlet.service(HttpServletRequest, HttpServletResponse)'

 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_GET); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_GET); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
        this.requestMockControl.reset(); 
 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_POST); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_GET); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
 
    
public voidtestServiceHttpServletRequestHttpServletResponsePOST()
Test method for 'org.apache.lucene.gdata.servlet.AbstractGdataServlet.service(HttpServletRequest, HttpServletResponse)'

 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_POST); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_POST); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
        this.requestMockControl.reset(); 
 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_PUT); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_POST); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
    
public voidtestServiceHttpServletRequestHttpServletResponsePUT()
Test method for 'org.apache.lucene.gdata.servlet.AbstractGdataServlet.service(HttpServletRequest, HttpServletResponse)'

 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_PUT); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_PUT); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
        this.requestMockControl.reset(); 
 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_POST); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), METHOD_PUT); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
    
public voidtestServiceNullOverrideHeader()

 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getMethod(), METHOD_POST); 
        this.requestMockControl.expectAndDefaultReturn(this.mockRequest 
                .getHeader(METHOD_HEADER_NAME), null); 
        this.requestMockControl.replay(); 
 
        try { 
            this.servletInstance.service(this.mockRequest, this.mockResponse); 
        } catch (ServletException e) { 
            fail("ServeltExpception not expected"); 
        } catch (IOException e) { 
            fail("IOExpception not expected"); 
        } 
 
        this.requestMockControl.verify(); 
        this.requestMockControl.reset();