Added assert operation as per RFC 7047 section 5.2.10 05/7405/1
authorMadhu Venugopal <mavenugo@gmail.com>
Mon, 26 May 2014 18:16:13 +0000 (11:16 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Mon, 26 May 2014 18:16:13 +0000 (11:16 -0700)
Change-Id: I31087a39bffc1f395652f0132fb5881cc45f8554
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
library/src/main/java/org/opendaylight/ovsdb/lib/operations/Assert.java [new file with mode: 0644]
library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java
library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java

diff --git a/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Assert.java b/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Assert.java
new file mode 100644 (file)
index 0000000..2d3e291
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+
+public class Assert extends Operation {
+
+    public static final String ASSERT = "assert";
+    String lock;
+
+    public Assert(String lock) {
+        super(null, ASSERT);
+        this.lock = lock;
+    }
+
+    public String getLock() {
+        return lock;
+    }
+}
index 341d7780b0429be23240403c7ce46604d439f0c5..912ff67caa5d3c961cadc8bbfab0c0d08533ecdd 100644 (file)
@@ -44,4 +44,12 @@ public class Operations {
     public Comment comment(String comment) {
         return new Comment(comment);
     }
+
+    /*
+     * Could not use Java keyword "assert" which clashes with the ovsdb json-rpc method.
+     * using assertion instead.
+     */
+    public Assert assertion(String lock) {
+        return new Assert(lock);
+    }
 }
\ No newline at end of file
index bb1f20e2d4a98c6274648b8c20cb70c36126964e..c09afc1293219323526a7f1142ee278aae44e10d 100644 (file)
@@ -111,8 +111,27 @@ public class OvsDBClientTestIT extends OvsdbTestBase {
 
         operationResults = results.get();
         Assert.assertFalse(operationResults.isEmpty());
+        /* Testing for Abort Error */
+        Assert.assertFalse(operationResults.get(1).getError() == null);
         System.out.println("Abort operation results = " + operationResults);
 
+        /*
+         * Adding a separate Abort operation in a transaction. Lets not mix this with other
+         * valid transactions as above.
+         */
+        results = ovs.transactBuilder()
+                .add(op.delete(bridge)
+                        .where(name.opEqual("br-int"))
+                        .operation())
+                .add(op.assertion("Assert12345")) // Failing intentionally
+                .execute();
+
+        operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        /* Testing for an Assertion Error */
+        Assert.assertFalse(operationResults.get(1).getError() == null);
+        System.out.println("Assert operation results = " + operationResults);
+
     }
 
     @Test