|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -18,17 +18,21 @@ package org.springframework.expression.spel; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.expression.EvaluationContext; |
|
|
|
import org.springframework.expression.Expression; |
|
|
|
import org.springframework.expression.Expression; |
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser; |
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser; |
|
|
|
|
|
|
|
import org.springframework.expression.spel.support.SimpleEvaluationContext; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Test construction of arrays. |
|
|
|
* Test construction of arrays. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Andy Clement |
|
|
|
* @author Andy Clement |
|
|
|
* @author Sam Brannen |
|
|
|
* @author Sam Brannen |
|
|
|
|
|
|
|
* @author Juergen Hoeller |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class ArrayConstructorTests extends AbstractExpressionTests { |
|
|
|
class ArrayConstructorTests extends AbstractExpressionTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -114,6 +118,14 @@ class ArrayConstructorTests extends AbstractExpressionTests { |
|
|
|
String[][][].class); |
|
|
|
String[][][].class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void noArrayConstruction() { |
|
|
|
|
|
|
|
EvaluationContext context = SimpleEvaluationContext.forReadWriteDataBinding().build(); |
|
|
|
|
|
|
|
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() -> |
|
|
|
|
|
|
|
parser.parseExpression("new int[2]").getValue(context)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void evaluateArrayBuildingExpression(String expression, String expectedToString) { |
|
|
|
private void evaluateArrayBuildingExpression(String expression, String expectedToString) { |
|
|
|
SpelExpressionParser parser = new SpelExpressionParser(); |
|
|
|
SpelExpressionParser parser = new SpelExpressionParser(); |
|
|
|
Expression e = parser.parseExpression(expression); |
|
|
|
Expression e = parser.parseExpression(expression); |
|
|
|
|