Search code examples
javamtomsun

Alternative to DataSourceStreamingDataHandler for MTOM testing


In a JUnit test I am using the class com.sun.xml.internal.ws.encoding.DataSourceStreamingDataHandler which is bad because it is an internal class and Maven refuses to compile my JUnit tests even with -DskipTests flag.

My JUnit test is:

@Test
public void test(){
    ClassToTest tom = new ClassToTest();
    URL url = this.getClass().getResource("/myXMLFile.xml");
    File file = new File(url.getPath());
    DataSource dataSource = new FileDataSource(file);
    DataHandler dataHandler = new DataSourceStreamingDataHandler(dataSource);
    MyJAXBObject list = tom.methodToTest(dataHandler);
    for( JAXBTransazioneICT t : lista.getListaTransazioniICT() ){
        LOG.debug(t.toString());
    }
}

Is there a good alternative to this class? If not, how can I compile my Maven project?


Solution

  • The alternative I found is org.apache.axiom.attachments.ConfigurableDataHandler from Axiom API.

    The maven dependency is:

    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-api</artifactId>
        <version>1.2.14</version>
    </dependency>