From f006b1231c6bfbae9286a062d4b4629a385cd166 Mon Sep 17 00:00:00 2001 From: Craig Walls Date: Thu, 22 May 2014 18:04:13 -0500 Subject: [PATCH 1/4] Add Spring Social autoconfiguration --- spring-boot-autoconfigure/pom.xml | 30 ++++++ .../social/FacebookAutoConfiguration.java | 91 +++++++++++++++++++ .../social/LinkedInAutoConfiguration.java | 90 ++++++++++++++++++ .../social/SocialWebAutoConfiguration.java | 78 ++++++++++++++++ .../social/TwitterAutoConfiguration.java | 91 +++++++++++++++++++ .../main/resources/META-INF/spring.factories | 4 + .../FacebookAutoConfigurationTests.java | 62 +++++++++++++ .../LinkedInAutoConfigurationTests.java | 62 +++++++++++++ .../social/TwitterAutoConfigurationTests.java | 62 +++++++++++++ .../src/test/resources/application.properties | 8 +- ...cialFacebookCompilerAutoConfiguration.java | 52 +++++++++++ ...cialLinkedInCompilerAutoConfiguration.java | 52 +++++++++++ ...ocialTwitterCompilerAutoConfiguration.java | 52 +++++++++++ ...oot.cli.compiler.CompilerAutoConfiguration | 3 + spring-boot-dependencies/pom.xml | 34 +++++++ spring-boot-starters/pom.xml | 3 + .../pom.xml | 48 ++++++++++ .../main/resources/META-INF/spring.provides | 1 + .../pom.xml | 48 ++++++++++ .../main/resources/META-INF/spring.provides | 1 + .../pom.xml | 48 ++++++++++ .../main/resources/META-INF/spring.provides | 1 + 22 files changed, 920 insertions(+), 1 deletion(-) create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java create mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java create mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java create mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java create mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java create mode 100644 spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java create mode 100644 spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java create mode 100644 spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java create mode 100644 spring-boot-starters/spring-boot-starter-social-facebook/pom.xml create mode 100644 spring-boot-starters/spring-boot-starter-social-facebook/src/main/resources/META-INF/spring.provides create mode 100644 spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml create mode 100644 spring-boot-starters/spring-boot-starter-social-linkedin/src/main/resources/META-INF/spring.provides create mode 100644 spring-boot-starters/spring-boot-starter-social-twitter/pom.xml create mode 100644 spring-boot-starters/spring-boot-starter-social-twitter/src/main/resources/META-INF/spring.provides diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index b95bfb217c3..b5ba8a6ea32 100644 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -221,6 +221,36 @@ spring-mobile-device true + + org.springframework.social + spring-social-config + true + + + org.springframework.social + spring-social-core + true + + + org.springframework.social + spring-social-web + true + + + org.springframework.social + spring-social-facebook + true + + + org.springframework.social + spring-social-twitter + true + + + org.springframework.social + spring-social-linkedin + true + org.thymeleaf thymeleaf diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java new file mode 100644 index 00000000000..f5acf41a5ac --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -0,0 +1,91 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.core.env.Environment; +import org.springframework.social.config.annotation.ConnectionFactoryConfigurer; +import org.springframework.social.config.annotation.EnableSocial; +import org.springframework.social.config.annotation.SocialConfigurerAdapter; +import org.springframework.social.connect.Connection; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.web.GenericConnectionStatusView; +import org.springframework.social.facebook.api.Facebook; +import org.springframework.social.facebook.api.impl.FacebookTemplate; +import org.springframework.social.facebook.connect.FacebookConnectionFactory; +import org.springframework.web.servlet.View; + +/** + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity + * with Facebook. + * + * @author Craig Walls + */ +@Configuration +@ConditionalOnClass({ FacebookConnectionFactory.class }) +@AutoConfigureAfter(WebMvcAutoConfiguration.class) +public class FacebookAutoConfiguration { + + @Configuration + @EnableSocial + @ConditionalOnWebApplication + protected static class FacebookAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + + private String appId; + private String appSecret; + + @Override + public void setEnvironment(Environment env) { + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + this.appId = propertyResolver.getRequiredProperty("facebook.appId"); + this.appSecret = propertyResolver.getRequiredProperty("facebook.appSecret"); + } + + @Override + public void addConnectionFactories(ConnectionFactoryConfigurer config, Environment env) { + config.addConnectionFactory(new FacebookConnectionFactory(appId, appSecret)); + } + + @Bean + @ConditionalOnMissingBean(Facebook.class) + @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + public Facebook facebook(ConnectionRepository repository) { + Connection connection = repository.findPrimaryConnection(Facebook.class); + return connection != null ? connection.getApi() : new FacebookTemplate(); + } + + @Bean(name={"connect/facebookConnect", "connect/facebookConnected"}) + @ConditionalOnExpression("${spring.social.auto_connection_views:false}") + public View facebookConnectView() { + return new GenericConnectionStatusView("facebook", "Facebook"); + } + + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java new file mode 100644 index 00000000000..d5533c8f37a --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.core.env.Environment; +import org.springframework.social.config.annotation.ConnectionFactoryConfigurer; +import org.springframework.social.config.annotation.EnableSocial; +import org.springframework.social.config.annotation.SocialConfigurerAdapter; +import org.springframework.social.connect.Connection; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.web.GenericConnectionStatusView; +import org.springframework.social.linkedin.api.LinkedIn; +import org.springframework.social.linkedin.connect.LinkedInConnectionFactory; +import org.springframework.web.servlet.View; + +/** + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity + * with LinkedIn. + * + * @author Craig Walls + */ +@Configuration +@ConditionalOnClass({ LinkedInConnectionFactory.class }) +@AutoConfigureAfter(WebMvcAutoConfiguration.class) +public class LinkedInAutoConfiguration { + + @Configuration + @EnableSocial + @ConditionalOnWebApplication + protected static class LinkedInAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + + private String appId; + private String appSecret; + + @Override + public void setEnvironment(Environment env) { + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + this.appId = propertyResolver.getRequiredProperty("linkedin.appId"); + this.appSecret = propertyResolver.getRequiredProperty("linkedin.appSecret"); + } + + @Override + public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { + cfConfig.addConnectionFactory(new LinkedInConnectionFactory(appId, appSecret)); + } + + @Bean + @ConditionalOnMissingBean(LinkedInConnectionFactory.class) + @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + public LinkedIn linkedin(ConnectionRepository repository) { + Connection connection = repository.findPrimaryConnection(LinkedIn.class); + return connection != null ? connection.getApi() : null; + } + + @Bean(name={"connect/linkedinConnect", "connect/linkedinConnected"}) + @ConditionalOnExpression("${spring.social.auto_connection_views:false}") + public View linkedInConnectView() { + return new GenericConnectionStatusView("linkedin", "LinkedIn"); + } + + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java new file mode 100644 index 00000000000..01ee6803190 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java @@ -0,0 +1,78 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.social.UserIdSource; +import org.springframework.social.config.annotation.EnableSocial; +import org.springframework.social.config.annotation.SocialConfigurerAdapter; +import org.springframework.social.connect.ConnectionFactoryLocator; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.web.ConnectController; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.view.BeanNameViewResolver; + +/** + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social's web connection support. + * + * @author Craig Walls + */ +@Configuration +@ConditionalOnClass({ ConnectController.class }) +@AutoConfigureAfter(WebMvcAutoConfiguration.class) +public class SocialWebAutoConfiguration { + + @Configuration + @EnableSocial + @ConditionalOnWebApplication + protected static class SocialAutoConfigurationAdapter extends SocialConfigurerAdapter { + @Bean + @ConditionalOnMissingBean(ConnectController.class) + public ConnectController connectController( + ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) { + return new ConnectController(connectionFactoryLocator, connectionRepository); + } + + @Bean + @ConditionalOnMissingBean(BeanNameViewResolver.class) + @ConditionalOnExpression("${spring.social.auto_connection_views:false}") + public ViewResolver beanNameViewResolver() { + BeanNameViewResolver bnvr = new BeanNameViewResolver(); + bnvr.setOrder(Integer.MIN_VALUE); + return bnvr; + } + + @Override + public UserIdSource getUserIdSource() { + return new UserIdSource() { + @Override + public String getUserId() { + return "anonymous"; + } + }; + } + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java new file mode 100644 index 00000000000..6741b7dabc2 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java @@ -0,0 +1,91 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.core.env.Environment; +import org.springframework.social.config.annotation.ConnectionFactoryConfigurer; +import org.springframework.social.config.annotation.EnableSocial; +import org.springframework.social.config.annotation.SocialConfigurerAdapter; +import org.springframework.social.connect.Connection; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.web.GenericConnectionStatusView; +import org.springframework.social.twitter.api.Twitter; +import org.springframework.social.twitter.api.impl.TwitterTemplate; +import org.springframework.social.twitter.connect.TwitterConnectionFactory; +import org.springframework.web.servlet.View; + +/** + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity + * with Twitter. + * + * @author Craig Walls + */ +@Configuration +@ConditionalOnClass({ TwitterConnectionFactory.class }) +@AutoConfigureAfter(WebMvcAutoConfiguration.class) +public class TwitterAutoConfiguration { + + @Configuration + @EnableSocial + @ConditionalOnWebApplication + protected static class TwitterAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + + private String appId; + private String appSecret; + + @Override + public void setEnvironment(Environment env) { + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + this.appId = propertyResolver.getRequiredProperty("twitter.appId"); + this.appSecret = propertyResolver.getRequiredProperty("twitter.appSecret"); + } + + @Override + public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { + cfConfig.addConnectionFactory(new TwitterConnectionFactory(appId, appSecret)); + } + + @Bean + @ConditionalOnMissingBean(TwitterConnectionFactory.class) + @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + public Twitter twitter(ConnectionRepository repository) { + Connection connection = repository.findPrimaryConnection(Twitter.class); + return connection != null ? connection.getApi() : new TwitterTemplate(appId, appSecret); + } + + @Bean(name={"connect/twitterConnect", "connect/twitterConnected"}) + @ConditionalOnExpression("${spring.social.auto_connection_views:false}") + public View twitterConnectView() { + return new GenericConnectionStatusView("twitter", "Twitter"); + } + + } + +} diff --git a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories index 6077195426f..c4670700267 100644 --- a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -33,6 +33,10 @@ org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration,\ org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration,\ org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\ org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration,\ +org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration,\ +org.springframework.boot.autoconfigure.social.LinkedInAutoConfiguration,\ +org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration,\ org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\ org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration,\ org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\ diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java new file mode 100644 index 00000000000..bd41ec58074 --- /dev/null +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Test; +import org.springframework.boot.test.EnvironmentTestUtils; +import org.springframework.social.UserIdSource; +import org.springframework.social.connect.ConnectionFactoryLocator; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.UsersConnectionRepository; +import org.springframework.social.facebook.api.Facebook; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +/** + * Tests for {@link FacebookAutoConfiguration}. + * + * @author Craig Walls + */ +public class FacebookAutoConfigurationTests { + + private AnnotationConfigWebApplicationContext context; + + @After + public void close() { + if (this.context != null) { + this.context.close(); + } + } + + @Test + public void expectedSocialBeansCreated() throws Exception { + this.context = new AnnotationConfigWebApplicationContext(); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appSecret:secret"); + this.context.register(SocialWebAutoConfiguration.class); + this.context.register(FacebookAutoConfiguration.class); + this.context.refresh(); + assertNotNull(this.context.getBean(UsersConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionFactoryLocator.class)); + assertNotNull(this.context.getBean(UserIdSource.class)); + assertNotNull(this.context.getBean(Facebook.class)); + } + +} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java new file mode 100644 index 00000000000..3e831a8622b --- /dev/null +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Test; +import org.springframework.boot.test.EnvironmentTestUtils; +import org.springframework.social.UserIdSource; +import org.springframework.social.connect.ConnectionFactoryLocator; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.UsersConnectionRepository; +import org.springframework.social.linkedin.api.LinkedIn; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +/** + * Tests for {@link LinkedInAutoConfiguration}. + * + * @author Craig Walls + */ +public class LinkedInAutoConfigurationTests { + + private AnnotationConfigWebApplicationContext context; + + @After + public void close() { + if (this.context != null) { + this.context.close(); + } + } + + @Test + public void expectedSocialBeansCreated() throws Exception { + this.context = new AnnotationConfigWebApplicationContext(); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appSecret:secret"); + this.context.register(SocialWebAutoConfiguration.class); + this.context.register(LinkedInAutoConfiguration.class); + this.context.refresh(); + assertNotNull(this.context.getBean(UsersConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionFactoryLocator.class)); + assertNotNull(this.context.getBean(UserIdSource.class)); + assertNotNull(this.context.getBean(LinkedIn.class)); + } + +} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java new file mode 100644 index 00000000000..a06868fe822 --- /dev/null +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.autoconfigure.social; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Test; +import org.springframework.boot.test.EnvironmentTestUtils; +import org.springframework.social.UserIdSource; +import org.springframework.social.connect.ConnectionFactoryLocator; +import org.springframework.social.connect.ConnectionRepository; +import org.springframework.social.connect.UsersConnectionRepository; +import org.springframework.social.twitter.api.Twitter; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +/** + * Tests for {@link TwitterAutoConfiguration}. + * + * @author Craig Walls + */ +public class TwitterAutoConfigurationTests { + + private AnnotationConfigWebApplicationContext context; + + @After + public void close() { + if (this.context != null) { + this.context.close(); + } + } + + @Test + public void expectedSocialBeansCreated() throws Exception { + this.context = new AnnotationConfigWebApplicationContext(); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appSecret:secret"); + this.context.register(SocialWebAutoConfiguration.class); + this.context.register(TwitterAutoConfiguration.class); + this.context.refresh(); + assertNotNull(this.context.getBean(UsersConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionRepository.class)); + assertNotNull(this.context.getBean(ConnectionFactoryLocator.class)); + assertNotNull(this.context.getBean(UserIdSource.class)); + assertNotNull(this.context.getBean(Twitter.class)); + } + +} diff --git a/spring-boot-autoconfigure/src/test/resources/application.properties b/spring-boot-autoconfigure/src/test/resources/application.properties index 3fa3f5bae02..c15c79e4719 100644 --- a/spring-boot-autoconfigure/src/test/resources/application.properties +++ b/spring-boot-autoconfigure/src/test/resources/application.properties @@ -1 +1,7 @@ -foo: bucket \ No newline at end of file +foo: bucket +spring.social.facebook.appId=fbid +spring.social.facebook.appSecret=fbsecret +spring.social.twitter.appId=twid +spring.social.twitter.appSecret=twsecret +spring.social.linkedin.appId=liid +spring.social.linkedin.appSecret=lisecret \ No newline at end of file diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java new file mode 100644 index 00000000000..6f6f1435011 --- /dev/null +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.cli.compiler.autoconfigure; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * {@link CompilerAutoConfiguration} for Spring Social Facebook. + * + * @author Craig Walls + */ +public class SpringSocialFacebookCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "Facebook"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) + throws CompilationFailedException { + dependencies + .ifAnyMissingClasses("org.springframework.social.facebook.api.Facebook") + .add("spring-boot-starter-social-facebook"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addStarImports("org.springframework.social.facebook.api"); + imports.addStarImports("org.springframework.social.config.annotation"); + } + +} diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java new file mode 100644 index 00000000000..2eac3d604ff --- /dev/null +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.cli.compiler.autoconfigure; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * {@link CompilerAutoConfiguration} for Spring Social LinkedIn. + * + * @author Craig Walls + */ +public class SpringSocialLinkedInCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "LinkedIn"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) + throws CompilationFailedException { + dependencies + .ifAnyMissingClasses("org.springframework.social.linkedin.api.LinkedIn") + .add("spring-boot-starter-social-linkedin"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addStarImports("org.springframework.social.linkedin.api"); + imports.addImports("org.springframework.social.config.annotation.EnableSocial"); + } + +} diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java new file mode 100644 index 00000000000..476db095f71 --- /dev/null +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012-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 + * + * 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.springframework.boot.cli.compiler.autoconfigure; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * {@link CompilerAutoConfiguration} for Spring Social Twitter. + * + * @author Craig Walls + */ +public class SpringSocialTwitterCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "Twitter"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) + throws CompilationFailedException { + dependencies + .ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter") + .add("spring-boot-starter-social-twitter"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addStarImports("org.springframework.social.twitter.api"); + imports.addImports("org.springframework.social.config.annotation.EnableSocial"); + } + +} diff --git a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration index 314bb1657a8..30748a2c992 100644 --- a/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration +++ b/spring-boot-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration @@ -11,5 +11,8 @@ org.springframework.boot.cli.compiler.autoconfigure.TransactionManagementCompile org.springframework.boot.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringSecurityCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringMobileCompilerAutoConfiguration +org.springframework.boot.cli.compiler.autoconfigure.SpringSocialFacebookCompilerAutoConfiguration +org.springframework.boot.cli.compiler.autoconfigure.SpringSocialLinkedInCompilerAutoConfiguration +org.springframework.boot.cli.compiler.autoconfigure.SpringSocialTwitterCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringTestCompilerAutoConfiguration org.springframework.boot.cli.compiler.autoconfigure.SpringWebsocketCompilerAutoConfiguration \ No newline at end of file diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 1f0e64db53e..2d3ade097a3 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -97,6 +97,10 @@ 4.0.1.RELEASE 1.2.0.RELEASE 1.1.1.RELEASE + 1.1.0.RELEASE + 1.1.0.RELEASE + 1.1.0.RELEASE + 1.0.0.RELEASE 3.2.4.RELEASE 1.0.2.RELEASE 2.1.3.RELEASE @@ -982,6 +986,36 @@ spring-security-jwt ${spring-security-jwt.version} + + org.springframework.social + spring-social-config + ${spring-social.version} + + + org.springframework.social + spring-social-core + ${spring-social.version} + + + org.springframework.social + spring-social-web + ${spring-social.version} + + + org.springframework.social + spring-social-facebook + ${spring-social-facebook.version} + + + org.springframework.social + spring-social-twitter + ${spring-social-twitter.version} + + + org.springframework.social + spring-social-linkedin + ${spring-social-linkedin.version} + org.thymeleaf thymeleaf diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 8f147379146..56d176131e7 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -40,6 +40,9 @@ spring-boot-starter-parent spring-boot-starter-redis spring-boot-starter-security + spring-boot-starter-social-facebook + spring-boot-starter-social-twitter + spring-boot-starter-social-linkedin spring-boot-starter-remote-shell spring-boot-starter-test spring-boot-starter-thymeleaf diff --git a/spring-boot-starters/spring-boot-starter-social-facebook/pom.xml b/spring-boot-starters/spring-boot-starter-social-facebook/pom.xml new file mode 100644 index 00000000000..ccd0e9dda05 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-facebook/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starters + 1.1.0.BUILD-SNAPSHOT + + spring-boot-starter-social-facebook + Spring Boot Social Facebook Starter + Spring Boot Social Facebook Starter + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + + + + ${project.groupId} + spring-boot-starter + ${project.version} + + + ${project.groupId} + spring-boot-starter-web + ${project.version} + + + org.springframework.social + spring-social-config + + + org.springframework.social + spring-social-core + + + org.springframework.social + spring-social-web + + + org.springframework.social + spring-social-facebook + + + diff --git a/spring-boot-starters/spring-boot-starter-social-facebook/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-social-facebook/src/main/resources/META-INF/spring.provides new file mode 100644 index 00000000000..0dfc2d109dd --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-facebook/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: spring-social-facebook \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml b/spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml new file mode 100644 index 00000000000..f8100221623 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starters + 1.1.0.BUILD-SNAPSHOT + + spring-boot-starter-social-linkedin + Spring Boot Social LinkedIn Starter + Spring Boot Social LinkedIn Starter + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + + + + ${project.groupId} + spring-boot-starter + ${project.version} + + + ${project.groupId} + spring-boot-starter-web + ${project.version} + + + org.springframework.social + spring-social-config + + + org.springframework.social + spring-social-core + + + org.springframework.social + spring-social-web + + + org.springframework.social + spring-social-linkedin + + + diff --git a/spring-boot-starters/spring-boot-starter-social-linkedin/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-social-linkedin/src/main/resources/META-INF/spring.provides new file mode 100644 index 00000000000..183a3a5a63c --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-linkedin/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: spring-social-linkedin \ No newline at end of file diff --git a/spring-boot-starters/spring-boot-starter-social-twitter/pom.xml b/spring-boot-starters/spring-boot-starter-social-twitter/pom.xml new file mode 100644 index 00000000000..917f7d372f5 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-twitter/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starters + 1.1.0.BUILD-SNAPSHOT + + spring-boot-starter-social-twitter + Spring Boot Social Twitter Starter + Spring Boot Social Twitter Starter + http://projects.spring.io/spring-boot/ + + Pivotal Software, Inc. + http://www.spring.io + + + ${basedir}/../.. + + + + ${project.groupId} + spring-boot-starter + ${project.version} + + + ${project.groupId} + spring-boot-starter-web + ${project.version} + + + org.springframework.social + spring-social-config + + + org.springframework.social + spring-social-core + + + org.springframework.social + spring-social-web + + + org.springframework.social + spring-social-twitter + + + diff --git a/spring-boot-starters/spring-boot-starter-social-twitter/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-social-twitter/src/main/resources/META-INF/spring.provides new file mode 100644 index 00000000000..0b627cbfbd5 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-social-twitter/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: spring-social-twitter \ No newline at end of file From 5e1913576e3ad597f64b79e90de8c195ae01e03b Mon Sep 17 00:00:00 2001 From: Craig Walls Date: Fri, 23 May 2014 08:46:23 -0500 Subject: [PATCH 2/4] Document Spring Social support --- .../social/FacebookAutoConfiguration.java | 1 + .../social/LinkedInAutoConfiguration.java | 1 + .../social/SocialWebAutoConfiguration.java | 1 + .../social/TwitterAutoConfiguration.java | 1 + ...ngSocialFacebookCompilerAutoConfiguration.java | 1 + ...ngSocialLinkedInCompilerAutoConfiguration.java | 1 + ...ingSocialTwitterCompilerAutoConfiguration.java | 1 + .../asciidoc/appendix-application-properties.adoc | 15 +++++++++++++++ .../appendix-auto-configuration-classes.adoc | 12 ++++++++++++ .../src/main/asciidoc/using-spring-boot.adoc | 9 +++++++++ 10 files changed, 43 insertions(+) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java index f5acf41a5ac..9646dcde093 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -46,6 +46,7 @@ import org.springframework.web.servlet.View; * with Facebook. * * @author Craig Walls + * @since 1.1.0 */ @Configuration @ConditionalOnClass({ FacebookConnectionFactory.class }) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java index d5533c8f37a..a3bf0dd2cda 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java @@ -45,6 +45,7 @@ import org.springframework.web.servlet.View; * with LinkedIn. * * @author Craig Walls + * @since 1.1.0 */ @Configuration @ConditionalOnClass({ LinkedInConnectionFactory.class }) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java index 01ee6803190..97326ef285c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java @@ -38,6 +38,7 @@ import org.springframework.web.servlet.view.BeanNameViewResolver; * {@link EnableAutoConfiguration Auto-configuration} for Spring Social's web connection support. * * @author Craig Walls + * @since 1.1.0 */ @Configuration @ConditionalOnClass({ ConnectController.class }) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java index 6741b7dabc2..bee82300fa8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java @@ -46,6 +46,7 @@ import org.springframework.web.servlet.View; * with Twitter. * * @author Craig Walls + * @since 1.1.0 */ @Configuration @ConditionalOnClass({ TwitterConnectionFactory.class }) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java index 6f6f1435011..a0246844c8c 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; * {@link CompilerAutoConfiguration} for Spring Social Facebook. * * @author Craig Walls + * @since 1.1.0 */ public class SpringSocialFacebookCompilerAutoConfiguration extends CompilerAutoConfiguration { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java index 2eac3d604ff..c1e97fcf530 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; * {@link CompilerAutoConfiguration} for Spring Social LinkedIn. * * @author Craig Walls + * @since 1.1.0 */ public class SpringSocialLinkedInCompilerAutoConfiguration extends CompilerAutoConfiguration { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java index 476db095f71..f66b405e5d3 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java @@ -27,6 +27,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; * {@link CompilerAutoConfiguration} for Spring Social Twitter. * * @author Craig Walls + * @since 1.1.0 */ public class SpringSocialTwitterCompilerAutoConfiguration extends CompilerAutoConfiguration { diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index c154ec25fd8..b81b633f59e 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -258,6 +258,21 @@ content into your application; rather pick only the properties that you need. # FILE ENCODING ({sc-spring-boot}/context/FileEncodingApplicationListener.{sc-ext}[FileEncodingApplicationListener]) spring.mandatory-file-encoding=false + # SPRING SOCIAL ({sc-spring-boot-autoconfigure}/social/SocialWebAutoConfiguration.{sc-ext}[SocialWebAutoConfiguration]) + spring.social.auto_connection_views=true # Set to true for default connection views or false if you provide your own + + # SPRING SOCIAL FACEBOOK ({sc-spring-boot-autoconfigure}/social/FacebookAutoConfiguration.{sc-ext}[FacebookAutoConfiguration]) + spring.social.facebook.appId= # your application's Facebook App ID + spring.social.facebook.appSecret= # your application's Facebook App Secret + + # SPRING SOCIAL LINKEDIN ({sc-spring-boot-autoconfigure}/social/LinkedInAutoConfiguration.{sc-ext}[LinkedInAutoConfiguration]) + spring.social.linkedin.appId= # your application's LinkedIn App ID + spring.social.linkedin.appSecret= # your application's LinkedIn App Secret + + # SPRING SOCIAL TWITTER ({sc-spring-boot-autoconfigure}/social/TwitterAutoConfiguration.{sc-ext}[TwitterAutoConfiguration]) + spring.social.twitter.appId= # your application's Twitter App ID + spring.social.twitter.appSecret= # your application's Twitter App Secret + # ---------------------------------------- # ACTUATOR PROPERTIES # ---------------------------------------- diff --git a/spring-boot-docs/src/main/asciidoc/appendix-auto-configuration-classes.adoc b/spring-boot-docs/src/main/asciidoc/appendix-auto-configuration-classes.adoc index a65e529a046..6a85e9dec67 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-auto-configuration-classes.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-auto-configuration-classes.adoc @@ -38,6 +38,9 @@ The following auto-configuration classes are from the `spring-boot-autoconfigure |{sc-spring-boot-autoconfigure}/web/EmbeddedServletContainerAutoConfiguration.{sc-ext}[EmbeddedServletContainerAutoConfiguration] |{dc-spring-boot-autoconfigure}/web/EmbeddedServletContainerAutoConfiguration.{dc-ext}[javadoc] +|{sc-spring-boot-autoconfigure}/social/FacebookAutoConfiguration.{sc-ext}[FacebookAutoConfiguration] +|{dc-spring-boot-autoconfigure}/social/FacebookAutoConfiguration.{dc-ext}[javadoc] + |{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[FreeMarkerAutoConfiguration] |{dc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{dc-ext}[javadoc] @@ -59,6 +62,9 @@ The following auto-configuration classes are from the `spring-boot-autoconfigure |{sc-spring-boot-autoconfigure}/data/JpaRepositoriesAutoConfiguration.{sc-ext}[JpaRepositoriesAutoConfiguration] |{dc-spring-boot-autoconfigure}/data/JpaRepositoriesAutoConfiguration.{dc-ext}[javadoc] +|{sc-spring-boot-autoconfigure}/social/LinkedInAutoConfiguration.{sc-ext}[LinkedInAutoConfiguration] +|{dc-spring-boot-autoconfigure}/social/LinkedInAutoConfiguration.{dc-ext}[javadoc] + |{sc-spring-boot-autoconfigure}/liquibase/LiquibaseAutoConfiguration.{sc-ext}[LiquibaseAutoConfiguration] |{dc-spring-boot-autoconfigure}/liquibase/LiquibaseAutoConfiguration.{dc-ext}[javadoc] @@ -95,6 +101,9 @@ The following auto-configuration classes are from the `spring-boot-autoconfigure |{sc-spring-boot-autoconfigure}/web/ServerPropertiesAutoConfiguration.{sc-ext}[ServerPropertiesAutoConfiguration] |{dc-spring-boot-autoconfigure}/web/ServerPropertiesAutoConfiguration.{dc-ext}[javadoc] +|{sc-spring-boot-autoconfigure}/social/SocialWebAutoConfiguration.{sc-ext}[SocialWebAutoConfiguration] +|{dc-spring-boot-autoconfigure}/social/SocialWebAutoConfiguration.{dc-ext}[javadoc] + |{sc-spring-boot-autoconfigure}/solr/SolrAutoConfiguration.{sc-ext}[SolrAutoConfiguration] |{dc-spring-boot-autoconfigure}/solr/SolrAutoConfiguration.{dc-ext}[javadoc] @@ -104,6 +113,9 @@ The following auto-configuration classes are from the `spring-boot-autoconfigure |{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[ThymeleafAutoConfiguration] |{dc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{dc-ext}[javadoc] +|{sc-spring-boot-autoconfigure}/social/TwitterAutoConfiguration.{sc-ext}[TwitterAutoConfiguration] +|{dc-spring-boot-autoconfigure}/social/TwitterAutoConfiguration.{dc-ext}[javadoc] + |{sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[VelocityAutoConfiguration] |{dc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{dc-ext}[javadoc] diff --git a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc index 3257719bc41..6db86b637af 100644 --- a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc +++ b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc @@ -257,6 +257,15 @@ and Hibernate. |`spring-boot-starter-security` |Support for `spring-security`. +|`spring-boot-starter-social-facebook` +|Support for `spring-social-facebook`. + +|`spring-boot-starter-social-linkedin` +|Support for `spring-social-linkedin`. + +|`spring-boot-starter-social-twitter` +|Support for `spring-social-twitter`. + |`spring-boot-starter-test` |Support for common test dependencies, including JUnit, Hamcrest and Mockito along with the `spring-test` module. From 47e3a7239010f016710f0fc339f594e14bff6cc4 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 28 May 2014 13:38:03 +0100 Subject: [PATCH 3/4] Source code formatting --- .../social/FacebookAutoConfiguration.java | 27 ++++++++++------- .../social/LinkedInAutoConfiguration.java | 27 ++++++++++------- .../social/SocialWebAutoConfiguration.java | 12 ++++---- .../social/TwitterAutoConfiguration.java | 30 +++++++++++-------- .../FacebookAutoConfigurationTests.java | 12 ++++---- .../LinkedInAutoConfigurationTests.java | 12 ++++---- .../social/TwitterAutoConfigurationTests.java | 12 ++++---- ...cialFacebookCompilerAutoConfiguration.java | 11 +++---- ...cialLinkedInCompilerAutoConfiguration.java | 11 +++---- ...ocialTwitterCompilerAutoConfiguration.java | 9 +++--- 10 files changed, 95 insertions(+), 68 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java index 9646dcde093..c9e97199711 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -42,9 +42,9 @@ import org.springframework.social.facebook.connect.FacebookConnectionFactory; import org.springframework.web.servlet.View; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity - * with Facebook. - * + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with + * Facebook. + * * @author Craig Walls * @since 1.1.0 */ @@ -56,32 +56,37 @@ public class FacebookAutoConfiguration { @Configuration @EnableSocial @ConditionalOnWebApplication - protected static class FacebookAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + protected static class FacebookAutoConfigurationAdapter extends + SocialConfigurerAdapter implements EnvironmentAware { private String appId; private String appSecret; @Override public void setEnvironment(Environment env) { - RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, + "spring.social."); this.appId = propertyResolver.getRequiredProperty("facebook.appId"); this.appSecret = propertyResolver.getRequiredProperty("facebook.appSecret"); } - + @Override - public void addConnectionFactories(ConnectionFactoryConfigurer config, Environment env) { - config.addConnectionFactory(new FacebookConnectionFactory(appId, appSecret)); + public void addConnectionFactories(ConnectionFactoryConfigurer config, + Environment env) { + config.addConnectionFactory(new FacebookConnectionFactory(this.appId, + this.appSecret)); } @Bean @ConditionalOnMissingBean(Facebook.class) - @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public Facebook facebook(ConnectionRepository repository) { - Connection connection = repository.findPrimaryConnection(Facebook.class); + Connection connection = repository + .findPrimaryConnection(Facebook.class); return connection != null ? connection.getApi() : new FacebookTemplate(); } - @Bean(name={"connect/facebookConnect", "connect/facebookConnected"}) + @Bean(name = { "connect/facebookConnect", "connect/facebookConnected" }) @ConditionalOnExpression("${spring.social.auto_connection_views:false}") public View facebookConnectView() { return new GenericConnectionStatusView("facebook", "Facebook"); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java index a3bf0dd2cda..da95ee8cbcd 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java @@ -41,9 +41,9 @@ import org.springframework.social.linkedin.connect.LinkedInConnectionFactory; import org.springframework.web.servlet.View; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity - * with LinkedIn. - * + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with + * LinkedIn. + * * @author Craig Walls * @since 1.1.0 */ @@ -55,32 +55,37 @@ public class LinkedInAutoConfiguration { @Configuration @EnableSocial @ConditionalOnWebApplication - protected static class LinkedInAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + protected static class LinkedInAutoConfigurationAdapter extends + SocialConfigurerAdapter implements EnvironmentAware { private String appId; private String appSecret; @Override public void setEnvironment(Environment env) { - RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, + "spring.social."); this.appId = propertyResolver.getRequiredProperty("linkedin.appId"); this.appSecret = propertyResolver.getRequiredProperty("linkedin.appSecret"); } - + @Override - public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { - cfConfig.addConnectionFactory(new LinkedInConnectionFactory(appId, appSecret)); + public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, + Environment env) { + cfConfig.addConnectionFactory(new LinkedInConnectionFactory(this.appId, + this.appSecret)); } @Bean @ConditionalOnMissingBean(LinkedInConnectionFactory.class) - @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public LinkedIn linkedin(ConnectionRepository repository) { - Connection connection = repository.findPrimaryConnection(LinkedIn.class); + Connection connection = repository + .findPrimaryConnection(LinkedIn.class); return connection != null ? connection.getApi() : null; } - @Bean(name={"connect/linkedinConnect", "connect/linkedinConnected"}) + @Bean(name = { "connect/linkedinConnect", "connect/linkedinConnected" }) @ConditionalOnExpression("${spring.social.auto_connection_views:false}") public View linkedInConnectView() { return new GenericConnectionStatusView("linkedin", "LinkedIn"); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java index 97326ef285c..c98998e0ca8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/SocialWebAutoConfiguration.java @@ -35,8 +35,9 @@ import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.view.BeanNameViewResolver; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Social's web connection support. - * + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social's web connection + * support. + * * @author Craig Walls * @since 1.1.0 */ @@ -52,10 +53,11 @@ public class SocialWebAutoConfiguration { @Bean @ConditionalOnMissingBean(ConnectController.class) public ConnectController connectController( - ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) { + ConnectionFactoryLocator connectionFactoryLocator, + ConnectionRepository connectionRepository) { return new ConnectController(connectionFactoryLocator, connectionRepository); } - + @Bean @ConditionalOnMissingBean(BeanNameViewResolver.class) @ConditionalOnExpression("${spring.social.auto_connection_views:false}") @@ -64,7 +66,7 @@ public class SocialWebAutoConfiguration { bnvr.setOrder(Integer.MIN_VALUE); return bnvr; } - + @Override public UserIdSource getUserIdSource() { return new UserIdSource() { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java index bee82300fa8..a1dbadff2eb 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfiguration.java @@ -42,9 +42,9 @@ import org.springframework.social.twitter.connect.TwitterConnectionFactory; import org.springframework.web.servlet.View; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity - * with Twitter. - * + * {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with + * Twitter. + * * @author Craig Walls * @since 1.1.0 */ @@ -56,32 +56,38 @@ public class TwitterAutoConfiguration { @Configuration @EnableSocial @ConditionalOnWebApplication - protected static class TwitterAutoConfigurationAdapter extends SocialConfigurerAdapter implements EnvironmentAware { + protected static class TwitterAutoConfigurationAdapter extends + SocialConfigurerAdapter implements EnvironmentAware { private String appId; private String appSecret; @Override public void setEnvironment(Environment env) { - RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "spring.social."); + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, + "spring.social."); this.appId = propertyResolver.getRequiredProperty("twitter.appId"); this.appSecret = propertyResolver.getRequiredProperty("twitter.appSecret"); } - + @Override - public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { - cfConfig.addConnectionFactory(new TwitterConnectionFactory(appId, appSecret)); + public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, + Environment env) { + cfConfig.addConnectionFactory(new TwitterConnectionFactory(this.appId, + this.appSecret)); } @Bean @ConditionalOnMissingBean(TwitterConnectionFactory.class) - @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES) + @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) public Twitter twitter(ConnectionRepository repository) { - Connection connection = repository.findPrimaryConnection(Twitter.class); - return connection != null ? connection.getApi() : new TwitterTemplate(appId, appSecret); + Connection connection = repository + .findPrimaryConnection(Twitter.class); + return connection != null ? connection.getApi() : new TwitterTemplate( + this.appId, this.appSecret); } - @Bean(name={"connect/twitterConnect", "connect/twitterConnected"}) + @Bean(name = { "connect/twitterConnect", "connect/twitterConnected" }) @ConditionalOnExpression("${spring.social.auto_connection_views:false}") public View twitterConnectView() { return new GenericConnectionStatusView("twitter", "Twitter"); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java index bd41ec58074..6a20b61d46e 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfigurationTests.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.social; -import static org.junit.Assert.*; - import org.junit.After; import org.junit.Test; import org.springframework.boot.test.EnvironmentTestUtils; @@ -28,9 +26,11 @@ import org.springframework.social.connect.UsersConnectionRepository; import org.springframework.social.facebook.api.Facebook; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import static org.junit.Assert.assertNotNull; + /** * Tests for {@link FacebookAutoConfiguration}. - * + * * @author Craig Walls */ public class FacebookAutoConfigurationTests { @@ -47,8 +47,10 @@ public class FacebookAutoConfigurationTests { @Test public void expectedSocialBeansCreated() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appId:12345"); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appSecret:secret"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.facebook.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.facebook.appSecret:secret"); this.context.register(SocialWebAutoConfiguration.class); this.context.register(FacebookAutoConfiguration.class); this.context.refresh(); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java index 3e831a8622b..d1f57909a08 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfigurationTests.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.social; -import static org.junit.Assert.*; - import org.junit.After; import org.junit.Test; import org.springframework.boot.test.EnvironmentTestUtils; @@ -28,9 +26,11 @@ import org.springframework.social.connect.UsersConnectionRepository; import org.springframework.social.linkedin.api.LinkedIn; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import static org.junit.Assert.assertNotNull; + /** * Tests for {@link LinkedInAutoConfiguration}. - * + * * @author Craig Walls */ public class LinkedInAutoConfigurationTests { @@ -47,8 +47,10 @@ public class LinkedInAutoConfigurationTests { @Test public void expectedSocialBeansCreated() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appId:12345"); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appSecret:secret"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.linkedin.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.linkedin.appSecret:secret"); this.context.register(SocialWebAutoConfiguration.class); this.context.register(LinkedInAutoConfiguration.class); this.context.refresh(); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java index a06868fe822..09988cea4c2 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/social/TwitterAutoConfigurationTests.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.social; -import static org.junit.Assert.*; - import org.junit.After; import org.junit.Test; import org.springframework.boot.test.EnvironmentTestUtils; @@ -28,9 +26,11 @@ import org.springframework.social.connect.UsersConnectionRepository; import org.springframework.social.twitter.api.Twitter; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import static org.junit.Assert.assertNotNull; + /** * Tests for {@link TwitterAutoConfiguration}. - * + * * @author Craig Walls */ public class TwitterAutoConfigurationTests { @@ -47,8 +47,10 @@ public class TwitterAutoConfigurationTests { @Test public void expectedSocialBeansCreated() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appId:12345"); - EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appSecret:secret"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.twitter.appId:12345"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.social.twitter.appSecret:secret"); this.context.register(SocialWebAutoConfiguration.class); this.context.register(TwitterAutoConfiguration.class); this.context.refresh(); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java index a0246844c8c..37fe98393c6 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialFacebookCompilerAutoConfiguration.java @@ -25,11 +25,12 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; /** * {@link CompilerAutoConfiguration} for Spring Social Facebook. - * + * * @author Craig Walls * @since 1.1.0 */ -public class SpringSocialFacebookCompilerAutoConfiguration extends CompilerAutoConfiguration { +public class SpringSocialFacebookCompilerAutoConfiguration extends + CompilerAutoConfiguration { @Override public boolean matches(ClassNode classNode) { @@ -39,9 +40,9 @@ public class SpringSocialFacebookCompilerAutoConfiguration extends CompilerAutoC @Override public void applyDependencies(DependencyCustomizer dependencies) throws CompilationFailedException { - dependencies - .ifAnyMissingClasses("org.springframework.social.facebook.api.Facebook") - .add("spring-boot-starter-social-facebook"); + dependencies.ifAnyMissingClasses( + "org.springframework.social.facebook.api.Facebook").add( + "spring-boot-starter-social-facebook"); } @Override diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java index c1e97fcf530..1f2763bd6b6 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialLinkedInCompilerAutoConfiguration.java @@ -25,11 +25,12 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; /** * {@link CompilerAutoConfiguration} for Spring Social LinkedIn. - * + * * @author Craig Walls * @since 1.1.0 */ -public class SpringSocialLinkedInCompilerAutoConfiguration extends CompilerAutoConfiguration { +public class SpringSocialLinkedInCompilerAutoConfiguration extends + CompilerAutoConfiguration { @Override public boolean matches(ClassNode classNode) { @@ -39,9 +40,9 @@ public class SpringSocialLinkedInCompilerAutoConfiguration extends CompilerAutoC @Override public void applyDependencies(DependencyCustomizer dependencies) throws CompilationFailedException { - dependencies - .ifAnyMissingClasses("org.springframework.social.linkedin.api.LinkedIn") - .add("spring-boot-starter-social-linkedin"); + dependencies.ifAnyMissingClasses( + "org.springframework.social.linkedin.api.LinkedIn").add( + "spring-boot-starter-social-linkedin"); } @Override diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java index f66b405e5d3..84a73538a66 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringSocialTwitterCompilerAutoConfiguration.java @@ -25,11 +25,12 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer; /** * {@link CompilerAutoConfiguration} for Spring Social Twitter. - * + * * @author Craig Walls * @since 1.1.0 */ -public class SpringSocialTwitterCompilerAutoConfiguration extends CompilerAutoConfiguration { +public class SpringSocialTwitterCompilerAutoConfiguration extends + CompilerAutoConfiguration { @Override public boolean matches(ClassNode classNode) { @@ -40,8 +41,8 @@ public class SpringSocialTwitterCompilerAutoConfiguration extends CompilerAutoCo public void applyDependencies(DependencyCustomizer dependencies) throws CompilationFailedException { dependencies - .ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter") - .add("spring-boot-starter-social-twitter"); + .ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter") + .add("spring-boot-starter-social-twitter"); } @Override From 195a3dd80dbc5fa1de7d0c100468cc3115ae3af0 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 28 May 2014 13:39:26 +0100 Subject: [PATCH 4/4] Use latest versions of Spring Social Facebook and LinkedIn --- spring-boot-dependencies/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 2d3ade097a3..3a1b6000f1a 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -98,9 +98,9 @@ 1.2.0.RELEASE 1.1.1.RELEASE 1.1.0.RELEASE - 1.1.0.RELEASE + 1.1.1.RELEASE 1.1.0.RELEASE - 1.0.0.RELEASE + 1.0.1.RELEASE 3.2.4.RELEASE 1.0.2.RELEASE 2.1.3.RELEASE