|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Properties;
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Ignore;
|
|
|
|
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
@ -75,9 +74,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Ignore
|
|
|
|
|
|
|
|
public void testSWF1086() {
|
|
|
|
public void testSWF1086() {
|
|
|
|
evaluate("printDouble(T(java.math.BigDecimal).valueOf(14.35))", "anullc", String.class);
|
|
|
|
evaluate("printDouble(T(java.math.BigDecimal).valueOf(14.35))", "14.35", String.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -101,7 +99,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull2(null)");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("tryToInvokeWithNull2(null)");
|
|
|
|
expr.getValue();
|
|
|
|
expr.getValue();
|
|
|
|
fail("Should have failed to find a method to which it could pass null");
|
|
|
|
fail("Should have failed to find a method to which it could pass null");
|
|
|
|
} catch (EvaluationException see) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (EvaluationException see) {
|
|
|
|
// success
|
|
|
|
// success
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eContext.setTypeLocator(new MyTypeLocator());
|
|
|
|
eContext.setTypeLocator(new MyTypeLocator());
|
|
|
|
@ -133,31 +132,44 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
static class MyTypeLocator extends StandardTypeLocator {
|
|
|
|
static class MyTypeLocator extends StandardTypeLocator {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Class<?> findType(String typename) throws EvaluationException {
|
|
|
|
public Class<?> findType(String typeName) throws EvaluationException {
|
|
|
|
if (typename.equals("Spr5899Class")) {
|
|
|
|
if (typeName.equals("Spr5899Class")) {
|
|
|
|
return Spr5899Class.class;
|
|
|
|
return Spr5899Class.class;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (typename.equals("Outer")) {
|
|
|
|
if (typeName.equals("Outer")) {
|
|
|
|
return Outer.class;
|
|
|
|
return Outer.class;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.findType(typename);
|
|
|
|
return super.findType(typeName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Spr5899Class {
|
|
|
|
static class Spr5899Class {
|
|
|
|
public Spr5899Class() {}
|
|
|
|
|
|
|
|
public Spr5899Class(Integer i) { }
|
|
|
|
|
|
|
|
public Spr5899Class(Integer i, String... s) { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer tryToInvokeWithNull(Integer value) { return value; }
|
|
|
|
public Spr5899Class() {
|
|
|
|
public Integer tryToInvokeWithNull2(int i) { return new Integer(i); }
|
|
|
|
}
|
|
|
|
public String tryToInvokeWithNull3(Integer value,String... strings) {
|
|
|
|
|
|
|
|
|
|
|
|
public Spr5899Class(Integer i) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Spr5899Class(Integer i, String... s) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer tryToInvokeWithNull(Integer value) {
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer tryToInvokeWithNull2(int i) {
|
|
|
|
|
|
|
|
return new Integer(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String tryToInvokeWithNull3(Integer value, String... strings) {
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for (int i=0;i<strings.length;i++) {
|
|
|
|
for (String string : strings) {
|
|
|
|
if (strings[i]==null) {
|
|
|
|
if (string == null) {
|
|
|
|
sb.append("null");
|
|
|
|
sb.append("null");
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
sb.append(strings[i]);
|
|
|
|
else {
|
|
|
|
|
|
|
|
sb.append(string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb.toString();
|
|
|
|
return sb.toString();
|
|
|
|
@ -182,11 +194,15 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Outer {
|
|
|
|
static class Outer {
|
|
|
|
|
|
|
|
|
|
|
|
static class Inner {
|
|
|
|
static class Inner {
|
|
|
|
|
|
|
|
|
|
|
|
public Inner() {}
|
|
|
|
public Inner() {}
|
|
|
|
|
|
|
|
|
|
|
|
public static int run() {
|
|
|
|
public static int run() {
|
|
|
|
return 12;
|
|
|
|
return 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int run2() {
|
|
|
|
public int run2() {
|
|
|
|
return 13;
|
|
|
|
return 13;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -276,7 +292,6 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
public Class<?>[] getSpecificTargetClasses() {
|
|
|
|
public Class<?>[] getSpecificTargetClasses() {
|
|
|
|
return new Class[] {Map.class};
|
|
|
|
return new Class[] {Map.class};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -323,13 +338,15 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
propertyAccessor.read(context, null, "abc");
|
|
|
|
propertyAccessor.read(context, null, "abc");
|
|
|
|
fail("Should have failed with an AccessException");
|
|
|
|
fail("Should have failed with an AccessException");
|
|
|
|
} catch (AccessException ae) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (AccessException ae) {
|
|
|
|
// success
|
|
|
|
// success
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
propertyAccessor.write(context, null, "abc","foo");
|
|
|
|
propertyAccessor.write(context, null, "abc","foo");
|
|
|
|
fail("Should have failed with an AccessException");
|
|
|
|
fail("Should have failed with an AccessException");
|
|
|
|
} catch (AccessException ae) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (AccessException ae) {
|
|
|
|
// success
|
|
|
|
// success
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -347,20 +364,25 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Foo {
|
|
|
|
static class Foo {
|
|
|
|
|
|
|
|
|
|
|
|
public ResourceSummary resource = new ResourceSummary();
|
|
|
|
public ResourceSummary resource = new ResourceSummary();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class ResourceSummary {
|
|
|
|
static class ResourceSummary {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final Resource resource;
|
|
|
|
|
|
|
|
|
|
|
|
ResourceSummary() {
|
|
|
|
ResourceSummary() {
|
|
|
|
this.resource = new Resource();
|
|
|
|
this.resource = new Resource();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private final Resource resource;
|
|
|
|
|
|
|
|
public Resource getResource() {
|
|
|
|
public Resource getResource() {
|
|
|
|
return resource;
|
|
|
|
return resource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Resource {
|
|
|
|
static class Resource {
|
|
|
|
|
|
|
|
|
|
|
|
public String getServer() {
|
|
|
|
public String getServer() {
|
|
|
|
return "abc";
|
|
|
|
return "abc";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -498,6 +520,7 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class XX {
|
|
|
|
static class XX {
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,String> m;
|
|
|
|
public Map<String,String> m;
|
|
|
|
|
|
|
|
|
|
|
|
public String floo ="bar";
|
|
|
|
public String floo ="bar";
|
|
|
|
@ -512,7 +535,9 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
static class Goo {
|
|
|
|
static class Goo {
|
|
|
|
|
|
|
|
|
|
|
|
public static Goo instance = new Goo();
|
|
|
|
public static Goo instance = new Goo();
|
|
|
|
|
|
|
|
|
|
|
|
public String bar = "key";
|
|
|
|
public String bar = "key";
|
|
|
|
|
|
|
|
|
|
|
|
public String value = null;
|
|
|
|
public String value = null;
|
|
|
|
|
|
|
|
|
|
|
|
public String wibble = "wobble";
|
|
|
|
public String wibble = "wobble";
|
|
|
|
@ -524,7 +549,6 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
public void setKey(String s) {
|
|
|
|
public void setKey(String s) {
|
|
|
|
value = s;
|
|
|
|
value = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Holder {
|
|
|
|
static class Holder {
|
|
|
|
@ -553,23 +577,27 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
parser.parseExpression(expression,context);
|
|
|
|
parser.parseExpression(expression,context);
|
|
|
|
fail("Should have failed");
|
|
|
|
fail("Should have failed");
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
if (!e.getMessage().equals(expectedMessage)) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assertEquals(expectedMessage,e.getMessage());
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
if (!ex.getMessage().equals(expectedMessage)) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(expectedMessage, ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static final ParserContext DOLLARSQUARE_TEMPLATE_PARSER_CONTEXT = new ParserContext() {
|
|
|
|
private static final ParserContext DOLLARSQUARE_TEMPLATE_PARSER_CONTEXT = new ParserContext() {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getExpressionPrefix() {
|
|
|
|
public String getExpressionPrefix() {
|
|
|
|
return "$[";
|
|
|
|
return "$[";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getExpressionSuffix() {
|
|
|
|
public String getExpressionSuffix() {
|
|
|
|
return "]";
|
|
|
|
return "]";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isTemplate() {
|
|
|
|
public boolean isTemplate() {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
@ -577,12 +605,14 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static class Foo2 {
|
|
|
|
static class Foo2 {
|
|
|
|
|
|
|
|
|
|
|
|
public void execute(String str){
|
|
|
|
public void execute(String str){
|
|
|
|
System.out.println("Value: " + str);
|
|
|
|
System.out.println("Value: " + str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class Message{
|
|
|
|
static class Message{
|
|
|
|
|
|
|
|
|
|
|
|
private String payload;
|
|
|
|
private String payload;
|
|
|
|
|
|
|
|
|
|
|
|
public String getPayload() {
|
|
|
|
public String getPayload() {
|
|
|
|
@ -605,7 +635,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@foo");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@foo");
|
|
|
|
assertEquals("custard",expr.getValue(eContext,String.class));
|
|
|
|
assertEquals("custard",expr.getValue(eContext,String.class));
|
|
|
|
} catch (SpelEvaluationException see) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (SpelEvaluationException see) {
|
|
|
|
assertEquals(SpelMessage.NO_BEAN_RESOLVER_REGISTERED,see.getMessageCode());
|
|
|
|
assertEquals(SpelMessage.NO_BEAN_RESOLVER_REGISTERED,see.getMessageCode());
|
|
|
|
assertEquals("foo",see.getInserts()[0]);
|
|
|
|
assertEquals("foo",see.getInserts()[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -624,7 +655,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@goo");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@goo");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
assertEquals(null,expr.getValue(eContext,String.class));
|
|
|
|
assertEquals(null,expr.getValue(eContext,String.class));
|
|
|
|
} catch (SpelEvaluationException see) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (SpelEvaluationException see) {
|
|
|
|
assertEquals(SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,see.getMessageCode());
|
|
|
|
assertEquals(SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,see.getMessageCode());
|
|
|
|
assertEquals("goo",see.getInserts()[0]);
|
|
|
|
assertEquals("goo",see.getInserts()[0]);
|
|
|
|
assertTrue(see.getCause() instanceof AccessException);
|
|
|
|
assertTrue(see.getCause() instanceof AccessException);
|
|
|
|
@ -639,19 +671,23 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@378");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("@378");
|
|
|
|
assertEquals("trouble",expr.getValue(eContext,String.class));
|
|
|
|
assertEquals("trouble",expr.getValue(eContext,String.class));
|
|
|
|
} catch (SpelParseException spe) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (SpelParseException spe) {
|
|
|
|
assertEquals(SpelMessage.INVALID_BEAN_REFERENCE,spe.getMessageCode());
|
|
|
|
assertEquals(SpelMessage.INVALID_BEAN_REFERENCE,spe.getMessageCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class MyBeanResolver implements BeanResolver {
|
|
|
|
static class MyBeanResolver implements BeanResolver {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Object resolve(EvaluationContext context, String beanname) throws AccessException {
|
|
|
|
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
|
|
|
|
if (beanname.equals("foo")) {
|
|
|
|
if (beanName.equals("foo")) {
|
|
|
|
return "custard";
|
|
|
|
return "custard";
|
|
|
|
} else if (beanname.equals("foo.bar")) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (beanName.equals("foo.bar")) {
|
|
|
|
return "trouble";
|
|
|
|
return "trouble";
|
|
|
|
} else if (beanname.equals("goo")) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (beanName.equals("goo")) {
|
|
|
|
throw new AccessException("DONT ASK ME ABOUT GOO");
|
|
|
|
throw new AccessException("DONT ASK ME ABOUT GOO");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
@ -678,7 +714,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(?'abc':'default')");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(?'abc':'default')");
|
|
|
|
expr.getValue(eContext);
|
|
|
|
expr.getValue(eContext);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (SpelEvaluationException see ) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (SpelEvaluationException see ) {
|
|
|
|
assertEquals(SpelMessage.TYPE_CONVERSION_ERROR,see.getMessageCode());
|
|
|
|
assertEquals(SpelMessage.TYPE_CONVERSION_ERROR,see.getMessageCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(false?'abc':null)");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(false?'abc':null)");
|
|
|
|
@ -689,7 +726,8 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(='default')");
|
|
|
|
expr = new SpelExpressionParser().parseRaw("(='default')");
|
|
|
|
expr.getValue(eContext);
|
|
|
|
expr.getValue(eContext);
|
|
|
|
fail();
|
|
|
|
fail();
|
|
|
|
} catch (SpelEvaluationException see ) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (SpelEvaluationException see ) {
|
|
|
|
assertEquals(SpelMessage.SETVALUE_NOT_SUPPORTED,see.getMessageCode());
|
|
|
|
assertEquals(SpelMessage.SETVALUE_NOT_SUPPORTED,see.getMessageCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -913,7 +951,6 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void varargsAndPrimitives_SPR8174() throws Exception {
|
|
|
|
public void varargsAndPrimitives_SPR8174() throws Exception {
|
|
|
|
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
|
|
|
|
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
|
|
|
|
@ -960,60 +997,59 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
args.add(TypeDescriptor.forObject(23f));
|
|
|
|
args.add(TypeDescriptor.forObject(23f));
|
|
|
|
me = new ReflectiveMethodResolver().resolve(emptyEvalContext,ru,"bar",args);
|
|
|
|
me = new ReflectiveMethodResolver().resolve(emptyEvalContext,ru,"bar",args);
|
|
|
|
me.execute(emptyEvalContext, ru, 12,23f);
|
|
|
|
me.execute(emptyEvalContext, ru, 12,23f);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ReflectionUtil<T extends Number> {
|
|
|
|
public class ReflectionUtil<T extends Number> {
|
|
|
|
|
|
|
|
|
|
|
|
public Object methodToCall(T param) {
|
|
|
|
public Object methodToCall(T param) {
|
|
|
|
System.out.println(param+" "+param.getClass());
|
|
|
|
System.out.println(param+" "+param.getClass());
|
|
|
|
return "Object methodToCall(T param)";
|
|
|
|
return "Object methodToCall(T param)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void foo(int... array) {
|
|
|
|
public void foo(int... array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(float...array) {
|
|
|
|
public void foo(float...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(double...array) {
|
|
|
|
public void foo(double...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(short...array) {
|
|
|
|
public void foo(short...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(long...array) {
|
|
|
|
public void foo(long...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(boolean...array) {
|
|
|
|
public void foo(boolean...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(char...array) {
|
|
|
|
public void foo(char...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void foo(byte...array) {
|
|
|
|
public void foo(byte...array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void bar(int... array) {
|
|
|
|
public void bar(int... array) {
|
|
|
|
if (array.length==0) {
|
|
|
|
if (array.length == 0) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1040,41 +1076,42 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
m.put("NE","xyz");
|
|
|
|
m.put("NE","xyz");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StandardEvaluationContext ctx = new StandardEvaluationContext(new Reserver());
|
|
|
|
StandardEvaluationContext ctx = new StandardEvaluationContext(new Reserver());
|
|
|
|
SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
|
SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
|
String ex = "getReserver().NE";
|
|
|
|
String ex = "getReserver().NE";
|
|
|
|
SpelExpression exp = null;
|
|
|
|
SpelExpression exp = parser.parseRaw(ex);
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
String value = (String) exp.getValue(ctx);
|
|
|
|
String value = (String)exp.getValue(ctx);
|
|
|
|
assertEquals("abc", value);
|
|
|
|
assertEquals("abc",value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ex = "getReserver().ne";
|
|
|
|
ex = "getReserver().ne";
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
value = (String)exp.getValue(ctx);
|
|
|
|
value = (String) exp.getValue(ctx);
|
|
|
|
assertEquals("def",value);
|
|
|
|
assertEquals("def", value);
|
|
|
|
|
|
|
|
|
|
|
|
ex = "getReserver().m[NE]";
|
|
|
|
ex = "getReserver().m[NE]";
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
value = (String)exp.getValue(ctx);
|
|
|
|
value = (String) exp.getValue(ctx);
|
|
|
|
assertEquals("xyz",value);
|
|
|
|
assertEquals("xyz", value);
|
|
|
|
|
|
|
|
|
|
|
|
ex = "getReserver().DIV";
|
|
|
|
ex = "getReserver().DIV";
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
assertEquals(1,exp.getValue(ctx));
|
|
|
|
assertEquals(1, exp.getValue(ctx));
|
|
|
|
|
|
|
|
|
|
|
|
ex = "getReserver().div";
|
|
|
|
ex = "getReserver().div";
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
exp = parser.parseRaw(ex);
|
|
|
|
assertEquals(3,exp.getValue(ctx));
|
|
|
|
assertEquals(3, exp.getValue(ctx));
|
|
|
|
|
|
|
|
|
|
|
|
exp = parser.parseRaw("NE");
|
|
|
|
exp = parser.parseRaw("NE");
|
|
|
|
assertEquals("abc",exp.getValue(ctx));
|
|
|
|
assertEquals("abc", exp.getValue(ctx));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testReservedWordProperties_9862() throws Exception {
|
|
|
|
public void testReservedWordProperties_9862() throws Exception {
|
|
|
|
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext ctx = new StandardEvaluationContext();
|
|
|
|
SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
|
SpelExpressionParser parser = new SpelExpressionParser();
|
|
|
|
SpelExpression expression = parser.parseRaw("T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST");
|
|
|
|
SpelExpression expression = parser.parseRaw(
|
|
|
|
|
|
|
|
"T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST");
|
|
|
|
Object value = expression.getValue(ctx);
|
|
|
|
Object value = expression.getValue(ctx);
|
|
|
|
assertEquals(value, Reserver.CONST);
|
|
|
|
assertEquals(value, Reserver.CONST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1107,47 +1144,53 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TestPropertyAccessor implements PropertyAccessor {
|
|
|
|
class TestPropertyAccessor implements PropertyAccessor {
|
|
|
|
|
|
|
|
|
|
|
|
private String mapName;
|
|
|
|
private String mapName;
|
|
|
|
|
|
|
|
|
|
|
|
public TestPropertyAccessor(String mapName) {
|
|
|
|
public TestPropertyAccessor(String mapName) {
|
|
|
|
this.mapName = mapName;
|
|
|
|
this.mapName = mapName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public Map<String, String> getMap(Object target) {
|
|
|
|
public Map<String, String> getMap(Object target) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Field f = target.getClass().getDeclaredField(mapName);
|
|
|
|
Field f = target.getClass().getDeclaredField(mapName);
|
|
|
|
return (Map<String,String>) f.get(target);
|
|
|
|
return (Map<String,String>) f.get(target);
|
|
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean canRead(EvaluationContext context, Object target, String name)
|
|
|
|
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
|
|
|
throws AccessException {
|
|
|
|
|
|
|
|
return getMap(target).containsKey(name);
|
|
|
|
return getMap(target).containsKey(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean canWrite(EvaluationContext context, Object target, String name)
|
|
|
|
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
|
|
|
|
throws AccessException {
|
|
|
|
|
|
|
|
return getMap(target).containsKey(name);
|
|
|
|
return getMap(target).containsKey(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Class<?>[] getSpecificTargetClasses() {
|
|
|
|
public Class<?>[] getSpecificTargetClasses() {
|
|
|
|
return new Class[]{ContextObject.class};
|
|
|
|
return new Class[] {ContextObject.class};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public TypedValue read(EvaluationContext context, Object target, String name)
|
|
|
|
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
|
|
|
|
throws AccessException {
|
|
|
|
|
|
|
|
return new TypedValue(getMap(target).get(name));
|
|
|
|
return new TypedValue(getMap(target).get(name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void write(EvaluationContext context, Object target, String name, Object newValue)
|
|
|
|
public void write(EvaluationContext context, Object target, String name, Object newValue)
|
|
|
|
throws AccessException {
|
|
|
|
throws AccessException {
|
|
|
|
getMap(target).put(name, (String) newValue);
|
|
|
|
getMap(target).put(name, (String) newValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ContextObject {
|
|
|
|
class ContextObject {
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> firstContext = new HashMap<String, String>();
|
|
|
|
public Map<String, String> firstContext = new HashMap<String, String>();
|
|
|
|
public Map<String, String> secondContext = new HashMap<String, String>();
|
|
|
|
public Map<String, String> secondContext = new HashMap<String, String>();
|
|
|
|
public Map<String, String> thirdContext = new HashMap<String, String>();
|
|
|
|
public Map<String, String> thirdContext = new HashMap<String, String>();
|
|
|
|
@ -1168,6 +1211,7 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
|
|
|
|
|
|
|
|
fourthContext.put("shouldBeFourth", "fourth");
|
|
|
|
fourthContext.put("shouldBeFourth", "fourth");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> getFirstContext() {return firstContext;}
|
|
|
|
public Map<String, String> getFirstContext() {return firstContext;}
|
|
|
|
public Map<String, String> getSecondContext() {return secondContext;}
|
|
|
|
public Map<String, String> getSecondContext() {return secondContext;}
|
|
|
|
public Map<String, String> getThirdContext() {return thirdContext;}
|
|
|
|
public Map<String, String> getThirdContext() {return thirdContext;}
|
|
|
|
@ -1180,7 +1224,6 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testCustomStaticFunctions_SPR9038() {
|
|
|
|
public void testCustomStaticFunctions_SPR9038() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
List<MethodResolver> methodResolvers = new ArrayList<MethodResolver>();
|
|
|
|
List<MethodResolver> methodResolvers = new ArrayList<MethodResolver>();
|
|
|
|
@ -1188,10 +1231,10 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected Method[] getMethods(Class<?> type) {
|
|
|
|
protected Method[] getMethods(Class<?> type) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return new Method[] {
|
|
|
|
return new Method[] {Integer.class.getDeclaredMethod("parseInt",
|
|
|
|
Integer.class.getDeclaredMethod("parseInt", new Class[] {
|
|
|
|
new Class[] {String.class, Integer.TYPE })};
|
|
|
|
String.class, Integer.TYPE }) };
|
|
|
|
}
|
|
|
|
} catch (NoSuchMethodException e1) {
|
|
|
|
catch (NoSuchMethodException ex) {
|
|
|
|
return new Method[0];
|
|
|
|
return new Method[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1203,10 +1246,6 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
|
|
|
|
|
|
|
|
Integer result = expression.getValue(context, "", Integer.class);
|
|
|
|
Integer result = expression.getValue(context, "", Integer.class);
|
|
|
|
assertEquals("Equal assertion failed: ", -255, result.intValue());
|
|
|
|
assertEquals("Equal assertion failed: ", -255, result.intValue());
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Unexpected exception: "+e.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -1239,8 +1278,7 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatFunctionResolverTest() {
|
|
|
|
public void SPR_9486_floatFunctionResolverTest() throws Exception {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedResult = Math.abs(-10.2f);
|
|
|
|
Number expectedResult = Math.abs(-10.2f);
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
SPR_9486_FunctionsClass testObject = new SPR_9486_FunctionsClass();
|
|
|
|
SPR_9486_FunctionsClass testObject = new SPR_9486_FunctionsClass();
|
|
|
|
@ -1249,13 +1287,10 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("abs(-10.2f)");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("abs(-10.2f)");
|
|
|
|
Number result = expression.getValue(context, testObject, Number.class);
|
|
|
|
Number result = expression.getValue(context, testObject, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatFunctionResolverTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatFunctionResolverTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatFunctionResolverTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class SPR_9486_FunctionsClass {
|
|
|
|
class SPR_9486_FunctionsClass {
|
|
|
|
|
|
|
|
|
|
|
|
public int abs(int value) {
|
|
|
|
public int abs(int value) {
|
|
|
|
return Math.abs(value);
|
|
|
|
return Math.abs(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1267,394 +1302,264 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_addFloatWithDoubleTest() {
|
|
|
|
public void SPR_9486_addFloatWithDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f + 10.2;
|
|
|
|
Number expectedNumber = 10.21f + 10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f + 10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f + 10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_addFloatWithDoubleTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_addFloatWithDoubleTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_addFloatWithDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_addFloatWithFloatTest() {
|
|
|
|
public void SPR_9486_addFloatWithFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f + 10.2f;
|
|
|
|
Number expectedNumber = 10.21f + 10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f + 10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f + 10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_addFloatWithFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_addFloatWithFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_addFloatWithFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_subtractFloatWithDoubleTest() {
|
|
|
|
public void SPR_9486_subtractFloatWithDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f - 10.2;
|
|
|
|
Number expectedNumber = 10.21f - 10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f - 10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f - 10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_subtractFloatWithDoubleTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_subtractFloatWithDoubleTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_subtractFloatWithDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_subtractFloatWithFloatTest() {
|
|
|
|
public void SPR_9486_subtractFloatWithFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f - 10.2f;
|
|
|
|
Number expectedNumber = 10.21f - 10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f - 10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f - 10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_subtractFloatWithFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_subtractFloatWithFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_subtractFloatWithFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_multiplyFloatWithDoubleTest() {
|
|
|
|
public void SPR_9486_multiplyFloatWithDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f * 10.2;
|
|
|
|
Number expectedNumber = 10.21f * 10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f * 10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f * 10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for float multiplied by double Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for float multiplied by double Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_multiplyFloatWithDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_multiplyFloatWithFloatTest() {
|
|
|
|
public void SPR_9486_multiplyFloatWithFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = 10.21f * 10.2f;
|
|
|
|
Number expectedNumber = 10.21f * 10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f * 10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f * 10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for float multiply by another float Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for float multiply by another float Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_multiplyFloatWithFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatDivideByFloatTest() {
|
|
|
|
public void SPR_9486_floatDivideByFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = -10.21f/-10.2f;
|
|
|
|
Number expectedNumber = -10.21f/-10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f / -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f / -10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for float divide Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for float divide Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatDivideByFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatDivideByDoubleTest() {
|
|
|
|
public void SPR_9486_floatDivideByDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedNumber = -10.21f/-10.2;
|
|
|
|
Number expectedNumber = -10.21f/-10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f / -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f / -10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for float divide Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for float divide Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatDivideByDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatEqFloatUnaryMinusTest() {
|
|
|
|
public void SPR_9486_floatEqFloatUnaryMinusTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = -10.21f == -10.2f;
|
|
|
|
Boolean expectedResult = -10.21f == -10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f == -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f == -10.2f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatUnaryMinusTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatUnaryMinusTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatEqFloatUnaryMinusTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatEqDoubleUnaryMinusTest() {
|
|
|
|
public void SPR_9486_floatEqDoubleUnaryMinusTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = -10.21f == -10.2;
|
|
|
|
Boolean expectedResult = -10.21f == -10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f == -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f == -10.2");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqDoubleUnaryMinusTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqDoubleUnaryMinusTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatEqDoubleUnaryMinusTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatEqFloatTest() {
|
|
|
|
public void SPR_9486_floatEqFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = 10.215f == 10.2109f;
|
|
|
|
Boolean expectedResult = 10.215f == 10.2109f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f == 10.2109f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f == 10.2109f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatEqFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatEqDoubleTest() {
|
|
|
|
public void SPR_9486_floatEqDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = 10.215f == 10.2109;
|
|
|
|
Boolean expectedResult = 10.215f == 10.2109;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f == 10.2109");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f == 10.2109");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqDoubleTest() Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqDoubleTest() Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatEqDoubleTest()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatNotEqFloatTest() {
|
|
|
|
public void SPR_9486_floatNotEqFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = 10.215f != 10.2109f;
|
|
|
|
Boolean expectedResult = 10.215f != 10.2109f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f != 10.2109f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f != 10.2109f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatEqFloatTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatEqFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatNotEqDoubleTest() {
|
|
|
|
public void SPR_9486_floatNotEqDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = 10.215f != 10.2109;
|
|
|
|
Boolean expectedResult = 10.215f != 10.2109;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f != 10.2109");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.215f != 10.2109");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatNotEqDoubleTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatNotEqDoubleTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatNotEqDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatLessThanFloatTest() {
|
|
|
|
public void SPR_9486_floatLessThanFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f < -10.2f;
|
|
|
|
Boolean expectedNumber = -10.21f < -10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f < -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f < -10.2f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatLessThanFloatTest()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatLessThanDoubleTest() {
|
|
|
|
public void SPR_9486_floatLessThanDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f < -10.2;
|
|
|
|
Boolean expectedNumber = -10.21f < -10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f < -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f < -10.2");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanDoubleTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanDoubleTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatLessThanDoubleTest()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatLessThanOrEqualFloatTest() {
|
|
|
|
public void SPR_9486_floatLessThanOrEqualFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f <= -10.22f;
|
|
|
|
Boolean expectedNumber = -10.21f <= -10.22f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f <= -10.22f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f <= -10.22f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanOrEqualFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanOrEqualFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatLessThanOrEqualFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatLessThanOrEqualDoubleTest() {
|
|
|
|
public void SPR_9486_floatLessThanOrEqualDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f <= -10.2;
|
|
|
|
Boolean expectedNumber = -10.21f <= -10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f <= -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f <= -10.2");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanOrEqualDoubleTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatLessThanOrEqualDoubleTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatLessThanOrEqualDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatGreaterThanFloatTest() {
|
|
|
|
public void SPR_9486_floatGreaterThanFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f > -10.2f;
|
|
|
|
Boolean expectedNumber = -10.21f > -10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f > -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f > -10.2f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatGreaterThanTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatGreaterThanDoubleTest() {
|
|
|
|
public void SPR_9486_floatGreaterThanDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = -10.21f > -10.2;
|
|
|
|
Boolean expectedResult = -10.21f > -10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f > -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f > -10.2");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanDoubleTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanDoubleTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatGreaterThanTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatGreaterThanOrEqualFloatTest() {
|
|
|
|
public void SPR_9486_floatGreaterThanOrEqualFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedNumber = -10.21f >= -10.2f;
|
|
|
|
Boolean expectedNumber = -10.21f >= -10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f >= -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f >= -10.2f");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanFloatTest Test: ", expectedNumber, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatGreaterThanTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatGreaterThanEqualDoubleTest() {
|
|
|
|
public void SPR_9486_floatGreaterThanEqualDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean expectedResult = -10.21f >= -10.2;
|
|
|
|
Boolean expectedResult = -10.21f >= -10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f >= -10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("-10.21f >= -10.2");
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
Boolean result = expression.getValue(context, null, Boolean.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanDoubleTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatGreaterThanDoubleTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatGreaterThanTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatModulusFloatTest() {
|
|
|
|
public void SPR_9486_floatModulusFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedResult = 10.21f % 10.2f;
|
|
|
|
Number expectedResult = 10.21f % 10.2f;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f % 10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f % 10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatModulusFloatTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatModulusFloatTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatModulusFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatModulusDoubleTest() {
|
|
|
|
public void SPR_9486_floatModulusDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedResult = 10.21f % 10.2;
|
|
|
|
Number expectedResult = 10.21f % 10.2;
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f % 10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f % 10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatModulusDoubleTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatModulusDoubleTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatModulusDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatPowerFloatTest() {
|
|
|
|
public void SPR_9486_floatPowerFloatTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedResult = Math.pow(10.21f, -10.2f);
|
|
|
|
Number expectedResult = Math.pow(10.21f, -10.2f);
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f ^ -10.2f");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f ^ -10.2f");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatPowerFloatTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatPowerFloatTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatPowerFloatTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void SPR_9486_floatPowerDoubleTest() {
|
|
|
|
public void SPR_9486_floatPowerDoubleTest() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Number expectedResult = Math.pow(10.21f, 10.2);
|
|
|
|
Number expectedResult = Math.pow(10.21f, 10.2);
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f ^ 10.2");
|
|
|
|
org.springframework.expression.Expression expression = parser.parseExpression("10.21f ^ 10.2");
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
Number result = expression.getValue(context, null, Number.class);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatPowerDoubleTest Test: ", expectedResult, result);
|
|
|
|
assertEquals("Equal assertion failed for SPR_9486_floatPowerDoubleTest Test: ", expectedResult, result);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail("Test failed - SPR_9486_floatPowerDoubleTest");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -1877,6 +1782,7 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
public T getProperty();
|
|
|
|
public T getProperty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class GenericImplementation implements GenericInterface<Integer> {
|
|
|
|
private static class GenericImplementation implements GenericInterface<Integer> {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -1885,6 +1791,7 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class PackagePrivateClassWithGetter {
|
|
|
|
static class PackagePrivateClassWithGetter {
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getProperty() {
|
|
|
|
public Integer getProperty() {
|
|
|
|
@ -1892,26 +1799,29 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class OnlyBridgeMethod extends PackagePrivateClassWithGetter {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class OnlyBridgeMethod extends PackagePrivateClassWithGetter {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static interface StaticFinal {
|
|
|
|
public static interface StaticFinal {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String VALUE = "interfaceValue";
|
|
|
|
public static final String VALUE = "interfaceValue";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract static class AbstractStaticFinal implements StaticFinal {
|
|
|
|
public abstract static class AbstractStaticFinal implements StaticFinal {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class StaticFinalImpl1 extends AbstractStaticFinal implements StaticFinal {
|
|
|
|
public static class StaticFinalImpl1 extends AbstractStaticFinal implements StaticFinal {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class StaticFinalImpl2 extends AbstractStaticFinal {
|
|
|
|
public static class StaticFinalImpl2 extends AbstractStaticFinal {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* The Class TestObject.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static class SPR10486 {
|
|
|
|
public static class SPR10486 {
|
|
|
|
|
|
|
|
|
|
|
|
private String name = "name";
|
|
|
|
private String name = "name";
|
|
|
|
@ -1923,14 +1833,14 @@ public class SpelReproTests extends ExpressionTestCase {
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class SPR11142 {
|
|
|
|
static class SPR11142 {
|
|
|
|
|
|
|
|
|
|
|
|
public String isSomething() {
|
|
|
|
public String isSomething() {
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|