use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.
the class UdpTransportTest method createProducer.
@Override
protected Transport createProducer() throws Exception {
LOG.info("Producer using URI: " + producerURI);
// we are not using the TransportFactory as this assumes that
// UDP transports talk to a server using a WireFormat Negotiation step
// rather than talking directly to each other
OpenWireFormat wireFormat = createWireFormat();
UdpTransport transport = new UdpTransport(wireFormat, new URI(producerURI));
transport.setSequenceGenerator(new IntSequenceGenerator());
return new CommandJoiner(transport, wireFormat);
}
use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.
the class InactivityMonitorTest method testClientHang.
public void testClientHang() throws Exception {
// Manually create a client transport so that it does not send KeepAlive
// packets. this should simulate a client hang.
clientTransport = new TcpTransport(new OpenWireFormat(), SocketFactory.getDefault(), new URI("tcp://localhost:" + serverPort), null);
clientTransport.setTransportListener(new TransportListener() {
@Override
public void onCommand(Object command) {
clientReceiveCount.incrementAndGet();
if (clientRunOnCommand != null) {
clientRunOnCommand.run();
}
}
@Override
public void onException(IOException error) {
if (!ignoreClientError.get()) {
LOG.info("Client transport error:");
error.printStackTrace();
clientErrorCount.incrementAndGet();
}
}
@Override
public void transportInterupted() {
}
@Override
public void transportResumed() {
}
});
clientTransport.start();
WireFormatInfo info = new WireFormatInfo();
info.setVersion(OpenWireFormat.DEFAULT_LEGACY_VERSION);
info.setMaxInactivityDuration(1000);
clientTransport.oneway(info);
assertEquals(0, serverErrorCount.get());
assertEquals(0, clientErrorCount.get());
// Server should consider the client timed out right away since the
// client is not hart beating fast enough.
Thread.sleep(6000);
assertEquals(0, clientErrorCount.get());
assertTrue(serverErrorCount.get() > 0);
}
use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.
the class UnreliableUdpTransportTest method createConsumer.
@Override
protected Transport createConsumer() throws Exception {
LOG.info("Consumer on port: " + consumerPort);
OpenWireFormat wireFormat = createWireFormat();
UdpTransport transport = new UdpTransport(wireFormat, consumerPort);
ReliableTransport reliableTransport = new ReliableTransport(transport, transport);
Replayer replayer = reliableTransport.getReplayer();
reliableTransport.setReplayStrategy(createReplayStrategy(replayer));
ResponseRedirectInterceptor redirectInterceptor = new ResponseRedirectInterceptor(reliableTransport, transport);
return new CommandJoiner(redirectInterceptor, wireFormat);
}
use of org.apache.activemq.openwire.OpenWireFormat in project activemq-artemis by apache.
the class SslTransportFactoryTest method testCompositeConfigure.
public void testCompositeConfigure() throws IOException {
// The 5 options being tested.
int[] optionSettings = new int[5];
String[] optionNames = { "wantClientAuth", "needClientAuth", "socket.wantClientAuth", "socket.needClientAuth", "socket.useClientMode" };
// 3^5 = 243 combos.
for (int i = 0; i < 243; ++i) {
Map<String, String> options = new HashMap<>();
for (int j = 0; j < 5; ++j) {
// -1 since the option range is [-1,1], not [0,2].
optionSettings[j] = getMthNaryDigit(i, j, 3) - 1;
if (optionSettings[j] != -1) {
options.put(optionNames[j], optionSettings[j] == 1 ? "true" : "false");
}
}
StubSSLSocket socketStub = new StubSSLSocket(null);
StubSslTransport transport = null;
try {
transport = new StubSslTransport(null, socketStub);
} catch (Exception e) {
fail("Unable to create StubSslTransport: " + e.getMessage());
}
if (verbose) {
LOG.info("");
LOG.info("Iteration: " + i);
LOG.info("Map settings: " + options);
for (int x = 0; x < optionSettings.length; x++) {
LOG.info("optionSetting[" + x + "] = " + optionSettings[x]);
}
}
factory.compositeConfigure(transport, new OpenWireFormat(), options);
// lets start the transport to force the introspection
try {
transport.start();
} catch (Exception e) {
// ignore bad connection
}
if (socketStub.getWantClientAuthStatus() != optionSettings[2]) {
LOG.info("sheiite");
}
assertEquals("wantClientAuth was not properly set for iteration: " + i, optionSettings[0], transport.getWantClientAuthStatus());
assertEquals("needClientAuth was not properly set for iteration: " + i, optionSettings[1], transport.getNeedClientAuthStatus());
assertEquals("socket.wantClientAuth was not properly set for iteration: " + i, optionSettings[2], socketStub.getWantClientAuthStatus());
assertEquals("socket.needClientAuth was not properly set for iteration: " + i, optionSettings[3], socketStub.getNeedClientAuthStatus());
assertEquals("socket.useClientMode was not properly set for iteration: " + i, optionSettings[4], socketStub.getUseClientModeStatus());
}
}
Aggregations