use of org.jboss.netty.channel.ChannelHandler in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirDoesNotExist.
@Test
public void getBaseChannelHandlersFailsIfTempDirDoesNotExist() throws IOException {
final File tmpDir = temporaryFolder.newFolder();
assumeTrue(tmpDir.delete());
System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {
@Override
protected Bootstrap getBootstrap() {
return super.getBootstrap();
}
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
return super.getBaseChannelHandlers(input);
}
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
transport.getBaseChannelHandlers(input);
}
use of org.jboss.netty.channel.ChannelHandler in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirIsNotWritable.
@Test
public void getBaseChannelHandlersFailsIfTempDirIsNotWritable() throws IOException {
final File tmpDir = temporaryFolder.newFolder();
assumeTrue(tmpDir.setWritable(false));
assumeFalse(tmpDir.canWrite());
System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {
@Override
protected Bootstrap getBootstrap() {
return super.getBootstrap();
}
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
return super.getBaseChannelHandlers(input);
}
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
transport.getBaseChannelHandlers(input);
}
use of org.jboss.netty.channel.ChannelHandler in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getBaseChannelHandlersGeneratesSelfSignedCertificates.
@Test
public void getBaseChannelHandlersGeneratesSelfSignedCertificates() {
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {
@Override
protected Bootstrap getBootstrap() {
return super.getBootstrap();
}
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
return super.getBaseChannelHandlers(input);
}
};
final MessageInput input = mock(MessageInput.class);
assertThat(transport.getBaseChannelHandlers(input)).containsKey("tls");
}
use of org.jboss.netty.channel.ChannelHandler in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getBaseChannelHandlersFailsIfTempDirIsNoDirectory.
@Test
public void getBaseChannelHandlersFailsIfTempDirIsNoDirectory() throws IOException {
final File file = temporaryFolder.newFile();
assumeTrue(file.isFile());
System.setProperty("java.io.tmpdir", file.getAbsolutePath());
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, bossPool, workerPool, connectionCounter) {
@Override
protected Bootstrap getBootstrap() {
return super.getBootstrap();
}
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getBaseChannelHandlers(MessageInput input) {
return super.getBaseChannelHandlers(input);
}
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Couldn't write to temporary directory: " + file.getAbsolutePath());
transport.getBaseChannelHandlers(input);
}
use of org.jboss.netty.channel.ChannelHandler in project camel by apache.
the class MultipleCodecsTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
// START SNIPPET: registry-beans
ChannelHandlerFactory lengthDecoder = ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
StringDecoder stringDecoder = new StringDecoder();
registry.bind("length-decoder", lengthDecoder);
registry.bind("string-decoder", stringDecoder);
LengthFieldPrepender lengthEncoder = new LengthFieldPrepender(4);
StringEncoder stringEncoder = new StringEncoder();
registry.bind("length-encoder", lengthEncoder);
registry.bind("string-encoder", stringEncoder);
List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
decoders.add(lengthDecoder);
decoders.add(stringDecoder);
List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
encoders.add(lengthEncoder);
encoders.add(stringEncoder);
registry.bind("encoders", encoders);
registry.bind("decoders", decoders);
// END SNIPPET: registry-beans
return registry;
}
Aggregations