creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1407966 - /creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/
Date Sun, 11 Nov 2012 12:57:36 GMT
Author: rdonkin
Date: Sun Nov 11 12:57:34 2012
New Revision: 1407966

URL: http://svn.apache.org/viewvc?rev=1407966&view=rev
Log:
Drat - missed a few new files for the integration testing framework

Added:
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java
  (with props)
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java
  (with props)
Removed:
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/LicenseVerifier.java
Modified:
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Helpers.java

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,48 @@
+/**
+ * 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.creadur.whisker.it;
+
+import static org.apache.creadur.whisker.it.CheckHelpers.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class AllCheck implements Check {
+
+    final List<Check> checks;
+
+    public AllCheck(Collection<Check> checks) {
+        super();
+        this.checks = new ArrayList<Check>(checks);
+    }
+
+    public void check(final String line) {
+        doCheck(line).with(checks);
+    }
+
+    public boolean hasPassed() {
+        return allPassed(checks);
+    }
+
+    public void report(final Results results) {
+       to(results).report(checks);
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AllCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.creadur.whisker.it;
+
+import static org.apache.creadur.whisker.it.CheckHelpers.*;
+import static org.apache.creadur.whisker.it.Not.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class AnyCheck implements Check {
+
+    final List<Check> checks;
+
+    public AnyCheck(Collection<Check> checks) {
+        super();
+        this.checks = new ArrayList<Check>(checks);
+    }
+
+    public void check(final String line) {
+        doCheck(line).with(checks);
+    }
+
+    public boolean hasPassed() {
+        return checks.size() == 0 || anyPassed(checks);
+    }
+
+    public void report(final Results results) {
+       if (not(hasPassed())) {
+           to(results).report(checks);
+       }
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/AnyCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,29 @@
+/**
+ * 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.creadur.whisker.it;
+
+public interface Check {
+
+    public abstract void check(String line);
+
+    public abstract boolean hasPassed();
+
+    public abstract void report(Results result);
+
+}
\ No newline at end of file

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Check.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,37 @@
+/**
+ * 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.creadur.whisker.it;
+
+import org.apache.commons.collections.Closure;
+
+public abstract class CheckClosure implements Closure {
+
+    public CheckClosure() {
+        super();
+    }
+
+    public abstract void execute(final Check check);
+
+    public void execute(Object input) {
+        if (input instanceof Check) {
+            execute((Check) input);
+        }
+    }
+
+}
\ No newline at end of file

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckClosure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,48 @@
+/**
+ * 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.creadur.whisker.it;
+
+
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.functors.NotPredicate;
+
+public class CheckHasPassedPredicate implements Predicate {
+
+    public static Predicate checkFailed() {
+        return new NotPredicate(checkPassed());
+    }
+
+    public static Predicate checkPassed() {
+        return new CheckHasPassedPredicate();
+    }
+
+    private CheckHasPassedPredicate() {}
+
+    public boolean evaluate(Object object) {
+        if (object instanceof Check) {
+            return evaluate((Check)object);
+        }
+        return false;
+    }
+
+    public boolean evaluate(final Check check) {
+        return check.hasPassed();
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHasPassedPredicate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,67 @@
+/**
+ * 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.creadur.whisker.it;
+
+
+import static org.apache.commons.collections.CollectionUtils.*;
+import static org.apache.creadur.whisker.it.CheckHasPassedPredicate.*;
+import static org.apache.creadur.whisker.it.Not.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class CheckHelpers {
+
+    public static AnyCheck aLineContainsEither(final String value, final String alternative)
{
+        return new AnyCheck(listAnyLineContains(value, alternative));
+    }
+
+    private static Collection<Check> listAnyLineContains(final String value,
+            final String alternative) {
+        final Collection<Check> checks = new ArrayList<Check>();
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(alternative));
+        return checks;
+    }
+
+    public static AllCheck containsBothLines(final String value, final String alternative)
{
+        return new AllCheck(listAnyLineContains(value, alternative));
+    }
+
+    public static boolean anyPassed(final Collection<Check> checks) {
+        return exists(checks, checkPassed());
+    }
+
+    public static boolean allPassed(final Collection<Check> checks) {
+        return not(anyFailed(checks));
+    }
+
+    public static boolean anyFailed(final Collection<Check> checks) {
+        return exists(checks, checkFailed());
+    }
+
+    public static ReportClosure to(final Results results) {
+        return new ReportClosure(results);
+    }
+
+    public static DoCheckClosure doCheck(final String line) {
+        return new DoCheckClosure(line);
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/CheckHelpers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.creadur.whisker.it;
+
+
+import static org.apache.commons.collections.CollectionUtils.*;
+
+import java.util.Collection;
+
+public class DoCheckClosure extends CheckClosure {
+
+    private final String line;
+
+    public DoCheckClosure(final String line) {
+        super();
+        this.line = line;
+    }
+
+    @Override
+    public void execute(final Check check) {
+        check.check(line);
+    }
+
+    public void with(Collection<Check> checks) {
+        forAllDo(checks, this);
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/DoCheckClosure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,65 @@
+/**
+ * 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.creadur.whisker.it;
+
+import static org.apache.creadur.whisker.it.CheckHelpers.*;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FileVerifier {
+
+    final File licenseFile;
+    final List<Check> checks;
+    final String title;
+
+
+    public FileVerifier(final File licenseFile, final String displayName) {
+        this.licenseFile = licenseFile;
+        this.checks = new ArrayList<Check>();
+        this.title = "FAILURES in " + displayName + ":";
+    }
+
+    public FileVerifier expectThat(final Check check) {
+        this.checks.add(check);
+        return this;
+    }
+
+    public String failures() throws Exception {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(
+                new FileInputStream(licenseFile), "UTF-8"));
+        try {
+            String line = null;
+            do {
+                line = checkLine(reader.readLine());
+            } while (line != null);
+        } finally {
+            reader.close();
+        }
+
+        final Results results = new Results().titled(title);
+        return to(results).report(checks).collate();
+    }
+
+    private String checkLine(final String line) {
+        doCheck(line).with(checks);
+        return line;
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/FileVerifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Helpers.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Helpers.java?rev=1407966&r1=1407965&r2=1407966&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Helpers.java
(original)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/Helpers.java
Sun Nov 11 12:57:34 2012
@@ -67,8 +67,8 @@ public class Helpers {
         return fileIsMissing(basedir, PATH_TO_LICENSE_FILE);
     }
 
-    public static LicenseVerifier licenseIn(File basedir) {
-        return new LicenseVerifier(new File(basedir, PATH_TO_LICENSE_FILE));
+    public static FileVerifier licenseIn(File basedir) {
+        return new FileVerifier(new File(basedir, PATH_TO_LICENSE_FILE), "LICENSE");
     }
 
     public static Results results() {

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.creadur.whisker.it;
+
+
+import static org.apache.commons.collections.CollectionUtils.*;
+
+import java.util.Collection;
+
+public class ReportClosure extends CheckClosure {
+
+    private final Results results;
+
+    public ReportClosure(Results results) {
+        super();
+        this.results = results;
+    }
+
+    @Override
+    public void execute(final Check check) {
+        check.report(results);
+    }
+
+    public Results report(Collection<Check> checks) {
+        forAllDo(checks, this);
+        return results;
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/ReportClosure.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,112 @@
+/**
+ * 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.creadur.whisker.it;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+public class TestAllCheck extends TestCase  {
+
+    Collection<Check> checks;
+    Results results;
+    AllCheck subject;
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        results = new Results();
+        checks = new ArrayList<Check>();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testNoChecksPass() {
+        subject = new AllCheck(Collections.<Check> emptyList());
+        subject.check("a line");
+        verifyPass();
+    }
+
+    public void testOneCheckFail() {
+        final String value = "some value";
+        checks.add(new AnyLineContainsCheck(value));
+
+        subject = new AllCheck(checks);
+        subject.check("a line");
+        verifyFail();
+    }
+
+    private void verifyFail() {
+        assertFalse(subject.hasPassed());
+        subject.report(results);
+        assertTrue(results.hasFailed());
+    }
+
+    public void testOneCheckPass() {
+        final String value = "some value";
+        checks.add(new AnyLineContainsCheck(value));
+
+        subject = new AllCheck(checks);
+        subject.check(value);
+        verifyPass();
+    }
+
+    private void verifyPass() {
+        assertTrue(subject.hasPassed());
+        subject.report(results);
+        assertFalse(results.hasFailed());
+    }
+
+    public void testTwoChecksPass() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AllCheck(checks);
+        subject.check(value);
+        subject.check(anotherValue);
+        verifyPass();
+    }
+
+    public void testTwoChecksFail() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AllCheck(checks);
+        subject.check("not");
+        verifyFail();
+    }
+
+    public void testTwoChecksWhenOneMatchFailsAllFail() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AllCheck(checks);
+        subject.check("not");
+        subject.check(value);
+        verifyFail();
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAllCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java?rev=1407966&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java
(added)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java
Sun Nov 11 12:57:34 2012
@@ -0,0 +1,112 @@
+/**
+ * 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.creadur.whisker.it;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+public class TestAnyCheck extends TestCase  {
+
+    Collection<Check> checks;
+    Results results;
+    AnyCheck subject;
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        results = new Results();
+        checks = new ArrayList<Check>();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testNoChecksPass() {
+        subject = new AnyCheck(Collections.<Check> emptyList());
+        subject.check("a line");
+        verifyPass();
+    }
+
+    public void testOneCheckFail() {
+        final String value = "some value";
+        checks.add(new AnyLineContainsCheck(value));
+
+        subject = new AnyCheck(checks);
+        subject.check("a line");
+        verifyFail();
+    }
+
+    private void verifyFail() {
+        assertFalse(subject.hasPassed());
+        subject.report(results);
+        assertTrue(results.hasFailed());
+    }
+
+    public void testOneCheckPass() {
+        final String value = "some value";
+        checks.add(new AnyLineContainsCheck(value));
+
+        subject = new AnyCheck(checks);
+        subject.check(value);
+        verifyPass();
+    }
+
+    private void verifyPass() {
+        assertTrue(subject.hasPassed());
+        subject.report(results);
+        assertFalse(results.hasFailed());
+    }
+
+    public void testTwoChecksPass() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AnyCheck(checks);
+        subject.check(value);
+        subject.check(anotherValue);
+        verifyPass();
+    }
+
+    public void testTwoChecksFail() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AnyCheck(checks);
+        subject.check("not");
+        verifyFail();
+    }
+
+    public void testTwoChecksPassWhenOneMatchFails() {
+        final String value = "some value";
+        final String anotherValue = "another value";
+        checks.add(new AnyLineContainsCheck(value));
+        checks.add(new AnyLineContainsCheck(anotherValue));
+        subject = new AnyCheck(checks);
+        subject.check("not");
+        subject.check(value);
+        verifyPass();
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-plugin4maven/src/test/java/org/apache/creadur/whisker/it/TestAnyCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message