use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class StartClientIT method shouldNotStartBolt.
@Test
public void shouldNotStartBolt() throws IOException {
// Given
AssertableLogProvider log = new AssertableLogProvider();
// When
new StartClient(System.out, System.err) {
@Override
protected GraphDatabaseShellServer getGraphDatabaseShellServer(File path, boolean readOnly, String configFile) throws RemoteException {
return new GraphDatabaseShellServer(new TestGraphDatabaseFactory().setUserLogProvider(log), path, readOnly, configFile);
}
}.start(new String[] { "-c", "RETURN 1;", "-path", db.getStoreDir(), "-config", getClass().getResource("/config-with-bolt-connector.conf").getFile() }, mock(CtrlCHandler.class));
// Then
log.assertNone(inLog(startsWith(WorkerFactory.class.getPackage().getName())).any());
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ConnectionInfoIT method hzTest.
@Test
public void hzTest() throws Throwable {
// given
testSocket = bindPort("0.0.0.0", 4243);
//when
AssertableLogProvider logProvider = new AssertableLogProvider();
AssertableLogProvider userLogProvider = new AssertableLogProvider();
HazelcastDiscoveryServiceFactory hzFactory = new HazelcastDiscoveryServiceFactory();
Config config = embeddedDefaults(stringMap(discovery_listen_address.name(), ":" + testSocket.getLocalPort(), CausalClusteringSettings.initial_discovery_members.name(), "localhost:" + testSocket.getLocalPort(), new BoltConnector("bolt").enabled.name(), "true", new HttpConnector("http").enabled.name(), "true"));
Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
jobScheduler.init();
CoreTopologyService coreTopologyService = hzFactory.coreTopologyService(config, new MemberId(UUID.randomUUID()), jobScheduler, logProvider, userLogProvider);
try {
coreTopologyService.init();
coreTopologyService.start();
}//then
catch (Throwable throwable) {
//expected
}
logProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
userLogProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ConnectionInfoIT method catchupServerMessage.
@Test
public void catchupServerMessage() throws Throwable {
// given
testSocket = bindPort("localhost", 4242);
// when
AssertableLogProvider logProvider = new AssertableLogProvider();
AssertableLogProvider userLogProvider = new AssertableLogProvider();
CoreState coreState = mock(CoreState.class);
Config config = Config.defaults().with(singletonMap(transaction_listen_address.name(), ":" + testSocket.getLocalPort()));
CatchupServer catchupServer = new CatchupServer(logProvider, userLogProvider, mockSupplier(), mockSupplier(), mockSupplier(), mockSupplier(), mock(BooleanSupplier.class), coreState, config, new Monitors(), mockSupplier(), mock(FileSystemAbstraction.class), mock(PageCache.class), new StoreCopyCheckPointMutex());
//then
try {
catchupServer.start();
} catch (Throwable throwable) {
//expected.
}
logProvider.assertContainsMessageContaining("Address is already bound for setting");
userLogProvider.assertContainsMessageContaining("Address is already bound for setting");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class NeoServerPortConflictIT method shouldComplainIfServerHTTPSPortIsAlreadyTaken.
@Test
public void shouldComplainIfServerHTTPSPortIsAlreadyTaken() throws IOException, InterruptedException {
ListenSocketAddress unContestedAddress = new ListenSocketAddress("localhost", 8888);
ListenSocketAddress contestedAddress = new ListenSocketAddress("localhost", 9999);
try (ServerSocket ignored = new ServerSocket(contestedAddress.getPort(), 0, InetAddress.getByName(contestedAddress.getHostname()))) {
AssertableLogProvider logProvider = new AssertableLogProvider();
CommunityNeoServer server = CommunityServerBuilder.server(logProvider).onAddress(unContestedAddress).onHttpsAddress(contestedAddress).withHttpsEnabled().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
try {
server.start();
fail("Should have reported failure to start");
} catch (ServerStartupException e) {
assertThat(e.getMessage(), containsString("Starting Neo4j failed"));
}
logProvider.assertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", unContestedAddress, format("At least one of the addresses %s or %s is already in use, cannot bind to it.", unContestedAddress, contestedAddress)));
server.stop();
}
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class NeoServerPortConflictIT method shouldComplainIfServerPortIsAlreadyTaken.
@Test
public void shouldComplainIfServerPortIsAlreadyTaken() throws IOException, InterruptedException {
ListenSocketAddress contestedAddress = new ListenSocketAddress("localhost", 9999);
try (ServerSocket ignored = new ServerSocket(contestedAddress.getPort(), 0, InetAddress.getByName(contestedAddress.getHostname()))) {
AssertableLogProvider logProvider = new AssertableLogProvider();
CommunityNeoServer server = CommunityServerBuilder.server(logProvider).onAddress(contestedAddress).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
try {
server.start();
fail("Should have reported failure to start");
} catch (ServerStartupException e) {
assertThat(e.getMessage(), containsString("Starting Neo4j failed"));
}
logProvider.assertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", contestedAddress, format("Address %s is already in use, cannot bind to it.", contestedAddress)));
server.stop();
}
}
Aggregations