Unit tests for RequestFailure derived classes 79/53079/5
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Thu, 9 Mar 2017 13:31:03 +0000 (14:31 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 10 Mar 2017 09:50:06 +0000 (10:50 +0100)
Change-Id: I3b9fb7f6707b4519ea91880a369cfba0af24eb4e
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestFailureTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientFailureTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/LocalHistoryFailureTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionFailureTest.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestFailureTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestFailureTest.java
new file mode 100644 (file)
index 0000000..a0a7986
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * 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
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.FrontendType;
+import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.MemberName;
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
+import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
+import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+
+public abstract class AbstractRequestFailureTest<T extends RequestFailure> {
+    private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
+            MemberName.forName("member"), FrontendType.forName("frontend"));
+
+    protected static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
+    protected static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(CLIENT_IDENTIFIER, 0);
+    protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
+            HISTORY_IDENTIFIER, 0);
+    protected static final RequestException CAUSE = new RuntimeRequestException("fail", new Throwable());
+
+    abstract T object();
+
+    @Test
+    public void getCauseTest() throws Exception {
+        Assert.assertEquals(CAUSE, object().getCause());
+    }
+
+    @Test
+    public void isHardFailureTest() throws Exception {
+        Assert.assertTrue(object().isHardFailure());
+    }
+}
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientFailureTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientFailureTest.java
new file mode 100644 (file)
index 0000000..b718c61
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * 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
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class ConnectClientFailureTest extends AbstractRequestFailureTest<ConnectClientFailure> {
+    private static final ConnectClientFailure OBJECT = new ConnectClientFailure(CLIENT_IDENTIFIER, 0, CAUSE);
+
+    @Override
+    ConnectClientFailure object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ConnectClientFailure clone = OBJECT.cloneAsVersion(ABIVersion.current());
+        Assert.assertEquals(OBJECT.getTarget(), clone.getTarget());
+        Assert.assertEquals(OBJECT.getSequence(), clone.getSequence());
+        Assert.assertEquals(OBJECT.getCause(), clone.getCause());
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final ConnectClientFailureProxyV1 proxy = (ConnectClientFailureProxyV1) OBJECT.externalizableProxy(
+                ABIVersion.current());
+        Assert.assertNotNull(proxy);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/LocalHistoryFailureTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/LocalHistoryFailureTest.java
new file mode 100644 (file)
index 0000000..c02ae09
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * 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
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class LocalHistoryFailureTest extends AbstractRequestFailureTest<LocalHistoryFailure> {
+    private static final LocalHistoryFailure OBJECT = new LocalHistoryFailure(HISTORY_IDENTIFIER, 0, CAUSE);
+
+    @Override
+    LocalHistoryFailure object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final LocalHistoryFailure clone = OBJECT.cloneAsVersion(ABIVersion.current());
+        Assert.assertEquals(OBJECT, clone);
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final LocalHistoryFailureProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.current());
+        Assert.assertNotNull(proxy);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionFailureTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionFailureTest.java
new file mode 100644 (file)
index 0000000..ff61651
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * 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
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionFailureTest extends AbstractRequestFailureTest<TransactionFailure> {
+    private static final TransactionFailure OBJECT = new TransactionFailure(TRANSACTION_IDENTIFIER, 0, CAUSE);
+
+    @Override
+    TransactionFailure object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionFailure clone = OBJECT.cloneAsVersion(ABIVersion.current());
+        Assert.assertEquals(OBJECT, clone);
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final TransactionFailureProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.current());
+        Assert.assertNotNull(proxy);
+    }
+}
\ No newline at end of file