Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd classloader issue in tests with org.apache.xalan code. #922

Closed
kklipsch opened this issue Oct 16, 2013 · 1 comment
Closed

Odd classloader issue in tests with org.apache.xalan code. #922

kklipsch opened this issue Oct 16, 2013 · 1 comment
Labels

Comments

@kklipsch
Copy link

This is an update for #869

In sbt 0.13.0 when using the built in java xslt transformer (javax.xml.transform.TransformerFactory) in a unit test (in this case using scalatest) you will get the following print to output "Warning: The encoding 'UTF-8' is not supported by the Java runtime.". Tracking this down, it appears that internally (in com.sun.org.apache.xml.internal.serializer.Encodings) the java transformer is looking for a properties file as a resource "com/sun/org/apache/xml/internal/serializer/Encodings.properties".

It finds this file correctly if run through a main in sbt but not in a unit test. This problem does not exist in 0.12.0.

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.{StreamResult, StreamSource}
import java.io.{OutputStream, ByteArrayInputStream}
import java.nio.charset.StandardCharsets
import org.scalatest.Suite

class Xalan extends Suite {

    def testResource() {
        val factory = TransformerFactory.newInstance()
        val transformer = factory.newTransformer(xsltSource)

        transformer.transform(xmlSource, new StreamResult(nullOutputStream))
    }

    def xsltSource = stringToSource(xsltString)
    def xmlSource = stringToSource(xmlString)

    def nullOutputStream = new OutputStream {
        def write(b: Int) {}
    }

    private def stringToSource(string: String) =
        new StreamSource(new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8)))

    private val xmlString = "<foo />"
    private val xsltString = "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" />"

}
@eed3si9n eed3si9n added the Bug label Apr 5, 2014
@eed3si9n
Copy link
Member

I am guessing that this is now fixed with sbt/zinc#473. Please let us know if that's not the case.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants