@Test @SuppressWarnings("unchecked") public void testNotificationRequestWithUnrecognizedSignalPackage() throws MgcpParseException, UnrecognizedMgcpPackageException, UnsupportedMgcpSignalException { final StringBuilder builder = new StringBuilder("RQNT 12345 mobicents/ivr/10@127.0.0.1:2427 MGCP 1.0").append("\n"); builder.append("N:restcomm@10.229.72.130:2727").append("\n"); builder.append("X:10").append("\n"); builder.append("S:AX/pa(an=http: builder.append("R:AX/oc(N),AX/of(N)"); final MgcpMessageParser parser = new MgcpMessageParser(); final NotifiedEntity notifiedEntity = new NotifiedEntity("restcomm", "10.229.72.130", 2727); final MgcpRequest request = parser.parseRequest(builder.toString()); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpEndpoint endpoint = mock(MgcpEndpoint.class); final MediaGroup mediaGroup = mock(MediaGroup.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final RequestNotificationCommand rqnt = new RequestNotificationCommand(request.getTransactionId(), request.getParameters(), endpointManager, packageManager, signalProvider); when(endpointManager.getEndpoint("mobicents/ivr/10@127.0.0.1:2427")).thenReturn(endpoint); when(endpoint.getMediaGroup()).thenReturn(mediaGroup); when(signalProvider.provide(eq("AX"), eq("pa"), eq(16), eq(notifiedEntity), any(Map.class), eq(endpoint))).thenThrow(new UnrecognizedMgcpPackageException("")); MgcpCommandResult result = rqnt.call(); Assert.assertNotNull(result); Assert.assertEquals(MgcpResponseCode.UNKNOWN_PACKAGE.code(), result.getCode()); }
@Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); @Override MgcpCommandResult call(); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); @Override MgcpCommandResult call();  }