This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push:
new 3f92ccf JEXL-300: unit test
3f92ccf is described below
commit 3f92ccf6daef14cb4d3640562f4139ad08ee89ca
Author: Henri Biestro <[email protected]>
AuthorDate: Mon May 20 09:30:12 2019 +0200
JEXL-300: unit test
---
.../org/apache/commons/jexl3/Issues300Test.java | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
new file mode 100644
index 0000000..554c3c3
--- /dev/null
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jexl3;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+
+/**
+ * Test cases for reported issue between JEXL-300 and JEXL-399.
+ */
+public class Issues300Test {
+ @Ignore
+ public void testNullArrayAccess301a() throws Exception {
+ JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new
JexlArithmetic(false)).create();
+ String[] srcs = new String[]{
+ "var x = null; x.0", "var x = null; x[0]", "var x = [null,1];
x[0][0]"
+ };
+ for (int i = 0; i < srcs.length; ++i) {
+ String src = srcs[i];
+ JexlScript s = jexl.createScript(src);
+ try {
+ Object o = s.execute(null);
+ if (i > 0) {
+ Assert.fail(src + ": Should have failed");
+ }
+ } catch (Exception ex) {
+ //
+ }
+ }
+ }
+
+ @Ignore
+ public void testNullArrayAccess301b() throws Exception {
+ JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new
JexlArithmetic(false)).create();
+ Object[] xs = new Object[]{null, null, new Object[]{null, 1}};
+ String[] srcs = new String[]{
+ "x.0", "x[0]", "x[0][0]"
+ };
+ JexlContext ctxt = new MapContext();
+ for (int i = 0; i < xs.length; ++i) {
+ ctxt.set("x", xs[i]);
+ String src = srcs[i];
+ JexlScript s = jexl.createScript(src);
+ try {
+ Object o = s.execute(null);
+ Assert.fail(src + ": Should have failed");
+ } catch (Exception ex) {
+ //
+ }
+ }
+ }
+}