Skip to content

Commit

Permalink
Add easily identifiable message to startup log
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed Mar 22, 2017
1 parent 8b715da commit a434926
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Expand Up @@ -50,6 +50,7 @@
import org.neo4j.kernel.impl.util.Dependencies;
import org.neo4j.kernel.impl.util.JobScheduler;
import org.neo4j.kernel.info.DiagnosticsManager;
import org.neo4j.kernel.internal.Version;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider;
Expand Down Expand Up @@ -109,6 +110,7 @@ public abstract class AbstractNeoServer implements NeoServer
Pattern.compile( "/browser.*" ),
Pattern.compile( "/" )
};
public static final String NEO4J_IS_STARTING_MESSAGE = "======== Neo4j " + Version.getNeo4jVersion() + " ========";

private final Database.Factory dbFactory;
private final GraphDatabaseFacadeFactory.Dependencies dependencies;
Expand Down Expand Up @@ -145,6 +147,7 @@ public AbstractNeoServer( Config config, Database.Factory dbFactory,
this.dependencies = dependencies;
this.logProvider = logProvider;
this.log = logProvider.getLog( getClass() );
log.info( NEO4J_IS_STARTING_MESSAGE );

httpAddress = httpConnector( config, HttpConnector.Encryption.NONE )
.orElseThrow( () ->
Expand Down
Expand Up @@ -19,24 +19,26 @@
*/
package org.neo4j.server;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import com.sun.jersey.api.client.Client;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.neo4j.logging.FormattedLogProvider;
import org.neo4j.server.helpers.ServerHelper;
import org.neo4j.server.rest.JaxRsResponse;
import org.neo4j.server.rest.RestRequest;
import org.neo4j.test.server.ExclusiveServerTestBase;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.neo4j.server.AbstractNeoServer.NEO4J_IS_STARTING_MESSAGE;

public class NeoServerStartupLoggingIT extends ExclusiveServerTestBase
{
Expand Down Expand Up @@ -66,8 +68,9 @@ public static void stopServer()
public void shouldLogStartup() throws Exception
{
// Check the logs
assertThat( out.toString().length(), is( greaterThan( 0 ) ) );

String logContent = out.toString();
assertThat( logContent.length(), is( greaterThan( 0 ) ) );
assertThat( logContent, containsString( NEO4J_IS_STARTING_MESSAGE ) );
// Check the server is alive
Client nonRedirectingClient = Client.create();
nonRedirectingClient.setFollowRedirects( false );
Expand Down
Expand Up @@ -48,6 +48,7 @@

import static org.hamcrest.MatcherAssert.assertThat;

import static org.neo4j.server.AbstractNeoServer.NEO4J_IS_STARTING_MESSAGE;
import static org.neo4j.server.configuration.ServerSettings.httpConnector;

public class StartupLoggingIT extends ExclusiveServerTestBase
Expand Down Expand Up @@ -76,6 +77,7 @@ public void shouldLogHelpfulStartupMessages() throws Throwable
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 http://.+:7474/" ),
Expand Down

0 comments on commit a434926

Please sign in to comment.