diff --git a/modules/api/pom.xml b/modules/api/pom.xml index d0fca00..9e4c699 100644 --- a/modules/api/pom.xml +++ b/modules/api/pom.xml @@ -15,14 +15,14 @@ jar Java Unified Expression Language API - 2.2.8-SNAPSHOT + ${parent.version} org.apache.maven.plugins maven-jar-plugin - 2.4 + ${maven-jar-plugin.version} false diff --git a/modules/api/src/test/java/javax/el/AllTests.java b/modules/api/src/test/java/javax/el/AllTests.java deleted file mode 100644 index 3fec357..0000000 --- a/modules/api/src/test/java/javax/el/AllTests.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 javax.el; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for javax.el"); - //$JUnit-BEGIN$ - suite.addTestSuite(ArrayELResolverTest.class); - suite.addTestSuite(BeanELResolverTest.class); - suite.addTestSuite(CompositeELResolverTest.class); - suite.addTestSuite(ListELResolverTest.class); - suite.addTestSuite(MapELResolverTest.class); - suite.addTestSuite(ResourceBundleELResolverTest.class); - suite.addTestSuite(ELContextTest.class); - suite.addTestSuite(MethodInfoTest.class); - suite.addTestSuite(ExpressionFactoryTest.class); - suite.addTestSuite(ValueReferenceTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/api/src/test/java/javax/el/ArrayELResolverTest.java b/modules/api/src/test/java/javax/el/ArrayELResolverTest.java index bbf492a..670d42d 100644 --- a/modules/api/src/test/java/javax/el/ArrayELResolverTest.java +++ b/modules/api/src/test/java/javax/el/ArrayELResolverTest.java @@ -15,12 +15,15 @@ */ package javax.el; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class ArrayELResolverTest extends TestCase { +public class ArrayELResolverTest { ELContext context = new TestContext(); + @Test public void testGetCommonPropertyType() { int scalar = 0; int[] array = { 1, 2, 3 }; @@ -36,6 +39,7 @@ public void testGetCommonPropertyType() { assertNull(resolver.getCommonPropertyType(context, null)); } + @Test public void testGetFeatureDescriptors() { int scalar = 0; int[] array = { 1, 2, 3 }; @@ -47,6 +51,7 @@ public void testGetFeatureDescriptors() { assertNull(resolver.getFeatureDescriptors(context, null)); } + @Test public void testGetType() { int scalar = 0; int[] array = { 1, 2, 3 }; @@ -94,6 +99,7 @@ public void testGetType() { } } + @Test public void testGetValue() { int scalar = 0; int[] array = { 1, 2, 3 }; @@ -131,6 +137,7 @@ public void testGetValue() { assertNull(resolver.getValue(context, array, array.length)); } + @Test public void testIsReadOnly() { int scalar = 0; int[] array = { 1, 2, 3 }; @@ -184,6 +191,7 @@ public void testIsReadOnly() { } } + @Test public void testSetValue() { int scalar = 0; int[] array = { 1, 2, 3 }; diff --git a/modules/api/src/test/java/javax/el/BeanELResolverTest.java b/modules/api/src/test/java/javax/el/BeanELResolverTest.java index 16bbbbc..9c5b96c 100644 --- a/modules/api/src/test/java/javax/el/BeanELResolverTest.java +++ b/modules/api/src/test/java/javax/el/BeanELResolverTest.java @@ -15,6 +15,8 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.beans.FeatureDescriptor; import java.util.ArrayList; import java.util.Iterator; @@ -23,9 +25,11 @@ import javax.el.test.TestClass; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; + +import static org.junit.jupiter.api.Assertions.*; -public class BeanELResolverTest extends TestCase { +public class BeanELResolverTest { public static class TestBean { int readOnly = 123; int readWrite = 456; @@ -68,6 +72,7 @@ int secret() { ELContext context = new TestContext(); + @Test public void testGetCommonPropertyType() { BeanELResolver resolver = new BeanELResolver(); @@ -78,6 +83,7 @@ public void testGetCommonPropertyType() { assertNull(resolver.getCommonPropertyType(context, null)); } + @Test public void testGetFeatureDescriptors() { BeanELResolver resolver = new BeanELResolver(); @@ -101,6 +107,7 @@ public void testGetFeatureDescriptors() { assertEquals(4, names.size()); } + @Test public void testGetType() { BeanELResolver resolver = new BeanELResolver(); @@ -131,6 +138,7 @@ public void testGetType() { } } + @Test public void testGetValue() { Properties properties = new Properties(); properties.setProperty(ExpressionFactory.class.getName(), TestFactory.class.getName()); @@ -163,6 +171,7 @@ public void testGetValue() { } } + @Test public void testGetValue2() { Properties properties = new Properties(); properties.setProperty(ExpressionFactory.class.getName(), TestFactory.class.getName()); @@ -181,6 +190,7 @@ public void testGetValue2() { assertTrue(context.isPropertyResolved()); } + @Test public void testIsReadOnly() { BeanELResolver resolver = new BeanELResolver(); BeanELResolver resolverReadOnly = new BeanELResolver(true); @@ -219,6 +229,7 @@ public void testIsReadOnly() { } } + @Test public void testSetValue() { BeanELResolver resolver = new BeanELResolver(); BeanELResolver resolverReadOnly = new BeanELResolver(true); @@ -270,6 +281,7 @@ public void testSetValue() { } } + @Test public void testInvoke() { BeanELResolver resolver = new BeanELResolver(); @@ -299,6 +311,7 @@ public void testInvoke() { } } + @Test public void testInvoke2() { BeanELResolver resolver = new BeanELResolver(); assertEquals(42, resolver.invoke(context, new TestClass().getAnonymousTestInterface(), "getFourtyTwo", null, new Class[]{})); diff --git a/modules/api/src/test/java/javax/el/CompositeELResolverTest.java b/modules/api/src/test/java/javax/el/CompositeELResolverTest.java index ac9db94..2afd92b 100644 --- a/modules/api/src/test/java/javax/el/CompositeELResolverTest.java +++ b/modules/api/src/test/java/javax/el/CompositeELResolverTest.java @@ -15,16 +15,18 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.beans.FeatureDescriptor; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class CompositeELResolverTest extends TestCase { +public class CompositeELResolverTest { ELContext context = new TestContext(); Map sampleMap() { @@ -35,6 +37,7 @@ Map sampleMap() { return map; } + @Test public void testGetCommonPropertyType() { CompositeELResolver resolver = new CompositeELResolver(); assertNull(resolver.getCommonPropertyType(context, null)); @@ -65,6 +68,7 @@ private int count(Iterator iterator) { return count; } + @Test public void testGetFeatureDescriptors() { CompositeELResolver resolver = new CompositeELResolver(); assertFalse(resolver.getFeatureDescriptors(context, null).hasNext()); @@ -80,6 +84,7 @@ public void testGetFeatureDescriptors() { assertEquals(5, count(resolver.getFeatureDescriptors(context, sampleMap()))); // 0, 1, 2, class, empty } + @Test public void testGetType() { CompositeELResolver resolver = new CompositeELResolver(); assertNull(resolver.getType(context, null, "foo")); @@ -98,6 +103,7 @@ public void testGetType() { assertEquals(Object.class, resolver.getType(context, sampleMap(), 0)); } + @Test public void testGetValue() { CompositeELResolver resolver = new CompositeELResolver(); assertNull(resolver.getValue(context, null, "foo")); @@ -116,6 +122,7 @@ public void testGetValue() { assertEquals(1, resolver.getValue(context, sampleMap(), 0)); } + @Test public void testIsReadOnly() { CompositeELResolver resolver = new CompositeELResolver(); assertFalse(resolver.isReadOnly(context, null, "foo")); @@ -134,6 +141,7 @@ public void testIsReadOnly() { assertFalse(resolver.isReadOnly(context, sampleMap(), 0)); } + @Test public void testSetValue() { CompositeELResolver resolver = new CompositeELResolver(); resolver.setValue(context, null, "foo", "bar"); diff --git a/modules/api/src/test/java/javax/el/ELContextTest.java b/modules/api/src/test/java/javax/el/ELContextTest.java index c207d31..c2d071c 100644 --- a/modules/api/src/test/java/javax/el/ELContextTest.java +++ b/modules/api/src/test/java/javax/el/ELContextTest.java @@ -15,14 +15,17 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.util.Locale; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class ELContextTest extends TestCase { +public class ELContextTest { + @Test public void testContext() { ELContext context = new TestContext(); assertNull(context.getContext(Integer.class)); @@ -30,6 +33,7 @@ public void testContext() { assertEquals("foo", context.getContext(Integer.class)); } + @Test public void testLocale() { ELContext context = new TestContext(); assertNull(context.getLocale()); @@ -37,6 +41,7 @@ public void testLocale() { assertEquals(Locale.ENGLISH, context.getLocale()); } + @Test public void testPropertyResolved() { ELContext context = new TestContext(); assertFalse(context.isPropertyResolved()); diff --git a/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java b/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java index a6fd114..ab45c30 100644 --- a/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java +++ b/modules/api/src/test/java/javax/el/ExpressionFactoryTest.java @@ -15,15 +15,17 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Properties; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; -public class ExpressionFactoryTest extends TestCase { +public class ExpressionFactoryTest { private String getFactoryClassName() throws IOException { String className = null; String serviceId = "META-INF/services/" + ExpressionFactory.class.getName(); @@ -36,12 +38,14 @@ private String getFactoryClassName() throws IOException { return className; } + @Test public void testNewInstance() throws IOException { ExpressionFactory factory = ExpressionFactory.newInstance(); assertNotNull(factory); assertEquals(factory.getClass().getName(), getFactoryClassName()); } + @Test public void testNewInstanceProperties() throws IOException { Properties properties = new Properties(); diff --git a/modules/api/src/test/java/javax/el/ListELResolverTest.java b/modules/api/src/test/java/javax/el/ListELResolverTest.java index 1742a82..256cc40 100644 --- a/modules/api/src/test/java/javax/el/ListELResolverTest.java +++ b/modules/api/src/test/java/javax/el/ListELResolverTest.java @@ -15,15 +15,19 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.util.Arrays; import java.util.List; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class ListELResolverTest extends TestCase { + +public class ListELResolverTest { ELContext context = new TestContext(); + @Test public void testGetCommonPropertyType() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); @@ -39,6 +43,7 @@ public void testGetCommonPropertyType() { assertNull(resolver.getCommonPropertyType(context, null)); } + @Test public void testGetFeatureDescriptors() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); @@ -50,6 +55,7 @@ public void testGetFeatureDescriptors() { assertNull(resolver.getFeatureDescriptors(context, null)); } + @Test public void testGetType() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); @@ -97,6 +103,7 @@ public void testGetType() { } } + @Test public void testGetValue() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); @@ -134,6 +141,7 @@ public void testGetValue() { assertNull(resolver.getValue(context, list, list.size())); } + @Test public void testIsReadOnly() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); @@ -187,6 +195,7 @@ public void testIsReadOnly() { } } + @Test public void testSetValue() { Integer scalar = 0; List list = Arrays.asList(1, 2, 3); diff --git a/modules/api/src/test/java/javax/el/MapELResolverTest.java b/modules/api/src/test/java/javax/el/MapELResolverTest.java index 8857275..dadee5a 100644 --- a/modules/api/src/test/java/javax/el/MapELResolverTest.java +++ b/modules/api/src/test/java/javax/el/MapELResolverTest.java @@ -15,6 +15,8 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.beans.FeatureDescriptor; import java.util.ArrayList; import java.util.HashMap; @@ -22,10 +24,10 @@ import java.util.List; import java.util.Map; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class MapELResolverTest extends TestCase { +public class MapELResolverTest { ELContext context = new TestContext(); Map sampleMap() { @@ -36,6 +38,7 @@ Map sampleMap() { return map; } + @Test public void testGetCommonPropertyType() { Integer scalar = 0; Map map = sampleMap(); @@ -51,6 +54,7 @@ public void testGetCommonPropertyType() { assertNull(resolver.getCommonPropertyType(context, null)); } + @Test public void testGetFeatureDescriptors() { Integer scalar = 0; Map map = sampleMap(); @@ -78,6 +82,7 @@ public void testGetFeatureDescriptors() { assertEquals(3, names.size()); } + @Test public void testGetType() { Integer scalar = 0; Map map = sampleMap(); @@ -107,6 +112,7 @@ public void testGetType() { assertTrue(context.isPropertyResolved()); } + @Test public void testGetValue() { Integer scalar = 0; Map map = sampleMap(); @@ -137,6 +143,7 @@ public void testGetValue() { assertTrue(context.isPropertyResolved()); } + @Test public void testIsReadOnly() { Integer scalar = 0; Map map = sampleMap(); @@ -173,6 +180,7 @@ public void testIsReadOnly() { assertTrue(context.isPropertyResolved()); } + @Test public void testSetValue() { Integer scalar = 0; Map map = sampleMap(); diff --git a/modules/api/src/test/java/javax/el/MethodInfoTest.java b/modules/api/src/test/java/javax/el/MethodInfoTest.java index b7b66ae..df0b054 100644 --- a/modules/api/src/test/java/javax/el/MethodInfoTest.java +++ b/modules/api/src/test/java/javax/el/MethodInfoTest.java @@ -15,18 +15,23 @@ */ package javax.el; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class MethodInfoTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; +public class MethodInfoTest { + + @Test public void testGetName() { assertEquals("foo", new MethodInfo("foo", Integer.class, new Class[]{String.class}).getName()); } + @Test public void testGetParamTypes() { assertEquals(String.class, new MethodInfo("foo", Integer.class, new Class[]{String.class}).getParamTypes()[0]); } + @Test public void testGetReturnType() { assertEquals(Integer.class, new MethodInfo("foo", Integer.class, new Class[]{String.class}).getReturnType()); } diff --git a/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java b/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java index f94a412..381c41a 100644 --- a/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java +++ b/modules/api/src/test/java/javax/el/ResourceBundleELResolverTest.java @@ -15,6 +15,8 @@ */ package javax.el; +import org.junit.jupiter.api.Test; + import java.beans.FeatureDescriptor; import java.util.ArrayList; import java.util.Iterator; @@ -22,10 +24,10 @@ import java.util.ListResourceBundle; import java.util.ResourceBundle; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import javax.el.TestContext; -public class ResourceBundleELResolverTest extends TestCase { +public class ResourceBundleELResolverTest { ELContext context = new TestContext(); ResourceBundle sampleBundle() { @@ -41,6 +43,7 @@ protected Object[][] getContents() { }; } + @Test public void testGetCommonPropertyType() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); @@ -56,6 +59,7 @@ public void testGetCommonPropertyType() { assertNull(resolver.getCommonPropertyType(context, null)); } + @Test public void testGetFeatureDescriptors() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); @@ -83,6 +87,7 @@ public void testGetFeatureDescriptors() { assertEquals(3, names.size()); } + @Test public void testGetType() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); @@ -112,6 +117,7 @@ public void testGetType() { assertTrue(context.isPropertyResolved()); } + @Test public void testGetValue() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); @@ -143,6 +149,7 @@ public void testGetValue() { assertTrue(context.isPropertyResolved()); } + @Test public void testIsReadOnly() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); @@ -172,6 +179,7 @@ public void testIsReadOnly() { assertTrue(context.isPropertyResolved()); } + @Test public void testSetValue() { Integer scalar = 0; ResourceBundle bundle = sampleBundle(); diff --git a/modules/api/src/test/java/javax/el/ValueReferenceTest.java b/modules/api/src/test/java/javax/el/ValueReferenceTest.java index 3ddc3c1..8fb9661 100644 --- a/modules/api/src/test/java/javax/el/ValueReferenceTest.java +++ b/modules/api/src/test/java/javax/el/ValueReferenceTest.java @@ -1,13 +1,17 @@ package javax.el; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class ValueReferenceTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; +public class ValueReferenceTest { + + @Test public void testGetBase() { assertEquals("foo", new ValueReference("foo", "bar").getBase()); } + @Test public void testGetProperty() { assertEquals("bar", new ValueReference("foo", "bar").getProperty()); } diff --git a/modules/impl/pom.xml b/modules/impl/pom.xml index 176add4..1a166cf 100644 --- a/modules/impl/pom.xml +++ b/modules/impl/pom.xml @@ -15,14 +15,14 @@ jar Java Unified Expression Language Implementation - 2.2.8-SNAPSHOT + ${parent.version} org.apache.maven.plugins maven-jar-plugin - 2.4 + ${maven-jar-plugin.version} false diff --git a/modules/impl/src/test/java/de/odysseus/el/AllSuites.java b/modules/impl/src/test/java/de/odysseus/el/AllSuites.java deleted file mode 100644 index 6953bcc..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/AllSuites.java +++ /dev/null @@ -1,33 +0,0 @@ -package de.odysseus.el; -import junit.framework.Test; -import junit.framework.TestSuite; - -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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. - */ - -public class AllSuites { - - public static Test suite() { - TestSuite suite = new TestSuite("All the test suites..."); - suite.addTest(de.odysseus.el.AllTests.suite()); - suite.addTest(de.odysseus.el.misc.AllTests.suite()); - suite.addTest(de.odysseus.el.tree.AllTests.suite()); - suite.addTest(de.odysseus.el.tree.impl.AllTests.suite()); - suite.addTest(de.odysseus.el.tree.impl.ast.AllTests.suite()); - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/AllTests.java b/modules/impl/src/test/java/de/odysseus/el/AllTests.java deleted file mode 100644 index 2c220a3..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/AllTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 de.odysseus.el; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for de.odysseus.el"); - //$JUnit-BEGIN$ - suite.addTestSuite(ExpressionFactoryImplTest.class); - suite.addTestSuite(ObjectValueExpressionTest.class); - suite.addTestSuite(TreeMethodExpressionTest.class); - suite.addTestSuite(TreeValueExpressionTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/ExpressionFactoryImplTest.java b/modules/impl/src/test/java/de/odysseus/el/ExpressionFactoryImplTest.java index a770ed3..8930010 100644 --- a/modules/impl/src/test/java/de/odysseus/el/ExpressionFactoryImplTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/ExpressionFactoryImplTest.java @@ -17,8 +17,11 @@ import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.Test; -public class ExpressionFactoryImplTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class ExpressionFactoryImplTest { public static long bar() { return 1; @@ -26,20 +29,24 @@ public static long bar() { private ExpressionFactoryImpl factory = new ExpressionFactoryImpl(); + @Test public void testCoerceToType() { assertEquals("1", factory.coerceToType(1l, String.class)); } + @Test public void testCreateTreeValueExpression() { SimpleContext context = new SimpleContext(new SimpleResolver()); assertEquals(1l, factory.createValueExpression(context, "${1}", Object.class).getValue(context)); } + @Test public void testCreateObjectValueExpression() { SimpleContext context = new SimpleContext(new SimpleResolver()); assertEquals("1", factory.createValueExpression("1", Object.class).getValue(context)); } + @Test public void testCreateMethodExpression() throws NoSuchMethodException { SimpleContext context = new SimpleContext(new SimpleResolver()); context.getELResolver().setValue(context, null, "foo", this); diff --git a/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java index 87eeb6a..511f47e 100644 --- a/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/ObjectValueExpressionTest.java @@ -18,40 +18,53 @@ import javax.el.ELException; import de.odysseus.el.misc.TypeConverter; +import org.junit.jupiter.api.Test; -public class ObjectValueExpressionTest extends TestCase { +import static de.odysseus.el.TestCase.deserialize; +import static de.odysseus.el.TestCase.serialize; +import static org.junit.jupiter.api.Assertions.*; + +public class ObjectValueExpressionTest { private TypeConverter converter = TypeConverter.DEFAULT; + @Test public void testHashCode() { assertEquals("foo".hashCode(), new ObjectValueExpression(converter, "foo", Object.class).hashCode()); } + @Test public void testEqualsObject() { assertTrue(new ObjectValueExpression(converter, "foo", Object.class).equals(new ObjectValueExpression(converter, "foo", Object.class))); assertTrue(new ObjectValueExpression(converter, new String("foo"), Object.class).equals(new ObjectValueExpression(converter, "foo", Object.class))); assertFalse(new ObjectValueExpression(converter, "foo", Object.class).equals(new ObjectValueExpression(converter, "bar", Object.class))); } + @Test public void testGetValue() { assertEquals("foo", new ObjectValueExpression(converter, "foo", Object.class).getValue(null)); } + @Test public void testGetExpressionString() { assertNull(new ObjectValueExpression(converter, "foo", Object.class).getExpressionString()); } + @Test public void testIsLiteralText() { assertFalse(new ObjectValueExpression(converter, "foo", Object.class).isLiteralText()); } + @Test public void testGetType() { assertNull(new ObjectValueExpression(converter, "foo", Object.class).getType(null)); } + @Test public void testIsReadOnly() { assertTrue(new ObjectValueExpression(converter, "foo", Object.class).isReadOnly(null)); } + @Test public void testSetValue() { try { new ObjectValueExpression(converter, "foo", Object.class).setValue(null, "bar"); @@ -59,6 +72,7 @@ public void testSetValue() { } catch (ELException e) {} } + @Test public void testSerialize() throws Exception { ObjectValueExpression expression = new ObjectValueExpression(converter, "foo", Object.class); assertEquals(expression, deserialize(serialize(expression))); diff --git a/modules/impl/src/test/java/de/odysseus/el/TestCase.java b/modules/impl/src/test/java/de/odysseus/el/TestCase.java index b8ab8da..f263bc6 100644 --- a/modules/impl/src/test/java/de/odysseus/el/TestCase.java +++ b/modules/impl/src/test/java/de/odysseus/el/TestCase.java @@ -24,15 +24,16 @@ import de.odysseus.el.tree.Tree; import de.odysseus.el.tree.impl.Builder; +import org.junit.jupiter.api.TestInstance; -public abstract class TestCase extends junit.framework.TestCase { +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public abstract class TestCase { protected static final Builder BUILDER = new Builder(Builder.Feature.METHOD_INVOCATIONS); protected static final Tree parse(String expression) { return BUILDER.build(expression); } - protected static byte[] serialize(Object value) throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bout); diff --git a/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java index 3b49478..f2e139c 100644 --- a/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/TreeMethodExpressionTest.java @@ -23,6 +23,10 @@ import de.odysseus.el.tree.impl.Builder.Feature; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TreeMethodExpressionTest extends TestCase { @@ -37,13 +41,14 @@ public int bar() { SimpleContext context; TreeStore store = new TreeStore(new Builder(Feature.METHOD_INVOCATIONS), null); - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver(new BeanELResolver())); context.getELResolver().setValue(context, null, "base", this); } + @Test public void testEqualsAndHashCode() { TreeMethodExpression e1, e2; e1 = new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]); @@ -55,21 +60,25 @@ public void testEqualsAndHashCode() { assertFalse(e1.equals(e2)); } + @Test public void testGetExpressionString() { assertEquals("${base.foo}", new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]).getExpressionString()); } + @Test public void testIsLiteralText() { assertFalse(new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]).isLiteralText()); assertTrue(new TreeMethodExpression(store, null, null, null, "base.foo", null, new Class[0]).isLiteralText()); } + @Test public void testIsDeferred() { assertFalse(new TreeMethodExpression(store, null, null, null, "foo", null, new Class[0]).isDeferred()); assertFalse(new TreeMethodExpression(store, null, null, null, "${foo}", null, new Class[0]).isDeferred()); assertTrue(new TreeMethodExpression(store, null, null, null, "#{foo}", null, new Class[0]).isDeferred()); } + @Test public void testGetMethodInfo() { TreeMethodExpression e = new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]); MethodInfo info = e.getMethodInfo(context); @@ -78,12 +87,14 @@ public void testGetMethodInfo() { assertEquals(int.class, info.getReturnType()); } + @Test public void testInvoke() { assertEquals(0, new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]).invoke(context, null)); assertEquals(0, new TreeMethodExpression(store, null, null, null, "${base.foo()}", null, null).invoke(context, null)); } + @Test public void testSerialize() throws Exception { TreeMethodExpression expression = new TreeMethodExpression(store, null, null, null, "${base.foo}", null, new Class[0]); assertEquals(expression, deserialize(serialize(expression))); diff --git a/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java b/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java index a35d4d3..0cb5bbe 100644 --- a/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/TreeValueExpressionTest.java @@ -22,6 +22,11 @@ import de.odysseus.el.tree.impl.Builder; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; public class TreeValueExpressionTest extends TestCase { @@ -42,7 +47,7 @@ public void setFoobar(int value) { SimpleContext context; TreeStore store = new TreeStore(new Builder(), null); - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver(new BeanELResolver())); context.getELResolver().setValue(context, null, "base", this); @@ -67,6 +72,7 @@ protected void setUp() throws Exception { context.getELResolver().setValue(context, null, "property_foo", "foo"); } + @Test public void testEqualsAndHashCode() throws NoSuchMethodException { TreeValueExpression e1, e2; @@ -116,34 +122,41 @@ public void testEqualsAndHashCode() throws NoSuchMethodException { assertFalse(e1.equals(e2)); } + @Test public void testGetExpressionString() { assertEquals("foo", new TreeValueExpression(store, null, null, null, "foo", Object.class).getExpressionString()); } + @Test public void testIsLiteralText() { assertTrue(new TreeValueExpression(store, null, null, null, "foo", Object.class).isLiteralText()); assertFalse(new TreeValueExpression(store, null, null, null, "${foo}", Object.class).isLiteralText()); } + @Test public void testIsDeferred() { assertFalse(new TreeValueExpression(store, null, null, null, "foo", Object.class).isDeferred()); assertFalse(new TreeValueExpression(store, null, null, null, "${foo}", Object.class).isDeferred()); assertTrue(new TreeValueExpression(store, null, null, null, "#{foo}", Object.class).isDeferred()); } + @Test public void testGetExpectedType() { assertEquals(Object.class, new TreeValueExpression(store, null, null, null, "${foo}", Object.class).getExpectedType()); assertEquals(String.class, new TreeValueExpression(store, null, null, null, "${foo}", String.class).getExpectedType()); } + @Test public void testGetType() { assertFalse(new TreeValueExpression(store, null, null, null, "${property_foo}", Object.class).isReadOnly(context)); } + @Test public void testIsReadOnly() { assertFalse(new TreeValueExpression(store, null, null, null, "${property_foo}", Object.class).isReadOnly(context)); } + @Test public void testSetValue() { new TreeValueExpression(store, null, null, null, "${property_foo}", Object.class).setValue(context, "bar"); assertEquals("bar", new TreeValueExpression(store, null, null, null, "${property_foo}", Object.class).getValue(context)); @@ -159,10 +172,12 @@ public void testSetValue() { } } + @Test public void testGetValue() { assertEquals("foo", new TreeValueExpression(store, null, null, null, "${property_foo}", Object.class).getValue(context)); } + @Test public void testSerialize() throws Exception { TreeValueExpression expression = new TreeValueExpression(store, context.getFunctionMapper(), context.getVariableMapper(), null, "${var_long_1 + foo()}", Object.class); assertEquals(expression, deserialize(serialize(expression))); diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/AllTests.java b/modules/impl/src/test/java/de/odysseus/el/misc/AllTests.java deleted file mode 100644 index 490d7cc..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/misc/AllTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 de.odysseus.el.misc; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for de.odysseus.el.lang"); - //$JUnit-BEGIN$ - suite.addTestSuite(NumberOperationsTest.class); - suite.addTestSuite(BooleanOperationsTest.class); - suite.addTestSuite(TypeConverterImplTest.class); - suite.addTestSuite(MessagesTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/BooleanOperationsTest.java b/modules/impl/src/test/java/de/odysseus/el/misc/BooleanOperationsTest.java index fb7b8ee..84384dc 100644 --- a/modules/impl/src/test/java/de/odysseus/el/misc/BooleanOperationsTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/misc/BooleanOperationsTest.java @@ -15,12 +15,16 @@ */ package de.odysseus.el.misc; +import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; public class BooleanOperationsTest extends TestCase { @@ -34,6 +38,7 @@ static enum Foo { BAR, BAZ }; /* * Test method for 'de.odysseus.el.lang.BooleanOperations.lt(Object, Object)' */ + @Test public void testLt() { assertFalse(BooleanOperations.lt(converter, Boolean.TRUE, Boolean.TRUE)); assertFalse(BooleanOperations.lt(converter, null, Boolean.TRUE)); @@ -85,6 +90,7 @@ public void testLt() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.gt(Object, Object)' */ + @Test public void testGt() { assertFalse(BooleanOperations.gt(converter, Boolean.TRUE, Boolean.TRUE)); assertFalse(BooleanOperations.gt(converter, null, Boolean.TRUE)); @@ -136,6 +142,7 @@ public void testGt() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.ge(Object, Object)' */ + @Test public void testGe() { assertTrue(BooleanOperations.ge(converter, Boolean.TRUE, Boolean.TRUE)); assertFalse(BooleanOperations.ge(converter, null, Boolean.TRUE)); @@ -187,6 +194,7 @@ public void testGe() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.le(Object, Object)' */ + @Test public void testLe() { assertTrue(BooleanOperations.le(converter, Boolean.TRUE, Boolean.TRUE)); assertFalse(BooleanOperations.le(converter, null, Boolean.TRUE)); @@ -238,6 +246,7 @@ public void testLe() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.eq(Object, Object)' */ + @Test public void testEq() { assertTrue(BooleanOperations.eq(converter, Boolean.TRUE, Boolean.TRUE)); assertFalse(BooleanOperations.eq(converter, null, Boolean.TRUE)); @@ -293,6 +302,7 @@ public void testEq() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.ne(Object, Object)' */ + @Test public void testNe() { assertFalse(BooleanOperations.ne(converter, Boolean.TRUE, Boolean.TRUE)); assertTrue(BooleanOperations.ne(converter, null, Boolean.TRUE)); @@ -348,6 +358,7 @@ public void testNe() { /* * Test method for 'de.odysseus.el.lang.BooleanOperations.empty(Object)' */ + @Test public void testEmpty() { assertTrue(BooleanOperations.empty(converter, null)); assertTrue(BooleanOperations.empty(converter, "")); diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/MessagesTest.java b/modules/impl/src/test/java/de/odysseus/el/misc/MessagesTest.java index 563e4c8..4551f0f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/misc/MessagesTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/misc/MessagesTest.java @@ -15,13 +15,17 @@ */ package de.odysseus.el.misc; -import junit.framework.TestCase; +import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class MessagesTest extends TestCase { /* * Test method for 'de.odysseus.el.lang.Messages.get(String)' */ + @Test public void testGetString() { assertTrue(LocalMessages.get("foo").matches(".*foo")); } @@ -29,6 +33,7 @@ public void testGetString() { /* * Test method for 'de.odysseus.el.lang.Messages.get(String, Object)' */ + @Test public void testGetStringObject() { assertTrue(LocalMessages.get("foo", "bar").matches(".*foo\\(bar\\)")); } @@ -36,6 +41,7 @@ public void testGetStringObject() { /* * Test method for 'de.odysseus.el.lang.Messages.get(String, Object, Object)' */ + @Test public void testGetStringObjectObject() { assertTrue(LocalMessages.get("foo", "bar", "baz").matches(".*foo\\(bar,\\s*baz\\)")); } diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/NumberOperationsTest.java b/modules/impl/src/test/java/de/odysseus/el/misc/NumberOperationsTest.java index c0b4def..248378f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/misc/NumberOperationsTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/misc/NumberOperationsTest.java @@ -15,10 +15,13 @@ */ package de.odysseus.el.misc; +import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; + import java.math.BigDecimal; import java.math.BigInteger; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; public class NumberOperationsTest extends TestCase { @@ -27,6 +30,7 @@ public class NumberOperationsTest extends TestCase { /* * Test method for 'de.odysseus.el.lang.NumberOperations.add(Object, Object)' */ + @Test public void testAdd() { assertEquals(new Long(0), NumberOperations.add(converter, null, null)); @@ -78,6 +82,7 @@ public void testAdd() { /* * Test method for 'de.odysseus.el.lang.NumberOperations.sub(Object, Object)' */ + @Test public void testSub() { assertEquals(new Long(0), NumberOperations.sub(converter, null, null)); @@ -129,6 +134,7 @@ public void testSub() { /* * Test method for 'de.odysseus.el.lang.NumberOperations.mul(Object, Object)' */ + @Test public void testMul() { assertEquals(new Long(0), NumberOperations.mul(converter, null, null)); @@ -180,6 +186,7 @@ public void testMul() { /* * Test method for 'de.odysseus.el.lang.NumberOperations.div(Object, Object)' */ + @Test public void testDiv() { assertEquals(new Long(0), NumberOperations.div(converter, null, null)); @@ -220,6 +227,7 @@ public void testDiv() { /* * Test method for 'de.odysseus.el.lang.NumberOperations.mod(Object, Object)' */ + @Test public void testMod() { assertEquals(new Long(0), NumberOperations.mod(converter, null, null)); @@ -270,6 +278,7 @@ public void testMod() { /* * Test method for 'de.odysseus.el.lang.NumberOperations.neg(Object)' */ + @Test public void testNeg() { assertEquals(new Long(0), NumberOperations.neg(converter, null)); diff --git a/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java b/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java index 9ef2fbb..217a806 100644 --- a/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/misc/TypeConverterImplTest.java @@ -15,9 +15,11 @@ */ package de.odysseus.el.misc; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; +import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; + +import javax.el.ELException; +import java.awt.*; import java.beans.PropertyChangeListener; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; @@ -25,9 +27,7 @@ import java.math.BigInteger; import java.util.Date; -import javax.el.ELException; - -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; /** * JUnit test case for {@link de.odysseus.el.misc.TypeConverterImpl}. @@ -74,6 +74,7 @@ public String toString() { TypeConverterImpl converter = new TypeConverterImpl(); + @Test public void testToBoolean() { assertFalse(converter.coerceToBoolean(null)); assertFalse(converter.coerceToBoolean("")); @@ -84,6 +85,7 @@ public void testToBoolean() { assertFalse(converter.coerceToBoolean("yes")); // Boolean.valueOf(String) never throws an exception... } + @Test public void testToCharacter() { assertEquals(Character.valueOf((char)0), converter.coerceToCharacter(null)); assertEquals(Character.valueOf((char)0), converter.coerceToCharacter("")); @@ -288,6 +290,7 @@ public void testToBigInteger() { } } + @Test public void testToString() { assertSame("foo", converter.coerceToString("foo")); assertEquals("", converter.coerceToString(null)); @@ -296,6 +299,7 @@ public void testToString() { assertEquals(value.toString(), converter.coerceToString(value)); } + @Test public void testToEnum() { assertNull(converter.coerceToEnum(null, Foo.class)); assertSame(Foo.BAR, converter.coerceToEnum(Foo.BAR, Foo.class)); @@ -304,6 +308,7 @@ public void testToEnum() { assertSame(Foo.BAZ, converter.coerceToEnum("BAZ", Foo.class)); } + @Test public void testToType() { assertEquals("foo", converter.coerceToType("foo", String.class)); assertEquals(new Long(0), converter.coerceToType("0", Long.class)); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/AllTests.java b/modules/impl/src/test/java/de/odysseus/el/tree/AllTests.java deleted file mode 100644 index d518f79..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/tree/AllTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 de.odysseus.el.tree; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for de.odysseus.el.tree"); - //$JUnit-BEGIN$ - suite.addTestSuite(BindingsTest.class); - suite.addTestSuite(NodePrinterTest.class); - suite.addTestSuite(TreeStoreTest.class); - suite.addTestSuite(TreeTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java index 7d7c4d5..6d83f2e 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/BindingsTest.java @@ -25,6 +25,13 @@ import de.odysseus.el.tree.Bindings; import de.odysseus.el.tree.Tree; import de.odysseus.el.util.SimpleContext; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; public class BindingsTest extends TestCase { @@ -38,7 +45,7 @@ public static int bar(int i) { private SimpleContext context; - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(); @@ -52,6 +59,7 @@ protected void setUp() throws Exception { context.setVariable("v", new ObjectValueExpression(TypeConverter.DEFAULT, new Long(0), long.class)); } + @Test public void testSerialize() throws Exception { Bindings bindings = null; @@ -62,6 +70,7 @@ public void testSerialize() throws Exception { assertEquals(bindings, deserialize(serialize(bindings))); } + @Test public void testEqualsAndHashcode() throws Exception { Bindings bindings1 = null; Bindings bindings2 = null; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/NodePrinterTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/NodePrinterTest.java index fb3676a..7c3da8f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/NodePrinterTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/NodePrinterTest.java @@ -6,13 +6,16 @@ import java.io.StringReader; import java.io.StringWriter; +import de.odysseus.el.TestCase; import de.odysseus.el.tree.impl.Builder; import de.odysseus.el.tree.impl.Builder.Feature; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; public class NodePrinterTest extends TestCase { + @Test public void testDump() throws IOException { Tree tree = new Builder(Feature.METHOD_INVOCATIONS).build("${foo.bar[baz] + foobar}"); StringWriter writer = new StringWriter(); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/TreeStoreTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/TreeStoreTest.java index bf7bf71..bc72f46 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/TreeStoreTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/TreeStoreTest.java @@ -19,8 +19,12 @@ import de.odysseus.el.tree.Tree; import de.odysseus.el.tree.TreeStore; import de.odysseus.el.tree.impl.Cache; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TreeStoreTest extends TestCase { + @Test public void test() { TreeStore store = new TreeStore(BUILDER, new Cache(1)); assertSame(BUILDER, store.getBuilder()); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/TreeTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/TreeTest.java index 1c674ce..7894143 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/TreeTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/TreeTest.java @@ -20,6 +20,10 @@ import de.odysseus.el.misc.TypeConverter; import de.odysseus.el.tree.Bindings; import de.odysseus.el.util.SimpleContext; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class TreeTest extends TestCase { @@ -33,7 +37,7 @@ public static int bar(int op) { private SimpleContext context; - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(); @@ -50,6 +54,7 @@ protected void setUp() throws Exception { context.setVariable("v1", new ObjectValueExpression(TypeConverter.DEFAULT, 1, long.class)); } + @Test public void testBindFunctions() throws Exception { Bindings bindings = null; @@ -85,6 +90,7 @@ public void testBindFunctions() throws Exception { try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {} } + @Test public void testBindVariables() throws Exception { Bindings bindings = null; @@ -106,6 +112,7 @@ public void testBindVariables() throws Exception { try { bindings.getVariable(1); fail(); } catch (Exception e) {} } + @Test public void testBindFunctionsAndVariables() throws Exception { Bindings bindings = parse("${ns:f0()+v0+g1(1)+v1+foo}").bind(context.getFunctionMapper(), context.getVariableMapper()); assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0)); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/AllTests.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/AllTests.java deleted file mode 100644 index c161874..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/AllTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 de.odysseus.el.tree.impl; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for de.odysseus.el.tree"); - //$JUnit-BEGIN$ - suite.addTestSuite(CacheTest.class); - suite.addTestSuite(ScannerTest.class); - suite.addTestSuite(ParserTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/CacheTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/CacheTest.java index 8086c63..1bec3ff 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/CacheTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/CacheTest.java @@ -27,8 +27,13 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Tree; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class CacheTest extends TestCase { + @Test public void testSingleThread() { Cache cache = null; @@ -96,6 +101,7 @@ public Long call() throws Exception { return result; } + @Test public void testMultiThread() throws Exception { testMultiThread(10000, 1, 100000); testMultiThread(1000, 10, 10000); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ParserTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ParserTest.java index 51e403f..800ee23 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ParserTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ParserTest.java @@ -18,6 +18,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Tree; import de.odysseus.el.tree.impl.ast.AstBinary; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class ParserTest extends TestCase { static Tree verifyLiteralExpression(String expression) { @@ -55,6 +58,7 @@ static Tree verifyCompositeExpression(String canonical) { return tree; } + @Test public void testLiteral() { verifyLiteralExpression(""); verifyLiteralExpression("$"); @@ -79,6 +83,7 @@ Tree verifyBinary(AstBinary.Operator op, String canonical) { return tree; } + @Test public void testBinray() { verifyEvalExpression("${a * a}"); verifyEvalExpression("${a / a}", "${a div a}"); @@ -121,6 +126,7 @@ public void testBinray() { verifyBinary(AstBinary.OR, "${! a || a}"); } + @Test public void testUnary() { verifyEvalExpression("${- a}"); verifyEvalExpression("${- - a}"); @@ -130,11 +136,13 @@ public void testUnary() { verifyEvalExpression("${! ! a}", "${not not a}", "${not ! a}"); } + @Test public void testDeferredExpression() { verifyEvalExpression("#{a}", "#{ a }"); } + @Test public void testComposite() { verifyCompositeExpression("a${a}a"); verifyCompositeExpression("a ${a} a"); @@ -142,19 +150,23 @@ public void testComposite() { try { parse("#{a}${a}"); fail(); } catch (Exception e) {} } + @Test public void testInteger() { verifyEvalExpression("${0}"); } + @Test public void testBoolean() { verifyEvalExpression("${true}"); verifyEvalExpression("${false}"); } + @Test public void testNull() { verifyEvalExpression("${null}"); } + @Test public void testString() { verifyEvalExpression("${''}", "${\"\"}"); verifyEvalExpression("${'\\''}", "${\"'\"}"); @@ -162,6 +174,7 @@ public void testString() { verifyEvalExpression("${'a'}", "${\"a\"}"); } + @Test public void testFloat() { verifyEvalExpression("${0.0}", "${0.0e0}"); verifyEvalExpression("${0.0}", "${0e0}", "${0E0}"); @@ -170,6 +183,7 @@ public void testFloat() { verifyEvalExpression("${0.0}", "${0e+0}", "${0e-0}"); } + @Test public void testChoice() { verifyEvalExpression("${a ? a : a}", "${a?a:a}"); verifyEvalExpression("${a ? b ? b : b : a}", "${a?b?b:b:a}"); @@ -181,16 +195,19 @@ public void testChoice() { try { parse("${a?a:f()}"); fail(); } catch (Exception e) {} } + @Test public void testNested() { verifyEvalExpression("${(a)}", "${ ( a ) }"); verifyEvalExpression("${((a))}"); } + @Test public void testIdentifier() { verifyEvalExpression("${a}", "${ a}", "${a }"); assertTrue(parse("${a}").getRoot().isLeftValue()); } + @Test public void testFunction() { verifyEvalExpression("${a()}"); verifyEvalExpression("${a(a)}"); @@ -200,6 +217,7 @@ public void testFunction() { verifyEvalExpression("${a:a(a, a)}"); } + @Test public void testProperty() { verifyEvalExpression("${a.a}", "${ a . a }"); verifyEvalExpression("${a.a.a}"); @@ -216,6 +234,7 @@ public void testProperty() { assertTrue(parse("${(1)[a]}").getRoot().isLeftValue()); } + @Test public void testIsDeferred() { assertFalse(parse("foo").isDeferred()); assertFalse(parse("${foo}").isDeferred()); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ScannerTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ScannerTest.java index c26f501..bbc9985 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ScannerTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ScannerTest.java @@ -18,13 +18,14 @@ import java.util.ArrayList; import java.util.Arrays; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.*; import de.odysseus.el.tree.impl.Scanner.*; +import org.junit.jupiter.api.Test; import static de.odysseus.el.tree.impl.Scanner.Symbol.*; -public class ScannerTest extends TestCase { +public class ScannerTest { void assertEquals(Object[] a1, Object[] a2) { assertTrue(Arrays.equals(a1, a2)); } @@ -40,6 +41,7 @@ Symbol[] symbols(String expression) throws ScanException { return list.toArray(new Symbol[list.size()]); } + @Test public void testInteger() throws ScanException { Symbol[] expected = { START_EVAL_DYNAMIC, INTEGER, END_EVAL }; @@ -48,6 +50,7 @@ public void testInteger() throws ScanException { assertEquals(expected, symbols("${01234567890}")); } + @Test public void testFloat() throws ScanException { Symbol[] expected = { START_EVAL_DYNAMIC, FLOAT, END_EVAL }; @@ -86,6 +89,7 @@ public void testFloat() throws ScanException { assertEquals(expected, symbols("${0.0E-0}")); } + @Test public void testString() throws ScanException { Symbol[] expected = { START_EVAL_DYNAMIC, STRING, END_EVAL }; @@ -104,6 +108,7 @@ public void testString() throws ScanException { try { symbols("${\"foo"); fail(); } catch (ScanException e) {} } + @Test public void testKeywords() throws ScanException { assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, NULL, END_EVAL }, symbols("${null}")); assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, TRUE, END_EVAL }, symbols("${true}")); @@ -126,6 +131,7 @@ public void testKeywords() throws ScanException { assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, IDENTIFIER, END_EVAL }, symbols("${nullx}")); } + @Test public void testOperators() throws ScanException { assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, MUL, END_EVAL }, symbols("${*}")); assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, DIV, END_EVAL }, symbols("${/}")); @@ -155,10 +161,12 @@ public void testOperators() throws ScanException { try { symbols("${=)"); fail(); } catch (ScanException e) {} } + @Test public void testWhitespace() throws ScanException { assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, END_EVAL }, symbols("${\t\n\r }")); } + @Test public void testIdentifier() throws ScanException { Symbol[] expected = { START_EVAL_DYNAMIC, IDENTIFIER, END_EVAL }; @@ -166,6 +174,7 @@ public void testIdentifier() throws ScanException { assertEquals(expected, symbols("${foo_1}")); } + @Test public void testText() throws ScanException { Symbol[] expected = { TEXT }; @@ -179,6 +188,7 @@ public void testText() throws ScanException { assertEquals(expected, symbols("\\${foo}")); } + @Test public void testMixed() throws ScanException { assertEquals(new Symbol[]{ TEXT, START_EVAL_DYNAMIC }, symbols("foo${")); assertEquals(new Symbol[]{ START_EVAL_DYNAMIC, IDENTIFIER }, symbols("${bar")); @@ -186,6 +196,7 @@ public void testMixed() throws ScanException { assertEquals(new Symbol[]{ TEXT, START_EVAL_DYNAMIC, END_EVAL, TEXT }, symbols("foo${}bar")); } + @Test public void testDeferred() throws ScanException { assertEquals(new Symbol[]{ START_EVAL_DEFERRED }, symbols("#{")); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AllTests.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AllTests.java deleted file mode 100644 index 741f9c0..0000000 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AllTests.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006-2009 Odysseus Software GmbH - * - * Licensed 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 de.odysseus.el.tree.impl.ast; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for de.odysseus.el.tree"); - //$JUnit-BEGIN$ - suite.addTestSuite(AstBinaryTest.class); - suite.addTestSuite(AstBooleanTest.class); - suite.addTestSuite(AstBracketTest.class); - suite.addTestSuite(AstChoiceTest.class); - suite.addTestSuite(AstCompositeTest.class); - suite.addTestSuite(AstDotTest.class); - suite.addTestSuite(AstEvalTest.class); - suite.addTestSuite(AstFunctionTest.class); - suite.addTestSuite(AstIdentifierTest.class); - suite.addTestSuite(AstMethodTest.class); - suite.addTestSuite(AstNestedTest.class); - suite.addTestSuite(AstNullTest.class); - suite.addTestSuite(AstNumberTest.class); - suite.addTestSuite(AstStringTest.class); - suite.addTestSuite(AstTextTest.class); - suite.addTestSuite(AstUnaryTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java index 74201a7..3f2782b 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBinaryTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstBinaryTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,6 +30,7 @@ AstBinary parseNode(String expression) { return (AstBinary)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals(6l, parseNode("${4+2}").eval(bindings, null)); assertEquals(8l, parseNode("${4*2}").eval(bindings, null)); @@ -62,6 +66,7 @@ public void testEval() { assertEquals(true, parseNode("${2 >= 1}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = null; s = new StringBuilder(); @@ -89,35 +94,43 @@ public void testAppendStructure() { assertEquals("1 && 11 || 1", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${1+1}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${1+1}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${1+1}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${1+1}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${1+1}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals(Long.valueOf(2l), parseNode("${1+1}").getValue(bindings, null, null)); assertEquals("2", parseNode("${1+1}").getValue(bindings, null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${1+1}").getValueReference(bindings, null)); } + @Test public void testOperators() { assertTrue((Boolean)parseNode("${true and true}").getValue(bindings, null, Boolean.class)); assertFalse((Boolean)parseNode("${true and false}").getValue(bindings, null, Boolean.class)); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java index 2bcdda5..13499ab 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBooleanTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstBooleanTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,11 +30,13 @@ AstBoolean parseNode(String expression) { return (AstBoolean)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals(true, parseNode("${true}").eval(bindings, null)); assertEquals(false, parseNode("${false}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${true}").appendStructure(s, bindings); @@ -39,31 +44,38 @@ public void testAppendStructure() { assertEquals("truefalse", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${true}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${true}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${true}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${true}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${true}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals(true, parseNode("${true}").getValue(bindings, null, null)); assertEquals("true", parseNode("${true}").getValue(bindings, null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${true}").getValueReference(bindings, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java index 31ef59b..3a6cd86 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstBracketTest.java @@ -29,6 +29,10 @@ import de.odysseus.el.tree.impl.Builder; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstBracketTest extends TestCase { AstBracket parseNode(String expression) { @@ -64,7 +68,7 @@ public Object getNullObject() { return null; } - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver()); context.getELResolver().setValue(context, null, "base", this); @@ -76,27 +80,32 @@ protected void setUp() throws Exception { bindings = new Bindings(null, new ValueExpression[2]); } + @Test public void testEval() { try { parseNode("${base[bad]}").eval(bindings, context); fail(); } catch (ELException e) {} assertEquals(1l, parseNode("${base['foo']}").eval(bindings, context)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${foo[bar]}").appendStructure(s, new Bindings(null, null)); assertEquals("foo[bar]", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${foo[bar]}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${'foo'[bar]}").isLeftValue()); assertTrue(parseNode("${foo[bar]}").isLeftValue()); } + @Test public void testGetType() { try { parseNode("${base[bad]}").getType(bindings, context); fail(); } catch (ELException e) {} assertEquals(long.class, parseNode("${base['foo']}").getType(bindings, context)); @@ -108,6 +117,7 @@ public void testGetType() { } } + @Test public void testIsReadOnly() { assertFalse(parseNode("${base['foo']}").isReadOnly(bindings, context)); assertTrue(parseNode("${'base'['foo']}").isReadOnly(bindings, context)); @@ -118,6 +128,7 @@ public void testIsReadOnly() { } } + @Test public void testSetValue() { try { parseNode("${base[bad]}").setValue(bindings, context, "good"); fail(); } catch (ELException e) {} parseNode("${base['foo']}").setValue(bindings, context, 2l); @@ -133,6 +144,7 @@ public void testSetValue() { } } + @Test public void testGetValue() { assertEquals(1l, parseNode("${base['foo']}").getValue(bindings, context, null)); assertEquals("1", parseNode("${base['foo']}").getValue(bindings, context, String.class)); @@ -144,11 +156,13 @@ public void testGetValue() { } } + @Test public void testGetValueReference() { assertEquals(this, parseNode("${base['foo']}").getValueReference(bindings, context).getBase()); assertEquals("foo", parseNode("${base['foo']}").getValueReference(bindings, context).getProperty()); } + @Test public void testInvoke() { assertEquals(1l, parseNode("${base['bar']}").invoke(bindings, context, long.class, new Class[0], null)); assertEquals(2l, parseNode("${base['bar']}").invoke(bindings, context, null, new Class[]{long.class}, new Object[]{2l})); @@ -164,6 +178,7 @@ public void testInvoke() { } } + @Test public void testGetMethodInfo() { MethodInfo info = null; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java index caadf63..cd9fa62 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstChoiceTest.java @@ -16,9 +16,11 @@ package de.odysseus.el.tree.impl.ast; import javax.el.ELException; +import static org.junit.jupiter.api.Assertions.*; import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; public class AstChoiceTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,42 +29,51 @@ AstChoice parseNode(String expression) { return (AstChoice)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals(1l, parseNode("${true?1:2}").eval(bindings, null)); assertEquals(2l, parseNode("${false?1:2}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${a?b:c}").appendStructure(s, bindings); assertEquals("a ? b : c", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${a?b:c}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${a?b:c}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${a?b:c}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${a?b:c}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${a?b:c}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals(1l, parseNode("${true?1:2}").getValue(bindings, null, null)); assertEquals("1", parseNode("${true?1:2}").getValue(bindings, null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${true?1:2}").getValueReference(bindings, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java index 687ca37..16d7bca 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstCompositeTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstCompositeTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,41 +30,50 @@ AstComposite parseNode(String expression) { return (AstComposite)parse(expression).getRoot(); } + @Test public void testEval() { assertEquals("101", parseNode("${1}0${1}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${1}0${1}").appendStructure(s, bindings); assertEquals("${1}0${1}", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${1}0${1}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${1}0${1}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${1}0${1}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${1}0${1}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${1}0${1}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals("101", parseNode("${1}0${1}").getValue(bindings, null, null)); assertEquals(101l, parseNode("${1}0${1}").getValue(bindings, null, Long.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${1}0${1}").getValueReference(bindings, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java index 1631ca6..39fd7a6 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstDotTest.java @@ -28,6 +28,10 @@ import de.odysseus.el.tree.Bindings; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstDotTest extends TestCase { AstDot parseNode(String expression) { @@ -63,7 +67,7 @@ public Object getNullObject() { return null; } - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver(new BeanELResolver())); context.getELResolver().setValue(context, null, "base", this); @@ -71,37 +75,44 @@ protected void setUp() throws Exception { bindings = new Bindings(null, new ValueExpression[1]); } + @Test public void testEval() { try { parseNode("${base.bad}").eval(bindings, context); fail(); } catch (ELException e) {} assertEquals(1l, parseNode("${base.foo}").eval(bindings, context)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${foo.bar}").appendStructure(s, new Bindings(null, null, null)); assertEquals("foo.bar", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${foo.bar}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${'foo'.bar}").isLeftValue()); assertTrue(parseNode("${foo.bar}").isLeftValue()); } + @Test public void testGetType() { try { parseNode("${base.bad}").getType(bindings, context); fail(); } catch (ELException e) {} assertEquals(long.class, parseNode("${base.foo}").getType(bindings, context)); assertNull(parseNode("${'base'.foo}").getType(bindings, context)); } + @Test public void testIsReadOnly() { assertFalse(parseNode("${base.foo}").isReadOnly(bindings, context)); assertTrue(parseNode("${'base'.foo}").isReadOnly(bindings, context)); } + @Test public void testSetValue() { try { parseNode("${base.bad}").setValue(bindings, context, "good"); fail(); } catch (ELException e) {} parseNode("${base.foo}").setValue(bindings, context, 2l); @@ -110,17 +121,20 @@ public void testSetValue() { assertEquals(3l, getFoo()); } + @Test public void testGetValue() { assertEquals(1l, parseNode("${base.foo}").getValue(bindings, context, null)); assertEquals("1", parseNode("${base.foo}").getValue(bindings, context, String.class)); assertNull(parseNode("${base.nullObject.class}").getValue(bindings, context, Object.class)); } + @Test public void testGetValueReference() { assertEquals(this, parseNode("${base.foo}").getValueReference(bindings, context).getBase()); assertEquals("foo", parseNode("${base.foo}").getValueReference(bindings, context).getProperty()); } + @Test public void testInvoke() { assertEquals(1l, parseNode("${base.bar}").invoke(bindings, context, long.class, new Class[0], null)); assertEquals(2l, parseNode("${base.bar}").invoke(bindings, context, null, new Class[]{long.class}, new Object[]{2l})); @@ -136,6 +150,7 @@ public void testInvoke() { } } + @Test public void testGetMethodInfo() { MethodInfo info = null; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstEvalTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstEvalTest.java index a747335..1ae7472 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstEvalTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstEvalTest.java @@ -16,26 +16,32 @@ package de.odysseus.el.tree.impl.ast; import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class AstEvalTest extends TestCase { AstEval parseNode(String expression) { return (AstEval)parse(expression).getRoot(); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${1}").isLeftValue()); assertTrue(parseNode("${foo.bar}").isLeftValue()); } + @Test public void testIsDeferred() { assertTrue(parseNode("#{1}").isDeferred()); assertFalse(parseNode("${1}").isDeferred()); } + @Test public void testEval() { assertEquals(1l, parseNode("${1}").eval(null, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${1}").appendStructure(s, null); diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java index 6fdbffd..cedc04c 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstFunctionTest.java @@ -23,6 +23,10 @@ import de.odysseus.el.tree.impl.Builder; import de.odysseus.el.tree.impl.Builder.Feature; import de.odysseus.el.util.SimpleContext; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstFunctionTest extends TestCase { public static int foo() { @@ -65,7 +69,7 @@ AstFunction getNode(Tree tree) { SimpleContext context; - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(); @@ -84,6 +88,7 @@ protected void setUp() throws Exception { context.getELResolver().setValue(context, null, "var111s", new String[]{"1","1","1"}); } + @Test public void testVarargs() { Builder builder = new Builder(Feature.VARARGS); Tree tree = null; @@ -107,6 +112,7 @@ public void testVarargs() { assertEquals(foovar(1,1,1), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), context)); } + @Test public void testEval() { Tree tree = null; @@ -129,6 +135,7 @@ public void testEval() { assertEquals(foobar(21,21), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null)); } + @Test public void testAppendStructure() { StringBuilder s = null; @@ -147,26 +154,32 @@ public void testAppendStructure() { assertEquals("p:f()p:f(x)p:f(x, y)", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${f()}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${f()}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${f()}").getType(null, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${f()}").isReadOnly(null, null)); } + @Test public void testSetValue() { try { parseNode("${f()}").setValue(null, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { Tree tree = null; @@ -176,6 +189,7 @@ public void testGetValue() { assertEquals("" + foo(), getNode(tree).getValue(tree.bind(context.getFunctionMapper(), null), null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${ns:f0()}").getValueReference(null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java index ad6e58b..80e3f05 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstIdentifierTest.java @@ -32,6 +32,11 @@ import de.odysseus.el.tree.TreeStore; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; public class AstIdentifierTest extends TestCase { public static long method_1() { @@ -83,7 +88,7 @@ AstIdentifier getNode(Tree tree) { SimpleContext context; - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver()); @@ -106,6 +111,7 @@ protected void setUp() throws Exception { context.setVariable("var_property_long_1", new TreeValueExpression(new TreeStore(BUILDER, null), null, context.getVariableMapper(), null, "${property_long_1}", long.class)); } + @Test public void testEval() { Tree tree = null; Bindings bindings = null; @@ -135,20 +141,24 @@ public void testEval() { assertEquals(1l, getNode(tree).eval(bindings, context)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${foo}").appendStructure(s, null); assertEquals("foo", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${foo}").isLiteralText()); } + @Test public void testIsLeftValue() { assertTrue(parseNode("${foo}").isLeftValue()); } + @Test public void testGetType() { Tree tree = null; Bindings bindings = null; @@ -174,6 +184,7 @@ public void testGetType() { assertEquals(null, getNode(tree).getType(bindings, context)); } + @Test public void testIsReadOnly() { Tree tree = null; Bindings bindings = null; @@ -199,6 +210,7 @@ public void testIsReadOnly() { assertTrue(getNode(tree).isReadOnly(bindings, context)); } + @Test public void testSetValue() { Tree tree = null; Bindings bindings = null; @@ -233,6 +245,7 @@ public void testSetValue() { try { getNode(tree).setValue(bindings, context, "bar"); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { Tree tree = null; Bindings bindings = null; @@ -247,6 +260,7 @@ public void testGetValue() { assertEquals("1", getNode(tree).getValue(bindings, context, String.class)); } + @Test public void testGetValueReference() { Tree tree = null; Bindings bindings = null; @@ -260,6 +274,7 @@ public void testGetValueReference() { assertNotNull(getNode(tree).getValueReference(bindings, context)); } + @Test public void testInvoke() { Tree tree = null; Bindings bindings = null; @@ -295,6 +310,7 @@ public void testInvoke() { } + @Test public void testGetMethodInfo() { Tree tree = null; Bindings bindings = null; diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java index bc86710..917167f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstMethodTest.java @@ -25,6 +25,10 @@ import de.odysseus.el.tree.Bindings; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.util.SimpleResolver; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstMethodTest extends TestCase { AstMethod parseNode(String expression) { @@ -56,7 +60,7 @@ public Object getNullObject() { return null; } - @Override + @BeforeAll protected void setUp() throws Exception { context = new SimpleContext(new SimpleResolver(new BeanELResolver())); context.getELResolver().setValue(context, null, "base", this); @@ -64,38 +68,46 @@ protected void setUp() throws Exception { bindings = new Bindings(null, new ValueExpression[1]); } + @Test public void testEval() { try { parseNode("${base.bad()}").eval(bindings, context); fail(); } catch (MethodNotFoundException e) {} assertEquals(1l, parseNode("${base.bar()}").eval(bindings, context)); assertEquals(3l, parseNode("${base.bar(3)}").eval(bindings, context)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${foo.bar(1)}").appendStructure(s, new Bindings(null, null, null)); assertEquals("foo.bar(1)", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${foo.bar()}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${foo.bar()}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${base.foo()}").getType(bindings, context)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${base.foo()}").isReadOnly(bindings, context)); } + @Test public void testSetValue() { try { parseNode("${base.foo()}").setValue(bindings, context, 0); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals("1", parseNode("${base.bar()}").getValue(bindings, context, String.class)); assertEquals("3", parseNode("${base.bar(3)}").getValue(bindings, context, String.class)); @@ -103,10 +115,12 @@ public void testGetValue() { assertNull(parseNode("${base.nullObject.toString()}").getValue(bindings, context, Object.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${base.bar()}").getValueReference(bindings, context)); } + @Test public void testInvoke() { assertEquals(1l, parseNode("${base.bar()}").invoke(bindings, context, null, null, new Object[]{999l})); assertEquals(3l, parseNode("${base.bar(3)}").invoke(bindings, context, null, new Class[]{long.class}, new Object[]{999l})); @@ -119,6 +133,7 @@ public void testInvoke() { } } + @Test public void testGetMethodInfo() { assertNull(parseNode("${base.bar()}").getMethodInfo(bindings, context, null, new Class[]{long.class})); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNestedTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNestedTest.java index ad04766..5e4117c 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNestedTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNestedTest.java @@ -16,26 +16,32 @@ package de.odysseus.el.tree.impl.ast; import de.odysseus.el.TestCase; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class AstNestedTest extends TestCase { AstNested parseNode(String expression) { return (AstNested)parse(expression).getRoot().getChild(0); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${(a)}").isLeftValue()); } + @Test public void testEval() { assertEquals(1l, parseNode("${(1)}").eval(null, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${(1)}").appendStructure(s, null); assertEquals("(1)", s.toString()); } + @Test public void testGetValueReference() { assertNull(parseNode("${(1)}").getValueReference(null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java index 3624773..9d22b61 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNullTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstNullTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,41 +30,50 @@ AstNull parseNode(String expression) { return (AstNull)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertNull(parseNode("${null}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${null}").appendStructure(s, bindings); assertEquals("null", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${null}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${null}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${null}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${null}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${null}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertNull(parseNode("${null}").getValue(bindings, null, null)); assertEquals("", parseNode("${null}").getValue(bindings, null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${null}").getValueReference(null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java index 9897aa0..092df7f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstNumberTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstNumberTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,42 +30,51 @@ AstNumber parseNode(String expression) { return (AstNumber)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals(1l, parseNode("${1}").eval(bindings, null)); assertEquals(1d, parseNode("${1.0}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${1}").appendStructure(s, bindings); assertEquals("1", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${1}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${1}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${1}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${1}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${1}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals(1l, parseNode("${1}").getValue(bindings, null, null)); assertEquals(1d, parseNode("${1}").getValue(bindings, null, Double.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${1}").getValueReference(null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java index 5581789..0dd3324 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstStringTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstStringTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,41 +30,50 @@ AstString parseNode(String expression) { return (AstString)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals("foo", parseNode("${'foo'}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${'foo'}").appendStructure(s, bindings); assertEquals("'foo'", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${'foo'}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${'foo'}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${'foo'}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${'foo'}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${'foo'}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals("1", parseNode("${'1'}").getValue(bindings, null, null)); assertEquals(1, parseNode("${'1'}").getValue(bindings, null, Integer.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${'foo'}").getValueReference(null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java index bfd0a1b..a46409f 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstTextTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstTextTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,50 +30,61 @@ AstText parseNode(String expression) { return (AstText)parse(expression).getRoot(); } + @Test public void testEval() { assertEquals("foo", parseNode("foo").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("foo").appendStructure(s, bindings); assertEquals("foo", s.toString()); } + @Test public void testIsLiteralText() { assertTrue(parseNode("foo").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("foo").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("foo").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("foo").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("foo").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals("1", parseNode("1").getValue(bindings, null, null)); assertEquals(1l, parseNode("1").getValue(bindings, null, Long.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("1").getValueReference(null, null)); } + @Test public void testInvoke() { assertEquals("1", parseNode("1").invoke(bindings, null, null, null, null)); assertEquals(1l, parseNode("1").invoke(bindings, null, Long.class, null, null)); } + @Test public void testGetMethodInfo() { assertNull(parseNode("foo").getMethodInfo(bindings, null, null, null)); } diff --git a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java index e0e4473..6e1d2bb 100644 --- a/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java +++ b/modules/impl/src/test/java/de/odysseus/el/tree/impl/ast/AstUnaryTest.java @@ -19,6 +19,9 @@ import de.odysseus.el.TestCase; import de.odysseus.el.tree.Bindings; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AstUnaryTest extends TestCase { private Bindings bindings = new Bindings(null, null, null); @@ -27,6 +30,7 @@ AstUnary parseNode(String expression) { return (AstUnary)parse(expression).getRoot().getChild(0); } + @Test public void testEval() { assertEquals(true, parseNode("${!false}").eval(bindings, null)); assertEquals(false, parseNode("${!true}").eval(bindings, null)); @@ -35,6 +39,7 @@ public void testEval() { assertEquals(-1l, parseNode("${-1}").eval(bindings, null)); } + @Test public void testAppendStructure() { StringBuilder s = new StringBuilder(); parseNode("${!1}").appendStructure(s, bindings); @@ -43,35 +48,43 @@ public void testAppendStructure() { assertEquals("! 1empty 1- 1", s.toString()); } + @Test public void testIsLiteralText() { assertFalse(parseNode("${-1}").isLiteralText()); } + @Test public void testIsLeftValue() { assertFalse(parseNode("${-1}").isLeftValue()); } + @Test public void testGetType() { assertNull(parseNode("${-1}").getType(bindings, null)); } + @Test public void testIsReadOnly() { assertTrue(parseNode("${-1}").isReadOnly(bindings, null)); } + @Test public void testSetValue() { try { parseNode("${-1}").setValue(bindings, null, null); fail(); } catch (ELException e) {} } + @Test public void testGetValue() { assertEquals(Long.valueOf(-1l), parseNode("${-1}").getValue(bindings, null, null)); assertEquals("-1", parseNode("${-1}").getValue(bindings, null, String.class)); } + @Test public void testGetValueReference() { assertNull(parseNode("${-1}").getValueReference(null, null)); } + @Test public void testOperators() { assertFalse((Boolean)parseNode("${not true}").getValue(bindings, null, Boolean.class)); assertTrue((Boolean)parseNode("${not false}").getValue(bindings, null, Boolean.class)); diff --git a/modules/spi/pom.xml b/modules/spi/pom.xml index 6aebbf6..f3a4aec 100644 --- a/modules/spi/pom.xml +++ b/modules/spi/pom.xml @@ -15,14 +15,14 @@ jar Java Unified Expression Language Service Provider - 2.2.8-SNAPSHOT + ${parent.version} org.apache.maven.plugins maven-jar-plugin - 2.4 + ${maven-jar-plugin.version} false diff --git a/pom.xml b/pom.xml index 8c11173..702e064 100644 --- a/pom.xml +++ b/pom.xml @@ -54,35 +54,66 @@ - UTF-8 + UTF-8 + 1.8 + ${java.version} + ${java.version} + ${encoding} + ${encoding} + 3.9.0 + 3.2.1 + 3.4.1 + 3.0.0-M5 + 3.2.1 + 5.9.0 - junit - junit - 3.8.1 + org.junit.jupiter + junit-jupiter + test + ${junit-jupiter.version} + + + org.junit.platform + junit-platform-suite + 1.9.0 test + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire.version} + + + org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + ${maven.compiler.version} - 1.5 - 1.5 - true + ${maven.compiler.source} + ${maven.compiler.target} + ${encoding} org.apache.maven.plugins maven-source-plugin - 2.1.2 + ${maven-source-plugin.version} true @@ -96,7 +127,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.7 + ${maven-javadoc-plugin.verions} Copyright © {inceptionYear}-{currentYear} {organizationName}.