From c943aafa37b606fb1b73f824404ec4b0dd79265a Mon Sep 17 00:00:00 2001 From: Rogan Creswick Date: Thu, 13 Jun 2013 22:15:05 -0700 Subject: removed obsolete headless test, updated testing rule sets to use report object --- .../main/java/com/galois/fiveui/BatchRunner.java | 1 + .../java/com/galois/fiveui/BatchExecutorTest.java | 122 --------------------- .../src/test/resources/ruleSets/makeError.js | 5 +- .../resources/ruleSets/headingGuidelines-caps.js | 5 +- .../ruleSets/headingGuidelines-noEmptyHdrs.js | 7 +- 5 files changed, 8 insertions(+), 132 deletions(-) delete mode 100644 src/batchtools/headless/src/test/java/com/galois/fiveui/BatchExecutorTest.java (limited to 'src') diff --git a/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java b/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java index a57a9eb..69b8c1c 100644 --- a/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java +++ b/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java @@ -261,6 +261,7 @@ public class BatchRunner { private String wrapRule(RuleSet ruleSet) throws IOException { String injected = "fiveui = {};"; injected += Utils.readFile(_root + JS_SRC_ROOT + J_QUERY_JS); + injected += Utils.readFile(_root + JS_SRC_ROOT + "lib/underscore.js"); injected += Utils.readFile(_root + JS_SRC_ROOT + MD5_JS); injected += Utils.readFile(_root + JS_SRC_ROOT + "fiveui/injected/prelude.js"); injected += Utils.readFile(_root + JS_SRC_ROOT + "fiveui/injected/jquery-plugins.js"); diff --git a/src/batchtools/headless/src/test/java/com/galois/fiveui/BatchExecutorTest.java b/src/batchtools/headless/src/test/java/com/galois/fiveui/BatchExecutorTest.java deleted file mode 100644 index 665876e..0000000 --- a/src/batchtools/headless/src/test/java/com/galois/fiveui/BatchExecutorTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * 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 java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.BindException; - - -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.Assert; - -import com.google.common.collect.ImmutableList; - - -/** - * @author bjones - * - */ -public class BatchExecutorTest { - - private static final String RUN_DESCRIPTION_DIR = "src/test/resources/runDescriptions/"; - private static Logger logger = Logger.getLogger(BatchExecutorTest.class); - private static NanoHTTPD httpServer; - - @BeforeClass - public static void setupTests() { - BasicConfigurator.configure(); - logger.setLevel(Level.DEBUG); - Logger root = Logger.getRootLogger(); - root.setLevel(Level.ERROR); - // start up local web server for crawl tests - File dir = new File("."); - logger.info("Starting NanoHTTPD webserver in " + dir.getAbsolutePath() + " on port 8000 ..."); - try { - httpServer = new NanoHTTPD(8000, dir); - } catch (BindException e) { - logger.debug("assuming that local web server is already running"); - } catch (IOException e1) { - e1.printStackTrace(); - Assert.assertTrue("failed to start NanoHTTPD in current directory " + dir.getAbsolutePath(), false); - } - } - - @AfterClass - public static void teardown() { - LogManager.shutdown(); - httpServer.stop(); - } - - /** - * This unit test requires that a webserver be running locally on port 8000, - * what it serves does not matter. - * - * @throws IOException - * @throws FileNotFoundException - */ - @Test - public void headlessRunTest0() throws IOException { - String jsonFileName = RUN_DESCRIPTION_DIR + "headlessRunTest0.json"; - testHeadlessRun(jsonFileName); - } - - /** - * This unit test requires Internet access to http://www.cnn.com - * - * @throws IOException - * @throws FileNotFoundException - */ - @Ignore - public void headlessRunTestCNN() throws IOException { - String jsonFileName = RUN_DESCRIPTION_DIR + "headlessRunTestCNN.json"; - testHeadlessRun(jsonFileName); - } - - /** - * Helper method for headless run unit tests. - * - * @param fn filename of a .json file containing a headless run description - */ - private static void testHeadlessRun(String fn) { - boolean flag = true; - try { - HeadlessRunDescription descr = HeadlessRunDescription.parse(fn); - BatchRunner runner = new BatchRunner(); - ImmutableList results = runner.runHeadless(descr); - logger.info(results.toString()); - } catch (Exception e) { - logger.error("testHeadlessRun: exception caught while running a headless run description"); - logger.error(e.toString()); - flag = false; - } - Assert.assertTrue(flag); - } - -} diff --git a/src/batchtools/headless/src/test/resources/ruleSets/makeError.js b/src/batchtools/headless/src/test/resources/ruleSets/makeError.js index d1705d3..57897c3 100644 --- a/src/batchtools/headless/src/test/resources/ruleSets/makeError.js +++ b/src/batchtools/headless/src/test/resources/ruleSets/makeError.js @@ -1,6 +1,5 @@ exports.name = "Generate Errors"; exports.description = "Always report an error"; -exports.rule = function() { - var r = this; - r.report("error", null); +exports.rule = function(report) { + report.error("error", null); }; \ No newline at end of file diff --git a/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-caps.js b/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-caps.js index 6178ac1..6c988bc 100644 --- a/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-caps.js +++ b/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-caps.js @@ -2,8 +2,7 @@ exports.name = "Headings are capitalized"; exports.description = "Check to see if all headings use leading capital letters."; -exports.rule = function() { - var r = this; +exports.rule = function(r) { var badHeadings = fiveui.query(':header').filter( function(idx) { @@ -15,6 +14,6 @@ exports.rule = function() { } }); $(badHeadings).map(function(idx, elt) { - r.report('Heading does not start with a capital letter.', elt); + r.error('Heading does not start with a capital letter.', elt); }); }; diff --git a/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-noEmptyHdrs.js b/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-noEmptyHdrs.js index 466f46e..e31f412 100644 --- a/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-noEmptyHdrs.js +++ b/src/batchtools/rsTester/src/test/resources/ruleSets/headingGuidelines-noEmptyHdrs.js @@ -2,12 +2,11 @@ exports.name = "Disallow Empty Headers"; exports.description = "Heading elements should contain text."; -exports.rule = function() { - var r = this; - fiveui.query(':header').each( +exports.rule = function(r) { + $5(':header').each( function(ix, elt) { if($(elt).text() == '') { - r.report('Heading does not contain text', elt); + r.error('Heading does not contain text', elt); } }); }; -- cgit v1.2.3