Skip to content

Commit

Permalink
Dealing with Windows end of line characters in the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwebber committed Jul 7, 2016
1 parent d250ee3 commit 4d38b70
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Expand Up @@ -142,7 +142,7 @@ public void makeSureCoreClusterCanBeRestoredFromABackup() throws Throwable
TestStoreId storeId = TestStoreId.readStoreId( dbPaths.get( 0 ), fs );

// when
StringBuilder output = RestoreClusterUtils.execute( () -> {
String output = RestoreClusterUtils.execute( () -> {
File homeDir = cluster.getCoreServerById( 0 ).homeDir();
RestoreNewClusterCli.main( toArray( args().homeDir( homeDir ).config( homeDir ).from( backupPath )
.database( "graph.db" ).force().build() ) );
Expand Down
Expand Up @@ -91,7 +91,7 @@ public void shouldReplicateTransactionToCoreServers() throws Throwable

File homeDir = cluster.getCoreServerById( 0 ).homeDir();

StringBuilder output = RestoreClusterUtils.execute( () -> RestoreNewClusterCli.main( toArray( args()
String output = RestoreClusterUtils.execute( () -> RestoreNewClusterCli.main( toArray( args()
.homeDir( homeDir ).config( homeDir ).from( classicNeo4jStore )
.database( "graph.db" ).force().build() ) ) );

Expand Down
Expand Up @@ -75,7 +75,7 @@ public void shouldRestoreDatabase() throws Throwable
LinkedList<String> args = ArgsBuilder.args().homeDir( homeDir ).config( homeDir )
.from( classicNeo4jStore ).database( "graph.db" ).build() ;

StringBuilder out = RestoreClusterUtils.execute( () -> RestoreNewClusterCli.main( args.toArray( new String[args.size()] ) ) );
String out = RestoreClusterUtils.execute( () -> RestoreNewClusterCli.main( args.toArray( new String[args.size()] ) ) );

// then
String seed = extractSeed( out );
Expand Down Expand Up @@ -118,9 +118,9 @@ private StoreMetadata metadataFor( File classicNeo4jStore ) throws IOException
}
}

public static String extractSeed( StringBuilder builder )
public static String extractSeed( String message )
{
return builder.toString().replace( "Cluster Seed: ", "" ).replace( "\n", "" );
return message.replace( "Cluster Seed: ", "" ).trim();
}

private File createClassicNeo4jStore( File base, int nodesToCreate, String recordFormat )
Expand Down
Expand Up @@ -25,14 +25,14 @@

public class RestoreClusterUtils
{
public static StringBuilder execute( Runnable function )
public static String execute(Runnable function )
{
StringBuilder builder = new StringBuilder();
PrintStream theRealOut = System.out;
System.setOut( new PrintStream( new MyOutputStream( builder ) ) );
function.run();
System.setOut( theRealOut );
return builder;
return builder.toString();
}

private static class MyOutputStream extends OutputStream
Expand Down

0 comments on commit 4d38b70

Please sign in to comment.