use of org.graylog2.plugin.inputs.util.ConnectionCounter 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.graylog2.plugin.inputs.util.ConnectionCounter 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.graylog2.plugin.inputs.util.ConnectionCounter 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.graylog2.plugin.inputs.util.ConnectionCounter 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.graylog2.plugin.inputs.util.ConnectionCounter in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method setUp.
@Before
public void setUp() {
throughputCounter = new ThroughputCounter(new HashedWheelTimer());
localRegistry = new LocalMetricRegistry();
bossPool = MoreExecutors.directExecutor();
workerPool = MoreExecutors.directExecutor();
connectionCounter = new ConnectionCounter();
}
Aggregations