Skip to content

Commit

Permalink
Consistent formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Mar 24, 2016
1 parent 2cdb0cf commit 517ebd1
Show file tree
Hide file tree
Showing 101 changed files with 677 additions and 505 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -101,7 +101,7 @@ private boolean matchesReturnValue(Class<?> type, Method method, Object returnVa
else if (Object.class == type && void.class == method.getReturnType()) {
return true;
}
else{
else {
return ClassUtils.isAssignable(type, method.getReturnType());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ protected void assertException(Method m, String pointcut, String returning, Stri
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public void before(Method method, Object[] args, Object target) throws Throwable
itb.setSpouse(new TestBean());
try {
itb.unreliableFileOperation();
} catch (IOException ex) {
}
catch (IOException ex) {
// we don't realy care...
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -97,12 +113,14 @@ private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService ta
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 {

/**
Expand All @@ -115,34 +133,40 @@ public SimpleThrowawayClassLoader(ClassLoader parent) {

}


@SuppressWarnings("serial")
public static class TestException extends RuntimeException {

public TestException(String string) {
super(string);
}

}


@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
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;
Expand All @@ -154,9 +178,9 @@ public void before(Method method, Object[] objects, Object o) throws Throwable {
countBefore++;
}

public void afterThrowing(Exception e) throws Throwable {
public void afterThrowing(Exception ex) throws Throwable {
countThrows++;
throw e;
throw ex;
}

public int getCountBefore() {
Expand All @@ -171,7 +195,6 @@ public void reset() {
countThrows = 0;
countBefore = 0;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void testExceptionPathStillLogsCorrectly() throws Throwable {
try {
interceptor.invoke(methodInvocation);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
checkCallCountTotal(interceptor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void testExceptionPathStillLogsCorrectly() throws Throwable {
try {
interceptor.invokeUnderTrace(mi, log);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}

verify(log).trace(anyString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public void testReuseDestroyedTarget() {
// try second time
try {
source.getTarget();
} catch(NullPointerException ex) {
}
catch (NullPointerException ex) {
fail("Should not throw NPE");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public <T> Future<T> submit(Callable<T> task) {
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");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -204,7 +204,7 @@ public Object getObject() throws IllegalAccessException {
// instance field
return this.fieldObject.get(this.targetObject);
}
else{
else {
// class field
return this.fieldObject.get(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,22 @@ public void testErrorOnTooManyOrTooFew() throws Exception {
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
Expand Down Expand Up @@ -138,7 +141,8 @@ public void testErrorOnTooManyOrTooFewWithCustomServiceLocatorException() {
TestService2Locator factory3 = (TestService2Locator) bf.getBean("factory3");
factory3.getTestService();
fail("Must fail on no matching type");
} catch (CustomServiceLocatorException3 ex) { /* expected */ }
}
catch (CustomServiceLocatorException3 ex) { /* expected */ }
}

@Test
Expand All @@ -160,7 +164,8 @@ public void testStringArgGetter() throws Exception {
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
Expand Down Expand Up @@ -275,7 +280,8 @@ public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exce
try {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setBeanFactory(beanFactory);
} catch (FatalBeanException ex) {
}
catch (FatalBeanException ex) {
// expected
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ public void testSecuritySanity() throws Exception {
try {
acc.checkPermission(new PropertyPermission("*", "read"));
fail("Acc should not have any permissions");
} catch (SecurityException se) {
}
catch (SecurityException se) {
// expected
}

Expand All @@ -342,7 +343,8 @@ public Object run() throws Exception {
}
}, acc);
fail("expected security exception");
} catch (Exception ex) {
}
catch (Exception ex) {
}

final Class<ConstructorBean> cl = ConstructorBean.class;
Expand All @@ -356,7 +358,8 @@ public Object run() throws Exception {
}
}, acc);
fail("expected security exception");
} catch (Exception ex) {
}
catch (Exception ex) {
}
}

Expand All @@ -365,7 +368,8 @@ public void testSpringInitBean() throws Exception {
try {
beanFactory.getBean("spring-init");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getCause() instanceof SecurityException);
}
}
Expand All @@ -375,7 +379,8 @@ public void testCustomInitBean() throws Exception {
try {
beanFactory.getBean("custom-init");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getCause() instanceof SecurityException);
}
}
Expand All @@ -399,7 +404,8 @@ public void testCustomFactoryObject() throws Exception {
try {
beanFactory.getBean("spring-factory");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getCause() instanceof SecurityException);
}

Expand All @@ -416,7 +422,8 @@ public void testCustomStaticFactoryMethod() throws Exception {
try {
beanFactory.getBean("custom-static-factory-method");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
Expand All @@ -426,7 +433,8 @@ public void testCustomInstanceFactoryMethod() throws Exception {
try {
beanFactory.getBean("custom-factory-method");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
Expand All @@ -436,7 +444,8 @@ public void testTrustedFactoryMethod() throws Exception {
try {
beanFactory.getBean("privileged-static-factory-method");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
}
Expand All @@ -446,7 +455,8 @@ public void testConstructor() throws Exception {
try {
beanFactory.getBean("constructor");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
// expected
assertTrue(ex.getMostSpecificCause() instanceof SecurityException);
}
Expand All @@ -472,7 +482,8 @@ public void testPropertyInjection() throws Exception {
try {
beanFactory.getBean("property-injection");
fail("expected security exception");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
assertTrue(ex.getMessage().contains("security"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void duplicateBeanIdsWithinSameNestingLevelRaisesError() {
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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ public void testParseShortGreaterThanMaxValueWithoutNumberFormat() {
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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ComponentDefinition[] getComponentDefinitions() {
@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);
}
Expand Down
Loading

0 comments on commit 517ebd1

Please sign in to comment.