X-Git-Url: https://juplo.de/gitweb/?p=percentcodec;a=blobdiff_plain;f=test%2Fsrc%2Fmain%2Fjava%2Fde%2Fhalbekunst%2Fjuplo%2Ftest%2FWebContextTestExecutionListener.java;fp=test%2Fsrc%2Fmain%2Fjava%2Fde%2Fhalbekunst%2Fjuplo%2Ftest%2FWebContextTestExecutionListener.java;h=0000000000000000000000000000000000000000;hp=68985c22e83813318a221e4d26a330aefbb552e4;hb=a6e0e65cce68acb20abc6ca935471611a740c342;hpb=1d395c6002486d485bde0d5dc713886d70bd3f8a diff --git a/test/src/main/java/de/halbekunst/juplo/test/WebContextTestExecutionListener.java b/test/src/main/java/de/halbekunst/juplo/test/WebContextTestExecutionListener.java deleted file mode 100644 index 68985c22..00000000 --- a/test/src/main/java/de/halbekunst/juplo/test/WebContextTestExecutionListener.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.halbekunst.juplo.test; - -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.config.Scope; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.support.SimpleThreadScope; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.support.AbstractTestExecutionListener; - -/** - * Diese Klasse ermöglicht es, Beans mit dem Scope REQUEST in JUnit-Testfällen - * zu verwenden. - *

- * Source: http://stackoverflow.com/questions/2411343/request-scoped-beans-in-spring-testing - *

- * Anwendung: - * - * @RunWith(SpringJUnit4ClassRunner.class) - * @ContextConfiguration(locations = "classpath:spring/TestScopedBeans-context.xml") - * @TestExecutionListeners({ - * WebContextTestExecutionListener.class, - * DependencyInjectionTestExecutionListener.class, - * DirtiesContextTestExecutionListener.class }) - * public class TestScopedBeans { - * ... - * - */ -public class WebContextTestExecutionListener extends AbstractTestExecutionListener { - @Override - public void prepareTestInstance(TestContext testContext) throws Exception { - - if (testContext.getApplicationContext() instanceof GenericApplicationContext) { - GenericApplicationContext context = (GenericApplicationContext) testContext.getApplicationContext(); - ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - Scope requestScope = new SimpleThreadScope(); - beanFactory.registerScope("request", requestScope); - Scope sessionScope = new SimpleThreadScope(); - beanFactory.registerScope("session", sessionScope); - } - } -}