// Path: src/main/java/ru/vyarus/guice/ext/core/generator/anchor/GeneratorAnchorModule.java
// public class GeneratorAnchorModule extends AbstractModule {
// 
//     @Override
//     protected void configure() {
//         // providers bound explicitly to tie them to child injector
//         bind(DynamicClassProvider.class);
//         bind(DynamicSingletonProvider.class);
//         // anchor bean used to tie dynamically provided beans to child injector
//         bind(AnchorBean.class).in(Singleton.class);
//     }
// }


import com.google.inject.*;
import com.google.inject.matcher.Matchers;
import com.google.inject.name.Names;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Assert;
import org.junit.Test;
import ru.vyarus.guice.ext.core.generator.anchor.GeneratorAnchorModule;
import ru.vyarus.guice.ext.generator.support.anchor.*;
import ru.vyarus.guice.ext.generator.support.aop.CustomAop;
import javax.inject.Inject;
import javax.inject.Provider;
package ru.vyarus.guice.ext.generator;



/**
 * @author Vyacheslav Rusakov
 * @since 21.09.2016
 */
public class GeneratorAnchorsTest {

    @Test(expected = AbstractMethodError.class)
    public void checkChildInjectorFailure() throws Exception {
        // aop registered in child injector
        Injector injector = Guice.createInjector().createChildInjector(new ChildAopModule());
        // bean will be generated at root injector and so no aop will apply on it
        injector.getInstance(TestIface.class).hello();
    }

    @Test
    public void testAnchorModule() throws Exception {
        // aop registered in child injector with anchor module
// Path: src/main/java/ru/vyarus/guice/ext/core/generator/anchor/GeneratorAnchorModule.java
// public class GeneratorAnchorModule extends AbstractModule {
// 
//     @Override
//     protected void configure() {
//         // providers bound explicitly to tie them to child injector
//         bind(DynamicClassProvider.class);
//         bind(DynamicSingletonProvider.class);
//         // anchor bean used to tie dynamically provided beans to child injector
//         bind(AnchorBean.class).in(Singleton.class);
//     }
// }


// Path: src/test/java/ru/vyarus/guice/ext/generator/GeneratorAnchorsTest.java
import com.google.inject.*;
import com.google.inject.matcher.Matchers;
import com.google.inject.name.Names;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Assert;
import org.junit.Test;
import ru.vyarus.guice.ext.core.generator.anchor.GeneratorAnchorModule;
import ru.vyarus.guice.ext.generator.support.anchor.*;
import ru.vyarus.guice.ext.generator.support.aop.CustomAop;
import javax.inject.Inject;
import javax.inject.Provider;

package ru.vyarus.guice.ext.generator;



/**
 * @author Vyacheslav Rusakov
 * @since 21.09.2016
 */
public class GeneratorAnchorsTest {

    @Test(expected = AbstractMethodError.class)
    public void checkChildInjectorFailure() throws Exception {
        // aop registered in child injector
        Injector injector = Guice.createInjector().createChildInjector(new ChildAopModule());
        // bean will be generated at root injector and so no aop will apply on it
        injector.getInstance(TestIface.class).hello();
    }

    @Test
    public void testAnchorModule() throws Exception {
        // aop registered in child injector with anchor module
        Injector injector = Guice.createInjector().createChildInjector(new ChildAopModule(), new GeneratorAnchorModule());