onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danielman...@apache.org
Subject svn commit: r1418140 [8/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...
Date Fri, 07 Dec 2012 00:11:37 GMT
Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/folder/FolderConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/folder/FolderConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/folder/FolderConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/folder/FolderConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,89 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.folder;
+
+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 FolderConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(FolderConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(FolderConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+
+		TestInterface instance = injector.getInstance(TestInterface.class);
+		Assert
+			.assertTrue("sayHello() - loaded by iterating through folder / read all files of this
folder"
+				.equals(instance.sayHello()));
+	}
+
+	@Configuration(name = @Named("config"), location = @PathConfig(value = "/conf/", type =
PathType.CLASSPATH), type = Type.VALUES)
+	public interface TestConfiguration {
+	}
+
+	public static interface TestInterface {
+		String sayHello();
+	}
+
+	@Bind
+	public static class TestImplementations implements TestInterface {
+		@Inject
+		@Named("message.1")
+		private String msg1;
+
+		@Inject
+		@Named("function.1")
+		private String func1;
+
+		@Override
+		public String sayHello() {
+			return "sayHello() - " + msg1 + " / " + func1;
+		}
+	}
+}

Propchange: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/URLConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/URLConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/URLConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/URLConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.url;
+
+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 URLConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(URLConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(URLConfigTests.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 = "http://devsurf.de/guice/configuration.properties",
type = PathType.URL))
+	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/url/both/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/both/BothURLConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/both/BothURLConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/both/BothURLConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/both/BothURLConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.url.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 BothURLConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(BothURLConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(BothURLConfigTests.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 = "http://devsurf.de/guice/configuration.properties",
type = PathType.URL), 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/url/override/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/DirectOverrideConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/DirectOverrideConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/DirectOverrideConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/DirectOverrideConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.url.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 DirectOverrideConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(DirectOverrideConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(DirectOverrideConfigTests.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 = "http://devsurf.de/guice/configuration.properties",
type = PathType.URL), alternative = @PathConfig(value = "http://devsurf.de/guice/nonexisting.properties",
type = PathType.URL))
+	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/url/override/OverrideConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/OverrideConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/OverrideConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/override/OverrideConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.url.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 OverrideConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(OverrideConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(OverrideConfigTests.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 = "http://devsurf.de/guice/configuration.properties",
type = PathType.URL), alternative = @PathConfig(value = "http://devsurf.de/guice/configuration.override.properties",
type = PathType.URL))
+	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/url/values/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/values/ValuesURLConfigTests.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/values/ValuesURLConfigTests.java?rev=1418140&view=auto
==============================================================================
--- incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/values/ValuesURLConfigTests.java
(added)
+++ incubator/onami/trunk/autobind/tests/src/test/java/org/apache/onami/autobind/test/configuration/url/values/ValuesURLConfigTests.java
Fri Dec  7 00:11:06 2012
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2010 Daniel Manzke <daniel.manzke@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.url.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 ValuesURLConfigTests {
+	@Test
+	public void createDynamicModule() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(ValuesURLConfigTests.class));
+		startup.addFeature(ConfigurationFeature.class);
+
+		Injector injector = Guice.createInjector(startup);
+		assertNotNull(injector);
+	}
+
+	@Test
+	public void createPListConfiguration() {
+		StartupModule startup = StartupModule.create(ASMClasspathScanner.class,
+			PackageFilter.create(ValuesURLConfigTests.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 = "http://devsurf.de/guice/configuration.properties",
type = PathType.URL), 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;
+		}
+	}
+}



Mime
View raw message