--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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