Skip to content

Commit 42fb76c

Browse files
committed
Fix non-prefix agnostic test
- fix test to make prefix agnostic - fix test that was failing because a scala Buffer doesn't automatically convert to a Seq anymore - update nullary method with no side effects to remove paren - fix hard coded scala version in integration tests Deprecation/Compatibility: Note that some changes in 2.13 may affect the order of prefixes with the same namespace and may also cause them to appear uniformly but interchangeably. Ex: `xmlns="urn:bin" xmlns:b="urn:bin" <element/>` may become `xmlns:b="urn:bin" xmlns="urn:bin" <b:element/>` and vice versa. DAFFODIL-2152
1 parent a25aa1e commit 42fb76c

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

daffodil-cli/src/test/scala/org/apache/daffodil/cli/cliTest/Util.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ object Util {
5757
Paths.get(s"daffodil-cli/target/universal/stage/bin/daffodil$ext")
5858
}
5959

60+
val scalaVersionForTargetPath: String = scala.util.Properties.versionNumberString match {
61+
case v if v.startsWith("2.12") => "scala-2.12"
62+
case v if v.startsWith("2.13") => "scala-2.13"
63+
case _ => throw new IllegalStateException("Unsupported version provided for tests")
64+
}
65+
6066
/**
6167
* Convert the parameter to a java Path. The string
6268
* parameter should contain unix path separators and it will be interpreted
@@ -68,7 +74,7 @@ object Util {
6874
Paths.get(string)
6975
}
7076

71-
def devNull(): String = if (isWindows) "NUL" else "/dev/null"
77+
def devNull: String = if (isWindows) "NUL" else "/dev/null"
7278

7379
def md5sum(path: Path): String = {
7480
val md = MessageDigest.getInstance("MD5")

daffodil-tdml-processor/src/test/java/org/apache/daffodil/processor/tdml/TestRunnerFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testPrimaryConstructor() {
5050
false,
5151
NoRoundTrip$.MODULE$,
5252
"off",
53-
CollectionConverters.asScala(Arrays.asList("daffodil", "ibm")),
53+
CollectionConverters.asScala(Arrays.asList("daffodil", "ibm")).toSeq(),
5454
false,
5555
false);
5656
runner.runOneTest("testPass");

daffodil-test-integration/src/test/scala/org/apache/daffodil/cliTest/TestCLIPlugins.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestCLIPlugins {
3232
* specific test
3333
*/
3434
private def testClasspath(extra: String*): Seq[Path] = {
35-
val classes = path("daffodil-test/target/scala-2.12/test-classes/")
35+
val classes = path(s"daffodil-test/target/$scalaVersionForTargetPath/test-classes/")
3636
val paths = extra.map(path(_))
3737
classes +: paths
3838
}
@@ -108,7 +108,7 @@ class TestCLIPlugins {
108108
"daffodil-udf/src/test/resources/org/apache/daffodil/udf/genericUdfSchema.xsd"
109109
)
110110
val classpath = testClasspath(
111-
"daffodil-udf/target/scala-2.12/test-classes/"
111+
s"daffodil-udf/target/$scalaVersionForTargetPath/test-classes/"
112112
)
113113

114114
withTempFile { parser =>

daffodil-test-integration/src/test/scala/org/apache/daffodil/cliTest/TestCLIUdfs.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestCLIUdfs {
3333
* the directory containing the META-INF dir needed for the test.
3434
*/
3535
private def udfClasspath(extra: String*): Seq[Path] = {
36-
val classes = path("daffodil-udf/target/scala-2.12/test-classes/")
36+
val classes = path(s"daffodil-udf/target/$scalaVersionForTargetPath/test-classes/")
3737
val paths = extra.map(path(_))
3838
classes +: paths
3939
}

daffodil-test/src/test/scala/org/apache/daffodil/infoset/TestStringAsXml.scala

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.apache.daffodil.lib.Implicits.intercept
3333
import org.apache.daffodil.lib.api.URISchemaSource
3434
import org.apache.daffodil.lib.api.ValidationMode
3535
import org.apache.daffodil.lib.util.Misc
36+
import org.apache.daffodil.lib.xml.XMLUtils
3637
import org.apache.daffodil.runtime1.api.DFDL.DataProcessor
3738

3839
import org.apache.commons.io.IOUtils
@@ -298,11 +299,12 @@ class TestStringAsXml {
298299
IOUtils.toString(is, StandardCharsets.UTF_8)
299300
}
300301
// diagnostic from full validation
301-
assertTrue(parseDiags.exists(_.contains("Element 'xmlStr' is a simple type")))
302-
// we still get the expected infoset, replace CRLF with LF because of git windows autocrlf
303-
assertEquals(
304-
parseInfosetExpected.replace("\r\n", "\n"),
305-
parseInfosetActual.replace("\r\n", "\n")
302+
assertTrue(parseDiags.exists(_.contains("xmlStr' is a simple type")))
303+
// we still get the expected infoset, use compareAndReport so prefix differences
304+
// don't matter
305+
XMLUtils.compareAndReport(
306+
scala.xml.XML.loadString(parseInfosetExpected),
307+
scala.xml.XML.loadString(parseInfosetActual)
306308
)
307309

308310
// validate the infoset using the handwritten WithPayload schema

0 commit comments

Comments
 (0)