Add and enforce spring checkstyle configurations

This commit is contained in:
Simon DeMartini
2022-03-19 00:25:55 -07:00
committed by Dave Syer
parent 7254dc8be7
commit 57c54fad2f
46 changed files with 1397 additions and 956 deletions

View File

@@ -1,18 +1,33 @@
package org.springframework.guice;
/*
* Copyright 2014-2022 the original author or authors.
*
* 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
*
* https://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.assertEquals;
import static org.junit.Assert.assertNotNull;
package org.springframework.guice;
import javax.inject.Inject;
import javax.inject.Named;
import org.junit.Before;
import org.junit.Test;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public abstract class AbstractCompleteWiringTests {
@@ -133,7 +148,7 @@ public abstract class AbstractCompleteWiringTests {
}
public static interface Parameterized<T> {
public interface Parameterized<T> {
}

View File

@@ -1,10 +1,27 @@
package org.springframework.guice;
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.assertTrue;
package org.springframework.guice;
import javax.inject.Inject;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -14,15 +31,9 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProce
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.guice.BeanPostProcessorTests.GuiceBeanThatWantsPostProcessedBean;
import org.springframework.guice.BeanPostProcessorTests.GuiceBeanThatWantsSpringBean;
import org.springframework.guice.BeanPostProcessorTests.PostProcessedBean;
import org.springframework.guice.BeanPostProcessorTests.SpringBeanThatWantsPostProcessedBean;
import org.springframework.guice.annotation.EnableGuiceModules;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import static org.junit.Assert.assertTrue;
public class BeanPostProcessorTests {
@@ -81,69 +92,69 @@ public class BeanPostProcessorTests {
}
}
@EnableGuiceModules
@Configuration
static class BeanPostProcessorTestConfig {
@EnableGuiceModules
@Configuration
class BeanPostProcessorTestConfig {
public static class PostProcessorRegistrar implements BeanDefinitionRegistryPostProcessor {
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(TestBeanPostProcessor.class);
registry.registerBeanDefinition("postProcessor", bean.getBeanDefinition());
@Bean
PostProcessorRegistrar postProcessorRegistrar() {
return new PostProcessorRegistrar();
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
@Bean
PostProcessedBean postProcessedBean() {
return new PostProcessedBean();
}
}
public static class TestBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof PostProcessedBean) {
((PostProcessedBean) bean).postProcessed = true;
}
return bean;
@Bean
SpringBeanThatWantsPostProcessedBean springBean(PostProcessedBean ppb) {
return new SpringBeanThatWantsPostProcessedBean(ppb);
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
@Bean
Module someGuiceModule() {
return new AbstractModule() {
@Override
protected void configure() {
binder().requireExplicitBindings();
bind(GuiceBeanThatWantsPostProcessedBean.class).asEagerSingleton();
bind(GuiceBeanThatWantsSpringBean.class).asEagerSingleton();
}
};
}
}
@Bean
public PostProcessorRegistrar postProcessorRegistrar() {
return new PostProcessorRegistrar();
}
@Bean
public PostProcessedBean postProcessedBean() {
return new PostProcessedBean();
}
@Bean
public SpringBeanThatWantsPostProcessedBean springBean(PostProcessedBean ppb) {
return new SpringBeanThatWantsPostProcessedBean(ppb);
}
@Bean
public Module someGuiceModule() {
return new AbstractModule() {
public static class PostProcessorRegistrar implements BeanDefinitionRegistryPostProcessor {
@Override
protected void configure() {
binder().requireExplicitBindings();
bind(GuiceBeanThatWantsPostProcessedBean.class).asEagerSingleton();
bind(GuiceBeanThatWantsSpringBean.class).asEagerSingleton();
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
BeanDefinitionBuilder bean = BeanDefinitionBuilder.genericBeanDefinition(TestBeanPostProcessor.class);
registry.registerBeanDefinition("postProcessor", bean.getBeanDefinition());
}
};
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
}
}
public static class TestBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof PostProcessedBean) {
((PostProcessedBean) bean).postProcessed = true;
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
}
}
}

View File

@@ -1,7 +1,20 @@
package org.springframework.guice;
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.assertEquals;
import static org.junit.Assert.assertNotNull;
package org.springframework.guice;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -12,25 +25,20 @@ import javax.inject.Named;
import javax.inject.Qualifier;
import com.google.inject.AbstractModule;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.BindingAnnotationTests.SomeDependencyWithBindingAnnotationOnProvider;
import org.springframework.guice.BindingAnnotationTests.SomeDependencyWithGuiceNamedAnnotationOnProvider;
import org.springframework.guice.BindingAnnotationTests.SomeDependencyWithNamedAnnotationOnProvider;
import org.springframework.guice.BindingAnnotationTests.SomeDependencyWithQualifierOnProvider;
import org.springframework.guice.BindingAnnotationTests.SomeDependencyWithQualifierOnProviderWhichImplementsSomeInterface;
import org.springframework.guice.BindingAnnotationTests.SomeInterface;
import org.springframework.guice.BindingAnnotationTests.SomeNamedDepWithType1;
import org.springframework.guice.BindingAnnotationTests.SomeNamedDepWithType2;
import org.springframework.guice.annotation.EnableGuiceModules;
import com.google.inject.BindingAnnotation;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class BindingAnnotationTests {
@@ -116,113 +124,113 @@ public class BindingAnnotationTests {
}
}
@Qualifier
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeQualifierAnnotation {
@Qualifier
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeQualifierAnnotation {
}
@BindingAnnotation
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeBindingAnnotation {
}
@BindingAnnotation
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeOtherBindingAnnotation {
}
static class SomeStringHolder {
@Autowired
@SomeBindingAnnotation
public String annotatedString;
@Autowired
@SomeOtherBindingAnnotation
String otherAnnotatedString;
}
@EnableGuiceModules
@Configuration
static class BindingAnnotationTestsConfig {
@Bean
@SomeQualifierAnnotation
SomeDependencyWithQualifierOnProvider someDependencyWithQualifierOnProvider() {
return new SomeDependencyWithQualifierOnProvider();
}
@Bean
@SomeBindingAnnotation
SomeDependencyWithBindingAnnotationOnProvider someDependencyWithBindingAnnotationOnProvider() {
return new SomeDependencyWithBindingAnnotationOnProvider();
}
@Bean
@Named("javaxNamed")
SomeDependencyWithNamedAnnotationOnProvider someDependencyWithNamedAnnotationOnProvider() {
return new SomeDependencyWithNamedAnnotationOnProvider();
}
@Bean(name = "javaxNamed2")
@Named("javaxNamed2")
SomeDependencyWithNamedAnnotationOnProvider someSecondDependencyWithNamedAnnotationOnProvider() {
return new SomeDependencyWithNamedAnnotationOnProvider();
}
@Bean
@com.google.inject.name.Named("guiceNamed")
SomeDependencyWithGuiceNamedAnnotationOnProvider someDependencyWithGuiceNamedAnnotationOnProvider() {
return new SomeDependencyWithGuiceNamedAnnotationOnProvider();
}
@Bean
@com.google.inject.name.Named("guiceNamed2")
SomeDependencyWithGuiceNamedAnnotationOnProvider someSecondDependencyWithGuiceNamedAnnotationOnProvider() {
return new SomeDependencyWithGuiceNamedAnnotationOnProvider();
}
@Bean
@SomeQualifierAnnotation
SomeInterface someInterface() {
return new SomeDependencyWithQualifierOnProviderWhichImplementsSomeInterface();
}
@Bean
@Named("sameNameDifferentType")
SomeNamedDepWithType1 someNamedDepWithType1() {
return new SomeNamedDepWithType1();
}
@Bean
@Named("sameNameDifferentType")
SomeNamedDepWithType2 someNamedDepWithType2() {
return new SomeNamedDepWithType2();
}
@Bean
SomeStringHolder stringHolder() {
return new SomeStringHolder();
}
@Bean
AbstractModule module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(SomeBindingAnnotation.class).toInstance("annotated");
bind(String.class).annotatedWith(SomeOtherBindingAnnotation.class).toInstance("other");
}
};
}
}
}
@BindingAnnotation
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeBindingAnnotation {
}
@BindingAnnotation
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@interface SomeOtherBindingAnnotation {
}
class SomeStringHolder {
@Autowired
@SomeBindingAnnotation
public String annotatedString;
@Autowired
@SomeOtherBindingAnnotation
String otherAnnotatedString;
}
@EnableGuiceModules
@Configuration
class BindingAnnotationTestsConfig {
@Bean
@SomeQualifierAnnotation
public SomeDependencyWithQualifierOnProvider someDependencyWithQualifierOnProvider() {
return new SomeDependencyWithQualifierOnProvider();
}
@Bean
@SomeBindingAnnotation
public SomeDependencyWithBindingAnnotationOnProvider someDependencyWithBindingAnnotationOnProvider() {
return new SomeDependencyWithBindingAnnotationOnProvider();
}
@Bean
@Named("javaxNamed")
public SomeDependencyWithNamedAnnotationOnProvider someDependencyWithNamedAnnotationOnProvider() {
return new SomeDependencyWithNamedAnnotationOnProvider();
}
@Bean(name = "javaxNamed2")
@Named("javaxNamed2")
public SomeDependencyWithNamedAnnotationOnProvider someSecondDependencyWithNamedAnnotationOnProvider() {
return new SomeDependencyWithNamedAnnotationOnProvider();
}
@Bean
@com.google.inject.name.Named("guiceNamed")
public SomeDependencyWithGuiceNamedAnnotationOnProvider someDependencyWithGuiceNamedAnnotationOnProvider() {
return new SomeDependencyWithGuiceNamedAnnotationOnProvider();
}
@Bean
@com.google.inject.name.Named("guiceNamed2")
public SomeDependencyWithGuiceNamedAnnotationOnProvider someSecondDependencyWithGuiceNamedAnnotationOnProvider() {
return new SomeDependencyWithGuiceNamedAnnotationOnProvider();
}
@Bean
@SomeQualifierAnnotation
public SomeInterface someInterface() {
return new SomeDependencyWithQualifierOnProviderWhichImplementsSomeInterface();
}
@Bean
@Named("sameNameDifferentType")
public SomeNamedDepWithType1 someNamedDepWithType1() {
return new SomeNamedDepWithType1();
}
@Bean
@Named("sameNameDifferentType")
public SomeNamedDepWithType2 someNamedDepWithType2() {
return new SomeNamedDepWithType2();
}
@Bean
public SomeStringHolder stringHolder() {
return new SomeStringHolder();
}
@Bean
public AbstractModule module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(SomeBindingAnnotation.class).toInstance("annotated");
bind(String.class).annotatedWith(SomeOtherBindingAnnotation.class).toInstance("other");
}
};
}
}

View File

@@ -1,17 +1,31 @@
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import com.google.inject.AbstractModule;
import com.google.inject.CreationException;
import com.google.inject.Module;
import com.google.inject.multibindings.OptionalBinder;
import org.junit.AfterClass;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.BindingDeduplicationTests.SomeDependency;
import org.springframework.guice.BindingDeduplicationTests.SomeOptionalDependency;
import org.springframework.guice.annotation.EnableGuiceModules;
import static org.junit.Assert.assertNotNull;
@@ -51,32 +65,32 @@ public class BindingDeduplicationTests {
}
@EnableGuiceModules
@Configuration
static class BindingDeduplicationTestsConfig {
@Bean
SomeDependency someBean() {
return new SomeDependency();
}
@Bean
SomeOptionalDependency someOptionalBean() {
return new SomeOptionalDependency();
}
@Bean
Module module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(SomeDependency.class).asEagerSingleton();
OptionalBinder.newOptionalBinder(binder(), SomeOptionalDependency.class).setDefault()
.to(SomeOptionalDependency.class);
}
};
}
}
}
@EnableGuiceModules
@Configuration
class BindingDeduplicationTestsConfig {
@Bean
public SomeDependency someBean() {
return new SomeDependency();
}
@Bean
public SomeOptionalDependency someOptionalBean() {
return new SomeOptionalDependency();
}
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(SomeDependency.class).asEagerSingleton();
OptionalBinder.newOptionalBinder(binder(), SomeOptionalDependency.class).setDefault()
.to(SomeOptionalDependency.class);
}
};
}
}

View File

@@ -1,25 +1,37 @@
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.DuplicateNamesDifferentTypesTests.SomeJavaxNamedDepWithType1;
import org.springframework.guice.DuplicateNamesDifferentTypesTests.SomeJavaxNamedDepWithType2;
import org.springframework.guice.DuplicateNamesDifferentTypesTests.SomeNamedDepWithType1;
import org.springframework.guice.DuplicateNamesDifferentTypesTests.SomeNamedDepWithType2;
import org.springframework.guice.annotation.EnableGuiceModules;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import static org.junit.Assert.assertNotNull;
public class DuplicateNamesDifferentTypesTests {
@@ -76,35 +88,35 @@ public class DuplicateNamesDifferentTypesTests {
}
}
@EnableGuiceModules
@Configuration
static class DuplicateNamesDifferentTypesTestsConfig {
@EnableGuiceModules
@Configuration
class DuplicateNamesDifferentTypesTestsConfig {
@Bean
Module module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(SomeNamedDepWithType1.class).annotatedWith(Names.named("sameNameDifferentType"))
.to(SomeNamedDepWithType1.class);
bind(SomeNamedDepWithType2.class).annotatedWith(Names.named("sameNameDifferentType"))
.to(SomeNamedDepWithType2.class);
}
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(SomeNamedDepWithType1.class).annotatedWith(Names.named("sameNameDifferentType"))
.to(SomeNamedDepWithType1.class);
bind(SomeNamedDepWithType2.class).annotatedWith(Names.named("sameNameDifferentType"))
.to(SomeNamedDepWithType2.class);
}
@Provides
@Named("sameJavaxName")
SomeJavaxNamedDepWithType1 someJavaxNamedDepWithType1() {
return new SomeJavaxNamedDepWithType1();
}
@Provides
@Named("sameJavaxName")
public SomeJavaxNamedDepWithType1 someJavaxNamedDepWithType1() {
return new SomeJavaxNamedDepWithType1();
}
@Provides
@Named("sameJavaxName")
SomeJavaxNamedDepWithType2 someJavaxNamedDepWithType2() {
return new SomeJavaxNamedDepWithType2();
}
};
}
@Provides
@Named("sameJavaxName")
public SomeJavaxNamedDepWithType2 someJavaxNamedDepWithType2() {
return new SomeJavaxNamedDepWithType2();
}
};
}
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import java.util.List;
@@ -11,7 +27,6 @@ import com.google.inject.Module;
import com.google.inject.Stage;
import com.google.inject.spi.Element;
import com.google.inject.spi.Elements;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -19,9 +34,6 @@ import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.ElementVisitorTests.DuplicateBean;
import org.springframework.guice.ElementVisitorTests.ElementVisitorTestGuiceBean;
import org.springframework.guice.ElementVisitorTests.ElementVisitorTestSpringBean;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.annotation.InjectorFactory;
@@ -69,7 +81,7 @@ public class ElementVisitorTests {
@Override
public String toString() {
return springBean.toString();
return this.springBean.toString();
}
}
@@ -78,52 +90,52 @@ public class ElementVisitorTests {
}
@EnableGuiceModules
@Configuration
static class ElementVisitorTestConfig {
@Bean
ElementVisitorTestSpringBean testBean() {
return new ElementVisitorTestSpringBean() {
@Override
public String toString() {
return "spring created";
}
};
}
@Bean
Module module() {
return new AbstractModule() {
@Override
protected void configure() {
binder().requireExplicitBindings();
bind(ElementVisitorTestGuiceBean.class).asEagerSingleton();
}
};
}
@Bean
InjectorFactory injectorFactory() {
return new InjectorFactory() {
@Override
public Injector createInjector(List<Module> modules) {
List<Element> elements = Elements.getElements(Stage.TOOL, modules);
return Guice.createInjector(Stage.PRODUCTION, Elements.getModule(elements));
}
};
}
@Bean
DuplicateBean dupeBean1() {
return new DuplicateBean();
}
@Bean
DuplicateBean dupeBean2() {
return new DuplicateBean();
}
}
}
@EnableGuiceModules
@Configuration
class ElementVisitorTestConfig {
@Bean
public ElementVisitorTestSpringBean testBean() {
return new ElementVisitorTestSpringBean() {
@Override
public String toString() {
return "spring created";
}
};
}
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
binder().requireExplicitBindings();
bind(ElementVisitorTestGuiceBean.class).asEagerSingleton();
}
};
}
@Bean
public InjectorFactory injectorFactory() {
return new InjectorFactory() {
@Override
public Injector createInjector(List<Module> modules) {
List<Element> elements = Elements.getElements(Stage.TOOL, modules);
return Guice.createInjector(Stage.PRODUCTION, Elements.getModule(elements));
}
};
}
@Bean
public DuplicateBean dupeBean1() {
return new DuplicateBean();
}
@Bean
public DuplicateBean dupeBean2() {
return new DuplicateBean();
}
}

View File

@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice;

View File

@@ -1,9 +1,26 @@
/*
* Copyright 2016-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import com.google.inject.Guice;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -11,12 +28,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.annotation.InjectorFactory;
import com.google.inject.Guice;
import com.google.inject.Module;
public class InjectorFactoryTests {
static final private InjectorFactory injectorFactory = Mockito.mock(InjectorFactory.class);
private static final InjectorFactory injectorFactory = Mockito.mock(InjectorFactory.class);
@Before
public void init() {
@@ -48,7 +62,7 @@ public class InjectorFactoryTests {
static class InjectorFactoryConfig {
@Bean
public InjectorFactory injectorFactory() {
InjectorFactory injectorFactory() {
return injectorFactory;
}
@@ -58,10 +72,10 @@ public class InjectorFactoryTests {
static class SecondInjectorFactoryConfig {
@Bean
public InjectorFactory injectorFactory2() {
InjectorFactory injectorFactory2() {
return injectorFactory;
}
}
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import javax.inject.Inject;

View File

@@ -1,7 +1,24 @@
/*
* Copyright 2020-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import com.google.inject.AbstractModule;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -45,7 +62,7 @@ public class LazyInitializationTests {
static class TestConfig {
@Bean
public Service service(@Lazy TestBean bean) {
Service service(@Lazy TestBean bean) {
return new Service(bean);
}
@@ -55,7 +72,7 @@ public class LazyInitializationTests {
static class GuiceConfig {
@Bean
public GuiceModule guiceModule() {
GuiceModule guiceModule() {
return new GuiceModule();
}
@@ -65,7 +82,7 @@ public class LazyInitializationTests {
static class SpringConfig {
@Bean
public TestBean testBean() {
TestBean testBean() {
return new TestBean();
}
@@ -84,12 +101,12 @@ public class LazyInitializationTests {
private final TestBean bean;
public Service(TestBean bean) {
Service(TestBean bean) {
this.bean = bean;
}
public TestBean getBean() {
return bean;
TestBean getBean() {
return this.bean;
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import java.util.Map;

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import com.google.inject.AbstractModule;
@@ -11,7 +27,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.ModuleFilteringTests.FilterThisModule;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.annotation.InjectorFactory;
@@ -47,7 +62,7 @@ public class ModuleFilteringTests {
}
}
public static interface SomeInterface {
public interface SomeInterface {
}
@@ -68,26 +83,26 @@ public class ModuleFilteringTests {
}
}
@EnableGuiceModules
@Configuration
static class ModuleFilteringTestsConfig {
@EnableGuiceModules
@Configuration
class ModuleFilteringTestsConfig {
@Bean
InjectorFactory injectorFactory() {
return (modules) -> Guice.createInjector(Stage.PRODUCTION, modules);
}
@Bean
public InjectorFactory injectorFactory() {
return modules -> Guice.createInjector(Stage.PRODUCTION, modules);
}
@Bean
Module module() {
return new AbstractModule() {
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
install(new FilterThisModule());
}
};
}
@Override
protected void configure() {
install(new FilterThisModule());
}
};
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2016-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,16 +16,15 @@
package org.springframework.guice;
import static org.junit.Assert.assertNotNull;
import javax.inject.Inject;
import org.junit.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer

View File

@@ -1,20 +1,21 @@
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.PrivateModuleTests.SomeInterface;
import org.springframework.guice.PrivateModuleTests.SomePrivateModule;
import org.springframework.guice.annotation.EnableGuiceModules;
import com.google.inject.AbstractModule;
import com.google.inject.ConfigurationException;
import com.google.inject.Injector;
@@ -22,6 +23,19 @@ import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.PrivateModule;
import com.google.inject.name.Names;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class PrivateModuleTests {
@@ -73,7 +87,7 @@ public class PrivateModuleTests {
BeanFactoryAnnotationUtils.qualifiedBeanOfType(context.getBeanFactory(), SomeInterface.class, "notexposed");
}
public static interface SomeInterface {
public interface SomeInterface {
}
@@ -94,25 +108,25 @@ public class PrivateModuleTests {
}
@EnableGuiceModules
@Configuration
static class PrivateModuleTestConfig {
@Bean
String somethingThatWantsAPrivateBinding(SomeInterface privateBinding) {
return "foo";
}
@Bean
Module module() {
return new AbstractModule() {
@Override
protected void configure() {
install(new SomePrivateModule());
}
};
}
}
}
@EnableGuiceModules
@Configuration
class PrivateModuleTestConfig {
@Bean
public String somethingThatWantsAPrivateBinding(SomeInterface privateBinding) {
return "foo";
}
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
install(new SomePrivateModule());
}
};
}
}

View File

@@ -1,15 +1,36 @@
/*
* Copyright 2020-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import javax.inject.Inject;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Module;
import org.junit.Test;
import org.springframework.context.annotation.*;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.guice.annotation.EnableGuiceModules;
import javax.inject.Inject;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
public class PrototypeScopedBeanTests {
@@ -29,7 +50,7 @@ public class PrototypeScopedBeanTests {
static class ModulesConfig {
@Bean
public Module guiceModule() {
Module guiceModule() {
return new AbstractModule() {
@Override
protected void configure() {
@@ -41,7 +62,7 @@ public class PrototypeScopedBeanTests {
@Bean
@Scope("prototype")
public PrototypeBean prototypeBean() {
PrototypeBean prototypeBean() {
return new PrototypeBean();
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import java.util.function.Supplier;
@@ -18,7 +34,8 @@ import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.injector.SpringInjector;
/**
* Test Generics (e.g., Supplier<T>) not losing type info across bridge in both directions
* Test Generics (e.g., {@literal Supplier<T>}) not losing type info across bridge in both
* directions
*
* @author Howard Yuan
*/
@@ -34,6 +51,21 @@ public class ProvidesSupplierWiringTests {
Bar bar = context.getBean(Bar.class);
}
// Test Spring -> Guice direction
// ToDo -- Today this direction doesn't work without further work. Ignore the test for
// now.
@SuppressWarnings("unused")
@Ignore
@Test
public void testProvidesSupplierSpring() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FooBarSpring.class);
SpringInjector injector = new SpringInjector(context);
Foo_Spring fooSpring = injector.getInstance(Key.get(new TypeLiteral<Supplier<Foo_Spring>>() {
})).get();
Bar_Spring barSpring = injector.getInstance(Key.get(new TypeLiteral<Supplier<Bar_Spring>>() {
})).get();
}
@Configuration
@EnableGuiceModules
static class ModulesConfig {
@@ -88,21 +120,6 @@ public class ProvidesSupplierWiringTests {
}
// Test Spring -> Guice direction
// ToDo -- Today this direction doesn't work without further work. Ignore the test for
// now.
@SuppressWarnings("unused")
@Ignore
@Test
public void testProvidesSupplierSpring() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FooBarSpring.class);
SpringInjector injector = new SpringInjector(context);
Foo_Spring fooSpring = injector.getInstance(Key.get(new TypeLiteral<Supplier<Foo_Spring>>() {
})).get();
Bar_Spring barSpring = injector.getInstance(Key.get(new TypeLiteral<Supplier<Bar_Spring>>() {
})).get();
}
@Configuration
static class FooBarSpring {

View File

@@ -1,24 +1,36 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.ScopingTests.CustomScope;
import org.springframework.guice.ScopingTests.SomeCustomScopeDependency;
import org.springframework.guice.ScopingTests.SomeNoScopeDependency;
import org.springframework.guice.ScopingTests.SomeSingletonDependency;
import org.springframework.guice.annotation.EnableGuiceModules;
import com.google.inject.AbstractModule;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.Provider;
import com.google.inject.Scope;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
public class ScopingTests {
@@ -76,30 +88,30 @@ public class ScopingTests {
}
}
@EnableGuiceModules
@Configuration
static class ScopingTestsConfig {
@EnableGuiceModules
@Configuration
class ScopingTestsConfig {
@Bean
Module module() {
return new AbstractModule() {
@Override
protected void configure() {
CustomScope customScope = new CustomScope() {
@SuppressWarnings("unchecked")
@Override
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
Provider<?> provider = () -> new SomeCustomScopeDependency("custom");
return (Provider<T>) provider;
}
};
bind(SomeSingletonDependency.class).asEagerSingleton();
bind(SomeNoScopeDependency.class);
bind(SomeCustomScopeDependency.class).in(customScope);
}
};
}
@Bean
public Module module() {
return new AbstractModule() {
@Override
protected void configure() {
CustomScope customScope = new CustomScope() {
@SuppressWarnings("unchecked")
@Override
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
Provider<?> provider = () -> new SomeCustomScopeDependency("custom");
return (Provider<T>) provider;
}
};
bind(SomeSingletonDependency.class).asEagerSingleton();
bind(SomeNoScopeDependency.class);
bind(SomeCustomScopeDependency.class).in(customScope);
}
};
}
}
}

