// Path: dagger-servlet/src/main/java/com/leacox/dagger/servlet/DaggerServletContextListener.java
// public static final String OBJECT_GRAPH_NAME = ObjectGraph.class.getName();


import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import org.testng.annotations.Test;
import javax.inject.Singleton;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpServlet;
import static com.leacox.dagger.servlet.DaggerServletContextListener.OBJECT_GRAPH_NAME;
import static org.easymock.EasyMock.*;
import static org.testng.Assert.*;
/**
 * Copyright (C) 2010 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;




/**
 * This gorgeous test asserts that multiple servlet pipelines can
 * run in the SAME JVM. booya.
 *
 * @author dhanji@gmail.com (Dhanji R. Prasanna)
 * @author John Leacox
 */
public class MultipleServletObjectGraphsTest {
    @Module(
            injects = {
            },
            includes = {
                    ServletModule.class
            },
            library = true
    )
    static class TestModule {
        @Provides
        @Singleton
        DummyServlet provideDummyServlet() {
            return new DummyServlet();
        }

        @Provides
        @Singleton
        DummyFilterImpl provideDummyFilter() {
            return new DummyFilterImpl();
        }
    }

    @Test
    public final void testTwoObjectGraphs() {
        ServletContext fakeContextOne = createMock(ServletContext.class);
        ServletContext fakeContextTwo = createMock(ServletContext.class);

// Path: dagger-servlet/src/main/java/com/leacox/dagger/servlet/DaggerServletContextListener.java
// public static final String OBJECT_GRAPH_NAME = ObjectGraph.class.getName();


// Path: dagger-servlet/src/test/java/com/leacox/dagger/servlet/MultipleServletObjectGraphsTest.java
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import org.testng.annotations.Test;
import javax.inject.Singleton;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpServlet;
import static com.leacox.dagger.servlet.DaggerServletContextListener.OBJECT_GRAPH_NAME;
import static org.easymock.EasyMock.*;
import static org.testng.Assert.*;

/**
 * Copyright (C) 2010 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;




/**
 * This gorgeous test asserts that multiple servlet pipelines can
 * run in the SAME JVM. booya.
 *
 * @author dhanji@gmail.com (Dhanji R. Prasanna)
 * @author John Leacox
 */
public class MultipleServletObjectGraphsTest {
    @Module(
            injects = {
            },
            includes = {
                    ServletModule.class
            },
            library = true
    )
    static class TestModule {
        @Provides
        @Singleton
        DummyServlet provideDummyServlet() {
            return new DummyServlet();
        }

        @Provides
        @Singleton
        DummyFilterImpl provideDummyFilter() {
            return new DummyFilterImpl();
        }
    }

    @Test
    public final void testTwoObjectGraphs() {
        ServletContext fakeContextOne = createMock(ServletContext.class);
        ServletContext fakeContextTwo = createMock(ServletContext.class);

        fakeContextOne.setAttribute(eq(OBJECT_GRAPH_NAME), isA(ObjectGraph.class));