Package com.github.jsr330.spi.config.builder

Examples of com.github.jsr330.spi.config.builder.BindingConditionsTest


        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
   
    @Test
    public void simpleBindingAsSingleton() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).asSingleton(TestImplementation1.class).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertTrue(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here


        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
   
    @Test
    public void simpleTypeAsSingleton() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).asSingleton().build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertTrue(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
   
    @Test
    public void simpleType() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
   
    @Test
    public void simpleTypeInheritance() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation2.class).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation2.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
    }
View Full Code Here

        }
    }
   
    @Test
    public void interfaceWithProvider() {
        TypeConfig config = defaultBinder.instance(TestInterface.class).with(new Provider<TestInterface>() {
           
            @Override
            public TestInterface get() {
                return new TestImplementation1();
            }
           
        }).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestInterface.class, null, null, null);
        assertNotNull(container);
        assertNotNull(container.getProvider());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.PROVIDER, container.getInstanceMode());
    }
View Full Code Here

        assertEquals(InstanceMode.PROVIDER, container.getInstanceMode());
    }
   
    @Test
    public void simpleTypeWithProvider() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).with(new Provider<TestImplementation1>() {
           
            @Override
            public TestImplementation1 get() {
                return new TestImplementation1();
            }
           
        }).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertNotNull(container.getProvider());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.PROVIDER, container.getInstanceMode());
    }
View Full Code Here

        defaultBinder = new DefaultBinder<Object>();
    }
   
    @Test
    public void usingDefaultConstructor() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation1.class)
                .using(defaultConstructor(TestImplementation1.class)).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
        assertEquals(defaultConstructor(TestImplementation1.class), container.getConstructor());
View Full Code Here

        assertNull(container.getFactoryMethod());
    }
   
    @Test
    public void usingCustomConstructor() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation1.class)
                .using(constructor(TestImplementation1.class, String.class, String.class)).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
        assertEquals(constructor(TestImplementation1.class, String.class, String.class), container.getConstructor());
View Full Code Here

        assertNull(container.getFactoryMethod());
    }
   
    @Test
    public void usingNotExistingConstructor() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).as(TestImplementation1.class)
                .using(constructor(TestImplementation1.class, String.class, Integer.class)).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertFalse(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
        assertNull(container.getConstructor());
View Full Code Here

        assertNull(container.getFactoryMethod());
    }
   
    @Test
    public void singletonUsingDefaultConstructor() {
        TypeConfig config = defaultBinder.instance(TestImplementation1.class).asSingleton(TestImplementation1.class)
                .using(defaultConstructor(TestImplementation1.class)).build();
        TypeContainer container;
       
        container = config.getTypeContainer(null, TestImplementation1.class, null, null, null);
        assertNotNull(container);
        assertEquals(TestImplementation1.class, container.getType());
        assertTrue(container.isSingleton());
        assertEquals(InstanceMode.CONSTRUCTOR, container.getInstanceMode());
        assertEquals(defaultConstructor(TestImplementation1.class), container.getConstructor());
View Full Code Here

TOP

Related Classes of com.github.jsr330.spi.config.builder.BindingConditionsTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.