-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
304 additions
and
262 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
2 changes: 1 addition & 1 deletion
2
sconfig/js/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala.js platform | ||
* [[ConfigDocumentFactory]] methods for Scala.js platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory | ||
extends ConfigDocumentFactoryShared {} |
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
78 changes: 78 additions & 0 deletions
78
sconfig/jvm-native/src/test/scala/org/ekrich/config/impl/ValidationFileTest.scala
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,78 @@ | ||
/** | ||
* Copyright (C) 2011 Typesafe Inc. <http://typesafe.com> | ||
*/ | ||
package org.ekrich.config.impl | ||
|
||
import org.junit._ | ||
|
||
import org.ekrich.config.ConfigFactory | ||
import org.ekrich.config.ConfigParseOptions | ||
import org.ekrich.config.ConfigException | ||
import FileUtils._ | ||
|
||
class ValidationFileTest extends TestUtils { | ||
// TODO: There is a problem upstream where an exception is not thrown | ||
// when the file does not exist. Added a check in FileUtils for native only | ||
// jvm would need it. | ||
@Test | ||
def validation(): Unit = { | ||
val reference = ConfigFactory.parseFile( | ||
resourceFile("validate-reference.conf"), | ||
ConfigParseOptions.defaults | ||
) | ||
val conf = ConfigFactory.parseFile( | ||
resourceFile("validate-invalid.conf"), | ||
ConfigParseOptions.defaults | ||
) | ||
val e = intercept[ConfigException.ValidationFailed] { | ||
conf.checkValid(reference) | ||
} | ||
|
||
val expecteds = Seq( | ||
Missing("willBeMissing", 1, "number"), | ||
WrongType("int3", 7, "number", "object"), | ||
WrongType("float2", 9, "number", "boolean"), | ||
WrongType("float3", 10, "number", "list"), | ||
WrongType("bool1", 11, "boolean", "number"), | ||
WrongType("bool3", 13, "boolean", "object"), | ||
Missing("object1.a", 17, "string"), | ||
WrongType("object2", 18, "object", "list"), | ||
WrongType("object3", 19, "object", "number"), | ||
WrongElementType("array3", 22, "boolean", "object"), | ||
WrongElementType("array4", 23, "object", "number"), | ||
WrongType("array5", 24, "list", "number"), | ||
WrongType("a.b.c.d.e.f.g", 28, "boolean", "number"), | ||
Missing("a.b.c.d.e.f.j", 28, "boolean"), | ||
WrongType("a.b.c.d.e.f.i", 30, "boolean", "list") | ||
) | ||
|
||
checkValidationException(e, expecteds) | ||
} | ||
|
||
@Test | ||
def validationWithRoot(): Unit = { | ||
val objectWithB = parseObject("""{ b : c }""") | ||
val reference = ConfigFactory | ||
.parseFile( | ||
resourceFile("validate-reference.conf"), | ||
ConfigParseOptions.defaults | ||
) | ||
.withFallback(objectWithB) | ||
val conf = ConfigFactory.parseFile( | ||
resourceFile("validate-invalid.conf"), | ||
ConfigParseOptions.defaults | ||
) | ||
val e = intercept[ConfigException.ValidationFailed] { | ||
conf.checkValid(reference, "a", "b") | ||
} | ||
|
||
val expecteds = Seq( | ||
Missing("b", 1, "string"), | ||
WrongType("a.b.c.d.e.f.g", 28, "boolean", "number"), | ||
Missing("a.b.c.d.e.f.j", 28, "boolean"), | ||
WrongType("a.b.c.d.e.f.i", 30, "boolean", "list") | ||
) | ||
|
||
checkValidationException(e, expecteds) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
sconfig/jvm/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala JVM platform | ||
* [[ConfigDocumentFactory]] methods for Scala JVM platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory | ||
extends ConfigDocumentFactoryJvmNative {} |
8 changes: 8 additions & 0 deletions
8
sconfig/jvm/src/test/scala/org/ekrich/config/impl/TestPath.scala
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,8 @@ | ||
package org.ekrich.config.impl | ||
|
||
import java.io.File | ||
|
||
// See: https://github.com/scala-native/scala-native/issues/4077 | ||
object TestPath { | ||
def file(): File = new File("src/test/resources") | ||
} |
24 changes: 24 additions & 0 deletions
24
sconfig/jvm/src/test/scala/org/ekrich/config/impl/ValidationSerializableTest.scala
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,24 @@ | ||
/** | ||
* Copyright (C) 2011 Typesafe Inc. <http://typesafe.com> | ||
*/ | ||
package org.ekrich.config.impl | ||
|
||
import org.junit._ | ||
|
||
import org.ekrich.config.ConfigException | ||
|
||
class ValidationSerializableTest extends TestUtils { | ||
@Test | ||
def validationFailedSerializable(): Unit = { | ||
// Reusing a previous test case to generate an error | ||
val reference = parseConfig("""{ a : [{},{},{}] }""") | ||
val conf = parseConfig("""{ a : 42 }""") | ||
val e = intercept[ConfigException.ValidationFailed] { | ||
conf.checkValid(reference) | ||
} | ||
val expecteds = Seq(WrongType("a", 1, "list", "number")) | ||
|
||
val actual = checkSerializableNoMeaningfulEquals(e) | ||
checkValidationException(actual, expecteds) | ||
} | ||
} |
162 changes: 0 additions & 162 deletions
162
sconfig/jvm/src/test/scala/org/ekrich/config/impl/ValidationTest.scala
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
sconfig/native/src/main/scala/org/ekrich/config/parser/PlatformConfigDocumentFactory.scala
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package org.ekrich.config.parser | ||
|
||
/** | ||
* [[ConfigFactoryDocument]] methods for Scala Native platform | ||
* [[ConfigDocumentFactory]] methods for Scala Native platform | ||
*/ | ||
abstract class PlatformConfigDocumentFactory | ||
extends ConfigDocumentFactoryJvmNative {} |
Oops, something went wrong.