From: Madhu Venugopal Date: Mon, 26 May 2014 18:16:13 +0000 (-0700) Subject: Added assert operation as per RFC 7047 section 5.2.10 X-Git-Tag: release/helium~170^2~89 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=491ccbb646435f5052fb9bcf163463236c40df0b;p=ovsdb.git Added assert operation as per RFC 7047 section 5.2.10 Change-Id: I31087a39bffc1f395652f0132fb5881cc45f8554 Signed-off-by: Madhu Venugopal --- 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 index 000000000..2d3e291b3 --- /dev/null +++ b/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Assert.java @@ -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; + } +} diff --git a/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java b/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java index 341d7780b..912ff67ca 100644 --- a/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java +++ b/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java @@ -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 diff --git a/library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java b/library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java index bb1f20e2d..c09afc129 100644 --- a/library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java +++ b/library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java @@ -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