From: Kai Moritz Date: Tue, 29 Oct 2019 15:31:36 +0000 (+0100) Subject: WIP: Spring-Upgrade auf 2.2.0 X-Git-Tag: wip-webclient~47 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=6c641b68e1d32fb958e21b8986ad9aff59d75b7b;p=facebook-errors WIP: Spring-Upgrade auf 2.2.0 * Added support for Spring-Security 5.2.0 * Removed support for Spring-Social --- diff --git a/src/test/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfigurationTest.java b/src/test/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfigurationTest.java deleted file mode 100644 index 651ced5..0000000 --- a/src/test/java/de/juplo/facebook/errors/FacebookErrorsSpringSocialAutoConfigurationTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.juplo.facebook.errors; - - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import org.junit.After; -import org.junit.Test; -import org.springframework.context.annotation.Configuration; -import static org.junit.Assert.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer; -import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration; -import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Scope; -import org.springframework.context.annotation.ScopedProxyMode; -import org.springframework.mock.env.MockEnvironment; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.social.connect.ConnectionRepository; -import org.springframework.social.facebook.api.Facebook; -import org.springframework.social.facebook.api.impl.FacebookTemplate; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - - - -public class FacebookErrorsSpringSocialAutoConfigurationTest -{ - private final Logger LOG = - LoggerFactory.getLogger(FacebookErrorsSpringSocialAutoConfigurationTest.class); - - - private ConfigurableApplicationContext context; - - - @After - public void tearDown() - { - if (this.context != null) - this.context.close(); - } - - - @Test - public void defaultConfiguration() - { - LOG.info("<-- Start Of New Test-Case!"); - Map properties = new HashMap<>(); - properties.put("spring.social.facebook.app-id", "APP_ID"); - properties.put("spring.social.facebook.app-secret", "APP_SECRET"); - context = loadWebApplicationContext(EmptyConfiguration.class, properties); - Facebook facebook = context.getBean("facebook", Facebook.class); - RestTemplate template = (RestTemplate) facebook.restOperations(); - assertEquals(GraphApiErrorHandler.class, template.getErrorHandler().getClass()); - } - - - @Configuration - static class EmptyConfiguration - { - /** - * We have to provide this scoped bean for all our tests. - * Otherwise, the tests will fail, if we do not set up a complete - * environment with a connection-repository and a properly mocked request, - * that holds appropriate information to fetch a connection from that - * repository. - * @param repository - * @return - */ - @Bean - @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES) - public Facebook facebook(ConnectionRepository repository) - { - return new FacebookTemplate("ACCESS_TOKEN"); - } - } - - - private ConfigurableApplicationContext loadWebApplicationContext( - Class config, - Map properties - ) - { - AnnotationConfigWebApplicationContext ctx = - new AnnotationConfigWebApplicationContext(); - if (properties != null) - { - MockEnvironment env = new MockEnvironment(); - for (Entry entry : properties.entrySet()) - env.withProperty(entry.getKey(), entry.getValue()); - ctx.setEnvironment(env); - } - ctx.register(FacebookErrorsSpringSocialAutoConfiguration.class); - ctx.register(FacebookAutoConfiguration.class); - ctx.register(SocialWebAutoConfiguration.class); - ctx.register(config); - AutoConfigurationReportLoggingInitializer report = - new AutoConfigurationReportLoggingInitializer(); - report.initialize(ctx); - MockHttpServletRequest request = new MockHttpServletRequest(); - ServletRequestAttributes attributes = new ServletRequestAttributes(request); - RequestContextHolder.setRequestAttributes(attributes); - ctx.refresh(); - return ctx; - } -}