From: Ivan Hrasko Date: Mon, 6 Mar 2017 15:09:20 +0000 (+0100) Subject: Unit tests for Request derived classes X-Git-Tag: release/carbon~186 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=02d6a79be57c1cc3eefe9424686fae863acea718 Unit tests for Request derived classes Change-Id: I56d98cb89bf0cc474e69a797553aace1d8c2c040 Signed-off-by: Ivan Hrasko --- diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java index ec960c68a3..5d801c67e6 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java @@ -7,9 +7,6 @@ */ package org.opendaylight.controller.cluster.access.commands; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.testkit.TestProbe; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendType; @@ -17,21 +14,18 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -public class AbortLocalTransactionRequestTest extends AbstractTransactionRequestTest { - +public class AbortLocalTransactionRequestTest + extends AbstractLocalTransactionRequestTest { private static final FrontendIdentifier FRONTEND = FrontendIdentifier.create( MemberName.forName("test"), FrontendType.forName("one")); private static final ClientIdentifier CLIENT = ClientIdentifier.create(FRONTEND, 0); private static final LocalHistoryIdentifier HISTORY = new LocalHistoryIdentifier(CLIENT, 0); private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0); - private static final ActorSystem SYSTEM = ActorSystem.create("test"); - private static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref(); - private static final AbortLocalTransactionRequest OBJECT = new AbortLocalTransactionRequest(TRANSACTION, ACTOR_REF); @Override - AbortLocalTransactionRequest object() { + protected AbortLocalTransactionRequest object() { return OBJECT; } } \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java new file mode 100644 index 0000000000..33cba17063 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java @@ -0,0 +1,28 @@ +/* + * 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 abstract class AbstractLocalTransactionRequestTest + extends AbstractTransactionRequestTest { + @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)); + } +} diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java new file mode 100644 index 0000000000..376e13f4b8 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java @@ -0,0 +1,38 @@ +/* + * 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 org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; + +public abstract class AbstractReadTransactionRequestTest + extends AbstractTransactionRequestTest { + protected static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY; + protected static final boolean SNAPSHOT_ONLY = true; + + @Override + protected abstract T object(); + + @Test + public void getPathTest() { + Assert.assertEquals(PATH, object().getPath()); + } + + @Test + public void isSnapshotOnlyTest() { + Assert.assertEquals(SNAPSHOT_ONLY, object().isSnapshotOnly()); + } + + @Test + public void addToStringAttributesTest() { + final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object())); + Assert.assertTrue(result.toString().contains("path=" + PATH)); + } +} diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java index 73ee6d6810..87a0af1c6b 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java @@ -9,18 +9,34 @@ 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.AbstractRequestTest; +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.RuntimeRequestException; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -public abstract class AbstractTransactionRequestTest { - abstract T object(); +public abstract class AbstractTransactionRequestTest + extends AbstractRequestTest { + private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create( + MemberName.forName("test"), FrontendType.forName("one")); + private 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); - @Test(expected = UnsupportedOperationException.class) - public void testExternalizableProxy() { - object().externalizableProxy(ABIVersion.BORON); - } + @Override + protected abstract T object(); @Test - public void cloneAsVersionTest() { - Assert.assertEquals(object(), object().cloneAsVersion(ABIVersion.BORON)); + public void toRequestFailureTest() { + final Throwable cause = new Throwable(); + final RequestException exception = new RuntimeRequestException("fail", cause); + final TransactionFailure failure = object().toRequestFailure(exception); + Assert.assertNotNull(failure); } } diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java index 4675c59e20..209766aac7 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java @@ -7,9 +7,6 @@ */ package org.opendaylight.controller.cluster.access.commands; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.testkit.TestProbe; import com.google.common.base.MoreObjects; import org.junit.Assert; import org.junit.Test; @@ -22,17 +19,14 @@ import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -public class CommitLocalTransactionRequestTest extends AbstractTransactionRequestTest { - +public class CommitLocalTransactionRequestTest + extends AbstractLocalTransactionRequestTest { private static final FrontendIdentifier FRONTEND = FrontendIdentifier.create( MemberName.forName("test"), FrontendType.forName("one")); private static final ClientIdentifier CLIENT = ClientIdentifier.create(FRONTEND, 0); private static final LocalHistoryIdentifier HISTORY = new LocalHistoryIdentifier(CLIENT, 0); private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0); - private static final ActorSystem SYSTEM = ActorSystem.create("test"); - private static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref(); - private static final DataTreeModification MODIFICATION = Mockito.mock(DataTreeModification.class); private static final boolean COORDINATED = Boolean.TRUE; @@ -40,7 +34,7 @@ public class CommitLocalTransactionRequestTest extends AbstractTransactionReques TRANSACTION, 0, ACTOR_REF, MODIFICATION, COORDINATED); @Override - CommitLocalTransactionRequest object() { + protected CommitLocalTransactionRequest object() { return OBJECT; } diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java new file mode 100644 index 0000000000..43f9450e3e --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java @@ -0,0 +1,75 @@ +/* + * 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 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; +import org.opendaylight.controller.cluster.access.concepts.FrontendType; +import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.access.concepts.RequestException; + +public class ConnectClientRequestTest extends AbstractRequestTest { + private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create( + MemberName.forName("member"), FrontendType.forName("frontend")); + private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0); + + private static final ABIVersion MIN_VERSION = ABIVersion.TEST_PAST_VERSION; + private static final ABIVersion MAX_VERSION = ABIVersion.TEST_FUTURE_VERSION; + + private static final ConnectClientRequest OBJECT = new ConnectClientRequest( + CLIENT_IDENTIFIER, 0, ACTOR_REF, MIN_VERSION, MAX_VERSION); + + @Override + protected ConnectClientRequest object() { + return OBJECT; + } + + @Test + public void getMinVersion() throws Exception { + Assert.assertEquals(MIN_VERSION, OBJECT.getMinVersion()); + } + + @Test + public void getMaxVersion() throws Exception { + Assert.assertEquals(MAX_VERSION, OBJECT.getMaxVersion()); + } + + @Test + public void toRequestFailure() 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 proxy = OBJECT.externalizableProxy( + ABIVersion.current()); + Assert.assertNotNull(proxy); + } + + @Test + public void cloneAsVersion() throws Exception { + final ConnectClientRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON); + Assert.assertNotNull(clone); + Assert.assertEquals(ABIVersion.BORON, clone.getVersion()); + } + + @Test + public void addToStringAttributes() 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)); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java new file mode 100644 index 0000000000..d80525bbe0 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java @@ -0,0 +1,38 @@ +/* + * 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 ExistsTransactionRequestTest extends AbstractReadTransactionRequestTest { + private static final ExistsTransactionRequest OBJECT = new ExistsTransactionRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF, PATH, SNAPSHOT_ONLY); + + @Override + protected ExistsTransactionRequest object() { + return OBJECT; + } + + @Test + public void cloneAsVersion() throws Exception { + final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION; + final ExistsTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion); + Assert.assertEquals(cloneVersion, clone.getVersion()); + Assert.assertEquals(OBJECT.getPath(), clone.getPath()); + 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); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java new file mode 100644 index 0000000000..6fe32bb271 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java @@ -0,0 +1,72 @@ +/* + * 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; +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 ModifyTransactionRequestTest extends AbstractTransactionRequestTest { + private static final NormalizedNode NODE = Builders.containerBuilder().withNodeIdentifier( + YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build(); + + private static final List MODIFICATIONS = Lists.newArrayList( + new TransactionWrite(YangInstanceIdentifier.EMPTY, NODE), + new TransactionMerge(YangInstanceIdentifier.EMPTY, NODE)); + + private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT; + + private static final ModifyTransactionRequest OBJECT = new ModifyTransactionRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF, MODIFICATIONS, PROTOCOL); + + @Override + protected ModifyTransactionRequest object() { + return OBJECT; + } + + @Test + public void getPersistenceProtocol() throws Exception { + final Optional result = OBJECT.getPersistenceProtocol(); + Assert.assertTrue(result.isPresent()); + Assert.assertEquals(PROTOCOL, result.get()); + } + + @Test + public void getModificationsTest() throws Exception { + final List result = OBJECT.getModifications(); + Assert.assertNotNull(result); + Assert.assertEquals(MODIFICATIONS, result); + } + + @Test + public void addToStringAttributesTest() { + final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT)); + Assert.assertTrue(result.toString().contains("operations=" + MODIFICATIONS)); + 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); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java new file mode 100644 index 0000000000..c8158878b2 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java @@ -0,0 +1,38 @@ +/* + * 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 ReadTransactionRequestTest extends AbstractReadTransactionRequestTest { + private static final ReadTransactionRequest OBJECT = new ReadTransactionRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF, PATH, SNAPSHOT_ONLY); + + @Override + protected ReadTransactionRequest object() { + return OBJECT; + } + + @Test + public void cloneAsVersion() throws Exception { + final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION; + final ReadTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion); + Assert.assertEquals(cloneVersion, clone.getVersion()); + Assert.assertEquals(OBJECT.getPath(), clone.getPath()); + 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); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java new file mode 100644 index 0000000000..79a2634b4f --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java @@ -0,0 +1,34 @@ +/* + * 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 TransactionAbortRequestTest extends AbstractTransactionRequestTest { + private static final TransactionAbortRequest OBJECT = new TransactionAbortRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF); + + @Override + protected TransactionAbortRequest object() { + return OBJECT; + } + + @Test + public void externalizableProxy() throws Exception { + final TransactionAbortRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON); + Assert.assertNotNull(proxy); + } + + @Test + public void cloneAsVersion() throws Exception { + final TransactionAbortRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON); + Assert.assertEquals(OBJECT, clone); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java new file mode 100644 index 0000000000..a0b6664b81 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java @@ -0,0 +1,34 @@ +/* + * 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 TransactionDoCommitRequestTest extends AbstractTransactionRequestTest { + private static final TransactionDoCommitRequest OBJECT = new TransactionDoCommitRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF); + + @Override + protected TransactionDoCommitRequest object() { + return OBJECT; + } + + @Test + public void externalizableProxy() throws Exception { + final TransactionDoCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON); + Assert.assertNotNull(proxy); + } + + @Test + public void cloneAsVersion() throws Exception { + final TransactionDoCommitRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON); + Assert.assertEquals(OBJECT, clone); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java new file mode 100644 index 0000000000..5b40e9e5da --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java @@ -0,0 +1,34 @@ +/* + * 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 TransactionPreCommitRequestTest extends AbstractTransactionRequestTest { + private static final TransactionPreCommitRequest OBJECT = new TransactionPreCommitRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF); + + @Override + protected TransactionPreCommitRequest object() { + return OBJECT; + } + + @Test + public void externalizableProxy() throws Exception { + final TransactionPreCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON); + Assert.assertNotNull(proxy); + } + + @Test + public void cloneAsVersion() throws Exception { + final TransactionPreCommitRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON); + Assert.assertEquals(OBJECT, clone); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java new file mode 100644 index 0000000000..a0581d4fde --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java @@ -0,0 +1,34 @@ +/* + * 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 TransactionPurgeRequestTest extends AbstractTransactionRequestTest { + private static final TransactionPurgeRequest OBJECT = new TransactionPurgeRequest( + TRANSACTION_IDENTIFIER, 0, ACTOR_REF); + + @Override + protected TransactionPurgeRequest object() { + return OBJECT; + } + + @Test + public void externalizableProxy() throws Exception { + final TransactionPurgeRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON); + Assert.assertNotNull(proxy); + } + + @Test + public void cloneAsVersion() throws Exception { + final TransactionPurgeRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON); + Assert.assertEquals(OBJECT, clone); + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java new file mode 100644 index 0000000000..6bf0088c96 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java @@ -0,0 +1,31 @@ +/* + * 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.testkit.TestProbe; +import com.google.common.base.MoreObjects; +import org.junit.Assert; +import org.junit.Test; + +public abstract class AbstractRequestTest { + private static final ActorSystem SYSTEM = ActorSystem.create("test"); + protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref(); + + protected abstract T object(); + + @Test + public void getReplyToTest() {} + + @Test + public void addToStringAttributesCommonTest() { + final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object())); + Assert.assertTrue(result.toString().contains("replyTo=" + ACTOR_REF)); + } +}