Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Sep 19, 2019
1 parent fde7b1e commit 734ceed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
Expand Up @@ -34,16 +34,19 @@
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.SimpleEvaluationContext;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.testresources.Inventor;
import org.springframework.expression.spel.testresources.Person;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* Tests accessing of properties.
* Unit tests for property access.
*
* @author Andy Clement
* @author Juergen Hoeller
* @author Joyce Zhan
* @author Sam Brannen
*/
public class PropertyAccessTests extends AbstractExpressionTests {

Expand Down Expand Up @@ -254,6 +257,15 @@ public void propertyAccessWithInstanceMethodResolverAndTypedRootObject() {
assertThat(context.getRootObject().getTypeDescriptor().getType()).isSameAs(Object.class);
}

@Test
void propertyAccessWithArrayIndexOutOfBounds() {
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
Expression expression = parser.parseExpression("stringArrayOfThreeItems[3]");
assertThatExceptionOfType(SpelEvaluationException.class)
.isThrownBy(() -> expression.getValue(context, new Inventor()))
.satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.ARRAY_INDEX_OUT_OF_BOUNDS));
}


// This can resolve the property 'flibbles' on any String (very useful...)
private static class StringyPropertyAccessor implements PropertyAccessor {
Expand Down

This file was deleted.

0 comments on commit 734ceed

Please sign in to comment.