commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1559141 - in /commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy: StaticMethodTest.java static-method.xml
Date Fri, 17 Jan 2014 15:20:41 GMT
Author: ate
Date: Fri Jan 17 15:20:41 2014
New Revision: 1559141

URL: http://svn.apache.org/r1559141
Log:
SCXML-186: Groovy Expression evaluator support
- adding simple static method test for Groovy (copied from jexl)

Added:
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
  (with props)
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
  (with props)

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java?rev=1559141&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
(added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
Fri Jan 17 15:20:41 2014
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.scxml2.env.groovy;
+
+import java.net.URL;
+import java.util.Set;
+
+import org.apache.commons.scxml2.Context;
+import org.apache.commons.scxml2.SCXMLExecutor;
+import org.apache.commons.scxml2.SCXMLTestHelper;
+import org.apache.commons.scxml2.model.TransitionTarget;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StaticMethodTest {
+
+    private URL staticmethod;
+
+    /**
+     * Set up instance variables required by this test case.
+     */
+    @Before
+    public void setUp() {
+        staticmethod = this.getClass().getClassLoader().
+            getResource("org/apache/commons/scxml2/env/groovy/static-method.xml");
+    }
+
+    /**
+     * Tear down instance variables required by this test case.
+     */
+    @After
+    public void tearDown() {
+        staticmethod = null;
+    }
+    
+    @Test
+    public void testGroovyStaticMethodInvocation() throws Exception {
+        Context jc = new GroovyContext();
+        jc.set("System", System.class);
+        SCXMLExecutor exec = SCXMLTestHelper.getExecutor(staticmethod,
+                jc, new GroovyEvaluator());
+        Set<TransitionTarget> currentStates = exec.getCurrentStatus().getStates();
+        Assert.assertEquals(1, currentStates.size());
+        Assert.assertEquals("static", currentStates.iterator().next().getId());
+    }
+
+}

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml?rev=1559141&view=auto
==============================================================================
--- commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
(added)
+++ commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
Fri Jan 17 15:20:41 2014
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!-- Example of invoking a static method when using Groovy, for example:
+     (public static) java.lang.System#currentTimeMillis()
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml"
+       version="1.0"
+       initial="static">
+
+    <state id="static" final="true">
+        <onentry>
+            <log expr="'Current time millis: ' + System.currentTimeMillis()" />
+        </onentry>
+    </state>
+
+</scxml>
+

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message