This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
add more check for config file & add test #108
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import java.io.File | |
|
||
import com.vesoft.nebula.exchange.config.{ | ||
Configs, | ||
DataBaseConfigEntry, | ||
FileBaseSourceConfigEntry, | ||
FileDataSourceConfigEntry, | ||
HBaseSourceConfigEntry, | ||
|
@@ -20,9 +21,13 @@ import com.vesoft.nebula.exchange.config.{ | |
SourceCategory | ||
} | ||
import com.vesoft.nebula.exchange.{Argument, KeyPolicy} | ||
import org.apache.log4j.Logger | ||
import org.junit.Test | ||
import org.scalatest.Assertions.assertThrows | ||
|
||
class ConfigsSuite { | ||
private[this] val LOG = Logger.getLogger(this.getClass) | ||
|
||
@Test | ||
def configsSuite(): Unit = { | ||
val args = List("-c", "src/test/resources/application.conf", "-h", "-d") | ||
|
@@ -237,4 +242,54 @@ class ConfigsSuite { | |
} | ||
} | ||
} | ||
|
||
/** | ||
* correct config | ||
*/ | ||
@Test | ||
def dataBaseConfigSuite(): Unit = { | ||
val graphAddress = List("127.0.0.1:9669", "127.0.0.1:9670") | ||
val metaAddress = List("127.0.0.1:9559", "127.0.0.1:9560") | ||
val space = "test" | ||
DataBaseConfigEntry(graphAddress, space, metaAddress) | ||
} | ||
|
||
/** | ||
* empty space | ||
*/ | ||
@Test | ||
def dataBaseConfigEmptySpaceSuite: Unit = { | ||
val graphAddress = List("127.0.0.1:9669", "127.0.0.1:9670") | ||
val metaAddress = List("127.0.0.1:9559", "127.0.0.1:9560") | ||
assertThrows[IllegalArgumentException] { | ||
DataBaseConfigEntry(graphAddress, "", metaAddress) | ||
} | ||
} | ||
|
||
/** | ||
* wrong graph address | ||
*/ | ||
@Test | ||
def dataBaseConfigWrongGraphSuite: Unit = { | ||
val wrongGraphAddress = List("127.0.0.1:9669,127.0.0.1:9670") | ||
val space = "test" | ||
val metaAddress = List("127.0.0.1:9559", "127.0.0.1:9560") | ||
|
||
assertThrows[IllegalArgumentException] { | ||
DataBaseConfigEntry(wrongGraphAddress, space, metaAddress) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use ExpectedException rule in the test method |
||
} | ||
} | ||
|
||
/** | ||
* wrong meta Address | ||
*/ | ||
@Test | ||
def dataBaseConfigWrongMetaSuite: Unit = { | ||
val graphAddress = List("127.0.0.1:9669", "127.0.0.1:9670") | ||
val space = "test" | ||
val wrongMetaAddress = List("127.0.0.1:9559,127.0.0.1:9560") | ||
assertThrows[IllegalArgumentException] { | ||
DataBaseConfigEntry(graphAddress, space, wrongMetaAddress) | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split multi test cases;
add @test(expected = IllegalArgumentException.class)