// Path: dagger-servlet/src/main/java/com/leacox/dagger/servlet/ManagedServletPipeline.java
// public static final String REQUEST_DISPATCHER_REQUEST = "javax.servlet.forward.servlet_path";


import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import dagger.ObjectGraph;
import org.testng.annotations.Test;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import static com.leacox.dagger.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
 * Copyright (C) 2008 Google Inc.
 * Copyright (C) 2014 John Leacox
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.leacox.dagger.servlet;




/**
 * Tests forwarding and inclusion (RequestDispatcher actions from the
 * servlet spec).
 *
 * @author Dhanji R. Prasanna (dhanji@gmail com)
 * @author John Leacox
 */
public class ServletPipelineRequestDispatcherTest {
    private static final Class<?> HTTP_SERLVET_CLASS = HttpServlet.class;
    private static final String A_KEY = "thinglyDEgintly" + new Date() + UUID.randomUUID();
    private static final String A_VALUE = ServletPipelineRequestDispatcherTest.class.toString()
            + new Date() + UUID.randomUUID();

    @Test
    public final void testIncludeManagedServlet() throws IOException, ServletException {
        String pattern = "blah.html";
        final ServletDefinition servletDefinition = new ServletDefinition(pattern,
                HttpServlet.class, UriPatternType.get(UriPatternType.SERVLET, pattern),
                new HashMap<String, String>(), null);

        ObjectGraph objectGraph = createMock(ObjectGraph.class);
        final HttpServletRequest requestMock = createMock(HttpServletRequest.class);

        expect(requestMock.getAttribute(A_KEY))
                .andReturn(A_VALUE);


// Path: dagger-servlet/src/main/java/com/leacox/dagger/servlet/ManagedServletPipeline.java
// public static final String REQUEST_DISPATCHER_REQUEST = "javax.servlet.forward.servlet_path";


// Path: dagger-servlet/src/test/java/com/leacox/dagger/servlet/ServletPipelineRequestDispatcherTest.java
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import dagger.ObjectGraph;
import org.testng.annotations.Test;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import static com.leacox.dagger.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
 * Copyright (C) 2008 Google Inc.
 * Copyright (C) 2014 John Leacox
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.leacox.dagger.servlet;




/**
 * Tests forwarding and inclusion (RequestDispatcher actions from the
 * servlet spec).
 *
 * @author Dhanji R. Prasanna (dhanji@gmail com)
 * @author John Leacox
 */
public class ServletPipelineRequestDispatcherTest {
    private static final Class<?> HTTP_SERLVET_CLASS = HttpServlet.class;
    private static final String A_KEY = "thinglyDEgintly" + new Date() + UUID.randomUUID();
    private static final String A_VALUE = ServletPipelineRequestDispatcherTest.class.toString()
            + new Date() + UUID.randomUUID();

    @Test
    public final void testIncludeManagedServlet() throws IOException, ServletException {
        String pattern = "blah.html";
        final ServletDefinition servletDefinition = new ServletDefinition(pattern,
                HttpServlet.class, UriPatternType.get(UriPatternType.SERVLET, pattern),
                new HashMap<String, String>(), null);

        ObjectGraph objectGraph = createMock(ObjectGraph.class);
        final HttpServletRequest requestMock = createMock(HttpServletRequest.class);

        expect(requestMock.getAttribute(A_KEY))
                .andReturn(A_VALUE);


        requestMock.setAttribute(REQUEST_DISPATCHER_REQUEST, true);