View File

@@ -1,19 +1,35 @@
package org.springframework.guice;
/*
* Copyright 2014-2022 the original author or authors.
*
* 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
*
* https://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;
package org.springframework.guice;
import javax.inject.Inject;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Test;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.injector.SpringInjector;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import static org.junit.Assert.assertNotNull;
public class SimpleWiringTests {

View File

@@ -1,16 +1,33 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import java.util.Map;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.injector.SpringInjector;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class SpringAutowiredCollectionTests {
@@ -33,18 +50,18 @@ public class SpringAutowiredCollectionTests {
static class TestConfig {
@Bean
public ServicesHolder serviceHolder(Map<String, Service> existingServices,
ServicesHolder serviceHolder(Map<String, Service> existingServices,
Map<String, NonExistingService> nonExistingServices) {
return new ServicesHolder(existingServices, nonExistingServices);
}
@Bean
public Service service() {
Service service() {
return new Service();
}
@Bean
public GuiceModule guiceServiceModule() {
GuiceModule guiceServiceModule() {
return new GuiceModule();
}
@@ -73,8 +90,7 @@ public class SpringAutowiredCollectionTests {
final Map<String, NonExistingService> nonExistingServices;
public ServicesHolder(Map<String, Service> existingServices,
Map<String, NonExistingService> nonExistingServices) {
ServicesHolder(Map<String, Service> existingServices, Map<String, NonExistingService> nonExistingServices) {
this.existingServices = existingServices;
this.nonExistingServices = nonExistingServices;
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice;
import com.google.inject.AbstractModule;
@@ -346,7 +362,7 @@ public class SuperClassTests {
static class DisableJITConfig {
@Bean
public AbstractModule disableJITModule() {
AbstractModule disableJITModule() {
return new AbstractModule() {
@Override
protected void configure() {
@@ -362,27 +378,27 @@ public class SuperClassTests {
static class ModulesConfig extends DisableJITConfig {
@Bean
public IGrandChild iGrandChild() {
IGrandChild iGrandChild() {
return new IGrandChildImpl();
}
@Bean
public IGrandChildWithType<String> iChildString() {
IGrandChildWithType<String> iChildString() {
return new IGrandChildString();
}
@Bean
public IGrandChildWithType<Integer> iChildInteger() {
IGrandChildWithType<Integer> iChildInteger() {
return new IGrandChildInteger();
}
@Bean
public SubFoo subFoo() {
SubFoo subFoo() {
return new SubFoo();
}
@Bean
public SubStringFoo stringFoo() {
SubStringFoo stringFoo() {
return new SubStringFoo();
}

View File

@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.annotation;
@@ -18,7 +21,6 @@ import javax.inject.Named;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import org.junit.After;
@@ -107,7 +109,7 @@ public class EnableGuiceModulesTests {
@Bean
public Foo foo() {
return injector.getInstance(Foo.class);
return this.injector.getInstance(Foo.class);
}
@Bean

View File

@@ -1,27 +1,38 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.annotation;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.junit.Assert.assertNotNull;
public class GuiceModuleAnnotationGenericTypeTests {
@Test
public void testBinding() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);
assertNotNull(context.getBean(Foo.class));
context.close();
}
public interface Foo<T> {
T getValue();
@@ -38,7 +49,7 @@ public class GuiceModuleAnnotationGenericTypeTests {
@Override
public T getValue() {
return payload;
return this.payload;
}
}
@@ -49,17 +60,10 @@ public class GuiceModuleAnnotationGenericTypeTests {
static class TestConfig {
@Bean
public FooImpl<String> fooBean() {
FooImpl<String> fooBean() {
return new FooImpl<String>("foo.foo.foo");
}
}
@Test
public void testBinding() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);
assertNotNull(context.getBean(Foo.class));
context.close();
}
}
}

View File

@@ -1,27 +1,31 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.annotation;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.HashMap;
import java.util.Map;
import com.google.inject.ConfigurationException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -30,9 +34,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.guice.module.SpringModule;
import com.google.inject.ConfigurationException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Dave Syer
@@ -64,7 +67,7 @@ public class GuiceModuleAnnotationTests {
@Test
public void excludes() throws Exception {
Injector injector = createInjector(TestConfig.class, MetadataExcludesConfig.class);
expected.expect(ConfigurationException.class);
this.expected.expect(ConfigurationException.class);
assertNull(injector.getInstance(Service.class));
}

View File

@@ -1,25 +1,30 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.annotation;
import static org.junit.Assert.assertNotNull;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -27,9 +32,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.guice.AbstractCompleteWiringTests;
import org.springframework.guice.injector.SpringInjector;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer

View File

@@ -1,25 +1,30 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.annotation;
import static org.junit.Assert.assertNotNull;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -27,9 +32,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.guice.AbstractCompleteWiringTests;
import org.springframework.guice.injector.SpringInjector;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Provides;
import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer

View File

@@ -1,23 +1,28 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.injector;
import static org.junit.Assert.assertNotNull;
import com.google.inject.Key;
import com.google.inject.name.Names;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -27,8 +32,7 @@ import org.springframework.guice.AbstractCompleteWiringTests.Baz;
import org.springframework.guice.AbstractCompleteWiringTests.MyService;
import org.springframework.guice.AbstractCompleteWiringTests.Service;
import com.google.inject.Key;
import com.google.inject.name.Names;
import static org.junit.Assert.assertNotNull;
public class SpringInjectorTests {
@@ -41,37 +45,37 @@ public class SpringInjectorTests {
@After
public void close() {
if (context != null) {
context.close();
if (this.context != null) {
this.context.close();
}
}
@Test
public void instance() {
assertNotNull(injector.getInstance(Service.class));
assertNotNull(this.injector.getInstance(Service.class));
}
@Test
public void multiple() {
injector = new SpringInjector(create(Additional.class));
expected.expect(NoUniqueBeanDefinitionException.class);
assertNotNull(injector.getInstance(Service.class));
this.injector = new SpringInjector(create(Additional.class));
this.expected.expect(NoUniqueBeanDefinitionException.class);
assertNotNull(this.injector.getInstance(Service.class));
}
@Test
public void named() {
injector = new SpringInjector(create(Additional.class));
assertNotNull(injector.getInstance(Key.get(Service.class, Names.named("service"))));
this.injector = new SpringInjector(create(Additional.class));
assertNotNull(this.injector.getInstance(Key.get(Service.class, Names.named("service"))));
}
@Test
public void provider() {
assertNotNull(injector.getProvider(Service.class).get());
assertNotNull(this.injector.getProvider(Service.class).get());
}
@Test
public void bindNewObject() {
assertNotNull(injector.getInstance(Baz.class));
assertNotNull(this.injector.getInstance(Baz.class));
}
private ApplicationContext create(Class<?>... config) {

View File

@@ -1,25 +1,28 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.injector;
import com.google.inject.Injector;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.AbstractCompleteWiringTests;
import com.google.inject.Injector;
/**
* @author Dave Syer
*

View File

@@ -1,18 +1,40 @@
/*
* Copyright 2021-2022 the original author or authors.
*
* 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
*
* https://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.springframework.guice.module;
import com.google.inject.*;
import java.util.List;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.Stage;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.annotation.EnableGuiceModules;
import org.springframework.guice.annotation.InjectorFactory;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -44,12 +66,12 @@ public class DevelepmentStageInjectorTest {
static class ModulesConfig {
@Bean
public TestGuiceModule testGuiceModule() {
TestGuiceModule testGuiceModule() {
return new TestGuiceModule();
}
@Bean
public InjectorFactory injectorFactory() {
InjectorFactory injectorFactory() {
return new TestDevelopmentStageInjectorFactory();
}
@@ -59,7 +81,7 @@ public class DevelepmentStageInjectorTest {
private boolean providerExecuted = false;
public boolean getProviderExecuted() {
boolean getProviderExecuted() {
return this.providerExecuted;
}
@@ -69,7 +91,7 @@ public class DevelepmentStageInjectorTest {
@Provides
@Singleton
public GuiceToken guiceToken() {
GuiceToken guiceToken() {
this.providerExecuted = true;
return new GuiceToken();
}

View File

@@ -1,15 +1,19 @@
/*
* Copyright 2016-2017 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.module;
import javax.inject.Inject;
@@ -19,7 +23,6 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Scopes;
import com.google.inject.util.Providers;
import org.junit.Test;
import org.springframework.context.ApplicationEvent;
@@ -79,12 +82,12 @@ public class SpringModuleGuiceBindingAwareTests {
static class GuiceProjectWithSpringLibraryTestSpringConfig {
@Bean
public ISpringBean springDefinedSomething(IGuiceDependency1 dependency) {
ISpringBean springDefinedSomething(IGuiceDependency1 dependency) {
return new SpringBean(dependency);
}
@Bean
public ApplicationListener<ApplicationEvent> eventListener(final IGuiceDependency1 dependency) {
ApplicationListener<ApplicationEvent> eventListener(final IGuiceDependency1 dependency) {
return new ApplicationListener<ApplicationEvent>() {
@Override
public void onApplicationEvent(ApplicationEvent event) {
@@ -95,17 +98,17 @@ public class SpringModuleGuiceBindingAwareTests {
}
static interface IGuiceDependency1 {
interface IGuiceDependency1 {
String doWork();
}
static interface IGuiceDependency2 {
interface IGuiceDependency2 {
}
static interface IGuiceDependency3 {
interface IGuiceDependency3 {
}
@@ -118,7 +121,7 @@ public class SpringModuleGuiceBindingAwareTests {
}
static interface ISpringBean {
interface ISpringBean {
IGuiceDependency1 getDep1();
@@ -139,23 +142,23 @@ public class SpringModuleGuiceBindingAwareTests {
private IGuiceDependency3 dep3;
@Inject
public SpringBean(IGuiceDependency1 dependency) {
SpringBean(IGuiceDependency1 dependency) {
this.dep1 = dependency;
}
@Override
public IGuiceDependency1 getDep1() {
return dep1;
return this.dep1;
}
@Override
public IGuiceDependency2 getDep2() {
return dep2;
return this.dep2;
}
@Override
public IGuiceDependency3 getDep3() {
return dep3;
return this.dep3;
}
}

View File

@@ -1,42 +1,43 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.module;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import javax.inject.Inject;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.guice.module.GuiceModuleMetadata;
import org.springframework.guice.module.SpringModule;
import com.google.inject.ConfigurationException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.ProvisionException;
import com.google.inject.name.Names;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author Dave Syer
@@ -56,7 +57,7 @@ public class SpringModuleMetadataTests {
@Test
public void twoServices() throws Exception {
Injector injector = createInjector(TestConfig.class, MoreConfig.class);
expected.expect(ProvisionException.class);
this.expected.expect(ProvisionException.class);
assertNotNull(injector.getInstance(Service.class));
}
@@ -75,14 +76,14 @@ public class SpringModuleMetadataTests {
@Test
public void includes() throws Exception {
Injector injector = createInjector(TestConfig.class, MetadataIncludesConfig.class);
expected.expect(ConfigurationException.class);
this.expected.expect(ConfigurationException.class);
assertNull(injector.getBinding(Service.class));
}
@Test
public void excludes() throws Exception {
Injector injector = createInjector(TestConfig.class, MetadataExcludesConfig.class);
expected.expect(ConfigurationException.class);
this.expected.expect(ConfigurationException.class);
assertNull(injector.getInstance(Service.class));
}

View File

@@ -1,18 +1,23 @@
/*
* Copyright 2013-2014 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.module;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
@@ -21,9 +26,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.guice.AbstractCompleteWiringTests;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* @author Dave Syer
*

View File

@@ -1,15 +1,19 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* 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
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://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.
* 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.springframework.guice.module;
import javax.inject.Inject;
@@ -18,7 +22,6 @@ import javax.inject.Named;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Test;
import org.springframework.context.annotation.Bean;