// Path: src/test/java/com/woinject/stubs/StubApplication.java
// public class StubApplication extends InjectableApplication {
//     private static class StubModule extends AbstractModule {
//         private boolean moduleWasLoaded = false;
// 
//         @Override
//         protected void configure() {
//             moduleWasLoaded = true;
// 
//             bind(String.class).annotatedWith(Names.named("field")).toInstance("fieldInjected");
//             bind(String.class).annotatedWith(Names.named("method")).toInstance("methodInjected");
//         }
//     }
// 
//     public static void setApplication(WOApplication application) {
//         try {
//             Method method = WOApplication.class.getDeclaredMethod("_setApplication", WOApplication.class);
// 
//             method.setAccessible(true);
// 
//             method.invoke(null, application);
//         } catch (Exception exception) {
//             throw new RuntimeException(exception);
//         }
//     }
// 
//     @Inject
//     @Named("field")
//     private String injectableField;
// 
//     private String injectableMethod;
// 
//     private boolean nullInjector = false;
// 
//     private StubModule stubModule;
// 
//     @Override
//     protected Class<StubSession> _sessionClass() {
//         return StubSession.class;
//     }
// 
//     public String getInjectableField() {
//         return injectableField;
//     }
// 
//     public String getInjectableMethod() {
//         return injectableMethod;
//     }
// 
//     @Inject
//     public void initInjectableMethod(@Named("method") String value) {
//         injectableMethod = value;
//     }
// 
//     @Override
//     public Injector injector() {
//         if (nullInjector) {
//             return null;
//         }
// 
//         return super.injector();
//     }
// 
//     @Override
//     protected Module[] modules() {
//         stubModule = new StubModule();
// 
//         return new Module[] { stubModule };
//     }
// 
//     public void setReturnNullInjector(boolean nullInjector) {
//         this.nullInjector = nullInjector;
//     }
// 
//     public boolean stubModuleWasLoaded() {
//         return stubModule.moduleWasLoaded;
//     }
// }


import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.inject.Key;
import com.google.inject.OutOfScopeException;
import com.google.inject.Provider;
import com.webobjects.appserver.WOApplication;
import com.webobjects.appserver.WOContext;
import com.webobjects.foundation.NSKeyValueCoding;
import com.woinject.stubs.StubApplication;
import er.extensions.appserver.ERXSession;
import er.extensions.appserver.ERXWOContext;
/**
 * Copyright (C) 2010 hprange <hprange@gmail.com>
 * 
 * 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.woinject;





/**
 * @author <a href="mailto:hprange@gmail.com">Henrique Prange</a>
 */
@RunWith(MockitoJUnitRunner.class)
public class TestWOSessionScope extends AbstractScopeTestCase<WOSessionScope> {
    @Mock
    private ERXSession mockSession;

    @Mock
    private WOContext mockContext;

    @Mock
    private WOApplication application;

    @Before
    public void setup() {
        scope = new WOSessionScope();

        ERXSession.setSession(mockSession);

        ERXWOContext.setCurrentContext(mockContext);

// Path: src/test/java/com/woinject/stubs/StubApplication.java
// public class StubApplication extends InjectableApplication {
//     private static class StubModule extends AbstractModule {
//         private boolean moduleWasLoaded = false;
// 
//         @Override
//         protected void configure() {
//             moduleWasLoaded = true;
// 
//             bind(String.class).annotatedWith(Names.named("field")).toInstance("fieldInjected");
//             bind(String.class).annotatedWith(Names.named("method")).toInstance("methodInjected");
//         }
//     }
// 
//     public static void setApplication(WOApplication application) {
//         try {
//             Method method = WOApplication.class.getDeclaredMethod("_setApplication", WOApplication.class);
// 
//             method.setAccessible(true);
// 
//             method.invoke(null, application);
//         } catch (Exception exception) {
//             throw new RuntimeException(exception);
//         }
//     }
// 
//     @Inject
//     @Named("field")
//     private String injectableField;
// 
//     private String injectableMethod;
// 
//     private boolean nullInjector = false;
// 
//     private StubModule stubModule;
// 
//     @Override
//     protected Class<StubSession> _sessionClass() {
//         return StubSession.class;
//     }
// 
//     public String getInjectableField() {
//         return injectableField;
//     }
// 
//     public String getInjectableMethod() {
//         return injectableMethod;
//     }
// 
//     @Inject
//     public void initInjectableMethod(@Named("method") String value) {
//         injectableMethod = value;
//     }
// 
//     @Override
//     public Injector injector() {
//         if (nullInjector) {
//             return null;
//         }
// 
//         return super.injector();
//     }
// 
//     @Override
//     protected Module[] modules() {
//         stubModule = new StubModule();
// 
//         return new Module[] { stubModule };
//     }
// 
//     public void setReturnNullInjector(boolean nullInjector) {
//         this.nullInjector = nullInjector;
//     }
// 
//     public boolean stubModuleWasLoaded() {
//         return stubModule.moduleWasLoaded;
//     }
// }


// Path: src/test/java/com/woinject/TestWOSessionScope.java
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.inject.Key;
import com.google.inject.OutOfScopeException;
import com.google.inject.Provider;
import com.webobjects.appserver.WOApplication;
import com.webobjects.appserver.WOContext;
import com.webobjects.foundation.NSKeyValueCoding;
import com.woinject.stubs.StubApplication;
import er.extensions.appserver.ERXSession;
import er.extensions.appserver.ERXWOContext;

/**
 * Copyright (C) 2010 hprange <hprange@gmail.com>
 * 
 * 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.woinject;





/**
 * @author <a href="mailto:hprange@gmail.com">Henrique Prange</a>
 */
@RunWith(MockitoJUnitRunner.class)
public class TestWOSessionScope extends AbstractScopeTestCase<WOSessionScope> {
    @Mock
    private ERXSession mockSession;

    @Mock
    private WOContext mockContext;

    @Mock
    private WOApplication application;

    @Before
    public void setup() {
        scope = new WOSessionScope();

        ERXSession.setSession(mockSession);

        ERXWOContext.setCurrentContext(mockContext);

        StubApplication.setApplication(application);