diff --git a/org.springframework.testsuite/src/test/java/common/beans/core/SideEffectBean.java b/org.springframework.testsuite/src/test/java/common/beans/core/SideEffectBean.java deleted file mode 100644 index 39d1f88db17..00000000000 --- a/org.springframework.testsuite/src/test/java/common/beans/core/SideEffectBean.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2002-2005 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 common.beans.core; - -/** - * Bean that changes state on a business invocation, so that - * we can check whether it's been invoked - * @author Rod Johnson - */ -public class SideEffectBean { - - private int count; - - public void setCount(int count) { - this.count = count; - } - - public int getCount() { - return this.count; - } - - public void doWork() { - ++count; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/aspects/PerTargetAspect.java b/org.springframework.testsuite/src/test/java/example/aspects/PerTargetAspect.java deleted file mode 100644 index 4244c389493..00000000000 --- a/org.springframework.testsuite/src/test/java/example/aspects/PerTargetAspect.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - */ -package example.aspects; - -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.core.Ordered; - -@Aspect("pertarget(execution(* *.getSpouse()))") -public class PerTargetAspect implements Ordered { - - public int count; - - private int order = Ordered.LOWEST_PRECEDENCE; - - @Around("execution(int *.getAge())") - public int returnCountAsAge() { - return count++; - } - - @Before("execution(void *.set*(int))") - public void countSetter() { - ++count; - } - - public int getOrder() { - return this.order; - } - - public void setOrder(int order) { - this.order = order; - } -} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/example/aspects/PerThisAspect.java b/org.springframework.testsuite/src/test/java/example/aspects/PerThisAspect.java deleted file mode 100644 index 9f95aaa018b..00000000000 --- a/org.springframework.testsuite/src/test/java/example/aspects/PerThisAspect.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2002-2005 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 example.aspects; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; - -@Aspect("perthis(execution(* getAge()))") -public class PerThisAspect { - - private int invocations = 0; - - public int getInvocations() { - return this.invocations; - } - - @Around("execution(* getAge())") - public int changeAge(ProceedingJoinPoint pjp) throws Throwable { - return invocations++; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/aspects/TwoAdviceAspect.java b/org.springframework.testsuite/src/test/java/example/aspects/TwoAdviceAspect.java deleted file mode 100644 index e69d7d99e57..00000000000 --- a/org.springframework.testsuite/src/test/java/example/aspects/TwoAdviceAspect.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * - */ -package example.aspects; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; - -@Aspect -public class TwoAdviceAspect { - private int totalCalls; - - @Around("execution(* getAge())") - public int returnCallCount(ProceedingJoinPoint pjp) throws Exception { - return totalCalls; - } - - @Before("execution(* setAge(int)) && args(newAge)") - public void countSet(int newAge) throws Exception { - ++totalCalls; - } -} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/example/scannable/AutowiredQualifierFooService.java b/org.springframework.testsuite/src/test/java/example/scannable/AutowiredQualifierFooService.java deleted file mode 100644 index 6db0d795543..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/AutowiredQualifierFooService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -/** - * @author Mark Fisher - */ -public class AutowiredQualifierFooService implements FooService { - - @Autowired - @Qualifier("testing") - private FooDao fooDao; - - private boolean initCalled = false; - - @PostConstruct - private void init() { - if (this.initCalled) { - throw new IllegalStateException("Init already called"); - } - this.initCalled = true; - } - - public String foo(int id) { - return this.fooDao.findFoo(id); - } - - public boolean isInitCalled() { - return this.initCalled; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/CustomComponent.java b/org.springframework.testsuite/src/test/java/example/scannable/CustomComponent.java deleted file mode 100644 index 2f6ef7f42a9..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/CustomComponent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Mark Fisher - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -public @interface CustomComponent { - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/CustomStereotype.java b/org.springframework.testsuite/src/test/java/example/scannable/CustomStereotype.java deleted file mode 100644 index 656ad49bd8f..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/CustomStereotype.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2008 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 example.scannable; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.stereotype.Component; - -/** - * @author Juergen Hoeller - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Component -public @interface CustomStereotype { - - String value() default "thoreau"; - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/DefaultNamedComponent.java b/org.springframework.testsuite/src/test/java/example/scannable/DefaultNamedComponent.java deleted file mode 100644 index 8ce68ee3d41..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/DefaultNamedComponent.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2002-2008 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 example.scannable; - - -/** - * @author Juergen Hoeller - */ -@CustomStereotype -public class DefaultNamedComponent { - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/FooDao.java b/org.springframework.testsuite/src/test/java/example/scannable/FooDao.java deleted file mode 100644 index 92fe2622d3e..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/FooDao.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -/** - * @author Mark Fisher - */ -public interface FooDao { - - String findFoo(int id); - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/FooService.java b/org.springframework.testsuite/src/test/java/example/scannable/FooService.java deleted file mode 100644 index f5fc4e6bfb0..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/FooService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -/** - * @author Mark Fisher - * @author Juergen Hoeller - */ -public interface FooService { - - String foo(int id); - - boolean isInitCalled(); - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/FooServiceImpl.java b/org.springframework.testsuite/src/test/java/example/scannable/FooServiceImpl.java deleted file mode 100644 index 1b13d9644db..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/FooServiceImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import java.util.List; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.MessageSource; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.stereotype.Service; - -/** - * @author Mark Fisher - * @author Juergen Hoeller - */ -@Service -public class FooServiceImpl implements FooService { - - @Autowired private FooDao fooDao; - - @Autowired public BeanFactory beanFactory; - - @Autowired public List listableBeanFactory; - - @Autowired public ResourceLoader resourceLoader; - - @Autowired public ResourcePatternResolver resourcePatternResolver; - - @Autowired public ApplicationEventPublisher eventPublisher; - - @Autowired public MessageSource messageSource; - - @Autowired public ApplicationContext context; - - @Autowired public ConfigurableApplicationContext[] configurableContext; - - @Autowired public AbstractApplicationContext genericContext; - - private boolean initCalled = false; - - @PostConstruct - private void init() { - if (this.initCalled) { - throw new IllegalStateException("Init already called"); - } - this.initCalled = true; - } - - public String foo(int id) { - return this.fooDao.findFoo(id); - } - - public boolean isInitCalled() { - return this.initCalled; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/MessageBean.java b/org.springframework.testsuite/src/test/java/example/scannable/MessageBean.java deleted file mode 100644 index a1035f114fb..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/MessageBean.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -/** - * @author Mark Fisher - */ -@CustomComponent -public class MessageBean { - - private String message; - - public MessageBean() { - this.message = "DEFAULT MESSAGE"; - } - - public MessageBean(String message) { - this.message = message; - } - - public String getMessage() { - return this.message; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/NamedComponent.java b/org.springframework.testsuite/src/test/java/example/scannable/NamedComponent.java deleted file mode 100644 index 748eef7be8a..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/NamedComponent.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import org.springframework.stereotype.Component; - -/** - * @author Mark Fisher - */ -@Component("myNamedComponent") -public class NamedComponent { - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/NamedStubDao.java b/org.springframework.testsuite/src/test/java/example/scannable/NamedStubDao.java deleted file mode 100644 index a4eb66b88c6..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/NamedStubDao.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import org.springframework.stereotype.Repository; - -/** - * @author Juergen Hoeller - */ -@Repository("myNamedDao") -public class NamedStubDao { - - public String find(int id) { - return "bar"; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/ScopedProxyTestBean.java b/org.springframework.testsuite/src/test/java/example/scannable/ScopedProxyTestBean.java deleted file mode 100644 index 5168b2b66ba..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/ScopedProxyTestBean.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import org.springframework.context.annotation.Scope; - -/** - * @author Mark Fisher - * @author Juergen Hoeller - */ -@Scope("myScope") -public class ScopedProxyTestBean implements FooService { - - public String foo(int id) { - return "bar"; - } - - public boolean isInitCalled() { - return false; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/ServiceInvocationCounter.java b/org.springframework.testsuite/src/test/java/example/scannable/ServiceInvocationCounter.java deleted file mode 100644 index a0aa9da7223..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/ServiceInvocationCounter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; - -import org.springframework.stereotype.Component; - -/** - * @author Mark Fisher - */ -@Component -@Aspect -public class ServiceInvocationCounter { - - private int useCount; - - @Pointcut("execution(* example.scannable.FooService+.*(..))") - public void serviceExecution() {} - - @Before("serviceExecution()") - public void countUse() { - this.useCount++; - } - - public int getCount() { - return this.useCount; - } - -} diff --git a/org.springframework.testsuite/src/test/java/example/scannable/StubFooDao.java b/org.springframework.testsuite/src/test/java/example/scannable/StubFooDao.java deleted file mode 100644 index b4ea5b65d5d..00000000000 --- a/org.springframework.testsuite/src/test/java/example/scannable/StubFooDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2007 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 example.scannable; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Repository; - -/** - * @author Mark Fisher - */ -@Repository -@Qualifier("testing") -public class StubFooDao implements FooDao { - - public String findFoo(int id) { - return "bar"; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml index d57f82193cb..add6b7e4815 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests-context.xml @@ -11,14 +11,14 @@ - + - + - + diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java index 72e9667def8..78b24f5aab8 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java @@ -24,8 +24,6 @@ import org.junit.Before; import org.junit.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; -import org.springframework.beans.ITestBean; -import org.springframework.beans.TestBean; import org.springframework.context.ApplicationContext; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; @@ -33,6 +31,9 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.support.XmlWebApplicationContext; +import test.beans.ITestBean; +import test.beans.TestBean; + /** * Integration tests for scoped proxy use in conjunction with aop: namespace. * Deemed an integration test because .web mocks and application contexts are required. diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml index 6eed48e89b9..4f9a0361c04 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests-context.xml @@ -34,7 +34,7 @@ - + @@ -74,20 +74,20 @@ - + - + - org.springframework.beans.ITestBean.getName + test.beans.ITestBean.getName - + 4 @@ -97,7 +97,7 @@ - + diff --git a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index 4ccc8e4c615..6d3e309c8e5 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -27,16 +27,18 @@ import javax.servlet.ServletException; import org.junit.Test; import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; -import org.springframework.beans.ITestBean; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.transaction.CallCountingTransactionManager; import org.springframework.transaction.NoTransactionException; +import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.interceptor.TransactionInterceptor; +import org.springframework.transaction.support.AbstractPlatformTransactionManager; +import org.springframework.transaction.support.DefaultTransactionStatus; import test.advice.CountingBeforeAdvice; import test.advice.MethodCounter; +import test.beans.ITestBean; import test.interceptor.NopInterceptor; /** @@ -311,3 +313,38 @@ class Rollback { } + +@SuppressWarnings("serial") +class CallCountingTransactionManager extends AbstractPlatformTransactionManager { + + public TransactionDefinition lastDefinition; + public int begun; + public int commits; + public int rollbacks; + public int inflight; + + protected Object doGetTransaction() { + return new Object(); + } + + protected void doBegin(Object transaction, TransactionDefinition definition) { + this.lastDefinition = definition; + ++begun; + ++inflight; + } + + protected void doCommit(DefaultTransactionStatus status) { + ++commits; + --inflight; + } + + protected void doRollback(DefaultTransactionStatus status) { + ++rollbacks; + --inflight; + } + + public void clear() { + begun = commits = rollbacks = inflight = 0; + } + +} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/BeanWithObjectProperty.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/BeanWithObjectProperty.java deleted file mode 100644 index 18ddbd3b78b..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/BeanWithObjectProperty.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2002-2005 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.beans; - -/** - * @author Juergen Hoeller - * @since 17.08.2004 - */ -public class BeanWithObjectProperty { - - private Object object; - - public Object getObject() { - return object; - } - - public void setObject(Object object) { - this.object = object; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/BooleanTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/BooleanTestBean.java deleted file mode 100644 index 608fb109eea..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/BooleanTestBean.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2002-2005 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.beans; - -/** - * @author Juergen Hoeller - * @since 10.06.2003 - */ -public class BooleanTestBean { - - private boolean bool1; - - private Boolean bool2; - - public boolean isBool1() { - return bool1; - } - - public void setBool1(boolean bool1) { - this.bool1 = bool1; - } - - public Boolean getBool2() { - return bool2; - } - - public void setBool2(Boolean bool2) { - this.bool2 = bool2; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/CustomEnum.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/CustomEnum.java deleted file mode 100644 index f1d7879132c..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/CustomEnum.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2002-2007 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.beans; - -/** - * @author Juergen Hoeller - */ -public enum CustomEnum { - - VALUE_1, VALUE_2; - - public String toString() { - return "CustomEnum: " + name(); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/DerivedTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/DerivedTestBean.java deleted file mode 100644 index db326041c36..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/DerivedTestBean.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2002-2007 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.beans; - -import java.io.Serializable; - -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.beans.factory.DisposableBean; - -/** - * @author Juergen Hoeller - * @since 21.08.2003 - */ -public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean { - - private String beanName; - - private boolean initialized; - - private boolean destroyed; - - - public DerivedTestBean() { - } - - public DerivedTestBean(String[] names) { - if (names == null || names.length < 2) { - throw new IllegalArgumentException("Invalid names array"); - } - setName(names[0]); - setBeanName(names[1]); - } - - public static DerivedTestBean create(String[] names) { - return new DerivedTestBean(names); - } - - - public void setBeanName(String beanName) { - if (this.beanName == null || beanName == null) { - this.beanName = beanName; - } - } - - public String getBeanName() { - return beanName; - } - - public void setSpouseRef(String name) { - setSpouse(new TestBean(name)); - } - - - public void initialize() { - this.initialized = true; - } - - public boolean wasInitialized() { - return initialized; - } - - - public void destroy() { - this.destroyed = true; - } - - public boolean wasDestroyed() { - return destroyed; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/Employee.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/Employee.java deleted file mode 100644 index 923c0041087..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/Employee.java +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * Copyright 2002-2005 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.beans; - -public class Employee extends TestBean { - - private String co; - - /** - * Constructor for Employee. - */ - public Employee() { - super(); - } - - public String getCompany() { - return co; - } - - public void setCompany(String co) { - this.co = co; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/FieldAccessBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/FieldAccessBean.java deleted file mode 100644 index f367fb5d6e3..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/FieldAccessBean.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2006 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.beans; - -/** - * @author Juergen Hoeller - * @since 07.03.2006 - */ -public class FieldAccessBean { - - public String name; - - protected int age; - - private TestBean spouse; - - - public String getName() { - return name; - } - - public int getAge() { - return age; - } - - public TestBean getSpouse() { - return spouse; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericBean.java deleted file mode 100644 index c92cf099b6d..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericBean.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2002-2008 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.beans; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.springframework.core.io.Resource; - -/** - * @author Juergen Hoeller - */ -public class GenericBean { - - private Set integerSet; - - private List resourceList; - - private List> listOfLists; - - private ArrayList listOfArrays; - - private List> listOfMaps; - - private Map plainMap; - - private Map shortMap; - - private HashMap longMap; - - private Map> collectionMap; - - private Map> mapOfMaps; - - private Map> mapOfLists; - - private CustomEnum customEnum; - - private T genericProperty; - - private List genericListProperty; - - - public GenericBean() { - } - - public GenericBean(Set integerSet) { - this.integerSet = integerSet; - } - - public GenericBean(Set integerSet, List resourceList) { - this.integerSet = integerSet; - this.resourceList = resourceList; - } - - public GenericBean(HashSet integerSet, Map shortMap) { - this.integerSet = integerSet; - this.shortMap = shortMap; - } - - public GenericBean(Map shortMap, Resource resource) { - this.shortMap = shortMap; - this.resourceList = Collections.singletonList(resource); - } - - public GenericBean(Map plainMap, Map shortMap) { - this.plainMap = plainMap; - this.shortMap = shortMap; - } - - public GenericBean(HashMap longMap) { - this.longMap = longMap; - } - - public GenericBean(boolean someFlag, Map> collectionMap) { - this.collectionMap = collectionMap; - } - - - public Set getIntegerSet() { - return integerSet; - } - - public void setIntegerSet(Set integerSet) { - this.integerSet = integerSet; - } - - public List getResourceList() { - return resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - public List> getListOfLists() { - return listOfLists; - } - - public ArrayList getListOfArrays() { - return listOfArrays; - } - - public void setListOfArrays(ArrayList listOfArrays) { - this.listOfArrays = listOfArrays; - } - - public void setListOfLists(List> listOfLists) { - this.listOfLists = listOfLists; - } - - public List> getListOfMaps() { - return listOfMaps; - } - - public void setListOfMaps(List> listOfMaps) { - this.listOfMaps = listOfMaps; - } - - public Map getPlainMap() { - return plainMap; - } - - public Map getShortMap() { - return shortMap; - } - - public void setShortMap(Map shortMap) { - this.shortMap = shortMap; - } - - public HashMap getLongMap() { - return longMap; - } - - public void setLongMap(HashMap longMap) { - this.longMap = longMap; - } - - public Map> getCollectionMap() { - return collectionMap; - } - - public void setCollectionMap(Map> collectionMap) { - this.collectionMap = collectionMap; - } - - public Map> getMapOfMaps() { - return mapOfMaps; - } - - public void setMapOfMaps(Map> mapOfMaps) { - this.mapOfMaps = mapOfMaps; - } - - public Map> getMapOfLists() { - return mapOfLists; - } - - public void setMapOfLists(Map> mapOfLists) { - this.mapOfLists = mapOfLists; - } - - public T getGenericProperty() { - return genericProperty; - } - - public void setGenericProperty(T genericProperty) { - this.genericProperty = genericProperty; - } - - public List getGenericListProperty() { - return genericListProperty; - } - - public void setGenericListProperty(List genericListProperty) { - this.genericListProperty = genericListProperty; - } - - public CustomEnum getCustomEnum() { - return customEnum; - } - - public void setCustomEnum(CustomEnum customEnum) { - this.customEnum = customEnum; - } - - - public static GenericBean createInstance(Set integerSet) { - return new GenericBean(integerSet); - } - - public static GenericBean createInstance(Set integerSet, List resourceList) { - return new GenericBean(integerSet, resourceList); - } - - public static GenericBean createInstance(HashSet integerSet, Map shortMap) { - return new GenericBean(integerSet, shortMap); - } - - public static GenericBean createInstance(Map shortMap, Resource resource) { - return new GenericBean(shortMap, resource); - } - - public static GenericBean createInstance(Map map, Map shortMap) { - return new GenericBean(map, shortMap); - } - - public static GenericBean createInstance(HashMap longMap) { - return new GenericBean(longMap); - } - - public static GenericBean createInstance(boolean someFlag, Map> collectionMap) { - return new GenericBean(someFlag, collectionMap); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericIntegerBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericIntegerBean.java deleted file mode 100644 index 7abdb3710fd..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericIntegerBean.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2002-2008 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.beans; - -/** - * @author Juergen Hoeller - */ -public class GenericIntegerBean extends GenericBean { - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericSetOfIntegerBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericSetOfIntegerBean.java deleted file mode 100644 index 54e18c3a179..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/GenericSetOfIntegerBean.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2002-2008 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.beans; - -import java.util.Set; - -/** - * @author Juergen Hoeller - */ -public class GenericSetOfIntegerBean extends GenericBean> { - -} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/NumberTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/NumberTestBean.java deleted file mode 100644 index 80c3ec372aa..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/NumberTestBean.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2002-2005 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.beans; - -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * @author Juergen Hoeller - * @since 10.06.2003 - */ -public class NumberTestBean { - - private short short1; - private Short short2; - - private int int1; - private Integer int2; - - private long long1; - private Long long2; - - private BigInteger bigInteger; - - private float float1; - private Float float2; - - private double double1; - private Double double2; - - private BigDecimal bigDecimal; - - public short getShort1() { - return short1; - } - - public void setShort1(short short1) { - this.short1 = short1; - } - - public Short getShort2() { - return short2; - } - - public void setShort2(Short short2) { - this.short2 = short2; - } - - public int getInt1() { - return int1; - } - - public void setInt1(int int1) { - this.int1 = int1; - } - - public Integer getInt2() { - return int2; - } - - public void setInt2(Integer int2) { - this.int2 = int2; - } - - public long getLong1() { - return long1; - } - - public void setLong1(long long1) { - this.long1 = long1; - } - - public Long getLong2() { - return long2; - } - - public void setLong2(Long long2) { - this.long2 = long2; - } - - public BigInteger getBigInteger() { - return bigInteger; - } - - public void setBigInteger(BigInteger bigInteger) { - this.bigInteger = bigInteger; - } - - public float getFloat1() { - return float1; - } - - public void setFloat1(float float1) { - this.float1 = float1; - } - - public Float getFloat2() { - return float2; - } - - public void setFloat2(Float float2) { - this.float2 = float2; - } - - public double getDouble1() { - return double1; - } - - public void setDouble1(double double1) { - this.double1 = double1; - } - - public Double getDouble2() { - return double2; - } - - public void setDouble2(Double double2) { - this.double2 = double2; - } - - public BigDecimal getBigDecimal() { - return bigDecimal; - } - - public void setBigDecimal(BigDecimal bigDecimal) { - this.bigDecimal = bigDecimal; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/Person.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/Person.java deleted file mode 100644 index af3bb924f7e..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/Person.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2005 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.beans; - -/** - * - * @author Rod Johnson - */ -public interface Person { - - String getName(); - void setName(String name); - int getAge(); - void setAge(int i); - - /** - * Test for non-property method matching. - * If the parameter is a Throwable, it will be thrown rather than - * returned. - */ - Object echo(Object o) throws Throwable; -} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/ResourceTestBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/ResourceTestBean.java deleted file mode 100644 index d9d8cd166ae..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/ResourceTestBean.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.springframework.beans; - -import java.io.InputStream; - -import org.springframework.core.io.Resource; - -/** - * @author Juergen Hoeller - * @since 01.04.2004 - */ -public class ResourceTestBean { - - private Resource resource; - - private InputStream inputStream; - - public ResourceTestBean() { - } - - public ResourceTestBean(Resource resource, InputStream inputStream) { - this.resource = resource; - this.inputStream = inputStream; - } - - public void setResource(Resource resource) { - this.resource = resource; - } - - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; - } - - public Resource getResource() { - return resource; - } - - public InputStream getInputStream() { - return inputStream; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/SerializablePerson.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/SerializablePerson.java deleted file mode 100644 index 66a41f51131..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/SerializablePerson.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2002-2005 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.beans; - -import java.io.Serializable; - -import org.springframework.util.ObjectUtils; - -/** - * Serializable implementation of the Person interface. - * - * @author Rod Johnson - */ -public class SerializablePerson implements Person, Serializable { - - private String name; - private int age; - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Object echo(Object o) throws Throwable { - if (o instanceof Throwable) { - throw (Throwable) o; - } - return o; - } - - public boolean equals(Object other) { - if (!(other instanceof SerializablePerson)) { - return false; - } - SerializablePerson p = (SerializablePerson) other; - return p.age == age && ObjectUtils.nullSafeEquals(name, p.name); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/DummyFactory.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/DummyFactory.java deleted file mode 100644 index 020e683d7d8..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/DummyFactory.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2002-2007 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.beans.factory; - -import org.springframework.beans.BeansException; -import org.springframework.beans.TestBean; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; - -/** - * Simple factory to allow testing of FactoryBean support in AbstractBeanFactory. - * Depending on whether its singleton property is set, it will return a singleton - * or a prototype instance. - * - *

Implements InitializingBean interface, so we can check that - * factories get this lifecycle callback if they want. - * - * @author Rod Johnson - * @since 10.03.2003 - */ -public class DummyFactory - implements FactoryBean, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean { - - public static final String SINGLETON_NAME = "Factory singleton"; - - private static boolean prototypeCreated; - - /** - * Clear static state. - */ - public static void reset() { - prototypeCreated = false; - } - - - /** - * Default is for factories to return a singleton instance. - */ - private boolean singleton = true; - - private String beanName; - - private AutowireCapableBeanFactory beanFactory; - - private boolean postProcessed; - - private boolean initialized; - - private TestBean testBean; - - private TestBean otherTestBean; - - - public DummyFactory() { - this.testBean = new TestBean(); - this.testBean.setName(SINGLETON_NAME); - this.testBean.setAge(25); - } - - /** - * Return if the bean managed by this factory is a singleton. - * @see org.springframework.beans.factory.FactoryBean#isSingleton() - */ - public boolean isSingleton() { - return this.singleton; - } - - /** - * Set if the bean managed by this factory is a singleton. - */ - public void setSingleton(boolean singleton) { - this.singleton = singleton; - } - - public void setBeanName(String beanName) { - this.beanName = beanName; - } - - public String getBeanName() { - return beanName; - } - - public void setBeanFactory(BeanFactory beanFactory) { - this.beanFactory = (AutowireCapableBeanFactory) beanFactory; - this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName); - } - - public BeanFactory getBeanFactory() { - return beanFactory; - } - - public void setPostProcessed(boolean postProcessed) { - this.postProcessed = postProcessed; - } - - public boolean isPostProcessed() { - return postProcessed; - } - - public void setOtherTestBean(TestBean otherTestBean) { - this.otherTestBean = otherTestBean; - this.testBean.setSpouse(otherTestBean); - } - - public TestBean getOtherTestBean() { - return otherTestBean; - } - - public void afterPropertiesSet() { - if (initialized) { - throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean"); - } - this.initialized = true; - } - - /** - * Was this initialized by invocation of the - * afterPropertiesSet() method from the InitializingBean interface? - */ - public boolean wasInitialized() { - return initialized; - } - - public static boolean wasPrototypeCreated() { - return prototypeCreated; - } - - - /** - * Return the managed object, supporting both singleton - * and prototype mode. - * @see org.springframework.beans.factory.FactoryBean#getObject() - */ - public Object getObject() throws BeansException { - if (isSingleton()) { - return this.testBean; - } - else { - TestBean prototype = new TestBean("prototype created at " + System.currentTimeMillis(), 11); - if (this.beanFactory != null) { - this.beanFactory.applyBeanPostProcessorsBeforeInitialization(prototype, this.beanName); - } - prototypeCreated = true; - return prototype; - } - } - - public Class getObjectType() { - return TestBean.class; - } - - - public void destroy() { - if (this.testBean != null) { - this.testBean.setName(null); - } - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/HasMap.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/HasMap.java deleted file mode 100644 index 3bac49498b5..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/HasMap.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2002-2005 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.beans.factory; - -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -/** - * Bean exposing a map. Used for bean factory tests. - * - * @author Rod Johnson - * @since 05.06.2003 - */ -public class HasMap { - - private Map map; - - private Set set; - - private Properties props; - - private Object[] objectArray; - - private Class[] classArray; - - private Integer[] intArray; - - private HasMap() { - } - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - - public Set getSet() { - return set; - } - - public void setSet(Set set) { - this.set = set; - } - - public Properties getProps() { - return props; - } - - public void setProps(Properties props) { - this.props = props; - } - - public Object[] getObjectArray() { - return objectArray; - } - - public void setObjectArray(Object[] objectArray) { - this.objectArray = objectArray; - } - - public Class[] getClassArray() { - return classArray; - } - - public void setClassArray(Class[] classArray) { - this.classArray = classArray; - } - - public Integer[] getIntegerArray() { - return intArray; - } - - public void setIntegerArray(Integer[] is) { - intArray = is; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/LifecycleBean.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/LifecycleBean.java deleted file mode 100644 index ebbbf1c7f86..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/LifecycleBean.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2002-2007 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.beans.factory; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; - -/** - * Simple test of BeanFactory initialization and lifecycle callbacks. - * - * @author Rod Johnson - * @author Colin Sampaleanu - * @since 12.03.2003 - */ -public class LifecycleBean implements BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean { - - protected boolean initMethodDeclared = false; - - protected String beanName; - - protected BeanFactory owningFactory; - - protected boolean postProcessedBeforeInit; - - protected boolean inited; - - protected boolean initedViaDeclaredInitMethod; - - protected boolean postProcessedAfterInit; - - protected boolean destroyed; - - - public void setInitMethodDeclared(boolean initMethodDeclared) { - this.initMethodDeclared = initMethodDeclared; - } - - public boolean isInitMethodDeclared() { - return initMethodDeclared; - } - - public void setBeanName(String name) { - this.beanName = name; - } - - public String getBeanName() { - return beanName; - } - - public void setBeanFactory(BeanFactory beanFactory) { - this.owningFactory = beanFactory; - } - - public void postProcessBeforeInit() { - if (this.inited || this.initedViaDeclaredInitMethod) { - throw new RuntimeException("Factory called postProcessBeforeInit after afterPropertiesSet"); - } - if (this.postProcessedBeforeInit) { - throw new RuntimeException("Factory called postProcessBeforeInit twice"); - } - this.postProcessedBeforeInit = true; - } - - public void afterPropertiesSet() { - if (this.owningFactory == null) { - throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean"); - } - if (!this.postProcessedBeforeInit) { - throw new RuntimeException("Factory didn't call postProcessBeforeInit before afterPropertiesSet on lifecycle bean"); - } - if (this.initedViaDeclaredInitMethod) { - throw new RuntimeException("Factory initialized via declared init method before initializing via afterPropertiesSet"); - } - if (this.inited) { - throw new RuntimeException("Factory called afterPropertiesSet twice"); - } - this.inited = true; - } - - public void declaredInitMethod() { - if (!this.inited) { - throw new RuntimeException("Factory didn't call afterPropertiesSet before declared init method"); - } - - if (this.initedViaDeclaredInitMethod) { - throw new RuntimeException("Factory called declared init method twice"); - } - this.initedViaDeclaredInitMethod = true; - } - - public void postProcessAfterInit() { - if (!this.inited) { - throw new RuntimeException("Factory called postProcessAfterInit before afterPropertiesSet"); - } - if (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) { - throw new RuntimeException("Factory called postProcessAfterInit before calling declared init method"); - } - if (this.postProcessedAfterInit) { - throw new RuntimeException("Factory called postProcessAfterInit twice"); - } - this.postProcessedAfterInit = true; - } - - /** - * Dummy business method that will fail unless the factory - * managed the bean's lifecycle correctly - */ - public void businessMethod() { - if (!this.inited || (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) || - !this.postProcessedAfterInit) { - throw new RuntimeException("Factory didn't initialize lifecycle object correctly"); - } - } - - public void destroy() { - if (this.destroyed) { - throw new IllegalStateException("Already destroyed"); - } - this.destroyed = true; - } - - public boolean isDestroyed() { - return destroyed; - } - - - public static class PostProcessor implements BeanPostProcessor { - - public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { - if (bean instanceof LifecycleBean) { - ((LifecycleBean) bean).postProcessBeforeInit(); - } - return bean; - } - - public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { - if (bean instanceof LifecycleBean) { - ((LifecycleBean) bean).postProcessAfterInit(); - } - return bean; - } - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/MustBeInitialized.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/MustBeInitialized.java deleted file mode 100644 index 1dedf6624c2..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/MustBeInitialized.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2005 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.beans.factory; - -/** - * Simple test of BeanFactory initialization - * @author Rod Johnson - * @since 12.03.2003 - */ -public class MustBeInitialized implements InitializingBean { - - private boolean inited; - - /** - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() throws Exception { - this.inited = true; - } - - /** - * Dummy business method that will fail unless the factory - * managed the bean's lifecycle correctly - */ - public void businessMethod() { - if (!this.inited) - throw new RuntimeException("Factory didn't call afterPropertiesSet() on MustBeInitialized object"); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleMapScope.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleMapScope.java deleted file mode 100644 index 42fb9fd89d5..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleMapScope.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2002-2008 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.beans.factory.config; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.springframework.beans.factory.ObjectFactory; - -/** - * @author Juergen Hoeller - */ -public class SimpleMapScope implements Scope, Serializable { - - private final Map map = new HashMap(); - - private final List callbacks = new LinkedList(); - - - public SimpleMapScope() { - } - - public final Map getMap() { - return this.map; - } - - - public Object get(String name, ObjectFactory objectFactory) { - synchronized (this.map) { - Object scopedObject = this.map.get(name); - if (scopedObject == null) { - scopedObject = objectFactory.getObject(); - this.map.put(name, scopedObject); - } - return scopedObject; - } - } - - public Object remove(String name) { - synchronized (this.map) { - return this.map.remove(name); - } - } - - public void registerDestructionCallback(String name, Runnable callback) { - this.callbacks.add(callback); - } - - public Object resolveContextualObject(String key) { - return null; - } - - public void close() { - for (Iterator it = this.callbacks.iterator(); it.hasNext();) { - Runnable runnable = (Runnable) it.next(); - runnable.run(); - } - } - - public String getConversationId() { - return null; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test-properties.xml b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test-properties.xml deleted file mode 100644 index e39b872c9fc..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test-properties.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - 99 - test - - diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test.properties b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test.properties deleted file mode 100644 index 9affcba0135..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/test.properties +++ /dev/null @@ -1,2 +0,0 @@ -tb.array[0].age=99 -tb.list[1].name=test diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/util.properties b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/util.properties deleted file mode 100644 index c9f0304f65e..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/util.properties +++ /dev/null @@ -1 +0,0 @@ -foo=bar \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java deleted file mode 100644 index 74d6b48540e..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2002-2007 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.beans.factory.parsing; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.springframework.core.CollectionFactory; - -/** - * @author Rob Harrop - * @author Juergen Hoeller - */ -public class CollectingReaderEventListener implements ReaderEventListener { - - private final List defaults = new LinkedList(); - - private final Map componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8); - - private final Map aliasMap = CollectionFactory.createLinkedMapIfPossible(8); - - private final List imports = new LinkedList(); - - - public void defaultsRegistered(DefaultsDefinition defaultsDefinition) { - this.defaults.add(defaultsDefinition); - } - - public List getDefaults() { - return Collections.unmodifiableList(this.defaults); - } - - public void componentRegistered(ComponentDefinition componentDefinition) { - this.componentDefinitions.put(componentDefinition.getName(), componentDefinition); - } - - public ComponentDefinition getComponentDefinition(String name) { - return (ComponentDefinition) this.componentDefinitions.get(name); - } - - public ComponentDefinition[] getComponentDefinitions() { - Collection collection = this.componentDefinitions.values(); - return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]); - } - - public void aliasRegistered(AliasDefinition aliasDefinition) { - List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName()); - if(aliases == null) { - aliases = new ArrayList(); - this.aliasMap.put(aliasDefinition.getBeanName(), aliases); - } - aliases.add(aliasDefinition); - } - - public List getAliases(String beanName) { - List aliases = (List) this.aliasMap.get(beanName); - return aliases == null ? null : Collections.unmodifiableList(aliases); - } - - public void importProcessed(ImportDefinition importDefinition) { - this.imports.add(importDefinition); - } - - public List getImports() { - return Collections.unmodifiableList(this.imports); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/ACATester.java b/org.springframework.testsuite/src/test/java/org/springframework/context/ACATester.java deleted file mode 100644 index 1bda64a785f..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/ACATester.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2002-2005 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.context; - -import java.util.Locale; - -public class ACATester implements ApplicationContextAware { - - private ApplicationContext ac; - - public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException { - // check reinitialization - if (this.ac != null) { - throw new IllegalStateException("Already initialized"); - } - - // check message source availability - if (ctx != null) { - try { - ctx.getMessage("code1", null, Locale.getDefault()); - } - catch (NoSuchMessageException ex) { - // expected - } - } - - this.ac = ctx; - } - - public ApplicationContext getApplicationContext() { - return ac; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatBroadcasts.java b/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatBroadcasts.java deleted file mode 100644 index f525d38fe16..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatBroadcasts.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2007 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.context; - -/** - * @author Juergen Hoeller - */ -public class BeanThatBroadcasts implements ApplicationContextAware { - - public ApplicationContext applicationContext; - - public int receivedCount; - - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - if (applicationContext.getDisplayName().indexOf("listener") != -1) { - applicationContext.getBean("listener"); - } - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatListens.java b/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatListens.java deleted file mode 100644 index 9ab3f8ea40d..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/BeanThatListens.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2002-2007 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.context; - -import java.util.Map; - -/** - * A stub {@link ApplicationListener}. - * - * @author Thomas Risberg - * @author Juergen Hoeller - */ -public class BeanThatListens implements ApplicationListener { - - private BeanThatBroadcasts beanThatBroadcasts; - - private int eventCount; - - - public BeanThatListens() { - } - - public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) { - this.beanThatBroadcasts = beanThatBroadcasts; - Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class); - if (!beans.isEmpty()) { - throw new IllegalStateException("Shouldn't have found any BeanThatListens instances"); - } - } - - - public void onApplicationEvent(ApplicationEvent event) { - eventCount++; - if (beanThatBroadcasts != null) { - beanThatBroadcasts.receivedCount++; - } - } - - public int getEventCount() { - return eventCount; - } - - public void zero() { - eventCount = 0; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/LifecycleContextBean.java b/org.springframework.testsuite/src/test/java/org/springframework/context/LifecycleContextBean.java deleted file mode 100644 index c3aba92b5f8..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/LifecycleContextBean.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2002-2005 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.context; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.LifecycleBean; - -/** - * Simple bean to test ApplicationContext lifecycle methods for beans - * - * @author Colin Sampaleanu - * @since 03.07.2004 - */ -public class LifecycleContextBean extends LifecycleBean implements ApplicationContextAware { - - protected ApplicationContext owningContext; - - public void setBeanFactory(BeanFactory beanFactory) { - super.setBeanFactory(beanFactory); - if (this.owningContext != null) - throw new RuntimeException("Factory called setBeanFactory after setApplicationContext"); - } - - public void afterPropertiesSet() { - super.afterPropertiesSet(); - if (this.owningContext == null) - throw new RuntimeException("Factory didn't call setAppliationContext before afterPropertiesSet on lifecycle bean"); - } - - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - if (this.owningFactory == null) - throw new RuntimeException("Factory called setApplicationContext before setBeanFactory"); - - this.owningContext = applicationContext; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/TestListener.java b/org.springframework.testsuite/src/test/java/org/springframework/context/TestListener.java deleted file mode 100644 index b9f57f73087..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/TestListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2002-2007 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.context; - -/** - * Listener that maintains a global count of events. - * - * @author Rod Johnson - * @since January 21, 2001 - */ -public class TestListener implements ApplicationListener { - - private int eventCount; - - public int getEventCount() { - return eventCount; - } - - public void zeroCounter() { - eventCount = 0; - } - - public void onApplicationEvent(ApplicationEvent e) { - ++eventCount; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeTests.java b/org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeIntegrationTests.java similarity index 99% rename from org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeTests.java rename to org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeIntegrationTests.java index c870ca29527..4b826450cc7 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeTests.java +++ b/org.springframework.testsuite/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerScopeIntegrationTests.java @@ -39,7 +39,7 @@ import org.springframework.web.context.support.GenericWebApplicationContext; * @author Juergen Hoeller * @author Chris Beams */ -public class ClassPathBeanDefinitionScannerScopeTests { +public class ClassPathBeanDefinitionScannerScopeIntegrationTests { private static final String DEFAULT_NAME = "default"; diff --git a/org.springframework.testsuite/src/test/java/org/springframework/core/task/NoOpRunnable.java b/org.springframework.testsuite/src/test/java/org/springframework/core/task/NoOpRunnable.java deleted file mode 100644 index 88ce25e7450..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/core/task/NoOpRunnable.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2002-2007 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.core.task; - -/** - * A no-op Runnable implementation. - * - * @author Rick Evans - */ -public class NoOpRunnable implements Runnable { - - public void run() { - // explicit no-op - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/mock/easymock/AbstractScalarMockTemplate.java b/org.springframework.testsuite/src/test/java/org/springframework/mock/easymock/AbstractScalarMockTemplate.java deleted file mode 100644 index aaba654bb56..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/mock/easymock/AbstractScalarMockTemplate.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2002-2006 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.mock.easymock; - -import org.easymock.MockControl; - -/** - * Makes those tests that require a single (scalar) EasyMock mock - * control and object easier to author. - * - * @author Rick Evans - * @since 2.0 - */ -public abstract class AbstractScalarMockTemplate { - - private static final int NORMAL = 0; - private static final int NICE = 1; - private static final int STRICT = 2; - - - private Class mockInterface; - - private int mode = NORMAL; - - - /** - * Creates a new instance of the {@link AbstractScalarMockTemplate} class. - */ - protected AbstractScalarMockTemplate() { - } - - /** - * Creates a new instance of the {@link AbstractScalarMockTemplate} class. - * @param mockInterface the interface that is to be mocked - */ - protected AbstractScalarMockTemplate(Class mockInterface) { - this.mockInterface = mockInterface; - } - - /** - * Creates a new instance of the {@link AbstractScalarMockTemplate} class. - * @param mockInterface the interface that is to be mocked - * @param nice true if a "nice" mock control is to be created; - * false if a "strict" control is to be created - */ - protected AbstractScalarMockTemplate(Class mockInterface, boolean nice) { - this.mockInterface = mockInterface; - this.mode = nice ? NICE : STRICT; - } - - - /** - * Sets the interface that is to be mocked. - * @param mockInterface the interface that is to be mocked - */ - public void setMockInterface(Class mockInterface) { - this.mockInterface = mockInterface; - } - - /** - * Gets the interface that is to be mocked. - * @return the interface that is to be mocked - */ - public Class getMockInterface() { - return mockInterface; - } - - - /** - * Setup any expectations for the test. - *

The default implementation is a no-op; i.e. no expectations are set. - * @param mockControl the EasyMock {@link org.easymock.MockControl} for the mocked object - * @param mockObject the mocked object - * @throws Exception if calling methods on the supplied mockObject - * that are declared as throwing one more exceptions (just here to satisfy the compiler really). - */ - public void setupExpectations(MockControl mockControl, Object mockObject) throws Exception { - } - - /** - * Do the EasyMock-driven test. - *

This is the driving template method, and should not typically need to overriden. - * @throws Exception if an exception is thrown during testing - */ - public void test() throws Exception { - MockControl mockControl = createMockControl(); - Object mockObject = mockControl.getMock(); - setupExpectations(mockControl, mockObject); - mockControl.replay(); - doTest(mockObject); - mockControl.verify(); - } - - /** - * Do the actual test using the supplied mock. - * @param mockObject the mocked object - * @throws Exception if an exception is thrown during the test logic - */ - public abstract void doTest(Object mockObject) throws Exception; - - - /** - * Create a {@link org.easymock.MockControl} for the mocked interface. - * @return a {@link org.easymock.MockControl} for the mocked interface - */ - protected MockControl createMockControl() { - return this.mode == NORMAL - ? MockControl.createControl(this.getMockInterface()) - : this.mode == NICE - ? MockControl.createNiceControl(this.getMockInterface()) - : MockControl.createStrictControl(this.getMockInterface()); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/mock/web/MockHttpServletRequest.java b/org.springframework.testsuite/src/test/java/org/springframework/mock/web/MockHttpServletRequest.java deleted file mode 100644 index 527f05c150a..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/mock/web/MockHttpServletRequest.java +++ /dev/null @@ -1,849 +0,0 @@ -/* - * Copyright 2002-2008 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.mock.web; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.security.Principal; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.Vector; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletInputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import org.springframework.util.Assert; - -/** - * Mock implementation of the {@link javax.servlet.http.HttpServletRequest} - * interface. Supports the Servlet 2.4 API level. - * - *

Used for testing the web framework; also useful for testing - * application controllers. - * - * @author Juergen Hoeller - * @author Rod Johnson - * @author Rick Evans - * @author Mark Fisher - * @since 1.0.2 - */ -public class MockHttpServletRequest implements HttpServletRequest { - - /** - * The default protocol: 'http'. - */ - public static final String DEFAULT_PROTOCOL = "http"; - - /** - * The default server address: '127.0.0.1'. - */ - public static final String DEFAULT_SERVER_ADDR = "127.0.0.1"; - - /** - * The default server name: 'localhost'. - */ - public static final String DEFAULT_SERVER_NAME = "localhost"; - - /** - * The default server port: '80'. - */ - public static final int DEFAULT_SERVER_PORT = 80; - - /** - * The default remote address: '127.0.0.1'. - */ - public static final String DEFAULT_REMOTE_ADDR = "127.0.0.1"; - - /** - * The default remote host: 'localhost'. - */ - public static final String DEFAULT_REMOTE_HOST = "localhost"; - - - private boolean active = true; - - - //--------------------------------------------------------------------- - // ServletRequest properties - //--------------------------------------------------------------------- - - private final Hashtable attributes = new Hashtable(); - - private String characterEncoding; - - private byte[] content; - - private String contentType; - - private final Map parameters = new LinkedHashMap(16); - - private String protocol = DEFAULT_PROTOCOL; - - private String scheme = DEFAULT_PROTOCOL; - - private String serverName = DEFAULT_SERVER_NAME; - - private int serverPort = DEFAULT_SERVER_PORT; - - private String remoteAddr = DEFAULT_REMOTE_ADDR; - - private String remoteHost = DEFAULT_REMOTE_HOST; - - /** List of locales in descending order */ - private final Vector locales = new Vector(); - - private boolean secure = false; - - private final ServletContext servletContext; - - private int remotePort = DEFAULT_SERVER_PORT; - - private String localName = DEFAULT_SERVER_NAME; - - private String localAddr = DEFAULT_SERVER_ADDR; - - private int localPort = DEFAULT_SERVER_PORT; - - - //--------------------------------------------------------------------- - // HttpServletRequest properties - //--------------------------------------------------------------------- - - private String authType; - - private Cookie[] cookies; - - /** - * The key is the lowercase header name; the value is a {@link HeaderValueHolder} object. - */ - private final Hashtable headers = new Hashtable(); - - private String method; - - private String pathInfo; - - private String contextPath = ""; - - private String queryString; - - private String remoteUser; - - private final Set userRoles = new HashSet(); - - private Principal userPrincipal; - - private String requestURI; - - private String servletPath = ""; - - private HttpSession session; - - private boolean requestedSessionIdValid = true; - - private boolean requestedSessionIdFromCookie = true; - - private boolean requestedSessionIdFromURL = false; - - - //--------------------------------------------------------------------- - // Constructors - //--------------------------------------------------------------------- - - /** - * Create a new MockHttpServletRequest with a default - * {@link MockServletContext}. - * @see MockServletContext - */ - public MockHttpServletRequest() { - this(null, "", ""); - } - - /** - * Create a new MockHttpServletRequest with a default - * {@link MockServletContext}. - * @param method the request method (may be null) - * @param requestURI the request URI (may be null) - * @see #setMethod - * @see #setRequestURI - * @see MockServletContext - */ - public MockHttpServletRequest(String method, String requestURI) { - this(null, method, requestURI); - } - - /** - * Create a new MockHttpServletRequest. - * @param servletContext the ServletContext that the request runs in - * (may be null to use a default MockServletContext) - * @see MockServletContext - */ - public MockHttpServletRequest(ServletContext servletContext) { - this(servletContext, "", ""); - } - - /** - * Create a new MockHttpServletRequest. - * @param servletContext the ServletContext that the request runs in - * (may be null to use a default MockServletContext) - * @param method the request method (may be null) - * @param requestURI the request URI (may be null) - * @see #setMethod - * @see #setRequestURI - * @see MockServletContext - */ - public MockHttpServletRequest(ServletContext servletContext, String method, String requestURI) { - this.servletContext = (servletContext != null ? servletContext : new MockServletContext()); - this.method = method; - this.requestURI = requestURI; - this.locales.add(Locale.ENGLISH); - } - - - //--------------------------------------------------------------------- - // Lifecycle methods - //--------------------------------------------------------------------- - - /** - * Return the ServletContext that this request is associated with. - * (Not available in the standard HttpServletRequest interface for some reason.) - */ - public ServletContext getServletContext() { - return this.servletContext; - } - - /** - * Return whether this request is still active (that is, not completed yet). - */ - public boolean isActive() { - return this.active; - } - - /** - * Mark this request as completed, keeping its state. - */ - public void close() { - this.active = false; - } - - /** - * Invalidate this request, clearing its state. - */ - public void invalidate() { - close(); - clearAttributes(); - } - - /** - * Check whether this request is still active (that is, not completed yet), - * throwing an IllegalStateException if not active anymore. - */ - protected void checkActive() throws IllegalStateException { - if (!this.active) { - throw new IllegalStateException("Request is not active anymore"); - } - } - - - //--------------------------------------------------------------------- - // ServletRequest interface - //--------------------------------------------------------------------- - - public Object getAttribute(String name) { - checkActive(); - return this.attributes.get(name); - } - - public Enumeration getAttributeNames() { - checkActive(); - return this.attributes.keys(); - } - - public String getCharacterEncoding() { - return this.characterEncoding; - } - - public void setCharacterEncoding(String characterEncoding) { - this.characterEncoding = characterEncoding; - } - - public void setContent(byte[] content) { - this.content = content; - } - - public int getContentLength() { - return (this.content != null ? this.content.length : -1); - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public String getContentType() { - return this.contentType; - } - - public ServletInputStream getInputStream() { - if (this.content != null) { - return new DelegatingServletInputStream(new ByteArrayInputStream(this.content)); - } - else { - return null; - } - } - - /** - * Set a single value for the specified HTTP parameter. - *

If there are already one or more values registered for the given - * parameter name, they will be replaced. - */ - public void setParameter(String name, String value) { - setParameter(name, new String[] {value}); - } - - /** - * Set an array of values for the specified HTTP parameter. - *

If there are already one or more values registered for the given - * parameter name, they will be replaced. - */ - public void setParameter(String name, String[] values) { - Assert.notNull(name, "Parameter name must not be null"); - this.parameters.put(name, values); - } - - /** - * Sets all provided parameters replacing any - * existing values for the provided parameter names. To add without - * replacing existing values, use {@link #addParameters(java.util.Map)}. - */ - public void setParameters(Map params) { - Assert.notNull(params, "Parameter map must not be null"); - for (Object key : params.keySet()) { - Assert.isInstanceOf(String.class, key, - "Parameter map key must be of type [" + String.class.getName() + "]"); - Object value = params.get(key); - if (value instanceof String) { - this.setParameter((String) key, (String) value); - } - else if (value instanceof String[]) { - this.setParameter((String) key, (String[]) value); - } - else { - throw new IllegalArgumentException( - "Parameter map value must be single value " + " or array of type [" + String.class.getName() + - "]"); - } - } - } - - /** - * Add a single value for the specified HTTP parameter. - *

If there are already one or more values registered for the given - * parameter name, the given value will be added to the end of the list. - */ - public void addParameter(String name, String value) { - addParameter(name, new String[] {value}); - } - - /** - * Add an array of values for the specified HTTP parameter. - *

If there are already one or more values registered for the given - * parameter name, the given values will be added to the end of the list. - */ - public void addParameter(String name, String[] values) { - Assert.notNull(name, "Parameter name must not be null"); - String[] oldArr = this.parameters.get(name); - if (oldArr != null) { - String[] newArr = new String[oldArr.length + values.length]; - System.arraycopy(oldArr, 0, newArr, 0, oldArr.length); - System.arraycopy(values, 0, newArr, oldArr.length, values.length); - this.parameters.put(name, newArr); - } - else { - this.parameters.put(name, values); - } - } - - /** - * Adds all provided parameters without replacing - * any existing values. To replace existing values, use - * {@link #setParameters(java.util.Map)}. - */ - public void addParameters(Map params) { - Assert.notNull(params, "Parameter map must not be null"); - for (Object key : params.keySet()) { - Assert.isInstanceOf(String.class, key, - "Parameter map key must be of type [" + String.class.getName() + "]"); - Object value = params.get(key); - if (value instanceof String) { - this.addParameter((String) key, (String) value); - } - else if (value instanceof String[]) { - this.addParameter((String) key, (String[]) value); - } - else { - throw new IllegalArgumentException("Parameter map value must be single value " + - " or array of type [" + String.class.getName() + "]"); - } - } - } - - /** - * Remove already registered values for the specified HTTP parameter, if any. - */ - public void removeParameter(String name) { - Assert.notNull(name, "Parameter name must not be null"); - this.parameters.remove(name); - } - - /** - * Removes all existing parameters. - */ - public void removeAllParameters() { - this.parameters.clear(); - } - - public String getParameter(String name) { - Assert.notNull(name, "Parameter name must not be null"); - String[] arr = this.parameters.get(name); - return (arr != null && arr.length > 0 ? arr[0] : null); - } - - public Enumeration getParameterNames() { - return Collections.enumeration(this.parameters.keySet()); - } - - public String[] getParameterValues(String name) { - Assert.notNull(name, "Parameter name must not be null"); - return this.parameters.get(name); - } - - public Map getParameterMap() { - return Collections.unmodifiableMap(this.parameters); - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getProtocol() { - return this.protocol; - } - - public void setScheme(String scheme) { - this.scheme = scheme; - } - - public String getScheme() { - return this.scheme; - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public String getServerName() { - return this.serverName; - } - - public void setServerPort(int serverPort) { - this.serverPort = serverPort; - } - - public int getServerPort() { - return this.serverPort; - } - - public BufferedReader getReader() throws UnsupportedEncodingException { - if (this.content != null) { - InputStream sourceStream = new ByteArrayInputStream(this.content); - Reader sourceReader = (this.characterEncoding != null) ? - new InputStreamReader(sourceStream, this.characterEncoding) : new InputStreamReader(sourceStream); - return new BufferedReader(sourceReader); - } - else { - return null; - } - } - - public void setRemoteAddr(String remoteAddr) { - this.remoteAddr = remoteAddr; - } - - public String getRemoteAddr() { - return this.remoteAddr; - } - - public void setRemoteHost(String remoteHost) { - this.remoteHost = remoteHost; - } - - public String getRemoteHost() { - return this.remoteHost; - } - - public void setAttribute(String name, Object value) { - checkActive(); - Assert.notNull(name, "Attribute name must not be null"); - if (value != null) { - this.attributes.put(name, value); - } - else { - this.attributes.remove(name); - } - } - - public void removeAttribute(String name) { - checkActive(); - Assert.notNull(name, "Attribute name must not be null"); - this.attributes.remove(name); - } - - /** - * Clear all of this request's attributes. - */ - public void clearAttributes() { - this.attributes.clear(); - } - - /** - * Add a new preferred locale, before any existing locales. - */ - public void addPreferredLocale(Locale locale) { - Assert.notNull(locale, "Locale must not be null"); - this.locales.add(0, locale); - } - - public Locale getLocale() { - return (Locale) this.locales.get(0); - } - - public Enumeration getLocales() { - return this.locales.elements(); - } - - public void setSecure(boolean secure) { - this.secure = secure; - } - - public boolean isSecure() { - return this.secure; - } - - public RequestDispatcher getRequestDispatcher(String path) { - return new MockRequestDispatcher(path); - } - - public String getRealPath(String path) { - return this.servletContext.getRealPath(path); - } - - public void setRemotePort(int remotePort) { - this.remotePort = remotePort; - } - - public int getRemotePort() { - return this.remotePort; - } - - public void setLocalName(String localName) { - this.localName = localName; - } - - public String getLocalName() { - return this.localName; - } - - public void setLocalAddr(String localAddr) { - this.localAddr = localAddr; - } - - public String getLocalAddr() { - return this.localAddr; - } - - public void setLocalPort(int localPort) { - this.localPort = localPort; - } - - public int getLocalPort() { - return this.localPort; - } - - - //--------------------------------------------------------------------- - // HttpServletRequest interface - //--------------------------------------------------------------------- - - public void setAuthType(String authType) { - this.authType = authType; - } - - public String getAuthType() { - return this.authType; - } - - public void setCookies(Cookie[] cookies) { - this.cookies = cookies; - } - - public Cookie[] getCookies() { - return this.cookies; - } - - /** - * Add a header entry for the given name. - *

If there was no entry for that header name before, - * the value will be used as-is. In case of an existing entry, - * a String array will be created, adding the given value (more - * specifically, its toString representation) as further element. - *

Multiple values can only be stored as list of Strings, - * following the Servlet spec (see getHeaders accessor). - * As alternative to repeated addHeader calls for - * individual elements, you can use a single call with an entire - * array or Collection of values as parameter. - * @see #getHeaderNames - * @see #getHeader - * @see #getHeaders - * @see #getDateHeader - * @see #getIntHeader - */ - public void addHeader(String name, Object value) { - HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - Assert.notNull(value, "Header value must not be null"); - if (header == null) { - header = new HeaderValueHolder(); - this.headers.put(name, header); - } - if (value instanceof Collection) { - header.addValues((Collection) value); - } - else if (value.getClass().isArray()) { - header.addValueArray(value); - } - else { - header.addValue(value); - } - } - - public long getDateHeader(String name) { - HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - Object value = (header != null ? header.getValue() : null); - if (value instanceof Date) { - return ((Date) value).getTime(); - } - else if (value instanceof Number) { - return ((Number) value).longValue(); - } - else if (value != null) { - throw new IllegalArgumentException( - "Value for header '" + name + "' is neither a Date nor a Number: " + value); - } - else { - return -1L; - } - } - - public String getHeader(String name) { - HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - return (header != null ? header.getValue().toString() : null); - } - - public Enumeration getHeaders(String name) { - HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - return Collections.enumeration(header != null ? header.getValues() : Collections.EMPTY_LIST); - } - - public Enumeration getHeaderNames() { - return this.headers.keys(); - } - - public int getIntHeader(String name) { - HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - Object value = (header != null ? header.getValue() : null); - if (value instanceof Number) { - return ((Number) value).intValue(); - } - else if (value instanceof String) { - return Integer.parseInt((String) value); - } - else if (value != null) { - throw new NumberFormatException("Value for header '" + name + "' is not a Number: " + value); - } - else { - return -1; - } - } - - public void setMethod(String method) { - this.method = method; - } - - public String getMethod() { - return this.method; - } - - public void setPathInfo(String pathInfo) { - this.pathInfo = pathInfo; - } - - public String getPathInfo() { - return this.pathInfo; - } - - public String getPathTranslated() { - return (this.pathInfo != null ? getRealPath(this.pathInfo) : null); - } - - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } - - public String getContextPath() { - return this.contextPath; - } - - public void setQueryString(String queryString) { - this.queryString = queryString; - } - - public String getQueryString() { - return this.queryString; - } - - public void setRemoteUser(String remoteUser) { - this.remoteUser = remoteUser; - } - - public String getRemoteUser() { - return this.remoteUser; - } - - public void addUserRole(String role) { - this.userRoles.add(role); - } - - public boolean isUserInRole(String role) { - return this.userRoles.contains(role); - } - - public void setUserPrincipal(Principal userPrincipal) { - this.userPrincipal = userPrincipal; - } - - public Principal getUserPrincipal() { - return this.userPrincipal; - } - - public String getRequestedSessionId() { - HttpSession session = getSession(); - return (session != null ? session.getId() : null); - } - - public void setRequestURI(String requestURI) { - this.requestURI = requestURI; - } - - public String getRequestURI() { - return this.requestURI; - } - - public StringBuffer getRequestURL() { - StringBuffer url = new StringBuffer(this.scheme); - url.append("://").append(this.serverName).append(':').append(this.serverPort); - url.append(getRequestURI()); - return url; - } - - public void setServletPath(String servletPath) { - this.servletPath = servletPath; - } - - public String getServletPath() { - return this.servletPath; - } - - public void setSession(HttpSession session) { - this.session = session; - if (session instanceof MockHttpSession) { - MockHttpSession mockSession = ((MockHttpSession) session); - mockSession.access(); - } - } - - public HttpSession getSession(boolean create) { - checkActive(); - // Reset session if invalidated. - if (this.session instanceof MockHttpSession && ((MockHttpSession) this.session).isInvalid()) { - this.session = null; - } - // Create new session if necessary. - if (this.session == null && create) { - this.session = new MockHttpSession(this.servletContext); - } - return this.session; - } - - public HttpSession getSession() { - return getSession(true); - } - - public void setRequestedSessionIdValid(boolean requestedSessionIdValid) { - this.requestedSessionIdValid = requestedSessionIdValid; - } - - public boolean isRequestedSessionIdValid() { - return this.requestedSessionIdValid; - } - - public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie) { - this.requestedSessionIdFromCookie = requestedSessionIdFromCookie; - } - - public boolean isRequestedSessionIdFromCookie() { - return this.requestedSessionIdFromCookie; - } - - public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL) { - this.requestedSessionIdFromURL = requestedSessionIdFromURL; - } - - public boolean isRequestedSessionIdFromURL() { - return this.requestedSessionIdFromURL; - } - - public boolean isRequestedSessionIdFromUrl() { - return isRequestedSessionIdFromURL(); - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java b/org.springframework.testsuite/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java deleted file mode 100644 index d5c2531fbde..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2002-2007 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.transaction; - -import org.springframework.transaction.support.AbstractPlatformTransactionManager; -import org.springframework.transaction.support.DefaultTransactionStatus; - -/** - * @author Rod Johnson - * @author Juergen Hoeller - */ -public class CallCountingTransactionManager extends AbstractPlatformTransactionManager { - - public TransactionDefinition lastDefinition; - public int begun; - public int commits; - public int rollbacks; - public int inflight; - - protected Object doGetTransaction() { - return new Object(); - } - - protected void doBegin(Object transaction, TransactionDefinition definition) { - this.lastDefinition = definition; - ++begun; - ++inflight; - } - - protected void doCommit(DefaultTransactionStatus status) { - ++commits; - --inflight; - } - - protected void doRollback(DefaultTransactionStatus status) { - ++rollbacks; - --inflight; - } - - public void clear() { - begun = commits = rollbacks = inflight = 0; - } - -} diff --git a/org.springframework.testsuite/src/test/java/org/springframework/util/SerializationTestUtils.java b/org.springframework.testsuite/src/test/java/org/springframework/util/SerializationTestUtils.java deleted file mode 100644 index dbe6421093e..00000000000 --- a/org.springframework.testsuite/src/test/java/org/springframework/util/SerializationTestUtils.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The Spring Framework is published under the terms - * of the Apache Software License. - */ - -package org.springframework.util; - -import java.awt.Point; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.NotSerializableException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.io.Serializable; - -import junit.framework.TestCase; - -import org.springframework.beans.TestBean; - -/** - * Utilities for testing serializability of objects. - * Exposes static methods for use in other test cases. - * Extends TestCase only to test itself. - * - * @author Rod Johnson - */ -public class SerializationTestUtils extends TestCase { - - public static void testSerialization(Object o) throws IOException { - OutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(o); - } - - public static boolean isSerializable(Object o) throws IOException { - try { - testSerialization(o); - return true; - } - catch (NotSerializableException ex) { - return false; - } - } - - public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(o); - oos.flush(); - baos.flush(); - byte[] bytes = baos.toByteArray(); - - ByteArrayInputStream is = new ByteArrayInputStream(bytes); - ObjectInputStream ois = new ObjectInputStream(is); - Object o2 = ois.readObject(); - - return o2; - } - - public SerializationTestUtils(String s) { - super(s); - } - - public void testWithNonSerializableObject() throws IOException { - TestBean o = new TestBean(); - assertFalse(o instanceof Serializable); - - assertFalse(isSerializable(o)); - - try { - testSerialization(o); - fail(); - } - catch (NotSerializableException ex) { - // Ok - } - } - - public void testWithSerializableObject() throws Exception { - int x = 5; - int y = 10; - Point p = new Point(x, y); - assertTrue(p instanceof Serializable); - - testSerialization(p); - - assertTrue(isSerializable(p)); - - Point p2 = (Point) serializeAndDeserialize(p); - assertNotSame(p, p2); - assertEquals(x, (int) p2.getX()); - assertEquals(y, (int) p2.getY()); - } - -} \ No newline at end of file diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/Colour.java b/org.springframework.testsuite/src/test/java/test/beans/Colour.java similarity index 95% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/Colour.java rename to org.springframework.testsuite/src/test/java/test/beans/Colour.java index 4db722187d9..5be4dfa761a 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/Colour.java +++ b/org.springframework.testsuite/src/test/java/test/beans/Colour.java @@ -14,13 +14,14 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; import org.springframework.core.enums.ShortCodedLabeledEnum; /** * @author Rob Harrop */ +@SuppressWarnings("serial") public class Colour extends ShortCodedLabeledEnum { public static final Colour RED = new Colour(0, "RED"); diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/INestedTestBean.java b/org.springframework.testsuite/src/test/java/test/beans/INestedTestBean.java similarity index 95% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/INestedTestBean.java rename to org.springframework.testsuite/src/test/java/test/beans/INestedTestBean.java index e9d9c581bb4..8167cc05ad3 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/INestedTestBean.java +++ b/org.springframework.testsuite/src/test/java/test/beans/INestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; public interface INestedTestBean { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/IOther.java b/org.springframework.testsuite/src/test/java/test/beans/IOther.java similarity index 95% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/IOther.java rename to org.springframework.testsuite/src/test/java/test/beans/IOther.java index 41f657082c4..e9e0dd23c90 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/IOther.java +++ b/org.springframework.testsuite/src/test/java/test/beans/IOther.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; public interface IOther { diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/ITestBean.java b/org.springframework.testsuite/src/test/java/test/beans/ITestBean.java similarity index 97% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/ITestBean.java rename to org.springframework.testsuite/src/test/java/test/beans/ITestBean.java index 2efb9b7be1b..1eabf181809 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/ITestBean.java +++ b/org.springframework.testsuite/src/test/java/test/beans/ITestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; import java.io.IOException; diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/IndexedTestBean.java b/org.springframework.testsuite/src/test/java/test/beans/IndexedTestBean.java similarity index 71% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/IndexedTestBean.java rename to org.springframework.testsuite/src/test/java/test/beans/IndexedTestBean.java index 4f3012666ea..951b732346a 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/IndexedTestBean.java +++ b/org.springframework.testsuite/src/test/java/test/beans/IndexedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; import java.util.ArrayList; import java.util.Collection; @@ -34,17 +34,17 @@ public class IndexedTestBean { private TestBean[] array; - private Collection collection; + private Collection collection; - private List list; + private List list; - private Set set; + private Set set; - private SortedSet sortedSet; + private SortedSet sortedSet; - private Map map; + private Map map; - private SortedMap sortedMap; + private SortedMap sortedMap; public IndexedTestBean() { @@ -69,17 +69,17 @@ public class IndexedTestBean { TestBean tbX = new TestBean("nameX", 0); TestBean tbY = new TestBean("nameY", 0); this.array = new TestBean[] {tb0, tb1}; - this.list = new ArrayList(); + this.list = new ArrayList(); this.list.add(tb2); this.list.add(tb3); - this.set = new TreeSet(); + this.set = new TreeSet(); this.set.add(tb6); this.set.add(tb7); - this.map = new HashMap(); + this.map = new HashMap(); this.map.put("key1", tb4); this.map.put("key2", tb5); this.map.put("key.3", tb5); - List list = new ArrayList(); + List list = new ArrayList(); list.add(tbX); list.add(tbY); this.map.put("key4", list); @@ -94,51 +94,51 @@ public class IndexedTestBean { this.array = array; } - public Collection getCollection() { + public Collection getCollection() { return collection; } - public void setCollection(Collection collection) { + public void setCollection(Collection collection) { this.collection = collection; } - public List getList() { + public List getList() { return list; } - public void setList(List list) { + public void setList(List list) { this.list = list; } - public Set getSet() { + public Set getSet() { return set; } - public void setSet(Set set) { + public void setSet(Set set) { this.set = set; } - public SortedSet getSortedSet() { + public SortedSet getSortedSet() { return sortedSet; } - public void setSortedSet(SortedSet sortedSet) { + public void setSortedSet(SortedSet sortedSet) { this.sortedSet = sortedSet; } - public Map getMap() { + public Map getMap() { return map; } - public void setMap(Map map) { + public void setMap(Map map) { this.map = map; } - public SortedMap getSortedMap() { + public SortedMap getSortedMap() { return sortedMap; } - public void setSortedMap(SortedMap sortedMap) { + public void setSortedMap(SortedMap sortedMap) { this.sortedMap = sortedMap; } diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/NestedTestBean.java b/org.springframework.testsuite/src/test/java/test/beans/NestedTestBean.java similarity index 97% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/NestedTestBean.java rename to org.springframework.testsuite/src/test/java/test/beans/NestedTestBean.java index 6b545416234..3919cf83837 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/NestedTestBean.java +++ b/org.springframework.testsuite/src/test/java/test/beans/NestedTestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; /** * Simple nested test bean used for testing bean factories, AOP framework etc. diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/Pet.java b/org.springframework.testsuite/src/test/java/test/beans/Pet.java similarity index 97% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/Pet.java rename to org.springframework.testsuite/src/test/java/test/beans/Pet.java index eb78f612fb0..b62b5c8bf3c 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/Pet.java +++ b/org.springframework.testsuite/src/test/java/test/beans/Pet.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; /** * @author Rob Harrop diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/TestBean.java b/org.springframework.testsuite/src/test/java/test/beans/TestBean.java similarity index 89% rename from org.springframework.testsuite/src/test/java/org/springframework/beans/TestBean.java rename to org.springframework.testsuite/src/test/java/test/beans/TestBean.java index c2a39d38788..2c42a8cca50 100644 --- a/org.springframework.testsuite/src/test/java/org/springframework/beans/TestBean.java +++ b/org.springframework.testsuite/src/test/java/test/beans/TestBean.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.beans; +package test.beans; import java.io.IOException; import java.util.ArrayList; @@ -40,7 +40,7 @@ import org.springframework.util.ObjectUtils; * @author Juergen Hoeller * @since 15 April 2001 */ -public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable { +public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable { private String beanName; @@ -70,13 +70,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt private Float myFloat = new Float(0.0); - private Collection friends = new LinkedList(); + private Collection friends = new LinkedList(); - private Set someSet = new HashSet(); + private Set someSet = new HashSet(); - private Map someMap = new HashMap(); + private Map someMap = new HashMap(); - private List someList = new ArrayList(); + private List someList = new ArrayList(); private Properties someProperties = new Properties(); @@ -94,9 +94,9 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt private Boolean someBoolean; - private List otherColours; + private List otherColours; - private List pets; + private List pets; public TestBean() { @@ -120,15 +120,15 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.someProperties = someProperties; } - public TestBean(List someList) { + public TestBean(List someList) { this.someList = someList; } - public TestBean(Set someSet) { + public TestBean(Set someSet) { this.someSet = someSet; } - public TestBean(Map someMap) { + public TestBean(Map someMap) { this.someMap = someMap; } @@ -262,35 +262,35 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.myFloat = myFloat; } - public Collection getFriends() { + public Collection getFriends() { return friends; } - public void setFriends(Collection friends) { + public void setFriends(Collection friends) { this.friends = friends; } - public Set getSomeSet() { + public Set getSomeSet() { return someSet; } - public void setSomeSet(Set someSet) { + public void setSomeSet(Set someSet) { this.someSet = someSet; } - public Map getSomeMap() { + public Map getSomeMap() { return someMap; } - public void setSomeMap(Map someMap) { + public void setSomeMap(Map someMap) { this.someMap = someMap; } - public List getSomeList() { + public List getSomeList() { return someList; } - public void setSomeList(List someList) { + public void setSomeList(List someList) { this.someList = someList; } @@ -350,19 +350,19 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.nestedIndexedBean = nestedIndexedBean; } - public List getOtherColours() { + public List getOtherColours() { return otherColours; } - public void setOtherColours(List otherColours) { + public void setOtherColours(List otherColours) { this.otherColours = otherColours; } - public List getPets() { + public List getPets() { return pets; } - public void setPets(List pets) { + public void setPets(List pets) { this.pets = pets; } diff --git a/org.springframework.testsuite/src/test/java/test/interceptor/SerializableNopInterceptor.java b/org.springframework.testsuite/src/test/java/test/interceptor/SerializableNopInterceptor.java index 3af0cbc2962..58b9fce2095 100644 --- a/org.springframework.testsuite/src/test/java/test/interceptor/SerializableNopInterceptor.java +++ b/org.springframework.testsuite/src/test/java/test/interceptor/SerializableNopInterceptor.java @@ -25,6 +25,7 @@ import java.io.Serializable; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class SerializableNopInterceptor extends NopInterceptor implements Serializable { /**