aboutsummaryrefslogtreecommitdiff
path: root/rsTester/src/test
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@gmail.com>2012-09-02 14:10:01 -0700
committerGravatar Rogan Creswick <creswick@gmail.com>2012-09-02 14:10:01 -0700
commita8664102395dc9c899428ea6e31a64ff6f22046e (patch)
treea1d764b3983ff385d59d2d2fad8c9ccda4e78495 /rsTester/src/test
parent172992b50a44417ec758ba79b25026c700961e4b (diff)
refactored the java-based apps: testrunner, rstester, batch-executor
Diffstat (limited to 'rsTester/src/test')
-rw-r--r--rsTester/src/test/java/com/galois/fiveui/BatchExecutorTest.java38
-rw-r--r--rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java57
-rw-r--r--rsTester/src/test/java/com/galois/fiveui/RunDescriptionTest.java82
-rw-r--r--rsTester/src/test/resources/ruleSets/emptyRuleSet.json4
-rw-r--r--rsTester/src/test/resources/ruleSets/headingGuidelines.json37
-rw-r--r--rsTester/src/test/resources/ruleSets/simpleRuleSet1.json9
-rw-r--r--rsTester/src/test/resources/runDescriptions/headingSample.json13
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample0.json4
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample1.json4
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample2.json10
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample3.json7
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample4.json10
-rw-r--r--rsTester/src/test/resources/runDescriptions/sample5.json13
13 files changed, 288 insertions, 0 deletions
diff --git a/rsTester/src/test/java/com/galois/fiveui/BatchExecutorTest.java b/rsTester/src/test/java/com/galois/fiveui/BatchExecutorTest.java
new file mode 100644
index 0000000..bb4dd31
--- /dev/null
+++ b/rsTester/src/test/java/com/galois/fiveui/BatchExecutorTest.java
@@ -0,0 +1,38 @@
+/**
+ * Module : BatchExecutorTest.java
+ * Copyright : (c) 2011-2012, Galois, Inc.
+ *
+ * Maintainer :
+ * Stability : Provisional
+ * Portability: Portable
+ *
+ * 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 com.galois.fiveui;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+
+/**
+ * @author creswick
+ *
+ */
+public class BatchExecutorTest {
+
+ @Test
+ public void simpleTest() {
+ Assert.assertEquals("Booleans are not equal.", true, true);
+ }
+}
diff --git a/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java b/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java
new file mode 100644
index 0000000..1cd4dae
--- /dev/null
+++ b/rsTester/src/test/java/com/galois/fiveui/RuleSetTest.java
@@ -0,0 +1,57 @@
+/**
+ * Module : RuleSetTest.java
+ * Copyright : (c) 2011-2012, Galois, Inc.
+ *
+ * Maintainer :
+ * Stability : Provisional
+ * Portability: Portable
+ *
+ * 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 com.galois.fiveui;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class RuleSetTest {
+ @Test
+ public void testParseNoFns() {
+ testParse("the name", "a descr", "[]", new ArrayList<String>());
+ }
+
+ @Ignore
+ @Test
+ public void testParseOneFn() {
+ List<String> rules = ImmutableList.of("\n function () {\n }\n");
+ testParse("the name", "a descr", "[function () {}]", rules);
+ }
+
+ private void testParse(String name, String desc, String rules, List<String> rulesOracle) {
+ RuleSet rs = RuleSet.parse("{ 'name': '" +name+"'" +
+ ", 'description': '"+desc+"'" +
+ ", 'rules': " + rules +
+ "};");
+
+ assertEquals("", name, rs.getName());
+ assertEquals("", desc, rs.getDescription());
+ Assert.assertArrayEquals("", rulesOracle.toArray(), rs.getRules().toArray());
+ }
+}
diff --git a/rsTester/src/test/java/com/galois/fiveui/RunDescriptionTest.java b/rsTester/src/test/java/com/galois/fiveui/RunDescriptionTest.java
new file mode 100644
index 0000000..4c58f74
--- /dev/null
+++ b/rsTester/src/test/java/com/galois/fiveui/RunDescriptionTest.java
@@ -0,0 +1,82 @@
+/**
+ * RunDescriptionTest.java
+ *
+ * Copyright (c) 2012 Galois, Inc.
+ */
+package com.galois.fiveui;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * @author creswick
+ *
+ */
+public class RunDescriptionTest {
+
+ private static final String RUN_DESCRIPTION_DIR = "src/test/resources/runDescriptions/";
+
+ /**
+ * Test method for {@link com.galois.fiveui.RSTestDescription#RunDescription(java.lang.String, java.util.List, com.galois.fiveui.RuleSet)}.
+ * @throws FileNotFoundException
+ */
+ @Test
+ public final void testDeserialize_sample0() throws FileNotFoundException {
+
+ String jsonFileName = RUN_DESCRIPTION_DIR + "sample0.json";
+ String ruleSetLoc =
+ RUN_DESCRIPTION_DIR + "../ruleSets/emptyRuleSet.json";
+
+ ImmutableList<Rule> emptyRuleList = ImmutableList.of();
+ RuleSet rsOracle =
+ new RuleSet("emptyRuleSet", "", emptyRuleList);
+
+ RSTestDescription oracle =
+ new RSTestDescription(ruleSetLoc,
+ new ArrayList<RSTestDescription.URIMap>(), rsOracle);
+
+
+ RSTestDescription actual = RSTestDescription.parse(jsonFileName);
+ assertObjEqual("Object deserialized incorrectly.", oracle, actual);
+ }
+
+ /**
+ * Test method for {@link com.galois.fiveui.RSTestDescription#RunDescription(java.lang.String, java.util.List, com.galois.fiveui.RuleSet)}.
+ * @throws FileNotFoundException
+ */
+ @Test
+ public final void testDeserialize_sample1() throws FileNotFoundException {
+
+ String jsonFileName = RUN_DESCRIPTION_DIR + "sample1.json";
+ String ruleSetLoc =
+ RUN_DESCRIPTION_DIR + "../ruleSets/simpleRuleSet1.json";
+
+ RuleSet rsOracle =
+ new RuleSet("simpleRuleSet1", "", ImmutableList.of(
+ new Rule("trivial check", "test desc", "", 42)));
+
+ RSTestDescription oracle =
+ new RSTestDescription(ruleSetLoc,
+ new ArrayList<RSTestDescription.URIMap>(), rsOracle);
+
+
+ RSTestDescription actual = RSTestDescription.parse(jsonFileName);
+ assertObjEqual("Object deserialized incorrectly.", oracle, actual);
+ }
+
+ private void assertObjEqual(String msg, Object oracle, Object actual) {
+ Assert.assertTrue(msg + "; expected: "+oracle+" actual: "+actual,
+ oracle.equals(actual));
+ }
+
+
+}
diff --git a/rsTester/src/test/resources/ruleSets/emptyRuleSet.json b/rsTester/src/test/resources/ruleSets/emptyRuleSet.json
new file mode 100644
index 0000000..a01bc68
--- /dev/null
+++ b/rsTester/src/test/resources/ruleSets/emptyRuleSet.json
@@ -0,0 +1,4 @@
+{ "name": "emptyRuleSet"
+, "description": ""
+, "rules": []
+}
diff --git a/rsTester/src/test/resources/ruleSets/headingGuidelines.json b/rsTester/src/test/resources/ruleSets/headingGuidelines.json
new file mode 100644
index 0000000..be69fac
--- /dev/null
+++ b/rsTester/src/test/resources/ruleSets/headingGuidelines.json
@@ -0,0 +1,37 @@
+{ "name": "Heading Guidelines"
+, "description": "Guidelines pertaining to the formatting and content of headings."
+, "rules": [ { "id": 1
+ , "name": "Headings are capitalized"
+ , "description": "Check to see if all headings use leading capital letters."
+ , "rule":
+ function() {
+ var badHeadings =
+ fiveui.query(':header').filter(
+ function(idx) {
+ var ch = $(this).text()[0];
+ if (ch) {
+ return (ch == ch.toLowerCase() );
+ } else {
+ return false;
+ }
+ });
+ $(badHeadings).map(function(idx, elt){
+ report('Heading does not start with a capitol letter.', elt);
+ });
+
+ }
+ },
+ { "id": 2
+ , "name": "Disallow Empty Headers"
+ , "description": "Heading elements should contain text."
+ , "rule": function() {
+ fiveui.query(':header').each(
+ function(ix, elt) {
+ if($(elt).text() == '') {
+ report('Heading does not contain text', elt);
+ }
+ });
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/rsTester/src/test/resources/ruleSets/simpleRuleSet1.json b/rsTester/src/test/resources/ruleSets/simpleRuleSet1.json
new file mode 100644
index 0000000..8365d1d
--- /dev/null
+++ b/rsTester/src/test/resources/ruleSets/simpleRuleSet1.json
@@ -0,0 +1,9 @@
+{ "name": "simpleRuleSet1"
+, "description": ""
+, "rules": [ { "id": 42
+ , "name": "trivial check"
+ , "description": "test desc"
+ , "rule":
+ function() { }
+ }]
+}
diff --git a/rsTester/src/test/resources/runDescriptions/headingSample.json b/rsTester/src/test/resources/runDescriptions/headingSample.json
new file mode 100644
index 0000000..e8228ca
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/headingSample.json
@@ -0,0 +1,13 @@
+{
+ 'ruleSet': '../ruleSets/headingGuidelines.json',
+ 'tests': [ { 'url': 'http://localhost:8000/exampleData/basic/headings.html',
+ 'oracle': [ { 'ruleId': 1
+ , 'results': ['Error', 'Error']
+ },
+ { 'ruleId': 2
+ , 'results': ['Error']
+ }
+ ]
+ }
+ ]
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample0.json b/rsTester/src/test/resources/runDescriptions/sample0.json
new file mode 100644
index 0000000..0c2bbb7
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample0.json
@@ -0,0 +1,4 @@
+{
+ 'ruleSet': '../ruleSets/emptyRuleSet.json',
+ 'tests': []
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample1.json b/rsTester/src/test/resources/runDescriptions/sample1.json
new file mode 100644
index 0000000..91f8f34
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample1.json
@@ -0,0 +1,4 @@
+{
+ 'ruleSet': '../ruleSets/simpleRuleSet1.json',
+ 'tests': []
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample2.json b/rsTester/src/test/resources/runDescriptions/sample2.json
new file mode 100644
index 0000000..a8ea9ec
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample2.json
@@ -0,0 +1,10 @@
+{
+ 'ruleSet': '../ruleSets/simpleRuleSet1.json',
+ 'tests': [ { 'url': 'http://localhost:8000/',
+ 'oracle': [ { 'ruleId': 42
+ , 'results': ['Error', 'Error']
+ }
+ ]
+ }
+ ]
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample3.json b/rsTester/src/test/resources/runDescriptions/sample3.json
new file mode 100644
index 0000000..e4d1cea
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample3.json
@@ -0,0 +1,7 @@
+{
+ 'ruleSet': '../ruleSets/simpleRuleSet1.json',
+ 'tests': [ { 'url': 'http://localhost:8000/',
+ 'oracle': [ ]
+ }
+ ]
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample4.json b/rsTester/src/test/resources/runDescriptions/sample4.json
new file mode 100644
index 0000000..c4f46cd
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample4.json
@@ -0,0 +1,10 @@
+{
+ 'ruleSet': '../ruleSets/simpleRuleSet1.json',
+ 'tests': [ { 'url': 'http://localhost:8000/',
+ 'oracle': [ ]
+ },
+ { 'url': 'http://localhost:8000/',
+ 'oracle': [ ]
+ }
+ ]
+}
diff --git a/rsTester/src/test/resources/runDescriptions/sample5.json b/rsTester/src/test/resources/runDescriptions/sample5.json
new file mode 100644
index 0000000..11ca957
--- /dev/null
+++ b/rsTester/src/test/resources/runDescriptions/sample5.json
@@ -0,0 +1,13 @@
+{
+ 'ruleSet': '../ruleSets/simpleRuleSet1.json',
+ 'tests': [ { 'url': 'http://localhost:8000/',
+ 'oracle': [ { 'ruleId': 42
+ , 'results': ['Error']
+ }
+ ]
+ },
+ { 'url': 'http://localhost:8000/',
+ 'oracle': [ ]
+ }
+ ]
+}