* 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.netconf.topology.singleton.impl.tx;
import static org.junit.Assert.assertEquals;
import akka.testkit.TestProbe;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
import java.net.InetSocketAddress;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
import org.opendaylight.netconf.topology.singleton.messages.transactions.PutRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.ReadRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
private static final FiniteDuration EXP_NO_MESSAGE_TIMEOUT = Duration.apply(300, TimeUnit.MILLISECONDS);
private static final RemoteDeviceId DEVICE_ID =
new RemoteDeviceId("dev1", InetSocketAddress.createUnresolved("localhost", 17830));
- private static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
+ private static final YangInstanceIdentifier PATH = YangInstanceIdentifier.empty();
private static final LogicalDatastoreType STORE = LogicalDatastoreType.CONFIGURATION;
private static ActorSystem system = ActorSystem.apply();
@AfterClass
public static void staticTearDown() {
- TestKit.shutdownActorSystem(system, Boolean.TRUE);
+ TestKit.shutdownActorSystem(system, true);
}
private ProxyReadWriteTransaction newSuccessfulProxyTx() {
return newSuccessfulProxyTx(Timeout.apply(5, TimeUnit.SECONDS));
}
- private ProxyReadWriteTransaction newSuccessfulProxyTx(Timeout timeout) {
+ private ProxyReadWriteTransaction newSuccessfulProxyTx(final Timeout timeout) {
return new ProxyReadWriteTransaction(DEVICE_ID, Futures.successful(masterActor.ref()),
system.dispatcher(), timeout);
}
}
}
- private void commit(ProxyReadWriteTransaction tx)
+ private void commit(final ProxyReadWriteTransaction tx)
throws InterruptedException, ExecutionException, TimeoutException {
final ListenableFuture<?> submit = tx.commit();
masterActor.expectMsgClass(SubmitRequest.class);
public void testRead() throws Exception {
ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
- final ListenableFuture<Optional<NormalizedNode<?, ?>>> read = tx.read(STORE, PATH);
+ final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
final ReadRequest readRequest = masterActor.expectMsgClass(ReadRequest.class);
assertEquals(STORE, readRequest.getStore());
assertEquals(PATH, readRequest.getPath());
masterActor.reply(new NormalizedNodeMessage(PATH, node));
- final Optional<NormalizedNode<?, ?>> result = read.get(5, TimeUnit.SECONDS);
+ final Optional<NormalizedNode> result = read.get(5, TimeUnit.SECONDS);
assertTrue(result.isPresent());
assertEquals(node, result.get());
}
public void testReadEmpty() throws Exception {
ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
- final ListenableFuture<Optional<NormalizedNode<?, ?>>> read = tx.read(STORE, PATH);
+ final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
masterActor.expectMsgClass(ReadRequest.class);
masterActor.reply(new EmptyReadResponse());
- final Optional<NormalizedNode<?, ?>> result = read.get(5, TimeUnit.SECONDS);
+ final Optional<NormalizedNode> result = read.get(5, TimeUnit.SECONDS);
assertFalse(result.isPresent());
}
public void testReadFailure() throws InterruptedException, TimeoutException {
ProxyReadWriteTransaction tx = newSuccessfulProxyTx();
- final ListenableFuture<Optional<NormalizedNode<?, ?>>> read = tx.read(STORE, PATH);
+ final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
masterActor.expectMsgClass(ReadRequest.class);
final RuntimeException mockEx = new RuntimeException("fail");
masterActor.reply(new Failure(mockEx));
ProxyReadWriteTransaction tx = new ProxyReadWriteTransaction(DEVICE_ID, promise.future(),
system.dispatcher(), Timeout.apply(5, TimeUnit.SECONDS));
- final ListenableFuture<Optional<NormalizedNode<?, ?>>> read = tx.read(STORE, PATH);
+ final ListenableFuture<Optional<NormalizedNode>> read = tx.read(STORE, PATH);
final ListenableFuture<Boolean> exists = tx.exists(STORE, PATH);
tx.put(STORE, PATH, node);
}
}
- private void verifyDocumentedException(Throwable cause) {
+ private static void verifyDocumentedException(final Throwable cause) {
assertTrue("Unexpected cause " + cause, cause instanceof DocumentedException);
final DocumentedException de = (DocumentedException) cause;
- assertEquals(DocumentedException.ErrorSeverity.WARNING, de.getErrorSeverity());
+ assertEquals(ErrorSeverity.WARNING, de.getErrorSeverity());
assertEquals(DocumentedException.ErrorTag.OPERATION_FAILED, de.getErrorTag());
- assertEquals(DocumentedException.ErrorType.APPLICATION, de.getErrorType());
+ assertEquals(ErrorType.APPLICATION, de.getErrorType());
}
}