Added the missing TearDown for HardwareVtep IT. 49/9949/2
authorMadhu Venugopal <mavenugo@gmail.com>
Thu, 14 Aug 2014 11:37:36 +0000 (04:37 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Thu, 14 Aug 2014 11:54:41 +0000 (04:54 -0700)
Change-Id: I170fd69f1a1cb1b44ae0bc4c36fef7072aec6783
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
schemas/hardwarevtep/src/test/java/org/opendaylight/ovsdb/schema/hardwarevtep/HardwareVtepSchemaSuiteIT.java
schemas/hardwarevtep/src/test/java/org/opendaylight/ovsdb/schema/hardwarevtep/TearDown.java [new file with mode: 0644]

index e99b34505b8c0d42461f9894044dffe100099832..f0be4956a9ace6728244358566c07787f0cadacc 100644 (file)
@@ -23,7 +23,8 @@ import java.util.Map;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
         MonitorTestCases.class,
-        ManagerTestCases.class
+        ManagerTestCases.class,
+        TearDown.class
 })
 
 public class HardwareVtepSchemaSuiteIT {
diff --git a/schemas/hardwarevtep/src/test/java/org/opendaylight/ovsdb/schema/hardwarevtep/TearDown.java b/schemas/hardwarevtep/src/test/java/org/opendaylight/ovsdb/schema/hardwarevtep/TearDown.java
new file mode 100644 (file)
index 0000000..2d15695
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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.schema.hardwarevtep;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
+
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class TearDown extends HardwareVtepSchemaTestBase {
+
+    @Override
+    @Before
+    public void setUp() throws ExecutionException, InterruptedException, TimeoutException, IOException {
+        super.setUp();
+    }
+
+    /**
+     * Tear down the rows in the OVSDB server created by the
+     * integration tests.
+     *
+     * @throws InterruptedException the interrupted exception
+     * @throws ExecutionException the execution exception
+     * @throws IOException the iO exception
+     * @throws TimeoutException the timeout exception
+     */
+    @Test
+    public void tearDown() throws InterruptedException, ExecutionException, IOException, TimeoutException {
+        Assume.assumeTrue(super.checkSchema());
+        Manager manager = this.ovs.getTypedRowWrapper(Manager.class, null);
+        Global glbl = this.ovs.getTypedRowWrapper(Global.class, null);
+        TransactionBuilder transactionBuilder = this.ovs.transactBuilder(HardwareVtepSchemaSuiteIT.dbSchema);
+
+        transactionBuilder.add(op.delete(manager.getSchema())
+                .where(manager.getUuidColumn().getSchema().opEqual(HardwareVtepSchemaSuiteIT.getTestManagerUuid()))
+                        .build())
+                .add(op.mutate(glbl.getSchema())
+                        .addMutation(glbl.getManagersColumn().getSchema(), Mutator.DELETE,
+                                Sets.newHashSet(HardwareVtepSchemaSuiteIT.getTestManagerUuid())))
+                .add(op.commit(true))
+                .execute();
+
+        ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+        List<OperationResult> operationResults = results.get();
+        for (OperationResult result : operationResults) {
+            Assert.assertNull(result.getError());
+        }
+        System.out.println("Delete operation results = " + operationResults);
+    }
+
+    @Override
+    public void update(Object context, UpdateNotification upadateNotification) {
+
+    }
+
+    @Override
+    public void locked(Object context, List<String> ids) {
+
+    }
+
+    @Override
+    public void stolen(Object context, List<String> ids) {
+
+    }
+}