From 517ebd1d3e56077e7061488dbb8a7e4cb047f610 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 24 Mar 2016 19:22:49 +0100 Subject: [PATCH] Consistent formatting --- .../aspectj/AspectJAfterReturningAdvice.java | 4 +- ...ctJAdviceParameterNameDiscovererTests.java | 3 +- ...hodInvocationProceedingJoinPointTests.java | 3 +- .../TrickyAspectJPointcutExpressionTests.java | 35 ++- .../interceptor/DebugInterceptorTests.java | 3 +- .../SimpleTraceInterceptorTests.java | 3 +- .../target/ThreadLocalTargetSourceTests.java | 3 +- .../AnnotationAsyncExecutionAspectTests.java | 3 +- .../config/FieldRetrievingFactoryBean.java | 4 +- .../ServiceLocatorFactoryBeanTests.java | 18 +- .../security/CallbacksSecurityTests.java | 33 ++- .../factory/xml/DuplicateBeanIdTests.java | 3 +- .../propertyeditors/CustomEditorTests.java | 3 +- .../beans/CollectingReaderEventListener.java | 2 +- .../AspectAndAdvicePrecedenceTests.java | 8 +- .../AspectJAutoProxyCreatorTests.java | 10 +- .../autoproxy/spr3064/SPR3064Tests.java | 10 +- .../aop/framework/AbstractAopProxyTests.java | 3 +- .../config/AbstractCacheAnnotationTests.java | 6 +- .../cache/config/CacheAdviceParserTests.java | 5 +- .../PropertySourceAnnotationTests.java | 2 +- .../ConfigurationClassProcessingTests.java | 2 +- .../annotation/spr10546/Spr10546Tests.java | 2 +- .../expression/FactoryBeanAccessTests.java | 3 +- ...erializableBeanFactoryMemoryLeakTests.java | 6 +- .../access/MBeanClientInterceptorTests.java | 12 +- .../RemoteMBeanClientInterceptorTests.java | 3 +- .../jmx/export/NotificationListenerTests.java | 9 +- .../ConnectorServerFactoryBeanTests.java | 15 +- ...MBeanServerConnectionFactoryBeanTests.java | 9 +- .../remoting/rmi/RmiSupportTests.java | 3 +- ...heduledTasksBeanDefinitionParserTests.java | 6 +- .../jruby/AdvisedJRubyScriptFactoryTests.java | 6 +- .../org/springframework/util/DigestUtils.java | 4 +- .../org/springframework/util/MimeType.java | 2 +- .../core/GenericTypeResolverTests.java | 2 +- .../core/env/PropertySourceTests.java | 3 +- ...etadataReadingVisitorMemberClassTests.java | 3 +- .../org/springframework/tests/Matchers.java | 2 +- .../org/springframework/tests/TestGroup.java | 3 +- .../util/AutoPopulatingListTests.java | 4 +- .../util/FastByteArrayOutputStreamTests.java | 2 +- .../ResizableByteArrayOutputStreamTests.java | 2 +- .../SettableListenableFutureTests.java | 15 +- .../xml/AbstractStaxXMLReaderTestCase.java | 8 +- .../expression/spel/CodeFlow.java | 2 +- .../expression/spel/EvaluationTests.java | 114 ++++---- .../spel/ExpressionLanguageScenarioTests.java | 15 +- .../expression/spel/ExpressionStateTests.java | 12 +- .../expression/spel/IndexingTests.java | 20 +- .../spel/OperatorOverloaderTests.java | 49 ++-- .../expression/spel/ParsingTests.java | 3 +- .../expression/spel/PropertyAccessTests.java | 36 ++- .../spel/ScenariosForSpringSecurity.java | 9 +- .../spel/SelectionAndProjectionTests.java | 3 +- .../expression/spel/SetValueTests.java | 31 +- .../spel/SpelCompilationCoverageTests.java | 6 +- .../spel/SpelCompilationPerformanceTests.java | 267 +++++++++--------- .../expression/spel/SpelReproTests.java | 6 +- .../spel/StandardTypeLocatorTests.java | 3 +- .../spel/VariableAndFunctionTests.java | 7 +- .../spel/standard/SpelParserTests.java | 61 ++-- .../jdbc/core/JdbcTemplate.java | 3 +- .../jdbc/core/JdbcTemplateQueryTests.java | 3 +- .../DataSourceJtaTransactionTests.java | 9 +- .../DataSourceTransactionManagerTests.java | 4 +- .../BeanFactoryDataSourceLookupTests.java | 5 +- .../jdbc/object/StoredProcedureTests.java | 2 +- .../rowset/ResultSetWrappingRowSetTests.java | 3 +- .../adapter/MessageListenerAdapterTests.java | 12 +- .../support/SimpleMessageConverterTests.java | 30 +- .../invocation/MethodMessageHandlerTests.java | 2 +- .../stomp/Reactor2TcpStompClientTests.java | 22 +- ...erRelayMessageHandlerIntegrationTests.java | 2 +- .../messaging/simp/stomp/StompCodecTests.java | 3 +- .../HibernateJtaTransactionTests.java | 19 +- .../mock/web/MockFilterChainTests.java | 6 +- .../result/StatusResultMatchersTests.java | 6 +- .../cors/UrlBasedCorsConfigurationSource.java | 2 +- .../web/method/annotation/ModelFactory.java | 26 +- .../web/util/HierarchicalUriComponents.java | 2 +- .../ProtobufHttpMessageConverterTests.java | 3 +- .../request/async/WebAsyncManagerTests.java | 16 +- .../web/context/support/Spr8510Tests.java | 15 +- .../web/util/Log4jWebConfigurerTests.java | 6 +- .../XmlPortletApplicationContextTests.java | 2 +- .../mvc/PortletWrappingControllerTests.java | 6 +- .../web/portlet/util/PortletUtilsTests.java | 5 +- .../resource/ResourceHttpRequestHandler.java | 4 +- .../servlet/resource/ResourceUrlProvider.java | 2 +- .../resource/VersionResourceResolver.java | 4 +- ...tationDrivenBeanDefinitionParserTests.java | 3 +- .../servlet/support/FlashMapManagerTests.java | 2 +- .../web/servlet/tags/form/OptionTagTests.java | 6 +- .../tags/form/PasswordInputTagTests.java | 3 +- .../view/script/ScriptTemplateViewTests.java | 4 +- .../frame/AbstractSockJsMessageCodec.java | 2 +- .../web/socket/ContextLoaderTestUtils.java | 3 +- ...currentWebSocketSessionDecoratorTests.java | 4 +- .../client/RestTemplateXhrTransportTests.java | 2 +- ...TransactionManagementIntegrationTests.java | 3 +- 101 files changed, 681 insertions(+), 509 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java index 40a547560cd..92f9cb4ad92 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -101,7 +101,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice else if (Object.class == type && void.class == method.getReturnType()) { return true; } - else{ + else { return ClassUtils.isAssignable(type, method.getReturnType()); } } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java index 5167b5d76cd..3a365963841 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java @@ -307,7 +307,8 @@ public class AspectJAdviceParameterNameDiscovererTests { try { discoverer.getParameterNames(m); fail("Expecting " + exceptionType.getName() + " with message '" + message + "'"); - } catch (RuntimeException expected) { + } + catch (RuntimeException expected) { assertEquals("Expecting exception of type " + exceptionType.getName(), exceptionType, expected.getClass()); assertEquals("Exception message does not match expected", message, expected.getMessage()); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index c4b1caac4ba..f8c39e7b44e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -215,7 +215,8 @@ public final class MethodInvocationProceedingJoinPointTests { itb.setSpouse(new TestBean()); try { itb.unreliableFileOperation(); - } catch (IOException ex) { + } + catch (IOException ex) { // we don't realy care... } } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java index 22ef9db88eb..8a9d63a4b96 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2016 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.aop.aspectj; import java.lang.annotation.Documented; @@ -97,12 +113,14 @@ public class TrickyAspectJPointcutExpressionTests { try { bean.sayHello(); fail("Expected exception"); - } catch (TestException e) { - assertEquals(message, e.getMessage()); + } + catch (TestException ex) { + assertEquals(message, ex.getMessage()); } assertEquals(1, logAdvice.getCountThrows()); } + public static class SimpleThrowawayClassLoader extends OverridingClassLoader { /** @@ -115,15 +133,16 @@ public class TrickyAspectJPointcutExpressionTests { } + @SuppressWarnings("serial") public static class TestException extends RuntimeException { public TestException(String string) { super(string); } - } + @Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented @@ -131,18 +150,23 @@ public class TrickyAspectJPointcutExpressionTests { public static @interface Log { } + public static interface TestService { + public String sayHello(); } + @Log public static class TestServiceImpl implements TestService { + @Override public String sayHello() { throw new TestException("TestServiceImpl"); } } + public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice { private int countBefore = 0; @@ -154,9 +178,9 @@ public class TrickyAspectJPointcutExpressionTests { countBefore++; } - public void afterThrowing(Exception e) throws Throwable { + public void afterThrowing(Exception ex) throws Throwable { countThrows++; - throw e; + throw ex; } public int getCountBefore() { @@ -171,7 +195,6 @@ public class TrickyAspectJPointcutExpressionTests { countThrows = 0; countBefore = 0; } - } } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java index 5096fe88dd7..a824083968a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java @@ -61,7 +61,8 @@ public final class DebugInterceptorTests { try { interceptor.invoke(methodInvocation); fail("Must have propagated the IllegalArgumentException."); - } catch (IllegalArgumentException expected) { + } + catch (IllegalArgumentException expected) { } checkCallCountTotal(interceptor); diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java index 5bdeb414dff..3b811b24431 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java @@ -60,7 +60,8 @@ public final class SimpleTraceInterceptorTests { try { interceptor.invokeUnderTrace(mi, log); fail("Must have propagated the IllegalArgumentException."); - } catch (IllegalArgumentException expected) { + } + catch (IllegalArgumentException expected) { } verify(log).trace(anyString()); diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index e805401ba5f..a7890cde605 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -154,7 +154,8 @@ public class ThreadLocalTargetSourceTests { // try second time try { source.getTarget(); - } catch(NullPointerException ex) { + } + catch (NullPointerException ex) { fail("Should not throw NPE"); } } diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java index d1715d7c653..1d7d1af4a0b 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java @@ -210,7 +210,8 @@ public class AnnotationAsyncExecutionAspectTests { public synchronized void waitForCompletion() { try { wait(WAIT_TIME); - } catch (InterruptedException e) { + } + catch (InterruptedException ex) { fail("Didn't finish the async job in " + WAIT_TIME + " milliseconds"); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index aca839616c3..6f035c17327 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -204,7 +204,7 @@ public class FieldRetrievingFactoryBean // instance field return this.fieldObject.get(this.targetObject); } - else{ + else { // class field return this.fieldObject.get(null); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java index 062f7757117..e360a669fec 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java @@ -81,19 +81,22 @@ public final class ServiceLocatorFactoryBeanTests { TestServiceLocator factory = (TestServiceLocator) bf.getBean("factory"); factory.getTestService(); fail("Must fail on more than one matching type"); - } catch (NoSuchBeanDefinitionException ex) { /* expected */ } + } + catch (NoSuchBeanDefinitionException ex) { /* expected */ } try { TestServiceLocator2 factory = (TestServiceLocator2) bf.getBean("factory2"); factory.getTestService(null); fail("Must fail on more than one matching type"); - } catch (NoSuchBeanDefinitionException ex) { /* expected */ } + } + catch (NoSuchBeanDefinitionException ex) { /* expected */ } try { TestService2Locator factory = (TestService2Locator) bf.getBean("factory3"); factory.getTestService(); fail("Must fail on no matching types"); - } catch (NoSuchBeanDefinitionException ex) { /* expected */ } + } + catch (NoSuchBeanDefinitionException ex) { /* expected */ } } @Test @@ -138,7 +141,8 @@ public final class ServiceLocatorFactoryBeanTests { TestService2Locator factory3 = (TestService2Locator) bf.getBean("factory3"); factory3.getTestService(); fail("Must fail on no matching type"); - } catch (CustomServiceLocatorException3 ex) { /* expected */ } + } + catch (CustomServiceLocatorException3 ex) { /* expected */ } } @Test @@ -160,7 +164,8 @@ public final class ServiceLocatorFactoryBeanTests { try { factory.getTestService("bogusTestService"); fail("Illegal operation allowed"); - } catch (NoSuchBeanDefinitionException ex) { /* expected */ } + } + catch (NoSuchBeanDefinitionException ex) { /* expected */ } } @Ignore @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory @@ -275,7 +280,8 @@ public final class ServiceLocatorFactoryBeanTests { try { ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); factory.setBeanFactory(beanFactory); - } catch (FatalBeanException ex) { + } + catch (FatalBeanException ex) { // expected } } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index 42bb23346b6..73cf1ffc789 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -324,7 +324,8 @@ public class CallbacksSecurityTests { try { acc.checkPermission(new PropertyPermission("*", "read")); fail("Acc should not have any permissions"); - } catch (SecurityException se) { + } + catch (SecurityException se) { // expected } @@ -342,7 +343,8 @@ public class CallbacksSecurityTests { } }, acc); fail("expected security exception"); - } catch (Exception ex) { + } + catch (Exception ex) { } final Class cl = ConstructorBean.class; @@ -356,7 +358,8 @@ public class CallbacksSecurityTests { } }, acc); fail("expected security exception"); - } catch (Exception ex) { + } + catch (Exception ex) { } } @@ -365,7 +368,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("spring-init"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getCause() instanceof SecurityException); } } @@ -375,7 +379,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("custom-init"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getCause() instanceof SecurityException); } } @@ -399,7 +404,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("spring-factory"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getCause() instanceof SecurityException); } @@ -416,7 +422,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("custom-static-factory-method"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getMostSpecificCause() instanceof SecurityException); } } @@ -426,7 +433,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("custom-factory-method"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getMostSpecificCause() instanceof SecurityException); } } @@ -436,7 +444,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("privileged-static-factory-method"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getMostSpecificCause() instanceof SecurityException); } } @@ -446,7 +455,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("constructor"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { // expected assertTrue(ex.getMostSpecificCause() instanceof SecurityException); } @@ -472,7 +482,8 @@ public class CallbacksSecurityTests { try { beanFactory.getBean("property-injection"); fail("expected security exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getMessage().contains("security")); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 04c31efe66c..a42359b98b8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -48,7 +48,8 @@ public class DuplicateBeanIdTests { try { reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-sameLevel-context.xml", this.getClass())); fail("expected parsing exception due to duplicate ids in same nesting level"); - } catch (Exception ex) { + } + catch (Exception ex) { // expected } } diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index 5f233a66135..806b6f3fa2f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -485,7 +485,8 @@ public class CustomEditorTests { CustomNumberEditor editor = new CustomNumberEditor(Short.class, true); editor.setAsText(String.valueOf(Short.MAX_VALUE + 1)); fail(Short.MAX_VALUE + 1 + " is greater than max value"); - } catch (NumberFormatException ex) { + } + catch (NumberFormatException ex) { // expected } } diff --git a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java b/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java index b7fa67912c1..2d42dd5637c 100644 --- a/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java +++ b/spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java @@ -70,7 +70,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { @Override public void aliasRegistered(AliasDefinition aliasDefinition) { List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName()); - if(aliases == null) { + if (aliases == null) { aliases = new ArrayList(); this.aliasMap.put(aliasDefinition.getBeanName(), aliases); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java index 2e4cfe2faf5..99bde98e650 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java @@ -186,7 +186,9 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered { try { ret = ((Integer)pjp.proceed()).intValue(); } - catch(Throwable t) { throw new RuntimeException(t); } + catch (Throwable t) { + throw new RuntimeException(t); + } this.collaborator.aroundAdviceOne(this.name); return ret; } @@ -197,7 +199,9 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered { try { ret = ((Integer)pjp.proceed()).intValue(); } - catch(Throwable t) {throw new RuntimeException(t);} + catch (Throwable t) { + throw new RuntimeException(t); + } this.collaborator.aroundAdviceTwo(this.name); return ret; } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index d1c2e3f0dd4..c753fd9f1b5 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -513,11 +513,13 @@ class RetryAspect { try { o = jp.proceed(); this.commitCalls++; - } catch (RetryableException e) { - this.rollbackCalls++; - throw e; } - } catch (RetryableException re) { + catch (RetryableException re) { + this.rollbackCalls++; + throw re; + } + } + catch (RetryableException re) { retry = true; } } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java index e2cf01144c3..b4229d15ede 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java @@ -1,5 +1,5 @@ /** - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.aop.aspectj.autoproxy.spr3064; import java.lang.annotation.Retention; @@ -35,6 +36,7 @@ public final class SPR3064Tests { private Service service; + @Test public void testServiceIsAdvised() { ClassPathXmlApplicationContext ctx = @@ -46,7 +48,7 @@ public final class SPR3064Tests { this.service.serveMe(); fail("service operation has not been advised by transaction interceptor"); } - catch(RuntimeException ex) { + catch (RuntimeException ex) { assertEquals("advice invoked",ex.getMessage()); } } @@ -56,7 +58,6 @@ public final class SPR3064Tests { @Retention(RetentionPolicy.RUNTIME) @interface Transaction { - } @@ -68,14 +69,12 @@ class TransactionInterceptor { throw new RuntimeException("advice invoked"); //return pjp.proceed(); } - } interface Service { void serveMe(); - } @@ -85,5 +84,4 @@ class ServiceImpl implements Service { @Transaction public void serveMe() { } - } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 3114bf62a8e..09b73f1c3aa 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -400,7 +400,8 @@ public abstract class AbstractAopProxyTests { public Object invoke(MethodInvocation invocation) throws Throwable { if (!context) { assertNoInvocationContext(); - } else { + } + else { assertNotNull("have context", ExposeInvocationInterceptor.currentInvocation()); } return s; diff --git a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java b/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java index fdf86d0690f..8a00e7358a3 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java @@ -354,7 +354,8 @@ public abstract class AbstractCacheAnnotationTests { try { service.throwCheckedSync(arg); fail("Excepted exception"); - } catch (Exception ex) { + } + catch (Exception ex) { ex.printStackTrace(); assertEquals("Wrong exception type", IOException.class, ex.getClass()); assertEquals(arg, ex.getMessage()); @@ -365,7 +366,8 @@ public abstract class AbstractCacheAnnotationTests { try { service.throwUncheckedSync(Long.valueOf(1)); fail("Excepted exception"); - } catch (RuntimeException ex) { + } + catch (RuntimeException ex) { assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass()); assertEquals("1", ex.getMessage()); } diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java index 5e624bda4ef..3d461ce3126 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java @@ -35,7 +35,10 @@ public class CacheAdviceParserTests { try { new GenericXmlApplicationContext("/org/springframework/cache/config/cache-advice-invalid.xml"); fail("Should have failed to load context, one advise define both a key and a key generator"); - } catch (BeanDefinitionStoreException e) { // TODO better exception handling + } + catch (BeanDefinitionStoreException ex) { + // TODO better exception handling } } + } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index 6b347b04514..b20afea1814 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java @@ -72,7 +72,7 @@ public class PropertySourceAnnotationTests { do { name = iterator.next().getName(); } - while(iterator.hasNext()); + while (iterator.hasNext()); assertThat(name, is("p1")); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index 04fa5290e23..498453338e7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -117,7 +117,7 @@ public class ConfigurationClassProcessingTests { BeanFactory factory = initBeanFactory(ConfigWithBeanWithAliases.class); assertSame(factory.getBean("name1"), ConfigWithBeanWithAliases.testBean); String[] aliases = factory.getAliases("name1"); - for(String alias : aliases) + for (String alias : aliases) assertSame(factory.getBean(alias), ConfigWithBeanWithAliases.testBean); // method name should not be registered diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java index d02b2ba3ba9..758fa053beb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java @@ -37,7 +37,7 @@ public class Spr10546Tests { @After public void closeContext() { - if(context != null) { + if (context != null) { context.close(); } } diff --git a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java index 60309a87b09..e1e1ca3e5ca 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java @@ -53,7 +53,8 @@ public class FactoryBeanAccessTests { try { assertEquals(Boat.class.getName(), expr.getValue(context)); fail("Expected BeanIsNotAFactoryException"); - } catch (BeanIsNotAFactoryException binafe) { + } + catch (BeanIsNotAFactoryException binafe) { // success } diff --git a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java index 527ca333dc7..7e2c8b86fee 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java @@ -85,9 +85,11 @@ public class SerializableBeanFactoryMemoryLeakTests { ctx.refresh(); assertThat(serializableFactoryCount(), equalTo(1)); ctx.close(); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { // ignore - this is expected on refresh() for failure case tests - } finally { + } + finally { assertThat(serializableFactoryCount(), equalTo(0)); } } diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java index 90fb6f9633a..5d32d0a9262 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java @@ -196,7 +196,8 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests { // now start the connector try { connector.start(); - } catch (BindException ex) { + } + catch (BindException ex) { System.out.println("Skipping remainder of JMX LazyConnectionToRemote test because binding to local port [" + port + "] failed: " + ex.getMessage()); return; @@ -206,13 +207,15 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests { try { assertEquals("Rob Harrop", bean.getName()); assertEquals(100, bean.getAge()); - } finally { + } + finally { connector.stop(); } try { bean.getName(); - } catch (JmxException ex) { + } + catch (JmxException ex) { // expected } @@ -223,7 +226,8 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests { try { assertEquals("Rob Harrop", bean.getName()); assertEquals(100, bean.getAge()); - } finally { + } + finally { connector.stop(); } } diff --git a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java index d34d6204191..4c3299bea51 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java @@ -63,7 +63,8 @@ public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTes this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer()); try { this.connectorServer.start(); - } catch (BindException ex) { + } + catch (BindException ex) { System.out.println("Skipping remote JMX tests because binding to local port [" + SERVICE_PORT + "] failed: " + ex.getMessage()); runTests = false; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java index 81dc5307706..149e574c27e 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java @@ -172,7 +172,8 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { if (notification instanceof AttributeChangeNotification) { AttributeChangeNotification changeNotification = (AttributeChangeNotification) notification; return "Name".equals(changeNotification.getAttributeName()); - } else { + } + else { return false; } } @@ -200,7 +201,8 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { try { new NotificationListenerBean().afterPropertiesSet(); fail("Must have thrown an IllegalArgumentException (no NotificationListener supplied)"); - } catch (IllegalArgumentException expected) { + } + catch (IllegalArgumentException expected) { } } @@ -463,7 +465,8 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { if (currentCount != null) { int count = currentCount.intValue() + 1; this.attributeCounts.put(attributeName, new Integer(count)); - } else { + } + else { this.attributeCounts.put(attributeName, new Integer(1)); } diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java index 754e4d22385..34bbb739e2f 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java @@ -67,7 +67,8 @@ public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { try { checkServerConnection(getServer()); - } finally { + } + finally { bean.destroy(); } } @@ -84,7 +85,8 @@ public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { try { checkServerConnection(getServer()); - } finally { + } + finally { bean.destroy(); } } @@ -102,7 +104,8 @@ public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { // Try to get the connector bean. ObjectInstance instance = getServer().getObjectInstance(ObjectName.getInstance(OBJECT_NAME)); assertNotNull("ObjectInstance should not be null", instance); - } finally { + } + finally { bean.destroy(); } } @@ -116,9 +119,11 @@ public class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { // Try to get the connector bean. getServer().getObjectInstance(ObjectName.getInstance(OBJECT_NAME)); fail("Instance should not be found"); - } catch (InstanceNotFoundException ex) { + } + catch (InstanceNotFoundException ex) { // expected - } finally { + } + finally { bean.destroy(); } } diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java index de4746c4e2d..660581261a0 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java @@ -74,10 +74,12 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe // perform simple MBean count test assertEquals("MBean count should be the same", getServer().getMBeanCount(), connection.getMBeanCount()); - } finally { + } + finally { bean.destroy(); } - } finally { + } + finally { connectorServer.stop(); } } @@ -104,7 +106,8 @@ public class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTe connector = getConnectorServer(); connector.start(); assertEquals("Incorrect MBean count", getServer().getMBeanCount(), connection.getMBeanCount()); - } finally { + } + finally { bean.destroy(); if (connector != null) { connector.stop(); diff --git a/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java b/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java index 6debb825a59..a3aba60d4e8 100644 --- a/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java +++ b/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java @@ -30,7 +30,6 @@ import java.rmi.UnknownHostException; import java.rmi.UnmarshalException; import org.aopalliance.intercept.MethodInvocation; - import org.junit.Test; import org.springframework.remoting.RemoteAccessException; @@ -342,7 +341,7 @@ public class RmiSupportTests { client.afterPropertiesSet(); fail("url isn't set, expected IllegalArgumentException"); } - catch(IllegalArgumentException e){ + catch (IllegalArgumentException ex){ // expected } } diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java index 3eef8738c00..191553a8a8d 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java @@ -41,15 +41,19 @@ public class LazyScheduledTasksBeanDefinitionParserTests { while (!task.executed) { try { Thread.sleep(10); - } catch (Exception e) { /* Do Nothing */ } + } + catch (Exception ex) { /* Do Nothing */ } } } + static class Task { + volatile boolean executed = false; public void doWork() { executed = true; } } + } diff --git a/spring-context/src/test/java/org/springframework/scripting/jruby/AdvisedJRubyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/jruby/AdvisedJRubyScriptFactoryTests.java index 368effe854f..10d1391a97b 100644 --- a/spring-context/src/test/java/org/springframework/scripting/jruby/AdvisedJRubyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/jruby/AdvisedJRubyScriptFactoryTests.java @@ -58,7 +58,8 @@ public final class AdvisedJRubyScriptFactoryTests { assertEquals(0, advice.getCalls()); bean.getMessage(); assertEquals(1, advice.getCalls()); - } finally { + } + finally { ctx.close(); } } @@ -76,7 +77,8 @@ public final class AdvisedJRubyScriptFactoryTests { assertEquals(0, advice.getCalls()); bean.getMessage(); assertEquals(1, advice.getCalls()); - } finally { + } + finally { ctx.close(); } } diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 87ca6b852e3..8de0b513cdc 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -127,7 +127,7 @@ public abstract class DigestUtils { ((UpdateMessageDigestInputStream) inputStream).updateMessageDigest(messageDigest); return messageDigest.digest(); } - else{ + else { return messageDigest.digest(StreamUtils.copyToByteArray(inputStream)); } } diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index 2d7480eee29..4b0fa6ac646 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.java @@ -198,7 +198,7 @@ public class MimeType implements Comparable, Serializable { * @see HTTP 1.1, section 2.2 */ private void checkToken(String token) { - for (int i=0; i < token.length(); i++ ) { + for (int i = 0; i < token.length(); i++ ) { char ch = token.charAt(i); if (!TOKEN.get(ch)) { throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + token + "\""); diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 1fed0c5b196..7e7c3d5bece 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -130,7 +130,7 @@ public class GenericTypeResolverTests { Type t = null; Type x = null; for (Map.Entry entry : map.entrySet()) { - if(entry.getKey().toString().equals("T")) { + if (entry.getKey().toString().equals("T")) { t = entry.getValue(); } else { diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index de39c59db42..79dd4f07ddb 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -111,7 +111,8 @@ public class PropertySourceTests { equalTo(String.format("%s [name='%s']", ps.getClass().getSimpleName(), name))); - } finally { + } + finally { logger.setLevel(original); } } diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java index cc4ca072bd4..5553f1707b0 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java @@ -35,7 +35,8 @@ public class ClassMetadataReadingVisitorMemberClassTests MetadataReader reader = new SimpleMetadataReaderFactory().getMetadataReader(clazz.getName()); return reader.getAnnotationMetadata(); - } catch (IOException ex) { + } + catch (IOException ex) { throw new IllegalStateException(ex); } } diff --git a/spring-core/src/test/java/org/springframework/tests/Matchers.java b/spring-core/src/test/java/org/springframework/tests/Matchers.java index 826bd1c7324..346836cbb69 100644 --- a/spring-core/src/test/java/org/springframework/tests/Matchers.java +++ b/spring-core/src/test/java/org/springframework/tests/Matchers.java @@ -51,7 +51,7 @@ public class Matchers { @Override public boolean matches(Object item) { Throwable cause = null; - if(item != null && item instanceof Throwable) { + if (item != null && item instanceof Throwable) { cause = ((Throwable)item).getCause(); } return matcher.matches(cause); diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java index aaf310f4067..f7b8525bc6c 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java @@ -93,7 +93,8 @@ public enum TestGroup { for (String group : value.split(",")) { try { groups.add(valueOf(group.trim().toUpperCase())); - } catch (IllegalArgumentException e) { + } + catch (IllegalArgumentException ex) { throw new IllegalArgumentException(format( "Unable to find test group '%s' when parsing testGroups value: '%s'. " + "Available groups include: [%s]", group.trim(), value, diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index ba0980b60a1..21ce95621fd 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -74,9 +74,9 @@ public class AutoPopulatingListTests { private void doTestWithElementFactory(AutoPopulatingList list) { doTestWithClass(list); - for(int x = 0; x < list.size(); x++) { + for (int x = 0; x < list.size(); x++) { Object element = list.get(x); - if(element instanceof TestObject) { + if (element instanceof TestObject) { assertEquals(x, ((TestObject) element).getAge()); } } diff --git a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java index 9eedeca8ee6..030083efb69 100644 --- a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java +++ b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java @@ -179,7 +179,7 @@ public class FastByteArrayOutputStreamTests { public void updateMessageDigestManyBuffers() throws Exception { StringBuilder builder = new StringBuilder("\"0"); // filling at least one 256 buffer - for( int i=0; i < 30; i++) { + for ( int i = 0; i < 30; i++) { this.os.write(helloBytes); } InputStream inputStream = this.os.getInputStream(); diff --git a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java index ec41e815f34..709b3fb0c5f 100644 --- a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java +++ b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java @@ -54,7 +54,7 @@ public class ResizableByteArrayOutputStreamTests { @Test public void autoGrow() { assertEquals(INITIAL_CAPACITY, this.baos.capacity()); - for(int i = 0; i < 129; i++) { + for (int i = 0; i < 129; i++) { this.baos.write(0); } assertEquals(256, this.baos.capacity()); diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java index 0e87d4e1568..ca0099ea98e 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java @@ -169,7 +169,8 @@ public class SettableListenableFutureTests { try { Thread.sleep(20L); settableListenableFuture.set(string); - } catch (InterruptedException ex) { + } + catch (InterruptedException ex) { throw new RuntimeException(ex); } } @@ -183,7 +184,8 @@ public class SettableListenableFutureTests { try { settableListenableFuture.get(1L, TimeUnit.MILLISECONDS); fail("Expected TimeoutException"); - } catch (TimeoutException ex) { + } + catch (TimeoutException ex) { // expected } } @@ -197,7 +199,8 @@ public class SettableListenableFutureTests { try { Thread.sleep(20L); settableListenableFuture.set(string); - } catch (InterruptedException ex) { + } + catch (InterruptedException ex) { throw new RuntimeException(ex); } } @@ -278,7 +281,8 @@ public class SettableListenableFutureTests { try { Thread.sleep(20L); settableListenableFuture.cancel(true); - } catch (InterruptedException ex) { + } + catch (InterruptedException ex) { throw new RuntimeException(ex); } } @@ -286,7 +290,8 @@ public class SettableListenableFutureTests { try { settableListenableFuture.get(100L, TimeUnit.MILLISECONDS); fail("Expected CancellationException"); - } catch (CancellationException ex) { + } + catch (CancellationException ex) { // expected } } diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java index 9dec693d614..41aa5f25a5f 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java @@ -194,8 +194,8 @@ public abstract class AbstractStaxXMLReaderTestCase { private static class SkipLocatorArgumentsAdapter implements InvocationArgumentsAdapter { @Override public Object[] adaptArguments(Object[] arguments) { - for(int i=0; i[] getSpecificTargetClasses() { - return new Class[] { String.class }; + return new Class[] {String.class}; } @Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { - if (!(target instanceof String)) + if (!(target instanceof String)) { throw new RuntimeException("Assertion Failed! target should be String"); + } return (name.equals("flibbles")); } @Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { - if (!(target instanceof String)) + if (!(target instanceof String)) { throw new RuntimeException("Assertion Failed! target should be String"); + } return (name.equals("flibbles")); } @Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { - if (!name.equals("flibbles")) + if (!name.equals("flibbles")) { throw new RuntimeException("Assertion Failed! name should be flibbles"); + } return new TypedValue(flibbles); } @Override - public void write(EvaluationContext context, Object target, String name, Object newValue) - throws AccessException { - if (!name.equals("flibbles")) + public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { + if (!name.equals("flibbles")) { throw new RuntimeException("Assertion Failed! name should be flibbles"); + } try { flibbles = (Integer) context.getTypeConverter().convertValue(newValue, TypeDescriptor.forObject(newValue), TypeDescriptor.valueOf(Integer.class)); - }catch (EvaluationException e) { + } + catch (EvaluationException ex) { throw new AccessException("Cannot set flibbles to an object of type '" + newValue.getClass() + "'"); } } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java b/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java index 2457a802ae5..ef753aa4a28 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java @@ -61,7 +61,8 @@ public class ScenariosForSpringSecurity extends AbstractExpressionTests { value = expr.getValue(ctx,Boolean.class); assertTrue(value); - } catch (EvaluationException ee) { + } + catch (EvaluationException ee) { ee.printStackTrace(); fail("Unexpected SpelException: " + ee.getMessage()); } @@ -160,10 +161,10 @@ public class ScenariosForSpringSecurity extends AbstractExpressionTests { public String[] getRoles() { return new String[]{"NONE"}; } public boolean hasAnyRole(String... roles) { - if (roles==null) return true; + if (roles == null) return true; String[] myRoles = getRoles(); - for (int i=0;i>"+title+": average for "+count+": compiled="+averageCompiled+"ms interpreted="+averageInterpreted+"ms: compiled takes "+((int)ratio)+"% of the interpreted time"); + logln(">>"+title+": average for "+count+": compiled="+averageCompiled+"ms interpreted="+averageInterpreted+"ms: compiled takes " + ((int)ratio)+"% of the interpreted time"); if (averageCompiled>averageInterpreted) { fail("Compiled version took longer than interpreted! CompiledSpeed=~"+averageCompiled+ "ms InterpretedSpeed="+averageInterpreted+"ms"); @@ -690,7 +690,8 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests { if (noisyTests) { if (message!=null && message.length>0) { System.out.println(message[0]); - } else { + } + else { System.out.println(); } } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index a7351125e38..f697237dd1d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -1968,7 +1968,8 @@ public class SpelReproTests extends AbstractExpressionTests { try { expr = new SpelExpressionParser().parseRaw("&@foo"); fail("Illegal syntax, error expected"); - } catch (SpelParseException spe) { + } + catch (SpelParseException spe) { assertEquals(SpelMessage.INVALID_BEAN_REFERENCE,spe.getMessageCode()); assertEquals(0,spe.getPosition()); } @@ -1976,7 +1977,8 @@ public class SpelReproTests extends AbstractExpressionTests { try { expr = new SpelExpressionParser().parseRaw("@&foo"); fail("Illegal syntax, error expected"); - } catch (SpelParseException spe) { + } + catch (SpelParseException spe) { assertEquals(SpelMessage.INVALID_BEAN_REFERENCE,spe.getMessageCode()); assertEquals(0,spe.getPosition()); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java index 33c5437e1a3..556cbc65d08 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java @@ -49,7 +49,8 @@ public class StandardTypeLocatorTests { try { locator.findType("URL"); fail("Should have failed"); - } catch (EvaluationException ee) { + } + catch (EvaluationException ee) { SpelEvaluationException sEx = (SpelEvaluationException)ee; assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode()); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java index 982c3c2ba60..db6f4fa563d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 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. @@ -78,7 +78,8 @@ public class VariableAndFunctionTests extends AbstractExpressionTests { @SuppressWarnings("unused") Object v = parser.parseRaw("#notStatic()").getValue(ctx); fail("Should have failed with exception - cannot call non static method that way"); - } catch (SpelEvaluationException se) { + } + catch (SpelEvaluationException se) { if (se.getMessageCode() != SpelMessage.FUNCTION_MUST_BE_STATIC) { se.printStackTrace(); fail("Should have failed a message about the function needing to be static, not: " @@ -86,6 +87,8 @@ public class VariableAndFunctionTests extends AbstractExpressionTests { } } } + + // this method is used by the test above public void nonStatic() { } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java index 248dd1c33fe..6993bfc7acc 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -116,9 +116,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("new String"); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.MISSING_CONSTRUCTOR_ARGS, spe.getMessageCode()); assertEquals(10, spe.getPosition()); } @@ -127,9 +128,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("new String(3,"); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS, spe.getMessageCode()); assertEquals(10, spe.getPosition()); } @@ -138,9 +140,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("new String(3"); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS, spe.getMessageCode()); assertEquals(10, spe.getPosition()); } @@ -149,9 +152,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("new String("); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.RUN_OUT_OF_ARGUMENTS, spe.getMessageCode()); assertEquals(10, spe.getPosition()); } @@ -160,9 +164,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("\"abc"); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.NON_TERMINATING_DOUBLE_QUOTED_STRING, spe.getMessageCode()); assertEquals(0, spe.getPosition()); } @@ -171,9 +176,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw("'abc"); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(SpelMessage.NON_TERMINATING_QUOTED_STRING, spe.getMessageCode()); assertEquals(0, spe.getPosition()); } @@ -274,7 +280,8 @@ public class SpelParserTests { try { new SpelExpressionParser().parseRaw("\"double quote: \\\"\\\".\""); fail("Should have failed"); - } catch (SpelParseException spe) { + } + catch (SpelParseException spe) { assertEquals(17, spe.getPosition()); assertEquals(SpelMessage.UNEXPECTED_ESCAPE_CHAR, spe.getMessageCode()); } @@ -401,9 +408,10 @@ public class SpelParserTests { Object o = expr.getValue(); assertEquals(value, o); assertEquals(type, o.getClass()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); + } + catch (Exception ex) { + ex.printStackTrace(); + fail(ex.getMessage()); } } @@ -412,9 +420,10 @@ public class SpelParserTests { SpelExpressionParser parser = new SpelExpressionParser(); parser.parseRaw(expression); fail(); - } catch (ParseException e) { - assertTrue(e instanceof SpelParseException); - SpelParseException spe = (SpelParseException) e; + } + catch (ParseException ex) { + assertTrue(ex instanceof SpelParseException); + SpelParseException spe = (SpelParseException) ex; assertEquals(expectedMessage, spe.getMessageCode()); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index b95d6596f52..ec716dd5134 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -1042,7 +1042,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { result[i] = rowsAffected.get(i); } return result; - } finally { + } + finally { if (pss instanceof ParameterDisposer) { ((ParameterDisposer) pss).cleanupParameters(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java index bbcc5657b69..f8fc598b8bd 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java @@ -150,7 +150,8 @@ public class JdbcTemplateQueryTests { this.thrown.expect(IncorrectResultSizeDataAccessException.class); try { this.template.queryForObject(sql, String.class); - } finally { + } + finally { verify(this.resultSet).close(); verify(this.statement).close(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java index c52477491f4..3cda75ea57c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java @@ -292,13 +292,14 @@ public class DataSourceJtaTransactionTests { assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); verify(userTransaction, times(6)).begin(); verify(transactionManager, times(5)).resume(transaction); - if(rollback) { + if (rollback) { verify(userTransaction, times(5)).commit(); verify(userTransaction).rollback(); - } else { + } + else { verify(userTransaction, times(6)).commit(); } - if(accessAfterResume && !openOuterConnection) { + if (accessAfterResume && !openOuterConnection) { verify(connection, times(7)).close(); } else { @@ -528,7 +529,7 @@ public class DataSourceJtaTransactionTests { assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); verify(userTransaction).begin(); - if(suspendException) { + if (suspendException) { verify(userTransaction).rollback(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index e4ecd2fccc1..211445a15f5 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -152,7 +152,7 @@ public class DataSourceTransactionManagerTests { assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(dsToUse)); assertTrue("Synchronization not active", !TransactionSynchronizationManager.isSynchronizationActive()); - if(autoCommit && (!lazyConnection || createStatement)) { + if (autoCommit && (!lazyConnection || createStatement)) { InOrder ordered = inOrder(con); ordered.verify(con).setAutoCommit(false); ordered.verify(con).commit(); @@ -244,7 +244,7 @@ public class DataSourceTransactionManagerTests { assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds)); assertTrue("Synchronization not active", !TransactionSynchronizationManager.isSynchronizationActive()); - if(autoCommit && (!lazyConnection || createStatement)) { + if (autoCommit && (!lazyConnection || createStatement)) { InOrder ordered = inOrder(con); ordered.verify(con).setAutoCommit(false); ordered.verify(con).rollback(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java index a1b19afacae..3cef22b80ee 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java @@ -63,10 +63,11 @@ public class BeanFactoryDataSourceLookupTests { BeanFactoryDataSourceLookup lookup = new BeanFactoryDataSourceLookup(beanFactory); lookup.getDataSource(DATASOURCE_BEAN_NAME); fail("should have thrown DataSourceLookupFailureException"); - } catch (DataSourceLookupFailureException ex) { /* expected */ } + } + catch (DataSourceLookupFailureException ex) { /* expected */ } } - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testLookupWhereBeanFactoryHasNotBeenSupplied() throws Exception { BeanFactoryDataSourceLookup lookup = new BeanFactoryDataSourceLookup(); lookup.getDataSource(DATASOURCE_BEAN_NAME); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java index 73427778474..073c3e266ea 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java @@ -81,7 +81,7 @@ public class StoredProcedureTests { @After public void verifyClosed() throws Exception { - if(verifyClosedAfter) { + if (verifyClosedAfter) { verify(callableStatement).close(); verify(connection, atLeastOnce()).close(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java index 1637764de6b..0b048d0812c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java @@ -205,7 +205,8 @@ public class ResultSetWrappingRowSetTests { if (arg instanceof String) { given(rset.findColumn((String) arg)).willReturn(1); given(rsetMethod.invoke(rset, 1)).willReturn(ret).willThrow(new SQLException("test")); - } else { + } + else { given(rsetMethod.invoke(rset, arg)).willReturn(ret).willThrow(new SQLException("test")); } rowsetMethod.invoke(rowset, arg); diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java index 3049c7911cd..d085341efb2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java @@ -307,7 +307,8 @@ public class MessageListenerAdapterTests { try { adapter.onMessage(sentTextMessage, session); fail("expected CouldNotSendReplyException with InvalidDestinationException"); - } catch(ReplyFailureException ex) { + } + catch (ReplyFailureException ex) { assertEquals(InvalidDestinationException.class, ex.getCause().getClass()); } @@ -345,7 +346,8 @@ public class MessageListenerAdapterTests { try { adapter.onMessage(sentTextMessage, session); fail("expected CouldNotSendReplyException with JMSException"); - } catch(ReplyFailureException ex) { + } + catch (ReplyFailureException ex) { assertEquals(JMSException.class, ex.getCause().getClass()); } @@ -371,7 +373,8 @@ public class MessageListenerAdapterTests { try { adapter.onMessage(message, session); fail("expected ListenerExecutionFailedException"); - } catch(ListenerExecutionFailedException ex) { /* expected */ } + } + catch (ListenerExecutionFailedException ex) { /* expected */ } } @Test @@ -425,7 +428,8 @@ public class MessageListenerAdapterTests { try { adapter.onMessage(sentTextMessage, session); fail("expected CouldNotSendReplyException with MessageConversionException"); - } catch(ReplyFailureException ex) { + } + catch (ReplyFailureException ex) { assertEquals(MessageConversionException.class, ex.getCause().getClass()); } } diff --git a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java index 1f2fd20d763..91bafe01752 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 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. @@ -45,7 +45,7 @@ import static org.mockito.BDDMockito.*; * @author Rick Evans * @since 18.09.2004 */ -public final class SimpleMessageConverterTests { +public class SimpleMessageConverterTests { @Test public void testStringConversion() throws JMSException { @@ -124,19 +124,18 @@ public final class SimpleMessageConverterTests { assertEquals(content, converter.fromMessage(msg)); } - @Test(expected=MessageConversionException.class) + @Test(expected = MessageConversionException.class) public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception { new SimpleMessageConverter().toMessage(null, null); } - @Test(expected=MessageConversionException.class) + @Test(expected = MessageConversionException.class) public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception { new SimpleMessageConverter().toMessage(new Object(), null); } @Test public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException { - Session session = mock(Session.class); ObjectMessage message = mock(ObjectMessage.class); @@ -147,7 +146,6 @@ public final class SimpleMessageConverterTests { @Test public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException { - Message message = mock(Message.class); SimpleMessageConverter converter = new SimpleMessageConverter(); @@ -157,36 +155,36 @@ public final class SimpleMessageConverterTests { @Test public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException { - MapMessage message = mock(MapMessage.class); - final Session session = mock(Session.class); + Session session = mock(Session.class); given(session.createMapMessage()).willReturn(message); - final Map content = new HashMap(1); + Map content = new HashMap(1); content.put(1, "value1"); - final SimpleMessageConverter converter = new SimpleMessageConverter(); + SimpleMessageConverter converter = new SimpleMessageConverter(); try { converter.toMessage(content, session); fail("expected MessageConversionException"); - } catch (MessageConversionException ex) { /* expected */ } + } + catch (MessageConversionException ex) { /* expected */ } } @Test public void testMapConversionWhereMapHasNNullForKey() throws JMSException { - MapMessage message = mock(MapMessage.class); - final Session session = mock(Session.class); + Session session = mock(Session.class); given(session.createMapMessage()).willReturn(message); - final Map content = new HashMap(1); + Map content = new HashMap(1); content.put(null, "value1"); - final SimpleMessageConverter converter = new SimpleMessageConverter(); + SimpleMessageConverter converter = new SimpleMessageConverter(); try { converter.toMessage(content, session); fail("expected MessageConversionException"); - } catch (MessageConversionException ex) { /* expected */ } + } + catch (MessageConversionException ex) { /* expected */ } } } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java index 6b471b310dd..be385a7cc96 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java @@ -275,7 +275,7 @@ public class MethodMessageHandlerTests { private static Map, Method> initExceptionMappings(Class handlerType) { Map, Method> result = new HashMap, Method>(); for (Method method : MethodIntrospector.selectMethods(handlerType, EXCEPTION_HANDLER_METHOD_FILTER)) { - for(Class exception : getExceptionsFromMethodSignature(method)) { + for (Class exception : getExceptionsFromMethodSignature(method)) { result.put(exception, method); } } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClientTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClientTests.java index 9d8a82e72d2..94bfce4be33 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClientTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,10 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.messaging.simp.stomp; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +package org.springframework.messaging.simp.stomp; import java.lang.reflect.Type; import java.util.ArrayList; @@ -41,6 +39,9 @@ import org.springframework.util.Assert; import org.springframework.util.SocketUtils; import org.springframework.util.concurrent.ListenableFuture; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + /** * Integration tests for {@link Reactor2TcpStompClient}. * @@ -86,7 +87,8 @@ public class Reactor2TcpStompClientTests { public void tearDown() throws Exception { try { this.client.shutdown(); - } catch (Throwable ex) { + } + catch (Throwable ex) { logger.error("Failed to shut client", ex); } final CountDownLatch latch = new CountDownLatch(1); @@ -100,7 +102,6 @@ public class Reactor2TcpStompClientTests { @Test public void publishSubscribe() throws Exception { - String destination = "/topic/foo"; ConsumingHandler consumingHandler1 = new ConsumingHandler(destination); ListenableFuture consumerFuture1 = this.client.connect(consumingHandler1); @@ -146,9 +147,9 @@ public class Reactor2TcpStompClientTests { public void handleTransportError(StompSession session, Throwable exception) { logger.error(exception); } - } + private static class ConsumingHandler extends LoggingSessionHandler { private final List topics; @@ -157,14 +158,12 @@ public class Reactor2TcpStompClientTests { private final List received = new ArrayList<>(); - public ConsumingHandler(String... topics) { Assert.notEmpty(topics); this.topics = Arrays.asList(topics); this.subscriptionLatch = new CountDownLatch(this.topics.size()); } - public List getReceived() { return this.received; } @@ -208,16 +207,15 @@ public class Reactor2TcpStompClientTests { } return true; } - } + private static class ProducingHandler extends LoggingSessionHandler { private final List topics = new ArrayList<>(); private final List payloads = new ArrayList<>(); - public ProducingHandler addToSend(String topic, Object payload) { this.topics.add(topic); this.payloads.add(payload); @@ -226,7 +224,7 @@ public class Reactor2TcpStompClientTests { @Override public void afterConnected(StompSession session, StompHeaders connectedHeaders) { - for (int i=0; i < this.topics.size(); i++) { + for (int i = 0; i < this.topics.size(); i++) { session.send(this.topics.get(i), this.payloads.get(i)); } } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java index c84dc71dab4..9f5cdfd7b3d 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java @@ -326,7 +326,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests { } public boolean matchMessage(Message message) { - for (int i=0 ; i < this.expected.length; i++) { + for (int i = 0 ; i < this.expected.length; i++) { if (this.expected[i].match(message)) { this.actual[i] = message; return true; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java index 3da0df98f9d..b6afa9a7aac 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java @@ -325,7 +325,8 @@ public class StompCodecTests { this.decoder.apply(buffer); if (consumer.arguments.isEmpty()) { return null; - } else { + } + else { return consumer.arguments.get(0); } } diff --git a/spring-orm/src/test/java/org/springframework/orm/hibernate3/HibernateJtaTransactionTests.java b/spring-orm/src/test/java/org/springframework/orm/hibernate3/HibernateJtaTransactionTests.java index b3b111e4717..9c1988efd49 100644 --- a/spring-orm/src/test/java/org/springframework/orm/hibernate3/HibernateJtaTransactionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/hibernate3/HibernateJtaTransactionTests.java @@ -166,7 +166,8 @@ public class HibernateJtaTransactionTests { if (readOnly) { verify(session).setFlushMode(FlushMode.MANUAL); - } else { + } + else { verify(session).flush(); } verify(session).close(); @@ -188,7 +189,8 @@ public class HibernateJtaTransactionTests { UserTransaction ut = mock(UserTransaction.class); if (status == Status.STATUS_NO_TRANSACTION) { given(ut.getStatus()).willReturn(status, status, Status.STATUS_ACTIVE); - } else { + } + else { given(ut.getStatus()).willReturn(status); } @@ -520,13 +522,13 @@ public class HibernateJtaTransactionTests { verify(ut).commit(); if (flushNever) { - if(!readOnly) { + if (!readOnly) { InOrder ordered = inOrder(session); ordered.verify(session).setFlushMode(FlushMode.AUTO); ordered.verify(session).setFlushMode(FlushMode.MANUAL); } } - if(!flushNever && !readOnly) { + if (!flushNever && !readOnly) { verify(session).flush(); } verify(session).afterTransactionCompletion(true, null); @@ -716,7 +718,7 @@ public class HibernateJtaTransactionTests { } verify(session1).disconnect(); verify(session1).close(); - if(!rollback) { + if (!rollback) { verify(session1).flush(); verify(session2, atLeastOnce()).flush(); } @@ -792,7 +794,7 @@ public class HibernateJtaTransactionTests { } verify(ut, atLeastOnce()).begin(); - if(!suspendException) { + if (!suspendException) { verify(tm).resume(tx); } verify(ut).rollback(); @@ -1448,10 +1450,11 @@ public class HibernateJtaTransactionTests { assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf)); InOrder ordered = inOrder(session); - if(flushNever) { + if (flushNever) { ordered.verify(session).setFlushMode(FlushMode.AUTO); ordered.verify(session).setFlushMode(FlushMode.MANUAL); - } else { + } + else { ordered.verify(session).flush(); } ordered.verify(session).disconnect(); diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java index 99fe6cca80e..e31aec3b8b6 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java @@ -79,7 +79,7 @@ public class MockFilterChainTests { chain.doFilter(this.request, this.response); fail("Expected Exception"); } - catch(IllegalStateException ex) { + catch (IllegalStateException ex) { assertEquals("This FilterChain has already been called!", ex.getMessage()); } } @@ -94,7 +94,7 @@ public class MockFilterChainTests { chain.doFilter(this.request, this.response); fail("Expected Exception"); } - catch(IllegalStateException ex) { + catch (IllegalStateException ex) { assertEquals("This FilterChain has already been called!", ex.getMessage()); } } @@ -118,7 +118,7 @@ public class MockFilterChainTests { chain.doFilter(this.request, this.response); fail("Expected Exception"); } - catch(IllegalStateException ex) { + catch (IllegalStateException ex) { assertEquals("This FilterChain has already been called!", ex.getMessage()); } } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java index 7b1c04d412e..ead30b9ecb1 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java @@ -59,7 +59,7 @@ public class StatusResultMatchersTests { List failures = new ArrayList(); - for(HttpStatus status : HttpStatus.values()) { + for (HttpStatus status : HttpStatus.values()) { MockHttpServletResponse response = new MockHttpServletResponse(); response.setStatus(status.value()); MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response); @@ -91,9 +91,7 @@ public class StatusResultMatchersTests { @Test public void statusRanges() throws Exception { - - for(HttpStatus status : HttpStatus.values()) { - + for (HttpStatus status : HttpStatus.values()) { MockHttpServletResponse response = new MockHttpServletResponse(); response.setStatus(status.value()); MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response); diff --git a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java index ff2c94a808a..749696ce04d 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java +++ b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java @@ -123,7 +123,7 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource @Override public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { String lookupPath = this.urlPathHelper.getLookupPathForRequest(request); - for(Map.Entry entry : this.corsConfigurations.entrySet()) { + for (Map.Entry entry : this.corsConfigurations.entrySet()) { if (this.pathMatcher.match(entry.getKey(), lookupPath)) { return entry.getValue(); } diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java index a78f5da6182..d3b1b5e5df1 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java @@ -48,9 +48,8 @@ import org.springframework.web.method.support.ModelAndViewContainer; * Assist with initialization of the {@link Model} before controller method * invocation and with updates to it after the invocation. * - *

On initialization the model is populated with attributes temporarily - * stored in the session and through the invocation of {@code @ModelAttribute} - * methods. + *

On initialization the model is populated with attributes temporarily stored + * in the session and through the invocation of {@code @ModelAttribute} methods. * *

On update model attributes are synchronized with the session and also * {@link BindingResult} attributes are added if missing. @@ -62,7 +61,6 @@ public final class ModelFactory { private static final Log logger = LogFactory.getLog(ModelFactory.class); - private final List modelMethods = new ArrayList(); private final WebDataBinderFactory dataBinderFactory; @@ -92,11 +90,11 @@ public final class ModelFactory { /** * Populate the model in the following order: *

    - *
  1. Retrieve "known" session attributes listed as {@code @SessionAttributes}. - *
  2. Invoke {@code @ModelAttribute} methods - *
  3. Find {@code @ModelAttribute} method arguments also listed as - * {@code @SessionAttributes} and ensure they're present in the model raising - * an exception if necessary. + *
  4. Retrieve "known" session attributes listed as {@code @SessionAttributes}. + *
  5. Invoke {@code @ModelAttribute} methods + *
  6. Find {@code @ModelAttribute} method arguments also listed as + * {@code @SessionAttributes} and ensure they're present in the model raising + * an exception if necessary. *
* @param request the current request * @param container a container with the model to be initialized @@ -108,15 +106,13 @@ public final class ModelFactory { Map sessionAttributes = this.sessionAttributesHandler.retrieveAttributes(request); container.mergeAttributes(sessionAttributes); - invokeModelAttributeMethods(request, container); for (String name : findSessionAttributeArguments(handlerMethod)) { if (!container.containsAttribute(name)) { Object value = this.sessionAttributesHandler.retrieveAttribute(request, name); if (value == null) { - throw new HttpSessionRequiredException( - "Expected session attribute '" + name + "'"); + throw new HttpSessionRequiredException("Expected session attribute '" + name + "'"); } container.addAttribute(name, value); } @@ -127,8 +123,8 @@ public final class ModelFactory { * Invoke model attribute methods to populate the model. * Attributes are added only if not already present in the model. */ - private void invokeModelAttributeMethods(NativeWebRequest request, - ModelAndViewContainer container) throws Exception { + private void invokeModelAttributeMethods(NativeWebRequest request, ModelAndViewContainer container) + throws Exception { while (!this.modelMethods.isEmpty()) { InvocableHandlerMethod modelMethod = getNextModelMethod(container).getHandlerMethod(); @@ -141,7 +137,6 @@ public final class ModelFactory { } Object returnValue = modelMethod.invokeForRequest(request, container); - if (!modelMethod.isVoid()){ String returnValueName = getNameForReturnValue(returnValue, modelMethod.getReturnType()); if (!ann.binding()) { @@ -291,7 +286,6 @@ public final class ModelFactory { private final Set dependencies = new HashSet(); - private ModelMethod(InvocableHandlerMethod handlerMethod) { this.handlerMethod = handlerMethod; for (MethodParameter parameter : handlerMethod.getMethodParameters()) { diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 811dfc1e6c6..5a374d8de1e 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -288,7 +288,7 @@ final class HierarchicalUriComponents extends UriComponents { return; } int length = source.length(); - for (int i=0; i < length; i++) { + for (int i = 0; i < length; i++) { char ch = source.charAt(i); if (ch == '%') { if ((i + 2) < length) { diff --git a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java index 87751c6fe8b..3334a7f3722 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java @@ -61,7 +61,8 @@ public class ProtobufHttpMessageConverterTests { public void extensionRegistryNull() { try { new ProtobufHttpMessageConverter(null); - } catch (Exception e) { + } + catch (Exception ex) { fail("Unable to create ProtobufHttpMessageConverter with null extensionRegistry"); } } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java index c763eeec6f9..d4a2ad47355 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java @@ -150,8 +150,9 @@ public class WebAsyncManagerTests { try { this.asyncManager.startCallableProcessing(task); fail("Expected Exception"); - }catch(Exception e) { - assertEquals(exception, e); + } + catch (Exception ex) { + assertEquals(exception, ex); } assertFalse(this.asyncManager.hasConcurrentResult()); @@ -162,7 +163,6 @@ public class WebAsyncManagerTests { @Test public void startCallableProcessingPreProcessException() throws Exception { - Callable task = new StubCallable(21); Exception exception = new Exception(); @@ -183,7 +183,6 @@ public class WebAsyncManagerTests { @Test public void startCallableProcessingPostProcessException() throws Exception { - Callable task = new StubCallable(21); Exception exception = new Exception(); @@ -205,7 +204,6 @@ public class WebAsyncManagerTests { @Test public void startCallableProcessingPostProcessContinueAfterException() throws Exception { - Callable task = new StubCallable(21); Exception exception = new Exception(); @@ -231,7 +229,6 @@ public class WebAsyncManagerTests { @Test public void startCallableProcessingWithAsyncTask() throws Exception { - AsyncTaskExecutor executor = mock(AsyncTaskExecutor.class); given(this.asyncWebRequest.getNativeRequest(HttpServletRequest.class)).willReturn(this.servletRequest); @@ -259,7 +256,6 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessing() throws Exception { - DeferredResult deferredResult = new DeferredResult(1000L); String concurrentResult = "abc"; @@ -282,7 +278,6 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessingBeforeConcurrentHandlingException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); Exception exception = new Exception(); @@ -295,7 +290,7 @@ public class WebAsyncManagerTests { this.asyncManager.startDeferredResultProcessing(deferredResult); fail("Expected Exception"); } - catch(Exception success) { + catch (Exception success) { assertEquals(exception, success); } @@ -328,7 +323,6 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessingPostProcessException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); Exception exception = new Exception(); @@ -371,6 +365,7 @@ public class WebAsyncManagerTests { verify(this.asyncWebRequest).dispatch(); } + private final class StubCallable implements Callable { private Object value; @@ -388,6 +383,7 @@ public class WebAsyncManagerTests { } } + @SuppressWarnings("serial") private static class SyncTaskExecutor extends SimpleAsyncTaskExecutor { diff --git a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java index a712e525499..dd56ff0076d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java @@ -49,7 +49,8 @@ public class Spr8510Tests { try { cll.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); - } catch (Throwable t) { + } + catch (Throwable t) { // assert that an attempt was made to load the correct XML assertTrue(t.getMessage(), t.getMessage().endsWith( "Could not open ServletContext resource [/programmatic.xml]")); @@ -75,7 +76,8 @@ public class Spr8510Tests { try { cll.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); - } catch (Throwable t) { + } + catch (Throwable t) { // assert that an attempt was made to load the correct XML assertTrue(t.getMessage(), t.getMessage().endsWith( "Could not open ServletContext resource [/from-init-param.xml]")); @@ -98,7 +100,8 @@ public class Spr8510Tests { try { cll.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); - } catch (Throwable t) { + } + catch (Throwable t) { // assert that an attempt was made to load the correct XML assertTrue(t.getMessage().endsWith( "Could not open ServletContext resource [/from-init-param.xml]")); @@ -125,7 +128,8 @@ public class Spr8510Tests { try { cll.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); - } catch (Throwable t) { + } + catch (Throwable t) { // assert that an attempt was made to load the correct XML System.out.println(t.getMessage()); assertTrue(t.getMessage().endsWith( @@ -150,7 +154,8 @@ public class Spr8510Tests { try { cll.contextInitialized(new ServletContextEvent(sc)); fail("expected exception"); - } catch (Throwable t) { + } + catch (Throwable t) { // assert that an attempt was made to load the correct XML System.out.println(t.getMessage()); assertTrue(t.getMessage().endsWith( diff --git a/spring-web/src/test/java/org/springframework/web/util/Log4jWebConfigurerTests.java b/spring-web/src/test/java/org/springframework/web/util/Log4jWebConfigurerTests.java index 5001f9fb81b..c32405e43da 100644 --- a/spring-web/src/test/java/org/springframework/web/util/Log4jWebConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/Log4jWebConfigurerTests.java @@ -101,7 +101,8 @@ public class Log4jWebConfigurerTests { try { assertLogOutput(); - } finally { + } + finally { Log4jWebConfigurer.shutdownLogging(sc); } assertTrue(MockLog4jAppender.closeCalled); @@ -132,7 +133,8 @@ public class Log4jWebConfigurerTests { try { assertLogOutput(); - } finally { + } + finally { listener.contextDestroyed(new ServletContextEvent(sc)); } assertTrue(MockLog4jAppender.closeCalled); diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java index 67a4530e630..b4f3e8e93b4 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/context/XmlPortletApplicationContextTests.java @@ -58,7 +58,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication beanFactory.addBeanPostProcessor(new BeanPostProcessor() { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if(bean instanceof TestBean) { + if (bean instanceof TestBean) { ((TestBean) bean).getFriends().add("myFriend"); } return bean; diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java index 3a5df549c18..62532a769a3 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/mvc/PortletWrappingControllerTests.java @@ -162,9 +162,11 @@ public final class PortletWrappingControllerTests { public void processAction(ActionRequest request, ActionResponse response) throws PortletException { if (request.getParameter("test") != null) { response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action"); - } else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) { + } + else if (request.getParameter(PORTLET_NAME_ACTION_REQUEST_PARAMETER_NAME) != null) { response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, getPortletConfig().getPortletName()); - } else { + } + else { throw new IllegalArgumentException("no request parameters"); } } diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java index 52c806652a3..7ab898b2770 100644 --- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java +++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/util/PortletUtilsTests.java @@ -435,12 +435,13 @@ public final class PortletUtilsTests { public void testGetRequiredSessionAttributeWithExistingSessionAndNoAttribute() throws Exception { MockPortletSession session = new MockPortletSession(); - final PortletRequest request = mock(PortletRequest.class); + PortletRequest request = mock(PortletRequest.class); given(request.getPortletSession(false)).willReturn(session); try { PortletUtils.getRequiredSessionAttribute(request, "foo"); fail("expected IllegalStateException"); - } catch (IllegalStateException ex) { /* expected */ } + } + catch (IllegalStateException ex) { /* expected */ } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index 6069882bf43..820afdc12cd 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -224,7 +224,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator if (this.contentNegotiationManager == null) { this.contentNegotiationManager = initContentNegotiationManager(); } - if( this.resourceHttpMessageConverter == null) { + if ( this.resourceHttpMessageConverter == null) { this.resourceHttpMessageConverter = new ResourceHttpMessageConverter(); } } @@ -486,7 +486,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator ServletWebRequest webRequest = new ServletWebRequest(request); try { List mediaTypes = getContentNegotiationManager().resolveMediaTypes(webRequest); - if(!mediaTypes.isEmpty()) { + if (!mediaTypes.isEmpty()) { mediaType = mediaTypes.get(0); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 5537a48cdc4..9ee0c5a8b70 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -218,7 +218,7 @@ public class ResourceUrlProvider implements ApplicationListener patternComparator = getPathMatcher().getPatternComparator(lookupPath); Collections.sort(matchingPatterns, patternComparator); - for(String pattern : matchingPatterns) { + for (String pattern : matchingPatterns) { String pathWithinMapping = getPathMatcher().extractPathWithinPattern(pattern, lookupPath); String pathMapping = lookupPath.substring(0, lookupPath.indexOf(pathWithinMapping)); if (logger.isTraceEnabled()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index 7ccc938ced1..f7eb7cb0144 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -123,9 +123,9 @@ public class VersionResourceResolver extends AbstractResourceResolver { List patternsList = Arrays.asList(pathPatterns); List prefixedPatterns = new ArrayList(pathPatterns.length); String versionPrefix = "/" + version; - for(String pattern : patternsList) { + for (String pattern : patternsList) { prefixedPatterns.add(pattern); - if(!pattern.startsWith(versionPrefix) && !patternsList.contains(versionPrefix + pattern)) { + if (!pattern.startsWith(versionPrefix) && !patternsList.contains(versionPrefix + pattern)) { prefixedPatterns.add(versionPrefix + pattern); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java index 3df9be225d3..0b48995a609 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -176,7 +176,8 @@ public class AnnotationDrivenBeanDefinitionParserTests { List> converters = (List>) value; if (hasDefaultRegistrations) { assertTrue("Default and custom converter expected", converters.size() > 2); - } else { + } + else { assertTrue("Only custom converters expected", converters.size() == 2); } assertTrue(converters.get(0) instanceof StringHttpMessageConverter); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java index 9a5e3cb7731..333a093bb61 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java @@ -181,7 +181,7 @@ public class FlashMapManagerTests { @Test public void retrieveAndUpdateRemoveExpired() throws InterruptedException { List flashMaps = new ArrayList(); - for (int i=0; i < 5; i++) { + for (int i = 0; i < 5; i++) { FlashMap expiredFlashMap = new FlashMap(); expiredFlashMap.startExpirationPeriod(-1); flashMaps.add(expiredFlashMap); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java index f341953202e..d68d8cf79f0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java @@ -465,7 +465,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests { tag.setValue("foo"); tag.doStartTag(); fail("Must throw an IllegalStateException when not nested within a