// 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 java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import dagger.Module;
import dagger.ObjectGraph;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static com.leacox.dagger.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
    @Singleton
    public static class ForwardingServlet extends HttpServlet {
        @Inject
        ForwardingServlet() {}

        @Override
        public void service(ServletRequest servletRequest, ServletResponse servletResponse)
                throws IOException, ServletException {
            final HttpServletRequest request = (HttpServletRequest) servletRequest;

            request.getRequestDispatcher("/blah.jsp")
                    .forward(servletRequest, servletResponse);
        }
    }

    @Singleton
    public static class ForwardedServlet extends HttpServlet {
        static int forwardedTo = 0;

        // Reset for test.
        @Inject
        public ForwardedServlet() {
            forwardedTo = 0;
        }

        @Override
        public void service(ServletRequest servletRequest, ServletResponse servletResponse)
                throws IOException, ServletException {
            final HttpServletRequest request = (HttpServletRequest) servletRequest;

// 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/ServletDispatchIntegrationTest.java
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import dagger.Module;
import dagger.ObjectGraph;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static com.leacox.dagger.servlet.ManagedServletPipeline.REQUEST_DISPATCHER_REQUEST;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

    @Singleton
    public static class ForwardingServlet extends HttpServlet {
        @Inject
        ForwardingServlet() {}

        @Override
        public void service(ServletRequest servletRequest, ServletResponse servletResponse)
                throws IOException, ServletException {
            final HttpServletRequest request = (HttpServletRequest) servletRequest;

            request.getRequestDispatcher("/blah.jsp")
                    .forward(servletRequest, servletResponse);
        }
    }

    @Singleton
    public static class ForwardedServlet extends HttpServlet {
        static int forwardedTo = 0;

        // Reset for test.
        @Inject
        public ForwardedServlet() {
            forwardedTo = 0;
        }

        @Override
        public void service(ServletRequest servletRequest, ServletResponse servletResponse)
                throws IOException, ServletException {
            final HttpServletRequest request = (HttpServletRequest) servletRequest;

            assertTrue((Boolean) request.getAttribute(REQUEST_DISPATCHER_REQUEST));