Consistent formatting
This commit is contained in:
parent
2cdb0cf690
commit
517ebd1d3e
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ public class ThreadLocalTargetSourceTests {
|
|||
// try second time
|
||||
try {
|
||||
source.getTarget();
|
||||
} catch(NullPointerException ex) {
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
fail("Should not throw NPE");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ConstructorBean> 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"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ public class PropertySourceTests {
|
|||
equalTo(String.format("%s [name='%s']",
|
||||
ps.getClass().getSimpleName(),
|
||||
name)));
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
logger.setLevel(original);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
o = parser.parseExpression("list2[3]").getValue(new StandardEvaluationContext(testClass));
|
||||
fail();
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
ee.printStackTrace();
|
||||
// success!
|
||||
}
|
||||
|
|
@ -241,7 +242,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
new SpelExpressionParser().parseExpression("placeOfBirth.foo.");
|
||||
fail("Should have failed to parse");
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
catch (ParseException e) {
|
||||
assertTrue(e instanceof SpelParseException);
|
||||
SpelParseException spe = (SpelParseException) e;
|
||||
assertEquals(SpelMessage.OOD, spe.getMessageCode());
|
||||
|
|
@ -265,7 +267,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
new SpelExpressionParser().parseRaw("placeOfBirth.23");
|
||||
fail();
|
||||
} catch (SpelParseException spe) {
|
||||
}
|
||||
catch (SpelParseException spe) {
|
||||
assertEquals(spe.getMessageCode(), SpelMessage.UNEXPECTED_DATA_AFTER_DOT);
|
||||
assertEquals("23", spe.getInserts()[0]);
|
||||
}
|
||||
|
|
@ -554,7 +557,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
assertFalse(parser.parseExpression("T(List)!=null").getValue(context, Boolean.class));
|
||||
fail("should have failed to find List");
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
// success - List not found
|
||||
}
|
||||
((StandardTypeLocator) context.getTypeLocator()).registerImport("java.util");
|
||||
|
|
@ -633,7 +637,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
context.registerMethodFilter(String.class, filter);
|
||||
fail("should have failed");
|
||||
} catch (IllegalStateException ise) {
|
||||
}
|
||||
catch (IllegalStateException ise) {
|
||||
assertEquals(
|
||||
"Method filter cannot be set as the reflective method resolver is not in use",
|
||||
ise.getMessage());
|
||||
|
|
@ -738,7 +743,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,String.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -754,7 +760,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
expression = parser.parseExpression("foo[3]");
|
||||
try {
|
||||
expression.setValue(ctx, "3");
|
||||
} catch(SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.UNABLE_TO_GROW_COLLECTION, see.getMessageCode());
|
||||
assertThat(instance.getFoo().size(), equalTo(3));
|
||||
}
|
||||
|
|
@ -771,7 +778,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -894,7 +902,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Double.TYPE);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.OPERAND_NOT_INCREMENTABLE,see.getMessageCode());
|
||||
}
|
||||
|
||||
|
|
@ -902,7 +911,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Double.TYPE);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.OPERAND_NOT_INCREMENTABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -917,14 +927,16 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
Expression e = parser.parseExpression("++1");
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
try {
|
||||
Expression e = parser.parseExpression("1++");
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -938,7 +950,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -1060,7 +1073,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Double.TYPE);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.OPERAND_NOT_DECREMENTABLE,see.getMessageCode());
|
||||
}
|
||||
|
||||
|
|
@ -1068,7 +1082,8 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
try {
|
||||
e.getValue(ctx,Double.TYPE);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.OPERAND_NOT_DECREMENTABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -1083,14 +1098,16 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
Expression e = parser.parseExpression("--1");
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
try {
|
||||
Expression e = parser.parseExpression("1--");
|
||||
e.getValue(ctx,Integer.class);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
assertEquals(SpelMessage.NOT_ASSIGNABLE,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -1123,36 +1140,6 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void expectFail(ExpressionParser parser, EvaluationContext eContext, String expressionString, SpelMessage messageCode) {
|
||||
try {
|
||||
Expression e = parser.parseExpression(expressionString);
|
||||
SpelUtilities.printAbstractSyntaxTree(System.out, e);
|
||||
e.getValue(eContext);
|
||||
fail();
|
||||
} catch (SpelEvaluationException see) {
|
||||
see.printStackTrace();
|
||||
assertEquals(messageCode,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
private void expectFailNotAssignable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.NOT_ASSIGNABLE);
|
||||
}
|
||||
|
||||
private void expectFailSetValueNotSupported(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.SETVALUE_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private void expectFailNotIncrementable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.OPERAND_NOT_INCREMENTABLE);
|
||||
}
|
||||
|
||||
private void expectFailNotDecrementable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.OPERAND_NOT_DECREMENTABLE);
|
||||
}
|
||||
|
||||
// Verify how all the nodes behave with assignment (++, --, =)
|
||||
@Test
|
||||
public void incrementAllNodeTypes() throws SecurityException, NoSuchMethodException {
|
||||
|
|
@ -1456,9 +1443,39 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
r = e.getValue(ctx,Integer.TYPE);
|
||||
assertEquals(100,r);
|
||||
assertEquals(100,helper.iii);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void expectFail(ExpressionParser parser, EvaluationContext eContext, String expressionString, SpelMessage messageCode) {
|
||||
try {
|
||||
Expression e = parser.parseExpression(expressionString);
|
||||
SpelUtilities.printAbstractSyntaxTree(System.out, e);
|
||||
e.getValue(eContext);
|
||||
fail();
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
see.printStackTrace();
|
||||
assertEquals(messageCode,see.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
private void expectFailNotAssignable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.NOT_ASSIGNABLE);
|
||||
}
|
||||
|
||||
private void expectFailSetValueNotSupported(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.SETVALUE_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private void expectFailNotIncrementable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.OPERAND_NOT_INCREMENTABLE);
|
||||
}
|
||||
|
||||
private void expectFailNotDecrementable(ExpressionParser parser, EvaluationContext eContext, String expressionString) {
|
||||
expectFail(parser,eContext,expressionString,SpelMessage.OPERAND_NOT_DECREMENTABLE);
|
||||
}
|
||||
|
||||
|
||||
static class MyBeanResolver implements BeanResolver {
|
||||
|
||||
@Override
|
||||
|
|
@ -1472,5 +1489,4 @@ public class EvaluationTests extends AbstractExpressionTests {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,10 +79,12 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
|
|||
|
||||
assertEquals("hello world", value);
|
||||
assertEquals(String.class, value.getClass());
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
ee.printStackTrace();
|
||||
fail("Unexpected Exception: " + ee.getMessage());
|
||||
} catch (ParseException pe) {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
pe.printStackTrace();
|
||||
fail("Unexpected Exception: " + pe.getMessage());
|
||||
}
|
||||
|
|
@ -186,10 +188,12 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
|
|||
Object value = expr.getValue(ctx);
|
||||
assertEquals("hellohello", value);
|
||||
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
ee.printStackTrace();
|
||||
fail("Unexpected Exception: " + ee.getMessage());
|
||||
} catch (ParseException pe) {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
pe.printStackTrace();
|
||||
fail("Unexpected Exception: " + pe.getMessage());
|
||||
}
|
||||
|
|
@ -213,7 +217,8 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
|
|||
try {
|
||||
expr.setValue(ctx, Color.blue);
|
||||
fail("Should not be allowed to set oranges to be blue !");
|
||||
} catch (SpelEvaluationException ee) {
|
||||
}
|
||||
catch (SpelEvaluationException ee) {
|
||||
assertEquals(ee.getMessageCode(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,8 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
|||
try {
|
||||
state.popActiveContextObject();
|
||||
fail("stack should be empty...");
|
||||
} catch (EmptyStackException ese) {
|
||||
}
|
||||
catch (EmptyStackException ese) {
|
||||
// success
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +222,8 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
|||
try {
|
||||
state.operate(Operation.ADD,1,2);
|
||||
fail("should have failed");
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
assertEquals(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageCode());
|
||||
}
|
||||
|
|
@ -229,7 +231,8 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
|||
try {
|
||||
state.operate(Operation.ADD,null,null);
|
||||
fail("should have failed");
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
assertEquals(SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES,sEx.getMessageCode());
|
||||
}
|
||||
|
|
@ -249,7 +252,8 @@ public class ExpressionStateTests extends AbstractExpressionTests {
|
|||
try {
|
||||
state.findType("someMadeUpName");
|
||||
fail("Should have failed to find it");
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
SpelEvaluationException sEx = (SpelEvaluationException)ee;
|
||||
assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,8 +191,9 @@ public class IndexingTests {
|
|||
expression = parser.parseExpression("property[0]");
|
||||
try {
|
||||
expression.setValue(this, "4");
|
||||
} catch (EvaluationException e) {
|
||||
assertTrue(e.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
catch (EvaluationException ex) {
|
||||
assertTrue(ex.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,8 +252,9 @@ public class IndexingTests {
|
|||
expression = parser.parseExpression("property[0]");
|
||||
try {
|
||||
assertEquals("bar", expression.getValue(this));
|
||||
} catch (EvaluationException e) {
|
||||
assertTrue(e.getMessage().startsWith("EL1027E"));
|
||||
}
|
||||
catch (EvaluationException ex) {
|
||||
assertTrue(ex.getMessage().startsWith("EL1027E"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,8 +270,9 @@ public class IndexingTests {
|
|||
expression = parser.parseExpression("property[0]");
|
||||
try {
|
||||
assertEquals("bar", expression.getValue(this));
|
||||
} catch (EvaluationException e) {
|
||||
assertTrue(e.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
catch (EvaluationException ex) {
|
||||
assertTrue(ex.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,8 +288,9 @@ public class IndexingTests {
|
|||
expression = parser.parseExpression("property2[0]");
|
||||
try {
|
||||
assertEquals("bar", expression.getValue(this));
|
||||
} catch (EvaluationException e) {
|
||||
assertTrue(e.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
catch (EvaluationException ex) {
|
||||
assertTrue(ex.getMessage().startsWith("EL1053E"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -33,29 +33,6 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class OperatorOverloaderTests extends AbstractExpressionTests {
|
||||
|
||||
static class StringAndBooleanAddition implements OperatorOverloader {
|
||||
|
||||
@Override
|
||||
public Object operate(Operation operation, Object leftOperand, Object rightOperand) throws EvaluationException {
|
||||
if (operation==Operation.ADD) {
|
||||
return ((String)leftOperand)+((Boolean)rightOperand).toString();
|
||||
} else {
|
||||
return leftOperand;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean overridesOperation(Operation operation, Object leftOperand, Object rightOperand)
|
||||
throws EvaluationException {
|
||||
if (leftOperand instanceof String && rightOperand instanceof Boolean) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOperations() throws Exception {
|
||||
// no built in support for this:
|
||||
|
|
@ -73,4 +50,28 @@ public class OperatorOverloaderTests extends AbstractExpressionTests {
|
|||
expr = (SpelExpression)parser.parseExpression("'abc'+null");
|
||||
assertEquals("abcnull",expr.getValue(eContext));
|
||||
}
|
||||
|
||||
|
||||
static class StringAndBooleanAddition implements OperatorOverloader {
|
||||
|
||||
@Override
|
||||
public Object operate(Operation operation, Object leftOperand, Object rightOperand) throws EvaluationException {
|
||||
if (operation==Operation.ADD) {
|
||||
return ((String)leftOperand)+((Boolean)rightOperand).toString();
|
||||
}
|
||||
else {
|
||||
return leftOperand;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean overridesOperation(Operation operation, Object leftOperand, Object rightOperand) throws EvaluationException {
|
||||
if (leftOperand instanceof String && rightOperand instanceof Boolean) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -462,7 +462,8 @@ public class ParsingTests {
|
|||
fail("Parsed exception was null");
|
||||
}
|
||||
assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST());
|
||||
} catch (ParseException ee) {
|
||||
}
|
||||
catch (ParseException ee) {
|
||||
ee.printStackTrace();
|
||||
fail("Unexpected Exception: " + ee.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,17 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
|||
try {
|
||||
expr.getValue(context);
|
||||
fail("Should have failed - default property resolver cannot resolve on null");
|
||||
} catch (Exception e) {
|
||||
checkException(e,SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
checkException(ex, SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL);
|
||||
}
|
||||
assertFalse(expr.isWritable(context));
|
||||
try {
|
||||
expr.setValue(context,"abc");
|
||||
fail("Should have failed - default property resolver cannot resolve on null");
|
||||
} catch (Exception e) {
|
||||
checkException(e,SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
checkException(ex, SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +96,8 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
|||
if (e instanceof SpelEvaluationException) {
|
||||
SpelMessage sm = ((SpelEvaluationException)e).getMessageCode();
|
||||
assertEquals("Expected exception type did not occur",expectedMessage,sm);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fail("Should be a SpelException "+e);
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +130,8 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
|||
try {
|
||||
expr.setValue(ctx, "not allowed");
|
||||
fail("Should not have been allowed");
|
||||
} catch (EvaluationException e) {
|
||||
}
|
||||
catch (EvaluationException ex) {
|
||||
// success - message will be: EL1063E:(pos 20): A problem occurred whilst attempting to set the property
|
||||
// 'flibbles': 'Cannot set flibbles to an object of type 'class java.lang.String''
|
||||
// System.out.println(e.getMessage());
|
||||
|
|
@ -176,33 +180,37 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
|||
|
||||
@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() + "'");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,8 @@ public class SelectionAndProjectionTests {
|
|||
for (int i = 0; i < 3; i++) {
|
||||
if (i == 1) {
|
||||
array[i] = new IntegerTestBean(5.9f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
array[i] = new IntegerTestBean(i + 5);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -39,6 +39,7 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
|
||||
private final static boolean DEBUG = false;
|
||||
|
||||
|
||||
@Test
|
||||
public void testSetProperty() {
|
||||
setValue("wonNobelPrize", true);
|
||||
|
|
@ -90,7 +91,8 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
try {
|
||||
assertFalse("Should not be writable!",e.isWritable(lContext));
|
||||
fail("Should have had an error because wibble does not really exist");
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
// org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 15): Property or field 'wibble' cannot be found on object of type 'org.springframework.expression.spel.testresources.ArrayContainer' - maybe not public?
|
||||
// at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:225)
|
||||
// success!
|
||||
|
|
@ -110,7 +112,8 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
try {
|
||||
assertFalse("Should not be writable!",e.isWritable(lContext));
|
||||
fail("Should have had an error because wibble does not really exist");
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
// success!
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +122,8 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
try {
|
||||
assertFalse("Should not be writable!",e.isWritable(lContext));
|
||||
fail("Should have had an error because wibble does not really exist");
|
||||
} catch (SpelEvaluationException see) {
|
||||
}
|
||||
catch (SpelEvaluationException see) {
|
||||
// success!
|
||||
}
|
||||
}
|
||||
|
|
@ -247,10 +251,12 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext();
|
||||
e.setValue(lContext, value);
|
||||
fail("expected an error");
|
||||
} catch (ParseException pe) {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
pe.printStackTrace();
|
||||
fail("Unexpected Exception: " + pe.getMessage());
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
// success!
|
||||
}
|
||||
}
|
||||
|
|
@ -268,10 +274,12 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
assertTrue("Expression is not writeable but should be", e.isWritable(lContext));
|
||||
e.setValue(lContext, value);
|
||||
assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass()));
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
ee.printStackTrace();
|
||||
fail("Unexpected Exception: " + ee.getMessage());
|
||||
} catch (ParseException pe) {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
pe.printStackTrace();
|
||||
fail("Unexpected Exception: " + pe.getMessage());
|
||||
}
|
||||
|
|
@ -299,12 +307,15 @@ public class SetValueTests extends AbstractExpressionTests {
|
|||
fail("Not the same: ["+a+"] type="+a.getClass()+" ["+b+"] type="+b.getClass());
|
||||
// assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
|
||||
}
|
||||
} catch (EvaluationException ee) {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
ee.printStackTrace();
|
||||
fail("Unexpected Exception: " + ee.getMessage());
|
||||
} catch (ParseException pe) {
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
pe.printStackTrace();
|
||||
fail("Unexpected Exception: " + pe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 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.
|
||||
|
|
@ -306,9 +306,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
long stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
b = expression.getValue(payload, Boolean.TYPE);
|
||||
}
|
||||
long etime = System.currentTimeMillis();
|
||||
|
|
@ -322,9 +322,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
boolean bc = false;
|
||||
expression.getValue(payload, Boolean.TYPE);
|
||||
log("timing compiled: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
long stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
bc = expression.getValue(payload, Boolean.TYPE);
|
||||
}
|
||||
long etime = System.currentTimeMillis();
|
||||
|
|
@ -369,9 +369,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -385,9 +385,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -443,9 +443,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -459,9 +459,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -490,9 +490,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -506,9 +506,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -535,9 +535,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
expression.getValue(testdata, String.class);
|
||||
}
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -551,9 +551,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -581,9 +581,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -597,9 +597,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -628,9 +628,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
}
|
||||
|
||||
log("timing interpreted: ");
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
interpretedResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -645,9 +645,9 @@ public class SpelCompilationPerformanceTests extends AbstractExpressionTests {
|
|||
|
||||
log("timing compiled: ");
|
||||
expression.getValue(testdata, String.class);
|
||||
for (int iter=0;iter<iterations;iter++) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
stime = System.currentTimeMillis();
|
||||
for (int i=0;i<count;i++) {
|
||||
for (int j = 0; j < count; j++) {
|
||||
compiledResult = expression.getValue(testdata, String.class);
|
||||
}
|
||||
etime = System.currentTimeMillis();
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,8 @@ public class DataSourceJtaTransactionTests {
|
|||
if (rollback) {
|
||||
verify(userTransaction, times(5)).commit();
|
||||
verify(userTransaction).rollback();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
verify(userTransaction, times(6)).commit();
|
||||
}
|
||||
if (accessAfterResume && !openOuterConnection) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ 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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -136,7 +136,6 @@ public final class SimpleMessageConverterTests {
|
|||
|
||||
@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<Integer, String> content = new HashMap<Integer, String>(1);
|
||||
Map<Integer, String> content = new HashMap<Integer, String>(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<Object, String> content = new HashMap<Object, String>(1);
|
||||
Map<Object, String> content = new HashMap<Object, String>(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 */ }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<StompSession> 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<String> topics;
|
||||
|
|
@ -157,14 +158,12 @@ public class Reactor2TcpStompClientTests {
|
|||
|
||||
private final List<String> received = new ArrayList<>();
|
||||
|
||||
|
||||
public ConsumingHandler(String... topics) {
|
||||
Assert.notEmpty(topics);
|
||||
this.topics = Arrays.asList(topics);
|
||||
this.subscriptionLatch = new CountDownLatch(this.topics.size());
|
||||
}
|
||||
|
||||
|
||||
public List<String> getReceived() {
|
||||
return this.received;
|
||||
}
|
||||
|
|
@ -208,16 +207,15 @@ public class Reactor2TcpStompClientTests {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class ProducingHandler extends LoggingSessionHandler {
|
||||
|
||||
private final List<String> topics = new ArrayList<>();
|
||||
|
||||
private final List<Object> payloads = new ArrayList<>();
|
||||
|
||||
|
||||
public ProducingHandler addToSend(String topic, Object payload) {
|
||||
this.topics.add(topic);
|
||||
this.payloads.add(payload);
|
||||
|
|
|
|||
|
|
@ -325,7 +325,8 @@ public class StompCodecTests {
|
|||
this.decoder.apply(buffer);
|
||||
if (consumer.arguments.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return consumer.arguments.get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
@ -1451,7 +1453,8 @@ public class HibernateJtaTransactionTests {
|
|||
if (flushNever) {
|
||||
ordered.verify(session).setFlushMode(FlushMode.AUTO);
|
||||
ordered.verify(session).setFlushMode(FlushMode.MANUAL);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ordered.verify(session).flush();
|
||||
}
|
||||
ordered.verify(session).disconnect();
|
||||
|
|
|
|||
|
|
@ -91,9 +91,7 @@ public class StatusResultMatchersTests {
|
|||
|
||||
@Test
|
||||
public void statusRanges() throws Exception {
|
||||
|
||||
for (HttpStatus status : HttpStatus.values()) {
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
response.setStatus(status.value());
|
||||
MvcResult mvcResult = new StubMvcResult(request, null, null, null, null, null, response);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
* <p>On initialization the model is populated with attributes temporarily
|
||||
* stored in the session and through the invocation of {@code @ModelAttribute}
|
||||
* methods.
|
||||
* <p>On initialization the model is populated with attributes temporarily stored
|
||||
* in the session and through the invocation of {@code @ModelAttribute} methods.
|
||||
*
|
||||
* <p>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<ModelMethod> modelMethods = new ArrayList<ModelMethod>();
|
||||
|
||||
private final WebDataBinderFactory dataBinderFactory;
|
||||
|
|
@ -108,15 +106,13 @@ public final class ModelFactory {
|
|||
|
||||
Map<String, ?> 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<String> dependencies = new HashSet<String>();
|
||||
|
||||
|
||||
private ModelMethod(InvocableHandlerMethod handlerMethod) {
|
||||
this.handlerMethod = handlerMethod;
|
||||
for (MethodParameter parameter : handlerMethod.getMethodParameters()) {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Object> task = new StubCallable(21);
|
||||
Exception exception = new Exception();
|
||||
|
||||
|
|
@ -183,7 +183,6 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startCallableProcessingPostProcessException() throws Exception {
|
||||
|
||||
Callable<Object> task = new StubCallable(21);
|
||||
Exception exception = new Exception();
|
||||
|
||||
|
|
@ -205,7 +204,6 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startCallableProcessingPostProcessContinueAfterException() throws Exception {
|
||||
|
||||
Callable<Object> 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<String> deferredResult = new DeferredResult<String>(1000L);
|
||||
String concurrentResult = "abc";
|
||||
|
||||
|
|
@ -282,7 +278,6 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startDeferredResultProcessingBeforeConcurrentHandlingException() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
Exception exception = new Exception();
|
||||
|
||||
|
|
@ -328,7 +323,6 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startDeferredResultProcessingPostProcessException() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
Exception exception = new Exception();
|
||||
|
||||
|
|
@ -371,6 +365,7 @@ public class WebAsyncManagerTests {
|
|||
verify(this.asyncWebRequest).dispatch();
|
||||
}
|
||||
|
||||
|
||||
private final class StubCallable implements Callable<Object> {
|
||||
|
||||
private Object value;
|
||||
|
|
@ -388,6 +383,7 @@ public class WebAsyncManagerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class SyncTaskExecutor extends SimpleAsyncTaskExecutor {
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */ }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||
List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) 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);
|
||||
|
|
|
|||
|
|
@ -465,7 +465,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
|||
tag.setValue("foo");
|
||||
tag.doStartTag();
|
||||
fail("Must throw an IllegalStateException when not nested within a <select/> tag.");
|
||||
} catch (IllegalStateException ex) {
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
@ -542,7 +543,8 @@ public class OptionTagTests extends AbstractHtmlElementTagTests {
|
|||
public String toId() {
|
||||
if (this.variant != null) {
|
||||
return this.rules + "-" + this.variant;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ public class PasswordInputTagTests extends InputTagTests {
|
|||
protected void assertValueAttribute(String output, String expectedValue) {
|
||||
if (this.getPasswordTag().isShowPassword()) {
|
||||
super.assertValueAttribute(output, expectedValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
super.assertValueAttribute(output, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ public class ContextLoaderTestUtils {
|
|||
public static void setCurrentWebApplicationContext(ClassLoader classLoader, WebApplicationContext applicationContext) {
|
||||
if (applicationContext != null) {
|
||||
currentContextPerThread.put(classLoader, applicationContext);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
currentContextPerThread.remove(classLoader);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ public class EnableTransactionManagementIntegrationTests {
|
|||
try {
|
||||
assertTxProxying(ctx);
|
||||
fail("expected exception");
|
||||
} catch (AssertionError ex) {
|
||||
}
|
||||
catch (AssertionError ex) {
|
||||
assertThat(ex.getMessage(), equalTo("FooRepository is not a TX proxy"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue