22 changed files with 920 additions and 1 deletions
@ -0,0 +1,91 @@
@@ -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<Facebook> 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"); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,90 @@
@@ -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<LinkedIn> 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"); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,78 @@
@@ -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"; |
||||
} |
||||
}; |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,91 @@
@@ -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<Twitter> 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"); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
@@ -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)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
@@ -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)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
@@ -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)); |
||||
} |
||||
|
||||
} |
||||
@ -1 +1,7 @@
@@ -1 +1,7 @@
|
||||
foo: bucket |
||||
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 |
||||
@ -0,0 +1,52 @@
@@ -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"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@
@@ -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"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@
@@ -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"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starters</artifactId> |
||||
<version>1.1.0.BUILD-SNAPSHOT</version> |
||||
</parent> |
||||
<artifactId>spring-boot-starter-social-facebook</artifactId> |
||||
<name>Spring Boot Social Facebook Starter</name> |
||||
<description>Spring Boot Social Facebook Starter</description> |
||||
<url>http://projects.spring.io/spring-boot/</url> |
||||
<organization> |
||||
<name>Pivotal Software, Inc.</name> |
||||
<url>http://www.spring.io</url> |
||||
</organization> |
||||
<properties> |
||||
<main.basedir>${basedir}/../..</main.basedir> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-config</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-facebook</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
provides: spring-social-facebook |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starters</artifactId> |
||||
<version>1.1.0.BUILD-SNAPSHOT</version> |
||||
</parent> |
||||
<artifactId>spring-boot-starter-social-linkedin</artifactId> |
||||
<name>Spring Boot Social LinkedIn Starter</name> |
||||
<description>Spring Boot Social LinkedIn Starter</description> |
||||
<url>http://projects.spring.io/spring-boot/</url> |
||||
<organization> |
||||
<name>Pivotal Software, Inc.</name> |
||||
<url>http://www.spring.io</url> |
||||
</organization> |
||||
<properties> |
||||
<main.basedir>${basedir}/../..</main.basedir> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-config</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-linkedin</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
provides: spring-social-linkedin |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starters</artifactId> |
||||
<version>1.1.0.BUILD-SNAPSHOT</version> |
||||
</parent> |
||||
<artifactId>spring-boot-starter-social-twitter</artifactId> |
||||
<name>Spring Boot Social Twitter Starter</name> |
||||
<description>Spring Boot Social Twitter Starter</description> |
||||
<url>http://projects.spring.io/spring-boot/</url> |
||||
<organization> |
||||
<name>Pivotal Software, Inc.</name> |
||||
<url>http://www.spring.io</url> |
||||
</organization> |
||||
<properties> |
||||
<main.basedir>${basedir}/../..</main.basedir> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>${project.groupId}</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-config</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.social</groupId> |
||||
<artifactId>spring-social-twitter</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
||||
Loading…
Reference in new issue