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,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;