DefaultTransmissionService extends Traceable implements TransmissionService { @Override public TransmissionResponse send(InputStream inputStream, Tag tag) throws IOException, OxalisTransmissionException, OxalisContentException { Span root = tracer.buildSpan("TransmissionService").start(); try { return send(inputStream, tag, root); } finally { root.finish(); } } @Inject  DefaultTransmissionService(TransmissionRequestFactory transmissionRequestFactory,
                                      Transmitter transmitter, Tracer tracer); @Override TransmissionResponse send(InputStream inputStream, Tag tag); @Override TransmissionResponse send(InputStream inputStream, Tag tag, Span root);  }
@Test public void simple() throws Exception { MockLookupModule.resetService(); TransmissionResponse transmissionResponse = transmissionService.send(getClass().getResourceAsStream("/peppol-bis-invoice-sbdh.xml")); Assert.assertTrue(transmissionResponse instanceof AsdTransmissionResponse); Assert.assertEquals(transmissionResponse.getProtocol(), TransportProfile.of("bdx-transport-asd")); Assert.assertNotNull(transmissionResponse.getHeader()); Assert.assertNotNull(transmissionResponse.getProtocol()); }
@Test(expectedExceptions = OxalisTransmissionException.class, enabled = false) public void simpleTriggerException() throws Exception { Mockito.reset(lookupService); Mockito.when(lookupService.lookup(Mockito.any(Header.class), Mockito.any(Span.class))) .thenThrow(new OxalisTransmissionException("From unit test.")); transmissionService.send(getClass().getResourceAsStream("/ehf-bii05-t10-valid-invoice.xml")); }
@Test(expectedExceptions = SocketTimeoutException.class, enabled = false) public void socketTimeoutException() throws Exception { MockLookupModule.resetService(); TransmissionResponse transmissionResponse = transmissionService.send(getClass().getResourceAsStream("/ehf-bii05-t10-valid-invoice.xml")); Assert.assertTrue(transmissionResponse instanceof AsdTransmissionResponse); Assert.assertEquals(transmissionResponse.getProtocol(), TransportProfile.of("bdx-transport-asd")); Assert.assertNotNull(transmissionResponse.getHeader()); Assert.assertNotNull(transmissionResponse.getProtocol()); }