Polish test code
Polish a few issue identified when adding checkstyle to the build. Although checkstyle is not enforcing rules on tests, these are a few minor changes that are still worth making. Issue: SPR-16968
This commit is contained in:
committed by
Juergen Hoeller
parent
81451aa800
commit
1c25cec44f
@@ -175,7 +175,7 @@ public abstract class AbstractAopProxyTests {
|
||||
ProxyFactory pf1 = new ProxyFactory(target1);
|
||||
pf1.addAdvice(new NopInterceptor());
|
||||
pf1.addAdvice(new NopInterceptor());
|
||||
ITestBean proxies[] = new ITestBean[howMany];
|
||||
ITestBean[] proxies = new ITestBean[howMany];
|
||||
for (int i = 0; i < howMany; i++) {
|
||||
proxies[i] = (ITestBean) createAopProxy(pf1).getProxy();
|
||||
assertEquals(age1, proxies[i].getAge());
|
||||
@@ -1356,7 +1356,7 @@ public abstract class AbstractAopProxyTests {
|
||||
rmi.getUserAttributes().putAll(valuesToAdd);
|
||||
return invocation.proceed();
|
||||
}
|
||||
};
|
||||
}
|
||||
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
|
||||
MapAwareMethodInterceptor mami1 = new MapAwareMethodInterceptor(new HashMap<>(), new HashMap<String, String>());
|
||||
Map<String, String> firstValuesToAdd = new HashMap<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -191,7 +191,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(String actionName, Object params[], String signature[]) throws MBeanException,
|
||||
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException,
|
||||
ReflectionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -109,7 +109,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
||||
@ManagedMetric(description="The QueueSize metric", currencyTimeLimit = 20, persistPolicy="OnUpdate", persistPeriod=300,
|
||||
category="utilization", metricType = MetricType.COUNTER, displayName="Queue Size", unit="messages")
|
||||
public long getQueueSize() {
|
||||
return 100l;
|
||||
return 100L;
|
||||
}
|
||||
|
||||
@ManagedMetric
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -156,7 +156,6 @@ public class JndiTemplateTests {
|
||||
jt.rebind(name, o);
|
||||
verify(context).rebind(name, o);
|
||||
verify(context).close();
|
||||
;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -63,7 +63,7 @@ public class StreamConverterTests {
|
||||
public void convertFromStreamToList() throws NoSuchFieldException {
|
||||
this.conversionService.addConverter(Number.class, String.class, new ObjectToStringConverter());
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings")); ;
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings"));
|
||||
Object result = this.conversionService.convert(stream, listOfStrings);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
@@ -80,7 +80,7 @@ public class StreamConverterTests {
|
||||
public void convertFromStreamToArray() throws NoSuchFieldException {
|
||||
this.conversionService.addConverterFactory(new NumberToNumberConverterFactory());
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs")); ;
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
|
||||
Object result = this.conversionService.convert(stream, arrayOfLongs);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
@@ -95,7 +95,7 @@ public class StreamConverterTests {
|
||||
@Test
|
||||
public void convertFromStreamToRawList() throws NoSuchFieldException {
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList")); ;
|
||||
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList"));
|
||||
Object result = this.conversionService.convert(stream, listOfStrings);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
@@ -111,7 +111,7 @@ public class StreamConverterTests {
|
||||
@Test
|
||||
public void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
|
||||
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs")); ;
|
||||
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
|
||||
|
||||
thrown.expect(ConversionFailedException.class);
|
||||
thrown.expectCause(is(instanceOf(ConverterNotFoundException.class)));
|
||||
@@ -123,7 +123,7 @@ public class StreamConverterTests {
|
||||
public void convertFromListToStream() throws NoSuchFieldException {
|
||||
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
|
||||
List<String> stream = Arrays.asList("1", "2", "3");
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers")); ;
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
|
||||
Object result = this.conversionService.convert(stream, streamOfInteger);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
@@ -143,7 +143,7 @@ public class StreamConverterTests {
|
||||
return source == 1;
|
||||
}
|
||||
});
|
||||
TypeDescriptor streamOfBoolean = new TypeDescriptor(Types.class.getField("streamOfBooleans")); ;
|
||||
TypeDescriptor streamOfBoolean = new TypeDescriptor(Types.class.getField("streamOfBooleans"));
|
||||
Object result = this.conversionService.convert(stream, streamOfBoolean);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
@@ -157,7 +157,7 @@ public class StreamConverterTests {
|
||||
@SuppressWarnings("resource")
|
||||
public void convertFromListToRawStream() throws NoSuchFieldException {
|
||||
List<String> stream = Arrays.asList("1", "2", "3");
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream")); ;
|
||||
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream"));
|
||||
Object result = this.conversionService.convert(stream, streamOfInteger);
|
||||
|
||||
assertNotNull("Converted object must not be null", result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -38,30 +38,30 @@ public class ExponentialBackOffTests {
|
||||
public void defaultInstance() {
|
||||
ExponentialBackOff backOff = new ExponentialBackOff();
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(2000l, execution.nextBackOff());
|
||||
assertEquals(3000l, execution.nextBackOff());
|
||||
assertEquals(4500l, execution.nextBackOff());
|
||||
assertEquals(2000L, execution.nextBackOff());
|
||||
assertEquals(3000L, execution.nextBackOff());
|
||||
assertEquals(4500L, execution.nextBackOff());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleIncrease() {
|
||||
ExponentialBackOff backOff = new ExponentialBackOff(100L, 2.0);
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(200l, execution.nextBackOff());
|
||||
assertEquals(400l, execution.nextBackOff());
|
||||
assertEquals(800l, execution.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
assertEquals(200L, execution.nextBackOff());
|
||||
assertEquals(400L, execution.nextBackOff());
|
||||
assertEquals(800L, execution.nextBackOff());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fixedIncrease() {
|
||||
ExponentialBackOff backOff = new ExponentialBackOff(100L, 1.0);
|
||||
backOff.setMaxElapsedTime(300l);
|
||||
backOff.setMaxElapsedTime(300L);
|
||||
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ public class ExponentialBackOffTests {
|
||||
backOff.setMaxInterval(4000L);
|
||||
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(2000l, execution.nextBackOff());
|
||||
assertEquals(4000l, execution.nextBackOff());
|
||||
assertEquals(4000l, execution.nextBackOff()); // max reached
|
||||
assertEquals(4000l, execution.nextBackOff());
|
||||
assertEquals(2000L, execution.nextBackOff());
|
||||
assertEquals(4000L, execution.nextBackOff());
|
||||
assertEquals(4000L, execution.nextBackOff()); // max reached
|
||||
assertEquals(4000L, execution.nextBackOff());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,8 +83,8 @@ public class ExponentialBackOffTests {
|
||||
backOff.setMaxElapsedTime(4000L);
|
||||
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(2000l, execution.nextBackOff());
|
||||
assertEquals(4000l, execution.nextBackOff());
|
||||
assertEquals(2000L, execution.nextBackOff());
|
||||
assertEquals(4000L, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff()); // > 4 sec wait in total
|
||||
}
|
||||
|
||||
@@ -98,10 +98,10 @@ public class ExponentialBackOffTests {
|
||||
BackOffExecution execution = backOff.start();
|
||||
BackOffExecution execution2 = backOff.start();
|
||||
|
||||
assertEquals(2000l, execution.nextBackOff());
|
||||
assertEquals(2000l, execution2.nextBackOff());
|
||||
assertEquals(4000l, execution.nextBackOff());
|
||||
assertEquals(4000l, execution2.nextBackOff());
|
||||
assertEquals(2000L, execution.nextBackOff());
|
||||
assertEquals(2000L, execution2.nextBackOff());
|
||||
assertEquals(4000L, execution.nextBackOff());
|
||||
assertEquals(4000L, execution2.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution2.nextBackOff());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -48,8 +48,8 @@ public class FixedBackOffTests {
|
||||
public void maxAttemptsReached() {
|
||||
FixedBackOff backOff = new FixedBackOff(200L, 2);
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(200l, execution.nextBackOff());
|
||||
assertEquals(200l, execution.nextBackOff());
|
||||
assertEquals(200L, execution.nextBackOff());
|
||||
assertEquals(200L, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public class FixedBackOffTests {
|
||||
BackOffExecution execution = backOff.start();
|
||||
BackOffExecution execution2 = backOff.start();
|
||||
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(100l, execution2.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
assertEquals(100L, execution2.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution2.nextBackOff());
|
||||
}
|
||||
@@ -69,12 +69,12 @@ public class FixedBackOffTests {
|
||||
public void liveUpdate() {
|
||||
FixedBackOff backOff = new FixedBackOff(100L, 1);
|
||||
BackOffExecution execution = backOff.start();
|
||||
assertEquals(100l, execution.nextBackOff());
|
||||
assertEquals(100L, execution.nextBackOff());
|
||||
|
||||
backOff.setInterval(200l);
|
||||
backOff.setInterval(200L);
|
||||
backOff.setMaxAttempts(2);
|
||||
|
||||
assertEquals(200l, execution.nextBackOff());
|
||||
assertEquals(200L, execution.nextBackOff());
|
||||
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ public class ObjectUtilsTests {
|
||||
@Test
|
||||
@Deprecated
|
||||
public void hashCodeWithLong() {
|
||||
long lng = 883l;
|
||||
long lng = 883L;
|
||||
int expected = (new Long(lng)).hashCode();
|
||||
assertEquals(expected, ObjectUtils.hashCode(lng));
|
||||
}
|
||||
@@ -489,12 +489,12 @@ public class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
public void nullSafeHashCodeWithLongArray() {
|
||||
long lng = 7993l;
|
||||
long lng = 7993L;
|
||||
int expected = 31 * 7 + (int) (lng ^ (lng >>> 32));
|
||||
lng = 84320l;
|
||||
lng = 84320L;
|
||||
expected = 31 * expected + (int) (lng ^ (lng >>> 32));
|
||||
|
||||
long[] array = {7993l, 84320l};
|
||||
long[] array = {7993L, 84320L};
|
||||
int actual = ObjectUtils.nullSafeHashCode(array);
|
||||
|
||||
assertEquals(expected, actual);
|
||||
@@ -715,7 +715,7 @@ public class ObjectUtilsTests {
|
||||
|
||||
@Test
|
||||
public void nullSafeToStringWithLongArray() {
|
||||
long[] array = {434l, 23423l};
|
||||
long[] array = {434L, 23423L};
|
||||
assertEquals("{434, 23423}", ObjectUtils.nullSafeToString(array));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -227,7 +227,7 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
||||
if (arguments[i] instanceof Attributes) {
|
||||
arguments[i] = new PartialAttributes((Attributes) arguments[i]);
|
||||
}
|
||||
};
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(expression);
|
||||
assertEquals("def", expression.getValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void nullsafeFieldPropertyDereferencing_SPR16489() throws Exception {
|
||||
FooObjectHolder foh = new FooObjectHolder();
|
||||
@@ -715,7 +715,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertEquals("hello",expression.getValue(context));
|
||||
foh.foo = null;
|
||||
assertNull(expression.getValue(context));
|
||||
|
||||
|
||||
// Now revert state of foh and try compiling it:
|
||||
foh.foo = new FooObject();
|
||||
assertEquals("hello",expression.getValue(context));
|
||||
@@ -723,7 +723,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertEquals("hello",expression.getValue(context));
|
||||
foh.foo = null;
|
||||
assertNull(expression.getValue(context));
|
||||
|
||||
|
||||
// Static references
|
||||
expression = (SpelExpression)parser.parseExpression("#var?.propertya");
|
||||
context.setVariable("var", StaticsHelper.class);
|
||||
@@ -760,7 +760,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
context.setVariable("var", null);
|
||||
assertNull(expression.getValue(context));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void nullsafeMethodChaining_SPR16489() throws Exception {
|
||||
FooObjectHolder foh = new FooObjectHolder();
|
||||
@@ -777,7 +777,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertEquals("hello",expression.getValue(context));
|
||||
foh.foo = null;
|
||||
assertNull(expression.getValue(context));
|
||||
|
||||
|
||||
// Static method references
|
||||
expression = (SpelExpression)parser.parseExpression("#var?.methoda()");
|
||||
context.setVariable("var", StaticsHelper.class);
|
||||
@@ -789,7 +789,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertEquals("sh",expression.getValue(context).toString());
|
||||
context.setVariable("var", null);
|
||||
assertNull(expression.getValue(context));
|
||||
|
||||
|
||||
// Nullsafe guard on expression element evaluating to primitive/null
|
||||
expression = (SpelExpression)parser.parseExpression("#var?.intValue()");
|
||||
context.setVariable("var", 4);
|
||||
@@ -802,7 +802,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
context.setVariable("var", null);
|
||||
assertNull(expression.getValue(context));
|
||||
|
||||
|
||||
|
||||
// Nullsafe guard on expression element evaluating to primitive/null
|
||||
expression = (SpelExpression)parser.parseExpression("#var?.booleanValue()");
|
||||
context.setVariable("var", false);
|
||||
@@ -863,7 +863,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
context.setVariable("var", null);
|
||||
assertNull(expression.getValue(context));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void elvis() throws Exception {
|
||||
Expression expression = parser.parseExpression("'a'?:'b'");
|
||||
@@ -1575,7 +1575,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(expression);
|
||||
assertTrue((Boolean) expression.getValue(f));
|
||||
|
||||
long l = 300l;
|
||||
long l = 300L;
|
||||
expression = parse("#root==300l");
|
||||
assertTrue((Boolean) expression.getValue(l));
|
||||
assertCanCompile(expression);
|
||||
@@ -3236,15 +3236,15 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertTrue(expression.getValue(Boolean.class));
|
||||
context.setVariable("it", null);
|
||||
assertNull(expression.getValue(Boolean.class));
|
||||
|
||||
|
||||
assertCanCompile(expression);
|
||||
|
||||
|
||||
context.setVariable("it", 3);
|
||||
assertTrue(expression.getValue(Boolean.class));
|
||||
context.setVariable("it", null);
|
||||
assertNull(expression.getValue(Boolean.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void failsWhenSettingContextForExpression_SPR12326() {
|
||||
SpelExpressionParser parser = new SpelExpressionParser(
|
||||
@@ -3259,9 +3259,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertTrue(expression.getValue(Boolean.class));
|
||||
context.setVariable("it", null);
|
||||
assertNull(expression.getValue(Boolean.class));
|
||||
|
||||
|
||||
assertCanCompile(expression);
|
||||
|
||||
|
||||
context.setVariable("it", person);
|
||||
assertTrue(expression.getValue(Boolean.class));
|
||||
context.setVariable("it", null);
|
||||
@@ -4813,46 +4813,46 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertEquals(3, expression.getValue(root));
|
||||
assertEquals(3, expression.getValue(root));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void elvisOperator_SPR15192() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
Expression exp;
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("bar()");
|
||||
assertEquals("BAR", exp.getValue(new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("BAR", exp.getValue(new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("bar('baz')");
|
||||
assertEquals("BAZ", exp.getValue(new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("BAZ", exp.getValue(new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("map", Collections.singletonMap("foo", "qux"));
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'])");
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'] ?: 'qux')");
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// When the condition is a primitive
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3?:'foo'");
|
||||
assertEquals("3", exp.getValue(context, new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("3", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// When the condition is a double slot primitive
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3L?:'foo'");
|
||||
assertEquals("3", exp.getValue(context, new Foo(), String.class));
|
||||
@@ -4866,7 +4866,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(exp);
|
||||
assertEquals("4", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// null condition
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("null?:4L");
|
||||
assertEquals("4", exp.getValue(context, new Foo(), String.class));
|
||||
@@ -4888,7 +4888,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(exp);
|
||||
assertEquals("foo", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// variable access returning array
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("#x?:'foo'");
|
||||
context.setVariable("x",new int[]{1,2,3});
|
||||
@@ -4904,13 +4904,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
Expression exp;
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setVariable("map", Collections.singletonMap("foo", "qux"));
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'] != null ? #map['foo'] : 'qux')");
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
assertEquals("QUX", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3==3?3:'foo'");
|
||||
assertEquals("3", exp.getValue(context, new Foo(), String.class));
|
||||
assertCanCompile(exp);
|
||||
@@ -4921,7 +4921,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(exp);
|
||||
assertEquals("foo", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// When the condition is a double slot primitive
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3==3?3L:'foo'");
|
||||
assertEquals("3", exp.getValue(context, new Foo(), String.class));
|
||||
@@ -4940,7 +4940,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(exp);
|
||||
assertEquals("abc", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// null condition
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("3==3?null:4L");
|
||||
assertEquals(null, exp.getValue(context, new Foo(), String.class));
|
||||
@@ -4962,7 +4962,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(exp);
|
||||
assertEquals("foo", exp.getValue(context, new Foo(), String.class));
|
||||
assertIsCompiled(exp);
|
||||
|
||||
|
||||
// variable access returning array
|
||||
exp = new SpelExpressionParser(configuration).parseExpression("#x==#x?'1,2,3':'foo'");
|
||||
context.setVariable("x",new int[]{1,2,3});
|
||||
@@ -5289,9 +5289,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
public static class FooObjectHolder {
|
||||
|
||||
|
||||
private FooObject foo = new FooObject();
|
||||
|
||||
|
||||
public FooObject getFoo() {
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -82,42 +82,42 @@ public class ResultSetWrappingRowSetTests {
|
||||
public void testGetTimestampInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
doTest(rset, rowset, 1, new Timestamp(1234l));
|
||||
doTest(rset, rowset, 1, new Timestamp(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimestampString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", String.class);
|
||||
doTest(rset, rowset, "test", new Timestamp(1234l));
|
||||
doTest(rset, rowset, "test", new Timestamp(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDateInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", int.class);
|
||||
doTest(rset, rowset, 1, new Date(1234l));
|
||||
doTest(rset, rowset, 1, new Date(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDateString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", String.class);
|
||||
doTest(rset, rowset, "test", new Date(1234l));
|
||||
doTest(rset, rowset, "test", new Date(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimeInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", int.class);
|
||||
doTest(rset, rowset, 1, new Time(1234l));
|
||||
doTest(rset, rowset, 1, new Time(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimeString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", String.class);
|
||||
doTest(rset, rowset, "test", new Time(1234l));
|
||||
doTest(rset, rowset, "test", new Time(1234L));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -121,7 +121,7 @@ public class MockBodyContent extends BodyContent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
public void write(char[] value, int offset, int length) throws IOException {
|
||||
getEnclosingWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -113,7 +113,7 @@ public class MockJspWriter extends JspWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
public void write(char[] value, int offset, int length) throws IOException {
|
||||
getTargetWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -72,7 +72,7 @@ public class RequestContextFilterTests {
|
||||
throw new IllegalStateException("Too many invocations");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DummyFilterChain fc = new DummyFilterChain();
|
||||
MockFilterConfig mfc = new MockFilterConfig(new MockServletContext(), "foo");
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ModelInitializerTests {
|
||||
MethodIntrospector.selectMethods(controller.getClass(), BINDER_METHODS)
|
||||
.stream()
|
||||
.map(method -> new SyncInvocableHandlerMethod(controller, method))
|
||||
.collect(Collectors.toList());;
|
||||
.collect(Collectors.toList());
|
||||
|
||||
WebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
|
||||
return new InitBinderBindingContext(bindingInitializer, binderMethods);
|
||||
|
||||
@@ -531,7 +531,7 @@ public class HttpEntityMethodProcessorMockTests {
|
||||
|
||||
then(resourceRegionMessageConverter).should(times(1)).write(
|
||||
anyCollection(), eq(APPLICATION_OCTET_STREAM),
|
||||
argThat(outputMessage -> outputMessage.getHeaders().getFirst(HttpHeaders.ACCEPT_RANGES) == "bytes"));
|
||||
argThat(outputMessage -> "bytes".equals(outputMessage.getHeaders().getFirst(HttpHeaders.ACCEPT_RANGES))));
|
||||
assertEquals(206, servletResponse.getStatus());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -392,7 +392,7 @@ public class RequestResponseBodyMethodProcessorMockTests {
|
||||
|
||||
then(resourceRegionMessageConverter).should(times(1)).write(
|
||||
anyCollection(), eq(MediaType.APPLICATION_OCTET_STREAM),
|
||||
argThat(outputMessage -> outputMessage.getHeaders().getFirst(HttpHeaders.ACCEPT_RANGES) == "bytes"));
|
||||
argThat(outputMessage -> "bytes".equals(outputMessage.getHeaders().getFirst(HttpHeaders.ACCEPT_RANGES))));
|
||||
assertEquals(206, servletResponse.getStatus());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user