Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always use canonical representation in database and store layout.
- Loading branch information
1 parent
6a29314
commit 9ffe0ca
Showing
9 changed files
with
177 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
community/io/src/test/java/org/neo4j/io/layout/DatabaseLayoutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.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 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.io.layout; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.neo4j.test.extension.Inject; | ||
import org.neo4j.test.extension.TestDirectoryExtension; | ||
import org.neo4j.test.rule.TestDirectory; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@ExtendWith( TestDirectoryExtension.class ) | ||
class DatabaseLayoutTest | ||
{ | ||
@Inject | ||
private TestDirectory testDirectory; | ||
|
||
@Test | ||
void databaseLayoutForAbsoluteFile() | ||
{ | ||
File databaseDir = testDirectory.databaseDir(); | ||
DatabaseLayout databaseLayout = DatabaseLayout.of( databaseDir ); | ||
assertEquals( databaseLayout.databaseDirectory(), databaseDir ); | ||
} | ||
|
||
@Test | ||
void databaseLayoutResolvesLinks() throws IOException | ||
{ | ||
Path basePath = testDirectory.directory().toPath(); | ||
File databaseDir = testDirectory.databaseDir("notAbsolute"); | ||
Path linkPath = basePath.resolve( "link" ); | ||
Path symbolicLink = Files.createSymbolicLink( linkPath, databaseDir.toPath() ); | ||
DatabaseLayout databaseLayout = DatabaseLayout.of( symbolicLink.toFile() ); | ||
assertEquals( databaseLayout.databaseDirectory(), databaseDir ); | ||
} | ||
|
||
@Test | ||
void databaseLayoutUseCanonicalRepresentation() | ||
{ | ||
File storeDir = testDirectory.storeDir( "notCanonical" ); | ||
Path basePath = testDirectory.databaseDir( storeDir ).toPath(); | ||
Path notCanonicalPath = basePath.resolve( "../anotherDatabase" ); | ||
DatabaseLayout databaseLayout = DatabaseLayout.of( notCanonicalPath.toFile() ); | ||
File expectedDirectory = StoreLayout.of( storeDir ).databaseLayout( "anotherDatabase" ).databaseDirectory(); | ||
assertEquals( expectedDirectory, databaseLayout.databaseDirectory() ); | ||
} | ||
|
||
@Test | ||
void databaseLayoutForName() | ||
{ | ||
String databaseName = "testDatabase"; | ||
StoreLayout storeLayout = testDirectory.storeLayout(); | ||
DatabaseLayout testDatabase = DatabaseLayout.of( storeLayout, databaseName ); | ||
assertEquals( new File( storeLayout.storeDirectory(), databaseName ), testDatabase.databaseDirectory() ); | ||
} | ||
|
||
@Test | ||
void databaseLayoutForFolderAndName() | ||
{ | ||
String database = "database"; | ||
DatabaseLayout databaseLayout = DatabaseLayout.of( testDirectory.storeDir(), database ); | ||
assertEquals( testDirectory.databaseLayout( database ).databaseDirectory(), databaseLayout.databaseDirectory() ); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
community/io/src/test/java/org/neo4j/io/layout/StoreLayoutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.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 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.io.layout; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.neo4j.test.extension.Inject; | ||
import org.neo4j.test.extension.TestDirectoryExtension; | ||
import org.neo4j.test.rule.TestDirectory; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@ExtendWith( TestDirectoryExtension.class ) | ||
class StoreLayoutTest | ||
{ | ||
@Inject | ||
private TestDirectory testDirectory; | ||
|
||
@Test | ||
void storeLayoutForAbsoluteFile() | ||
{ | ||
File storeDir = testDirectory.storeDir(); | ||
StoreLayout storeLayout = StoreLayout.of( storeDir ); | ||
assertEquals( storeDir, storeLayout.storeDirectory() ); | ||
} | ||
|
||
@Test | ||
void storeLayoutResolvesLinks() throws IOException | ||
{ | ||
Path basePath = testDirectory.directory().toPath(); | ||
File storeDir = testDirectory.storeDir("notAbsolute"); | ||
Path linkPath = basePath.resolve( "link" ); | ||
Path symbolicLink = Files.createSymbolicLink( linkPath, storeDir.toPath() ); | ||
StoreLayout storeLayout = StoreLayout.of( symbolicLink.toFile() ); | ||
assertEquals( storeDir, storeLayout.storeDirectory() ); | ||
} | ||
|
||
@Test | ||
void storeLayoutUseCanonicalRepresentation() | ||
{ | ||
Path basePath = testDirectory.storeDir("notCanonical").toPath(); | ||
Path notCanonicalPath = basePath.resolve( "../anotherLocation" ); | ||
StoreLayout storeLayout = StoreLayout.of( notCanonicalPath.toFile() ); | ||
assertEquals( testDirectory.directory( "anotherLocation" ), storeLayout.storeDirectory() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters