Unit tests: add serialization tests 85/53085/18
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Thu, 9 Mar 2017 14:45:27 +0000 (15:45 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 13 Mar 2017 15:34:44 +0000 (16:34 +0100)
- remove separate tests for proxy
- proxy classes are tested with serialization tests

Change-Id: I238d02d4c33a417c5d13d4ac1f59389d79594e4e
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
35 files changed:
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractRequestFailureTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientFailureTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestProxyV1Test.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/LocalHistoryFailureTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestEmptyTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1EmptyModificationsTest.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1NotEmptyModificationsTest.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessNoDataTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestProxyV1Test.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCanCommitSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCommitSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestProxyV1Test.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionFailureTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestProxyV1Test.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitSuccessTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestProxyV1Test.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeResponseTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestProxyTest.java [deleted file]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java

index 5d801c6..60e7dc8 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import org.junit.Assert;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
@@ -28,4 +29,10 @@ public class AbortLocalTransactionRequestTest
     protected AbortLocalTransactionRequest object() {
         return OBJECT;
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof AbortLocalTransactionRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((AbortLocalTransactionRequest) deserialize).getReplyTo());
+    }
 }
\ No newline at end of file
index 33cba17..2696767 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -16,13 +17,14 @@ public abstract class AbstractLocalTransactionRequestTest<T extends AbstractLoca
     @Override
     protected abstract T object();
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testExternalizableProxy() {
-        object().externalizableProxy(ABIVersion.BORON);
-    }
-
     @Test
     public void cloneAsVersionTest() {
         Assert.assertEquals(object(), object().cloneAsVersion(ABIVersion.BORON));
     }
+
+    @Override
+    @Test(expected = UnsupportedOperationException.class)
+    public void serializationTest() {
+        SerializationUtils.clone(object());
+    }
 }
index a0a7986..69c9ea2 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
@@ -40,4 +41,14 @@ public abstract class AbstractRequestFailureTest<T extends RequestFailure> {
     public void isHardFailureTest() throws Exception {
         Assert.assertTrue(object().isHardFailure());
     }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void serializationTest() {
+        final Object deserialize = SerializationUtils.clone(object());
+
+        Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
+        Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
+        Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
+    }
 }
index e762912..d67ebd8 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import org.apache.commons.lang.SerializationUtils;
+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;
@@ -23,4 +26,16 @@ public abstract class AbstractTransactionSuccessTest<T extends TransactionSucces
 
     protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
             HISTORY_IDENTIFIER, 0);
+
+    protected abstract T object();
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void serializationTest() {
+        final Object deserialize = SerializationUtils.clone(object());
+
+        Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
+        Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
+        Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
+    }
 }
index 646a7c5..d8dc842 100644 (file)
@@ -53,4 +53,11 @@ public class CommitLocalTransactionRequestTest
         final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
         Assert.assertTrue(result.toString().contains("coordinated=" + COORDINATED));
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof CommitLocalTransactionRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((CommitLocalTransactionRequest) deserialize).getReplyTo());
+        Assert.assertEquals(OBJECT.getModification(), ((CommitLocalTransactionRequest) deserialize).getModification());
+    }
 }
\ No newline at end of file
index b718c61..38a678e 100644 (file)
@@ -20,17 +20,10 @@ public class ConnectClientFailureTest extends AbstractRequestFailureTest<Connect
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() 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/ConnectClientRequestProxyV1Test.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestProxyV1Test.java
deleted file mode 100644 (file)
index 2ebc726..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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;
-import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class ConnectClientRequestProxyV1Test extends AbstractRequestProxyTest<ConnectClientRequestProxyV1> {
-    private static final ConnectClientRequest REQUEST = new ConnectClientRequest(
-            CLIENT_IDENTIFIER, ACTOR_REF, ABIVersion.TEST_PAST_VERSION, ABIVersion.TEST_FUTURE_VERSION);
-    private static final ConnectClientRequestProxyV1 OBJECT = new ConnectClientRequestProxyV1(REQUEST);
-
-    @Override
-    public ConnectClientRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(CLIENT_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index 43f9450..b4da36f 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.base.MoreObjects;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
-import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxy;
 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestTest;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
@@ -36,40 +35,43 @@ public class ConnectClientRequestTest extends AbstractRequestTest<ConnectClientR
     }
 
     @Test
-    public void getMinVersion() throws Exception {
+    public void getMinVersionTest() throws Exception {
         Assert.assertEquals(MIN_VERSION, OBJECT.getMinVersion());
     }
 
     @Test
-    public void getMaxVersion() throws Exception {
+    public void getMaxVersionTest() throws Exception {
         Assert.assertEquals(MAX_VERSION, OBJECT.getMaxVersion());
     }
 
     @Test
-    public void toRequestFailure() throws Exception {
+    public void toRequestFailureTest() throws Exception {
         final RequestException exception = new DeadTransactionException(0);
         final ConnectClientFailure failure = OBJECT.toRequestFailure(exception);
         Assert.assertNotNull(failure);
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> proxy = OBJECT.externalizableProxy(
-                ABIVersion.current());
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ConnectClientRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertNotNull(clone);
         Assert.assertEquals(ABIVersion.BORON, clone.getVersion());
     }
 
     @Test
-    public void addToStringAttributes() throws Exception {
+    public void addToStringAttributesTest() throws Exception {
         final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
         Assert.assertTrue(result.toString().contains("minVersion=" + MIN_VERSION));
         Assert.assertTrue(result.toString().contains("maxVersion=" + MAX_VERSION));
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof ConnectClientRequest);
+        final ConnectClientRequest casted = (ConnectClientRequest) deserialize;
+
+        Assert.assertEquals(OBJECT.getMaxVersion(), casted.getMaxVersion());
+        Assert.assertEquals(OBJECT.getMinVersion(), casted.getMinVersion());
+        Assert.assertEquals(OBJECT.getReplyTo(), casted.getReplyTo());
+    }
 }
\ No newline at end of file
index d80525b..1d6cb26 100644 (file)
@@ -21,7 +21,7 @@ public class ExistsTransactionRequestTest extends AbstractReadTransactionRequest
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
         final ExistsTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
         Assert.assertEquals(cloneVersion, clone.getVersion());
@@ -29,10 +29,10 @@ public class ExistsTransactionRequestTest extends AbstractReadTransactionRequest
         Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
     }
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final ABIVersion proxyVersion = ABIVersion.TEST_FUTURE_VERSION;
-        final ExistsTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(proxyVersion);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof ExistsTransactionRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((ExistsTransactionRequest) deserialize).getReplyTo());
+        Assert.assertEquals(OBJECT.getPath(), ((ExistsTransactionRequest) deserialize).getPath());
     }
 }
\ No newline at end of file
index 027613f..fe823ef 100644 (file)
@@ -18,26 +18,25 @@ public class ExistsTransactionSuccessTest extends AbstractTransactionSuccessTest
     private static final ExistsTransactionSuccess OBJECT = new ExistsTransactionSuccess(
             TRANSACTION_IDENTIFIER, 0, EXISTS);
 
-    @Test
-    public void getExists() throws Exception {
-        final boolean result = OBJECT.getExists();
-        Assert.assertEquals(EXISTS, result);
+    @Override
+    protected ExistsTransactionSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final ExistsTransactionSuccessProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    public void getExistsTest() throws Exception {
+        final boolean result = OBJECT.getExists();
+        Assert.assertEquals(EXISTS, result);
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ExistsTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
 
     @Test
-    public void addToStringAttributes() throws Exception {
+    public void addToStringAttributesTest() throws Exception {
         final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
         Assert.assertTrue(result.toString().contains("exists=" + EXISTS));
     }
index c02ae09..a1da0ec 100644 (file)
@@ -20,14 +20,8 @@ public class LocalHistoryFailureTest extends AbstractRequestFailureTest<LocalHis
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() 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/ModifyTransactionRequestEmptyTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestEmptyTest.java
new file mode 100644 (file)
index 0000000..692c661
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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 com.google.common.base.MoreObjects;
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class ModifyTransactionRequestEmptyTest extends AbstractTransactionRequestTest<ModifyTransactionRequest> {
+    private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT;
+
+    private static final ModifyTransactionRequest OBJECT = new ModifyTransactionRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, Lists.newArrayList(), PROTOCOL);
+
+    @Override
+    protected ModifyTransactionRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void getPersistenceProtocolTest() throws Exception {
+        final Optional<PersistenceProtocol> result = OBJECT.getPersistenceProtocol();
+        Assert.assertTrue(result.isPresent());
+        Assert.assertEquals(PROTOCOL, result.get());
+    }
+
+    @Test
+    public void getModificationsTest() throws Exception {
+        final List<TransactionModification> result = OBJECT.getModifications();
+        Assert.assertNotNull(result);
+        Assert.assertTrue(result.isEmpty());
+    }
+
+    @Test
+    public void addToStringAttributesTest() {
+        final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
+        Assert.assertTrue(result.toString().contains("operations=" + Lists.newArrayList()));
+        Assert.assertTrue(result.toString().contains("protocol=" + PROTOCOL));
+    }
+
+    @Test
+    public void cloneAsVersionTest() throws Exception {
+        final ModifyTransactionRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof ModifyTransactionRequest);
+        final ModifyTransactionRequest casted = (ModifyTransactionRequest) deserialize;
+
+        Assert.assertEquals(OBJECT.getReplyTo(), casted.getReplyTo());
+        Assert.assertEquals(OBJECT.getModifications(), casted.getModifications());
+        Assert.assertEquals(OBJECT.getPersistenceProtocol(), casted.getPersistenceProtocol());
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1EmptyModificationsTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1EmptyModificationsTest.java
deleted file mode 100644 (file)
index 1a85d22..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class ModifyTransactionRequestProxyV1EmptyModificationsTest
-        extends AbstractRequestProxyTest<ModifyTransactionRequestProxyV1> {
-    private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT;
-    private static final ModifyTransactionRequest REQUEST = new ModifyTransactionRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, Lists.newArrayList(), PROTOCOL);
-    private static final ModifyTransactionRequestProxyV1 OBJECT = new ModifyTransactionRequestProxyV1(REQUEST);
-
-    @Override
-    public ModifyTransactionRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1NotEmptyModificationsTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1NotEmptyModificationsTest.java
deleted file mode 100644 (file)
index 8218ea5..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-
-public class ModifyTransactionRequestProxyV1NotEmptyModificationsTest
-        extends AbstractRequestProxyTest<ModifyTransactionRequestProxyV1> {
-    private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT;
-    private static final NormalizedNode<?, ?> NODE = Builders.containerBuilder().withNodeIdentifier(
-            YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build();
-    private static final TransactionModification MODIFICATION = new TransactionWrite(
-            YangInstanceIdentifier.EMPTY, NODE);
-    private static final ModifyTransactionRequest REQUEST = new ModifyTransactionRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, Lists.newArrayList(MODIFICATION), PROTOCOL);
-    private static final ModifyTransactionRequestProxyV1 OBJECT = new ModifyTransactionRequestProxyV1(REQUEST);
-
-    @Override
-    public ModifyTransactionRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index 6fe32bb..35514ea 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
+import static org.opendaylight.controller.cluster.access.commands.TransactionModification.TYPE_WRITE;
+
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.Lists;
 import java.util.List;
@@ -24,8 +26,7 @@ public class ModifyTransactionRequestTest extends AbstractTransactionRequestTest
             YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build();
 
     private static final List<TransactionModification> MODIFICATIONS = Lists.newArrayList(
-            new TransactionWrite(YangInstanceIdentifier.EMPTY, NODE),
-            new TransactionMerge(YangInstanceIdentifier.EMPTY, NODE));
+            new TransactionWrite(YangInstanceIdentifier.EMPTY, NODE));
 
     private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT;
 
@@ -38,7 +39,7 @@ public class ModifyTransactionRequestTest extends AbstractTransactionRequestTest
     }
 
     @Test
-    public void getPersistenceProtocol() throws Exception {
+    public void getPersistenceProtocolTest() throws Exception {
         final Optional<PersistenceProtocol> result = OBJECT.getPersistenceProtocol();
         Assert.assertTrue(result.isPresent());
         Assert.assertEquals(PROTOCOL, result.get());
@@ -58,15 +59,24 @@ public class ModifyTransactionRequestTest extends AbstractTransactionRequestTest
         Assert.assertTrue(result.toString().contains("protocol=" + PROTOCOL));
     }
 
-    @Test
-    public void externalizableProxyTest() throws Exception {
-        final ModifyTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
     @Test
     public void cloneAsVersionTest() throws Exception {
         final ModifyTransactionRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof ModifyTransactionRequest);
+        final ModifyTransactionRequest casted = (ModifyTransactionRequest) deserialize;
+
+        Assert.assertEquals(OBJECT.getReplyTo(), casted.getReplyTo());
+        Assert.assertEquals(OBJECT.getPersistenceProtocol(), casted.getPersistenceProtocol());
+
+        Assert.assertNotNull(casted.getModifications());
+        Assert.assertEquals(1, casted.getModifications().size());
+        final TransactionModification modification = casted.getModifications().get(0);
+        Assert.assertEquals(YangInstanceIdentifier.EMPTY, modification.getPath());
+        Assert.assertEquals(TYPE_WRITE, modification.getType());
+    }
 }
\ No newline at end of file
index 0961493..1f7e3d4 100644 (file)
@@ -15,15 +15,13 @@ public class ModifyTransactionSuccessTest extends AbstractTransactionSuccessTest
     private static final ModifyTransactionSuccess OBJECT = new ModifyTransactionSuccess(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<ModifyTransactionSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected ModifyTransactionSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ModifyTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT.getVersion(), clone.getVersion());
         Assert.assertEquals(OBJECT.getSequence(), clone.getSequence());
index c815887..ab1e1bb 100644 (file)
@@ -21,7 +21,7 @@ public class ReadTransactionRequestTest extends AbstractReadTransactionRequestTe
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
         final ReadTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
         Assert.assertEquals(cloneVersion, clone.getVersion());
@@ -29,10 +29,10 @@ public class ReadTransactionRequestTest extends AbstractReadTransactionRequestTe
         Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
     }
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final ABIVersion proxyVersion = ABIVersion.TEST_FUTURE_VERSION;
-        final ReadTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(proxyVersion);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof ReadTransactionRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((ReadTransactionRequest) deserialize).getReplyTo());
+        Assert.assertEquals(OBJECT.getPath(), ((ReadTransactionRequest) deserialize).getPath());
     }
 }
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessNoDataTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessNoDataTest.java
new file mode 100644 (file)
index 0000000..9e7c796
--- /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 com.google.common.base.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class ReadTransactionSuccessNoDataTest extends AbstractTransactionSuccessTest<ReadTransactionSuccess> {
+    private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
+            TRANSACTION_IDENTIFIER, 0, Optional.absent());
+
+    @Override
+    protected ReadTransactionSuccess object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void getDataTest() throws Exception {
+        final Optional<NormalizedNode<?, ?>> result = OBJECT.getData();
+        Assert.assertFalse(result.isPresent());
+    }
+
+    @Test
+    public void cloneAsVersionTest() throws Exception {
+        final ReadTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
index 55f665a..0f4871f 100644 (file)
@@ -23,22 +23,20 @@ public class ReadTransactionSuccessTest extends AbstractTransactionSuccessTest<R
     private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
             TRANSACTION_IDENTIFIER, 0, Optional.of(NODE));
 
+    @Override
+    protected ReadTransactionSuccess object() {
+        return OBJECT;
+    }
+
     @Test
-    public void getData() throws Exception {
+    public void getDataTest() throws Exception {
         final Optional<NormalizedNode<?, ?>> result = OBJECT.getData();
         Assert.assertTrue(result.isPresent());
         Assert.assertEquals(NODE.getValue(), result.get().getValue());
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<ReadTransactionSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final ReadTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestProxyV1Test.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestProxyV1Test.java
deleted file mode 100644 (file)
index e4c40cc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class TransactionAbortRequestProxyV1Test extends AbstractRequestProxyTest<TransactionAbortRequestProxyV1> {
-    private static final TransactionAbortRequest REQUEST = new TransactionAbortRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-    private static final TransactionAbortRequestProxyV1 OBJECT = new TransactionAbortRequestProxyV1(REQUEST);
-
-    @Override
-    public TransactionAbortRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index 79a2634..1478579 100644 (file)
@@ -21,14 +21,14 @@ public class TransactionAbortRequestTest extends AbstractTransactionRequestTest<
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final TransactionAbortRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionAbortRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof TransactionAbortRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((TransactionAbortRequest)deserialize).getReplyTo());
+    }
 }
\ No newline at end of file
index b86e42c..f7bd108 100644 (file)
@@ -15,15 +15,13 @@ public class TransactionAbortSuccessTest extends AbstractTransactionSuccessTest<
     private static final TransactionAbortSuccess OBJECT = new TransactionAbortSuccess(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<TransactionAbortSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected TransactionAbortSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionAbortSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
index bf2677d..80001e0 100644 (file)
@@ -15,15 +15,13 @@ public class TransactionCanCommitSuccessTest extends AbstractTransactionSuccessT
     private static final TransactionCanCommitSuccess OBJECT = new TransactionCanCommitSuccess(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<TransactionCanCommitSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected TransactionCanCommitSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionCanCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
index 363707f..6d5049c 100644 (file)
@@ -15,15 +15,13 @@ public class TransactionCommitSuccessTest extends AbstractTransactionSuccessTest
     private static final TransactionCommitSuccess OBJECT = new TransactionCommitSuccess(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<TransactionCommitSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected TransactionCommitSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestProxyV1Test.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestProxyV1Test.java
deleted file mode 100644 (file)
index b90438e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class TransactionDoCommitRequestProxyV1Test extends AbstractRequestProxyTest<TransactionDoCommitRequestProxyV1> {
-    private static final TransactionDoCommitRequest REQUEST = new TransactionDoCommitRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-    private static final TransactionDoCommitRequestProxyV1 OBJECT = new TransactionDoCommitRequestProxyV1(REQUEST);
-
-    @Override
-    public TransactionDoCommitRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index a0b6664..9c6b1fb 100644 (file)
@@ -21,14 +21,14 @@ public class TransactionDoCommitRequestTest extends AbstractTransactionRequestTe
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final TransactionDoCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionDoCommitRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof TransactionDoCommitRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((TransactionDoCommitRequest) deserialize).getReplyTo());
+    }
 }
\ No newline at end of file
index ff61651..6adeaae 100644 (file)
@@ -20,14 +20,8 @@ public class TransactionFailureTest extends AbstractRequestFailureTest<Transacti
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() 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
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestProxyV1Test.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestProxyV1Test.java
deleted file mode 100644 (file)
index 693b05d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class TransactionPreCommitRequestProxyV1Test
-        extends AbstractRequestProxyTest<TransactionPreCommitRequestProxyV1> {
-    private static final TransactionPreCommitRequest REQUEST = new TransactionPreCommitRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-    private static final TransactionPreCommitRequestProxyV1 OBJECT = new TransactionPreCommitRequestProxyV1(REQUEST);
-
-    @Override
-    public TransactionPreCommitRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index 5b40e9e..9bc9b68 100644 (file)
@@ -21,14 +21,14 @@ public class TransactionPreCommitRequestTest extends AbstractTransactionRequestT
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final TransactionPreCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionPreCommitRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof TransactionPreCommitRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((TransactionPreCommitRequest) deserialize).getReplyTo());
+    }
 }
\ No newline at end of file
index fc426fc..fbb0faf 100644 (file)
@@ -15,15 +15,13 @@ public class TransactionPreCommitSuccessTest extends AbstractTransactionSuccessT
     private static final TransactionPreCommitSuccess OBJECT = new TransactionPreCommitSuccess(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<TransactionPreCommitSuccess> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected TransactionPreCommitSuccess object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionPreCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestProxyV1Test.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestProxyV1Test.java
deleted file mode 100644 (file)
index c106ad5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.AbstractRequestProxyTest;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-
-public class TransactionPurgeRequestProxyV1Test extends AbstractRequestProxyTest<TransactionPurgeRequestProxyV1> {
-    private static final TransactionPurgeRequest REQUEST = new TransactionPurgeRequest(
-            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-    private static final TransactionPurgeRequestProxyV1 OBJECT = new TransactionPurgeRequestProxyV1(REQUEST);
-
-    @Override
-    public TransactionPurgeRequestProxyV1 object() {
-        return OBJECT;
-    }
-
-    @Test
-    public void createRequestTest() {
-        final Request request = object().createRequest(TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
-        Assert.assertNotNull(request);
-    }
-}
\ No newline at end of file
index a0581d4..22266e2 100644 (file)
@@ -21,14 +21,14 @@ public class TransactionPurgeRequestTest extends AbstractTransactionRequestTest<
     }
 
     @Test
-    public void externalizableProxy() throws Exception {
-        final TransactionPurgeRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
-    }
-
-    @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionPurgeRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
+
+    @Override
+    protected void doAdditionalAssertions(final Object deserialize) {
+        Assert.assertTrue(deserialize instanceof TransactionPurgeRequest);
+        Assert.assertEquals(OBJECT.getReplyTo(), ((TransactionPurgeRequest) deserialize).getReplyTo());
+    }
 }
\ No newline at end of file
index c190e61..4a60a0f 100644 (file)
@@ -15,15 +15,13 @@ public class TransactionPurgeResponseTest extends AbstractTransactionSuccessTest
     private static final TransactionPurgeResponse OBJECT = new TransactionPurgeResponse(
             TRANSACTION_IDENTIFIER, 0);
 
-    @Test
-    public void externalizableProxy() throws Exception {
-        final AbstractTransactionSuccessProxy<TransactionPurgeResponse> proxy = OBJECT.externalizableProxy(
-                ABIVersion.BORON);
-        Assert.assertNotNull(proxy);
+    @Override
+    protected TransactionPurgeResponse object() {
+        return OBJECT;
     }
 
     @Test
-    public void cloneAsVersion() throws Exception {
+    public void cloneAsVersionTest() throws Exception {
         final TransactionPurgeResponse clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
         Assert.assertEquals(OBJECT, clone);
     }
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestProxyTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestProxyTest.java
deleted file mode 100644 (file)
index 3aceaa6..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.concepts;
-
-import akka.actor.ActorRef;
-import akka.actor.ActorSystem;
-import akka.actor.ExtendedActorSystem;
-import akka.serialization.JavaSerializer;
-import akka.testkit.TestProbe;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Constructor;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class AbstractRequestProxyTest<T extends AbstractRequestProxy> {
-    public abstract T object();
-
-    private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
-            MemberName.forName("test"), FrontendType.forName("one"));
-    protected static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
-
-    private static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(
-            CLIENT_IDENTIFIER, 0);
-    protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
-            HISTORY_IDENTIFIER, 0);
-
-    private static final ActorSystem SYSTEM = ActorSystem.create("test");
-    protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
-
-    @Before
-    public void setUp() {
-        JavaSerializer.currentSystem().value_$eq((ExtendedActorSystem) SYSTEM);
-    }
-
-    @Test
-    public void externalizableTest() throws Exception {
-        final T copy = copy();
-        Assert.assertTrue(copy != null);
-    }
-
-    @SuppressWarnings("unchecked")
-    private T copy() throws Exception {
-        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
-            object().writeExternal(oos);
-        }
-
-        try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
-            final Constructor constructor = object().getClass().getConstructor();
-            constructor.setAccessible(true);
-            final T result = (T) constructor.newInstance();
-            result.readExternal(ois);
-            return result;
-        }
-    }
-
-    @Test
-    public void readTargetTest() throws Exception {
-        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
-            object().writeExternal(oos);
-        }
-
-        final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
-        Assert.assertNotNull(object().readTarget(ois));
-    }
-}
\ No newline at end of file
index 6bf0088..2229aff 100644 (file)
@@ -9,9 +9,13 @@ package org.opendaylight.controller.cluster.access.concepts;
 
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
+import akka.actor.ExtendedActorSystem;
+import akka.serialization.JavaSerializer;
 import akka.testkit.TestProbe;
 import com.google.common.base.MoreObjects;
+import org.apache.commons.lang.SerializationUtils;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 public abstract class AbstractRequestTest<T extends Request> {
@@ -20,12 +24,32 @@ public abstract class AbstractRequestTest<T extends Request> {
 
     protected abstract T object();
 
+    @Before
+    public void setUp() {
+        JavaSerializer.currentSystem().value_$eq((ExtendedActorSystem) SYSTEM);
+    }
+
     @Test
-    public void getReplyToTest() {}
+    public void getReplyToTest() {
+        Assert.assertEquals(ACTOR_REF, object().getReplyTo());
+    }
 
     @Test
     public void addToStringAttributesCommonTest() {
         final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object()));
         Assert.assertTrue(result.toString().contains("replyTo=" + ACTOR_REF));
     }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void serializationTest() {
+        final Object deserialize = SerializationUtils.clone(object());
+
+        Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
+        Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
+        Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
+        doAdditionalAssertions((T) deserialize);
+    }
+
+    protected abstract void doAdditionalAssertions(final Object deserialize);
 }