private List<String> getStdOut() { List<String> lines = suppress.getOutputVoice().lines(); // Remove empty lines return lines.stream().filter( line -> !line.equals( "" ) ).collect( Collectors.toList() ); }
@Test public void shouldNotThrowNullPointerExceptionIfConfigurationValidationFails() throws Exception { // given ServerBootstrapper serverBootstrapper = new ServerBootstrapper() { @Override protected GraphFactory createGraphFactory( Config config ) { return new CommunityGraphFactory(); } @Override protected NeoServer createNeoServer( GraphFactory graphFactory, Config config, GraphDatabaseDependencies dependencies ) { return mock( NeoServer.class ); } }; File dir = Files.createTempDirectory( "test-server-bootstrapper" ).toFile(); dir.deleteOnExit(); // when serverBootstrapper.start( dir, Optional.empty(), MapUtil.stringMap( database_path.name(), homeDir.absolutePath().getAbsolutePath() ) ); // then no exceptions are thrown and assertThat( suppress.getOutputVoice().lines(), not( empty() ) ); } }
List<String> errorLines = suppressOutput.getErrorVoice().lines(); assertContains( errorLines, "Starting a database on these store files will likely fail or observe inconsistent records" );
@Test public void shouldLogHelpfulStartupMessages() { CommunityBootstrapper boot = new CommunityBootstrapper(); Map<String,String> propertyPairs = getPropertyPairs(); boot.start( testDir.directory(), Optional.of( new File( "nonexistent-file.conf" ) ), propertyPairs ); URI uri = boot.getServer().baseUri(); boot.stop(); List<String> captured = suppressOutput.getOutputVoice().lines(); assertThat( captured, containsAtLeastTheseLines( warn( "Config file \\[nonexistent-file.conf\\] does not exist." ), info( NEO4J_IS_STARTING_MESSAGE ), info( "Starting..." ), info( "Started." ), info( "Remote interface available at " + uri.toString() ), info( "Stopping..." ), info( "Stopped." ) ) ); }