Search in sources :

Example 66 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project bgpcep by opendaylight.

the class BgpPeerRpcTest method testRouteRefreshRequestSuccessRequest.

@Test
public void testRouteRefreshRequestSuccessRequest() throws InterruptedException, ExecutionException {
    final RouteRefreshRequestInput input = new RouteRefreshRequestInputBuilder().setAfi(Ipv4AddressFamily.class).setSafi(SubsequentAddressFamily.class).setPeerRef(this.peer).build();
    final Future<RpcResult<Void>> result = this.rpc.routeRefreshRequest(input);
    assertTrue(result.get().getErrors().isEmpty());
}
Also used : RouteRefreshRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev171207.RouteRefreshRequestInputBuilder) RouteRefreshRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev171207.RouteRefreshRequestInput) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 67 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project bgpcep by opendaylight.

the class BgpPeerRpcTest method testResetSessionRequestSuccessRequest.

@Test
public void testResetSessionRequestSuccessRequest() throws InterruptedException, ExecutionException {
    Mockito.doReturn(Futures.immediateFuture(null)).when(this.peerRpcs).releaseConnection();
    final ResetSessionInput input = new ResetSessionInputBuilder().setPeerRef(this.peer).build();
    final Future<RpcResult<Void>> result = this.rpc.resetSession(input);
    assertTrue(result.get().getErrors().isEmpty());
}
Also used : ResetSessionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev171207.ResetSessionInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ResetSessionInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev171207.ResetSessionInputBuilder) Test(org.junit.Test)

Example 68 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project bgpcep by opendaylight.

the class Stateful07TopologySessionListenerTest method testOnErrorMessage.

@Test
public void testOnErrorMessage() throws InterruptedException, ExecutionException {
    final Message errorMsg = MsgBuilderUtil.createErrorMsg(PCEPErrors.NON_ZERO_PLSPID, 1L);
    this.listener.onSessionUp(this.session);
    final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
    this.listener.onMessage(this.session, errorMsg);
    final AddLspOutput output = futureOutput.get().getResult();
    assertEquals(FailureType.Failed, output.getFailure());
    assertEquals(1, output.getError().size());
    final ErrorObject err = output.getError().get(0).getErrorObject();
    assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorType(), err.getType().shortValue());
    assertEquals(PCEPErrors.NON_ZERO_PLSPID.getErrorValue(), err.getValue().shortValue());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 69 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project bgpcep by opendaylight.

the class Stateful07TopologySessionListenerTest method testOnSessionDown.

@Test
public void testOnSessionDown() throws InterruptedException, ExecutionException {
    this.listener.onSessionUp(this.session);
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
    assertFalse(this.session.isClosed());
    this.listener.onSessionDown(this.session, new IllegalArgumentException());
    assertTrue(this.session.isClosed());
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 70 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project bgpcep by opendaylight.

the class Stateful07TopologySessionListenerTest method testOnServerSessionManagerUnstarted.

/**
 * Verify the PCEP session should not be up when server session manager is down,
 * otherwise it would be a problem when the session is up while it's not registered with session manager.
 */
@Test
public void testOnServerSessionManagerUnstarted() throws InterruptedException, ExecutionException, TransactionCommitFailedException, ReadFailedException {
    stopSessionManager();
    assertFalse(this.session.isClosed());
    this.listener.onSessionUp(this.session);
    // verify the session was NOT added to topology
    checkNotPresentOperational(getDataBroker(), TOPO_IID);
    // verify the session is closed due to server session manager is closed
    assertTrue(this.session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = this.topologyRpcs.addLsp(createAddLspInput());
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)360 Test (org.junit.Test)120 ExecutionException (java.util.concurrent.ExecutionException)118 ArrayList (java.util.ArrayList)61 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)37 InOrder (org.mockito.InOrder)30 List (java.util.List)29 BigInteger (java.math.BigInteger)26 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)25 FutureCallback (com.google.common.util.concurrent.FutureCallback)24 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)24 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)24 RpcError (org.opendaylight.yangtools.yang.common.RpcError)24 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)22 Future (java.util.concurrent.Future)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)21 Logger (org.slf4j.Logger)21 LoggerFactory (org.slf4j.LoggerFactory)21