Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2002-2014 "Neo Technology," Network Engine for Objects in Lund AB [http://neotechnology.com] This file is part of Neo4j. Neo4j is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 package org.neo4j.backup;
 
 import java.io.File;
 import java.util.List;
 
 import org.junit.Test;
 
 
 import static org.junit.Assert.assertEquals;
 import static org.neo4j.helpers.Settings.osIsWindows;
 
 public class BackupEmbeddedIT
 {
     public static final File PATH = TargetDirectory.forTestBackupEmbeddedIT.class ).cleanDirectory"db" );
     public static final File BACKUP_PATH = TargetDirectory.forTestBackupEmbeddedIT.class ).cleanDirectory"backup" +
             "-db" );
 
     private GraphDatabaseService db;
     private String ip;
 
     @Before
     public void before() throws Exception
     {
         if ( osIsWindows() ) return;
         FileUtils.deleteDirectory );
         FileUtils.deleteDirectory  );
          = InetAddress.getLocalHost().getHostAddress();
     }
 
     @SuppressWarnings("deprecation")
     public static DbRepresentation createSomeDataGraphDatabaseService db )
     {
         Transaction tx = db.beginTx();
         Node node = db.createNode();
         node.setProperty"name""Neo" );
         db.createNode().createRelationshipTonode, DynamicRelationshipType.withName"KNOWS" ) );
         tx.success();
         tx.finish();
         return DbRepresentation.ofdb );
     }
 
     @After
     public void after()
     {
         if ( osIsWindows() ) return;
         .shutdown();
     }
 
     @Test
     public void makeSureBackupCanBePerformedWithDefaultPort() throws Exception
     {
         if ( osIsWindows() ) return;
         startDbnull );
         assertEquals(
                 0,
                 runBackupToolFromOtherJvmToGetExitCode"-from",
                         . + "://""-to",
                         .getPath() ) );
         assertEquals( DbRepresentation.of ), DbRepresentation.of ) );
         createSomeData );
         assertEquals(
                 0,
                 runBackupToolFromOtherJvmToGetExitCode"-from". + "://",
                         "-to".getPath() ) );
        assertEquals( DbRepresentation.of ), DbRepresentation.of ) );
    }
    @Test
    {
        if ( osIsWindows() ) return;
        int port = 4445;
        startDb"" + port );
        assertEquals(
                1,
                runBackupToolFromOtherJvmToGetExitCode"-from",
                        . + "://" + "-to",
                        .getPath() ) );
        assertEquals(
                0,
                runBackupToolFromOtherJvmToGetExitCode"-from",
                        . + "://" +":" + port,
                        "-to".getPath() ) );
        assertEquals( DbRepresentation.of ), DbRepresentation.of ) );
        createSomeData );
        assertEquals(
                0,
                runBackupToolFromOtherJvmToGetExitCode"-from". + "://" +":"
                                 + port"-to",
                        .getPath() ) );
        assertEquals( DbRepresentation.of ), DbRepresentation.of ) );
    }
    private void startDbString backupPort )
    {
                .getPath() ).
                setConfig.. );
        if(backupPort != null)
        {
            dbBuild = dbBuild.setConfig. +":" + backupPort );
        }
         = dbBuild.newGraphDatabase();
        createSomeData );
    }
    public static int runBackupToolFromOtherJvmToGetExitCodeString... args )
            throws Exception
    {
        List<StringallArgs = new ArrayList<String>( Arrays.asList"java""-cp", System.getProperty"java.class.path" ), BackupTool.class.getName() ) );
        allArgs.addAll( Arrays.asListargs ) );
        Process process = Runtime.getRuntime().execallArgs.toArraynew String[allArgs.size()] ));
        return new ProcessStreamHandlerprocessfalse ).waitForResult();
    }
New to GrepCode? Check out our FAQ X