Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding expectations to the DSL wrapper

  • Loading branch information...
commit 2de606c5ee875351a6d43ba0127f9d677f5929aa 1 parent 221ddcf
@hyperthunk authored
View
49 axiom-core/src/main/java/org/axiom/scenario/PredicateExpectation.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2009, Tim Watson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.axiom.scenario;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+
+/**
+ * Defines an {@link Expectation} predicated upon an instance of
+ * <i>camel's</i> {@link Predicate} interface.
+ */
+public class PredicateExpectation<E extends Exchange> implements Expectation<E> {
+
+ private final Predicate<E> predicate;
+
+ public PredicateExpectation(final Predicate<E> predicate) {
+ this.predicate = predicate;
+ }
+
+ @Override public void verify(final E exchange) throws VerificationFailureException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
View
66 axiom-core/src/main/java/org/axiom/scenario/VerificationFailureException.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2009, Tim Watson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.axiom.scenario;
+
+import org.apache.commons.lang.ClassUtils;
+
+/**
+ * Checked exception class that represents a failed step
+ * during scenario verification.
+ */
+public class VerificationFailureException extends Exception {
+
+ private final Object target;
+
+ public VerificationFailureException(final Object target) {
+ this.target = target;
+ }
+
+ public VerificationFailureException(final Object target, final String s) {
+ super(s);
+ this.target = target;
+ }
+
+ public VerificationFailureException(final Object target, final String s, final Throwable throwable) {
+ super(s, throwable);
+ this.target = target;
+ }
+
+ public Object getTarget() {
+ return target;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T> T getTarget(final Class<T> asClazz) {
+ if (ClassUtils.isAssignable(target.getClass(), asClazz)) {
+ return (T) target;
+ }
+ return null;
+ }
+}
View
10 axiom-core/src/test/java/org/axiom/scenario/PredicateExpectationSpec.java
@@ -0,0 +1,10 @@
+package org.axiom.scenario;
+
+import jdave.Specification;
+import jdave.junit4.JDaveRunner;
+import org.junit.runner.RunWith;
+
+@RunWith(JDaveRunner.class)
+public class PredicateExpectationSpec extends Specification<PredicateExpectation> {
+
+}
View
2  install.sh
@@ -49,7 +49,7 @@ if [[ "$1" == *--help* ]]; then
echo "--dest Destination folder (default = /opt/axiom)"
echo "--home Axiom Home folder (default = $INSTALL/.axiom)"
echo "--bin Location for the executable script (optional, default = /usr/bin)"
- exit 1
+ exit 0
fi
INSTALL_DIR=/opt/axiom
Please sign in to comment.
Something went wrong with that request. Please try again.