You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by da...@apache.org on 2012/12/07 01:11:37 UTC
svn commit: r1418140 [7/8] - in /incubator/onami/trunk/autobind:
aop/src/main/java/org/apache/ aop/src/main/java/org/nnsoft/
aop/src/test/java/org/apache/ aop/src/test/java/org/apache/onami/
aop/src/test/java/org/nnsoft/ configuration/src/main/java/org...
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/PackageFilterTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/PackageFilterTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/PackageFilterTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/PackageFilterTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,150 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.filter;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class PackageFilterTests
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( PackageFilterTests.class, false ) ) );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void testWithWrongPackage()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance;
+ try
+ {
+ testInstance = injector.getInstance( TestInterface.class );
+ fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+ + ( testInstance == null ) );
+ }
+ catch ( ConfigurationException e )
+ {
+ // ok
+ }
+ }
+
+ @Test
+ public void createTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( PackageFilterTests.class, false ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance = injector.getInstance( TestInterface.class );
+ assertNotNull( testInstance );
+ assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+ assertTrue( testInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof SecondTestInterface );
+ }
+
+ @Test
+ public void createSecondTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( PackageFilterTests.class, false ) ) );
+ assertNotNull( injector );
+
+ SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+ assertNotNull( sameInstance );
+ assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+ assertTrue( sameInstance instanceof TestInterfaceImplementation );
+ assertTrue( sameInstance instanceof TestInterface );
+ }
+
+ @Test
+ public void createAllInterfaces()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( PackageFilterTests.class, false ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance = injector.getInstance( TestInterface.class );
+ assertNotNull( testInstance );
+ assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+ assertTrue( testInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof SecondTestInterface );
+
+ SecondTestInterface sameInstance = injector.getInstance( SecondTestInterface.class );
+ assertNotNull( sameInstance );
+ assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+ assertTrue( sameInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof TestInterface );
+ }
+
+ public static interface TestInterface
+ {
+ String sayHello();
+ }
+
+ public static interface SecondTestInterface
+ {
+ String fireEvent();
+ }
+
+ @Bind
+ public static class TestInterfaceImplementation
+ implements TestInterface, SecondTestInterface
+ {
+ public static final String TEST = "test";
+
+ public static final String EVENT = "event";
+
+ @Override
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ @Override
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/dummy/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/dummy/DummyImplementation.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/dummy/DummyImplementation.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/dummy/DummyImplementation.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/filter/dummy/DummyImplementation.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,47 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.filter.dummy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.filter.PackageFilterTests.SecondTestInterface;
+import org.apache.onami.autobind.scanner.asm.tests.autobind.filter.PackageFilterTests.TestInterface;
+
+@Bind
+public class DummyImplementation
+ implements TestInterface, SecondTestInterface
+{
+
+ public static final String TEST = "test";
+
+ public static final String EVENT = "event";
+
+ @Override
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ @Override
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/multiple/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/multiple/MultibindTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/multiple/MultibindTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/multiple/MultibindTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/multiple/MultibindTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,255 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.multiple;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class MultibindTests
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( MultibindTests.class ) ) );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void testWithWrongPackage1()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+ assertNotNull( injector );
+
+ try
+ {
+ FirstContainer container = injector.getInstance( FirstContainer.class );
+ fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+ + ( container == null ) );
+ }
+ catch ( ConfigurationException e )
+ {
+ // ok
+ }
+ }
+
+ @Test
+ public void testWithWrongPackage2()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+ assertNotNull( injector );
+
+ try
+ {
+ SecondContainer container = injector.getInstance( SecondContainer.class );
+ fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+ + ( container == null ) );
+ }
+ catch ( ConfigurationException e )
+ {
+ // ok
+ }
+ }
+
+ @Test
+ public void createFirstContainer()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( MultibindTests.class ) ) );
+ assertNotNull( injector );
+
+ FirstContainer container = injector.getInstance( FirstContainer.class );
+ assertNotNull( container );
+ assertTrue( container.size() == 2 );
+ for ( FirstInterface obj : container.get() )
+ {
+ assertTrue( obj instanceof FirstInterface );
+ assertTrue( obj instanceof SecondInterface );
+ assertTrue( obj instanceof FirstImplementation || obj instanceof SecondImplementation );
+ }
+ }
+
+ @Test
+ public void createSecondTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( MultibindTests.class ) ) );
+ assertNotNull( injector );
+
+ SecondContainer container = injector.getInstance( SecondContainer.class );
+ assertNotNull( container );
+ assertTrue( container.size() == 2 );
+ for ( SecondInterface obj : container.get() )
+ {
+ assertTrue( obj instanceof FirstInterface );
+ assertTrue( obj instanceof SecondInterface );
+ assertTrue( obj instanceof FirstImplementation || obj instanceof SecondImplementation );
+ }
+ }
+
+ @Test
+ public void createAllInterfaces()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( MultibindTests.class ) ) );
+ assertNotNull( injector );
+
+ FirstContainer firstContainer = injector.getInstance( FirstContainer.class );
+ assertNotNull( firstContainer );
+ assertTrue( firstContainer.size() == 2 );
+ for ( FirstInterface obj : firstContainer.get() )
+ {
+ assertTrue( obj instanceof FirstInterface );
+ assertTrue( obj instanceof SecondInterface );
+ assertTrue( obj instanceof FirstImplementation || obj instanceof SecondImplementation );
+ }
+
+ SecondContainer secondContainer = injector.getInstance( SecondContainer.class );
+ assertNotNull( secondContainer );
+ assertTrue( secondContainer.size() == 2 );
+ for ( SecondInterface obj : secondContainer.get() )
+ {
+ assertTrue( obj instanceof FirstInterface );
+ assertTrue( obj instanceof SecondInterface );
+ assertTrue( obj instanceof FirstImplementation || obj instanceof SecondImplementation );
+ }
+ }
+
+ public static interface FirstInterface
+ {
+ String sayHello();
+ }
+
+ public static interface SecondInterface
+ {
+ String fireEvent();
+ }
+
+ public static class FirstContainer
+ {
+ private List<FirstInterface> implementations;
+
+ @Inject
+ public FirstContainer( Set<FirstInterface> implementations )
+ {
+ super();
+ this.implementations = new ArrayList<FirstInterface>( implementations );
+ }
+
+ public int size()
+ {
+ return implementations.size();
+ }
+
+ public List<FirstInterface> get()
+ {
+ return implementations;
+ }
+ }
+
+ public static class SecondContainer
+ {
+ private List<SecondInterface> implementations;
+
+ @Inject
+ public SecondContainer( Set<SecondInterface> implementations )
+ {
+ super();
+ this.implementations = new ArrayList<SecondInterface>( implementations );
+ }
+
+ public int size()
+ {
+ return implementations.size();
+ }
+
+ public List<SecondInterface> get()
+ {
+ return implementations;
+ }
+ }
+
+ @Bind( multiple = true )
+ public static class FirstImplementation
+ implements FirstInterface, SecondInterface
+ {
+ public static final String TEST = "test1";
+
+ public static final String EVENT = "event1";
+
+ @Override
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ @Override
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+ }
+
+ @Bind( multiple = true )
+ public static class SecondImplementation
+ implements FirstInterface, SecondInterface
+ {
+ public static final String TEST = "test2";
+
+ public static final String EVENT = "event2";
+
+ @Override
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ @Override
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/names/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/names/NamedAutobindTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/names/NamedAutobindTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/names/NamedAutobindTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/names/NamedAutobindTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,156 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.names;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.inject.Named;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.jsr330.Names;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+
+public class NamedAutobindTests
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( NamedAutobindTests.class ) ) );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void testWithWrongPackage()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance;
+ try
+ {
+ testInstance = injector.getInstance( Key.get( TestInterface.class, Names.named( "testname" ) ) );
+ fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+ + ( testInstance == null ) );
+ }
+ catch ( ConfigurationException e )
+ {
+ // ok
+ }
+ }
+
+ @Test
+ public void createTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( NamedAutobindTests.class ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance = injector.getInstance( Key.get( TestInterface.class, Names.named( "testname" ) ) );
+ assertNotNull( testInstance );
+ assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+ assertTrue( testInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof SecondTestInterface );
+ }
+
+ @Test
+ public void createSecondTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( NamedAutobindTests.class ) ) );
+ assertNotNull( injector );
+
+ SecondTestInterface sameInstance =
+ injector.getInstance( Key.get( SecondTestInterface.class, Names.named( "testname" ) ) );
+ assertNotNull( sameInstance );
+ assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+ assertTrue( sameInstance instanceof TestInterfaceImplementation );
+ assertTrue( sameInstance instanceof TestInterface );
+ }
+
+ @Test
+ public void createAllInterfaces()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( NamedAutobindTests.class ) ) );
+ assertNotNull( injector );
+
+ TestInterface testInstance = injector.getInstance( Key.get( TestInterface.class, Names.named( "testname" ) ) );
+ assertNotNull( testInstance );
+ assertTrue( testInstance.sayHello().equals( TestInterfaceImplementation.TEST ) );
+ assertTrue( testInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof SecondTestInterface );
+
+ SecondTestInterface sameInstance =
+ injector.getInstance( Key.get( SecondTestInterface.class, Names.named( "testname" ) ) );
+ assertNotNull( sameInstance );
+ assertTrue( sameInstance.fireEvent().equals( TestInterfaceImplementation.EVENT ) );
+ assertTrue( sameInstance instanceof TestInterfaceImplementation );
+ assertTrue( testInstance instanceof TestInterface );
+ }
+
+ public static interface TestInterface
+ {
+ String sayHello();
+ }
+
+ public static interface SecondTestInterface
+ {
+ String fireEvent();
+ }
+
+ @Bind( @Named( "testname" ) )
+ public static class TestInterfaceImplementation
+ implements TestInterface, SecondTestInterface
+ {
+ public static final String TEST = "test";
+
+ public static final String EVENT = "event";
+
+ @Override
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ @Override
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/only/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/only/ImplementationOnlyTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/only/ImplementationOnlyTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/only/ImplementationOnlyTests.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/only/ImplementationOnlyTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,112 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.only;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import javax.inject.Named;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.annotations.To;
+import org.apache.onami.autobind.annotations.To.Type;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.jsr330.Names;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+
+public class ImplementationOnlyTests
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( ImplementationOnlyTests.class ) ) );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void testWithWrongPackage()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( "java" ) ) );
+ assertNotNull( injector );
+
+ TestInterfaceImplementation testInstance;
+ try
+ {
+ testInstance =
+ injector.getInstance( Key.get( TestInterfaceImplementation.class, Names.named( "testname" ) ) );
+ fail( "The Scanner scanned the wrong package, so no Implementation should be bound to this Interface. Instance null? "
+ + ( testInstance == null ) );
+ }
+ catch ( ConfigurationException e )
+ {
+ // ok
+ }
+ }
+
+ @Test
+ public void createTestInterface()
+ {
+ Injector injector =
+ Guice.createInjector( StartupModule.create( ASMClasspathScanner.class,
+ PackageFilter.create( ImplementationOnlyTests.class ) ) );
+ assertNotNull( injector );
+
+ try
+ {
+ TestInterfaceImplementation testInstance =
+ injector.getInstance( Key.get( TestInterfaceImplementation.class, Names.named( "testname" ) ) );
+ fail( "Named Bindings for Implementation only is not supported yet! " + ( testInstance != null ) );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+
+ @Bind( value = @Named( "testname" ), to = @To( value = Type.IMPLEMENTATION ) )
+ public static class TestInterfaceImplementation
+ {
+ public static final String TEST = "test";
+
+ public static final String EVENT = "event";
+
+ public String sayHello()
+ {
+ return TEST;
+ }
+
+ public String fireEvent()
+ {
+ return EVENT;
+ }
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Container.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Container.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Container.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Container.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,37 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.provider;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class Container
+{
+
+ @Inject
+ @Named( "mode" )
+ private Mode mode;
+
+ public Mode get()
+ {
+ return mode;
+ }
+
+}
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Mode.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Mode.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Mode.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/Mode.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,28 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.provider;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public enum Mode
+{
+
+ ALL,
+ UNKNOWN;
+
+}
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/ProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/ProviderTest.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/ProviderTest.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/provider/ProviderTest.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,71 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.provider;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class ProviderTest
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ System.setProperty( "mode", "ALL" );
+ StartupModule startup =
+ StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( ProviderTest.class ) );
+ startup.bindSystemProperties().disableStartupConfiguration();
+ Injector injector = Guice.createInjector( startup );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void createTestInterface()
+ {
+ System.setProperty( "mode", "ALL" );
+ StartupModule startup =
+ StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( ProviderTest.class ) );
+ startup.bindSystemProperties().disableStartupConfiguration();
+
+ Injector injector = Guice.createInjector( startup );
+ assertNotNull( injector );
+
+ try
+ {
+ Container instance = injector.getInstance( Container.class );
+ assertTrue( instance.get() == Mode.ALL );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ fail( e.getMessage() );
+ }
+ }
+
+}
Propchange: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Container.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Container.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Container.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Container.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,37 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.startconfig;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class Container
+{
+
+ @Inject
+ @Named( "mode" )
+ private Mode mode;
+
+ public Mode get()
+ {
+ return mode;
+ }
+
+}
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Mode.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Mode.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Mode.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/Mode.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,28 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.startconfig;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public enum Mode
+{
+
+ ALL,
+ UNKNOWN;
+
+}
Added: incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/StartConfigProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/StartConfigProviderTest.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/StartConfigProviderTest.java (added)
+++ incubator/onami/trunk/autobind/scanner/asm/src/test/java/org/apache/onami/autobind/scanner/asm/tests/autobind/startconfig/StartConfigProviderTest.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,68 @@
+package org.apache.onami.autobind.scanner.asm.tests.autobind.startconfig;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class StartConfigProviderTest
+{
+
+ @Test
+ public void createDynamicModule()
+ {
+ StartupModule startup =
+ StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( StartConfigProviderTest.class ) );
+
+ Injector injector = Guice.createInjector( startup );
+ assertNotNull( injector );
+ }
+
+ @Test
+ public void createTestInterface()
+ {
+ StartupModule startup =
+ StartupModule.create( ASMClasspathScanner.class, PackageFilter.create( StartConfigProviderTest.class ) );
+
+ Injector injector = Guice.createInjector( startup );
+ assertNotNull( injector );
+
+ try
+ {
+ Container instance = injector.getInstance( Container.class );
+ assertTrue( instance.get() == Mode.ALL );
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ fail( e.getMessage() );
+ }
+ }
+
+}
Modified: incubator/onami/trunk/autobind/tests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/pom.xml?rev=1418140&r1=1418139&r2=1418140&view=diff
==============================================================================
--- incubator/onami/trunk/autobind/tests/pom.xml (original)
+++ incubator/onami/trunk/autobind/tests/pom.xml Fri Dec 7 00:11:06 2012
@@ -37,6 +37,12 @@
<type>jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.onami.autobind</groupId>
+ <artifactId>onami-autobind-configuration</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
</dependencies>
<build>
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/
------------------------------------------------------------------------------
bugtraq:number = true
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/AllTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/AllTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/AllTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration;
+
+import org.apache.onami.autobind.test.configuration.classpath.ClasspathConfigTests;
+import org.apache.onami.autobind.test.configuration.classpath.both.BothClasspathConfigTests;
+import org.apache.onami.autobind.test.configuration.classpath.values.ValuesClasspathConfigTests;
+import org.apache.onami.autobind.test.configuration.duplicate.DuplicateClasspathConfigTests;
+import org.apache.onami.autobind.test.configuration.failure.FailureConfigTests;
+import org.apache.onami.autobind.test.configuration.file.FileConfigTests;
+import org.apache.onami.autobind.test.configuration.file.both.BothFileConfigTests;
+import org.apache.onami.autobind.test.configuration.file.override.DirectFileConfigTests;
+import org.apache.onami.autobind.test.configuration.file.override.OverrideFileConfigTests;
+import org.apache.onami.autobind.test.configuration.file.values.ValueFileConfigTests;
+import org.apache.onami.autobind.test.configuration.url.URLConfigTests;
+import org.apache.onami.autobind.test.configuration.url.both.BothURLConfigTests;
+import org.apache.onami.autobind.test.configuration.url.override.DirectOverrideConfigTests;
+import org.apache.onami.autobind.test.configuration.url.override.OverrideConfigTests;
+import org.apache.onami.autobind.test.configuration.url.values.ValuesURLConfigTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( { ClasspathConfigTests.class, ValuesClasspathConfigTests.class, BothClasspathConfigTests.class, DuplicateClasspathConfigTests.class,
+ FailureConfigTests.class, FileConfigTests.class, ValueFileConfigTests.class, BothFileConfigTests.class, URLConfigTests.class, ValuesURLConfigTests.class, BothURLConfigTests.class,
+ DirectOverrideConfigTests.class, OverrideConfigTests.class, DirectFileConfigTests.class,
+ OverrideFileConfigTests.class })
+public class AllTests {
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/ClasspathConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/ClasspathConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/ClasspathConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/ClasspathConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.classpath;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class ClasspathConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.properties"))
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/both/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/both/BothClasspathConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/both/BothClasspathConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/both/BothClasspathConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/both/BothClasspathConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,92 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.classpath.both;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.Configuration.Type;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class BothClasspathConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(BothClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(BothClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.properties"), type=Type.BOTH)
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("message")
+ private String message;
+
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ String msg = config.getProperty("message","");
+ if(msg.equals(message)){
+ return "sayHello() - " + message;
+ }
+ return "message in Properties-Map isn't equal to direct injected Message";
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/values/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/values/ValuesClasspathConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/values/ValuesClasspathConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/values/ValuesClasspathConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/classpath/values/ValuesClasspathConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,82 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.classpath.values;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.Configuration.Type;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class ValuesClasspathConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ValuesClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ValuesClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.properties"), type=Type.VALUES)
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("message")
+ private String message;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + message;
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/duplicate/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/duplicate/DuplicateClasspathConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/duplicate/DuplicateClasspathConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/duplicate/DuplicateClasspathConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/duplicate/DuplicateClasspathConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,91 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.duplicate;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class DuplicateClasspathConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(DuplicateClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(DuplicateClasspathConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("ok"), location = @PathConfig(value = "/configuration.properties"))
+ public interface ValidConfiguration {
+ }
+
+ @Configuration(name = @Named("one"), location = @PathConfig(value = "/configuration.override.properties"))
+ public interface FirstConfiguration {
+ }
+
+ @Configuration(name = @Named("one"), location = @PathConfig(value = "/configuration.override.properties"))
+ public interface SecondConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("ok")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/failure/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/failure/FailureConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/failure/FailureConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/failure/FailureConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/failure/FailureConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,87 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.failure;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class FailureConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(FailureConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(FailureConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "/configuration.properties"))
+ public interface TestConfiguration {
+ }
+
+ @Configuration(name = @Named("config2"), location = @PathConfig(value = "/configuration2.properties"))
+ public interface Test2Configuration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/FileConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/FileConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/FileConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/FileConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.file;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.PathConfig.PathType;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class FileConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(FileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(FileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "src/test/resources/configuration.properties", type = PathType.FILE))
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/both/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/both/BothFileConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/both/BothFileConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/both/BothFileConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/both/BothFileConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.file.both;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.Configuration.Type;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.PathConfig.PathType;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class BothFileConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(BothFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(BothFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "src/test/resources/configuration.properties", type = PathType.FILE), type=Type.BOTH)
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("message")
+ private String message;
+
+ @Inject
+ @Named("config")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ String msg = config.getProperty("message","");
+ if(msg.equals(message)){
+ return "sayHello() - " + message;
+ }
+ return "message in Properties-Map isn't equal to direct injected Message";
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/DirectFileConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/DirectFileConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/DirectFileConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/DirectFileConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.file.override;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.PathConfig.PathType;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class DirectFileConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(DirectFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(DirectFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue(instance.sayHello(), "sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("direct"), location = @PathConfig(value = "src/test/resources/configuration.properties", type = PathType.FILE), alternative = @PathConfig(value = "src/test/resources/configuration.nonexisting.properties", type = PathType.FILE))
+ public interface DirectConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class DirectImplementations implements TestInterface {
+ @Inject
+ @Named("direct")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/OverrideFileConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/OverrideFileConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/OverrideFileConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/override/OverrideFileConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.file.override;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.PathConfig.PathType;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class OverrideFileConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(OverrideFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(OverrideFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue(instance.sayHello(), "sayHello() - overriden yeahh!!".equals(instance
+ .sayHello()));
+ }
+
+ @Configuration(name = @Named("override"), location = @PathConfig(value = "src/test/resources/configuration.properties", type = PathType.FILE), alternative = @PathConfig(value = "src/test/resources/configuration.override.properties", type = PathType.FILE))
+ public interface OverrideConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class DirectImplementations implements TestInterface {
+ @Inject
+ @Named("override")
+ private Properties config;
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + config.getProperty("message");
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/values/
------------------------------------------------------------------------------
bugtraq:number = true
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/values/ValueFileConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/values/ValueFileConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/values/ValueFileConfigTests.java (added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/file/values/ValueFileConfigTests.java Fri Dec 7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <da...@googlemail.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 org.apache.onami.autobind.test.configuration.file.values;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import junit.framework.Assert;
+
+import org.apache.onami.autobind.annotations.Bind;
+import org.apache.onami.autobind.configuration.Configuration;
+import org.apache.onami.autobind.configuration.Configuration.Type;
+import org.apache.onami.autobind.configuration.PathConfig;
+import org.apache.onami.autobind.configuration.PathConfig.PathType;
+import org.apache.onami.autobind.configuration.StartupModule;
+import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
+import org.apache.onami.autobind.scanner.PackageFilter;
+import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+
+public class ValueFileConfigTests {
+ @Test
+ public void createDynamicModule() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ValueFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+ }
+
+ @Test
+ public void createPListConfiguration() {
+ StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+ PackageFilter.create(ValueFileConfigTests.class));
+ startup.addFeature(ConfigurationFeature.class);
+
+ Injector injector = Guice.createInjector(startup);
+ assertNotNull(injector);
+
+ TestInterface instance = injector.getInstance(TestInterface.class);
+ Assert.assertTrue("sayHello() - yeahh!!".equals(instance.sayHello()));
+ }
+
+ @Configuration(name = @Named("config"), location = @PathConfig(value = "src/test/resources/configuration.properties", type = PathType.FILE), type=Type.VALUES)
+ public interface TestConfiguration {
+ }
+
+ public static interface TestInterface {
+ String sayHello();
+ }
+
+ @Bind
+ public static class TestImplementations implements TestInterface {
+ @Inject
+ @Named("message")
+ private String message;
+
+
+ @Override
+ public String sayHello() {
+ return "sayHello() - " + message;
+ }
+ }
+}
Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/folder/
------------------------------------------------------------------------------
bugtraq:number = true