diff options
6 files changed, 28 insertions, 17 deletions
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java index 09ccb115..6eb27160 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java @@ -94,7 +94,9 @@ public class SLCommandFactory extends SLUnmarshaller { * <code>context</code>. * * @param source - * the <code>Source</code> to unmarshall from + * the <code>StreamSource</code> to unmarshal from + * Note that the StreamSource _must_ contain a Reader set with + * setReader() * @return the <code>SLCommand</code> unmarshalled from the given * <code>source</code> * @throws SLRequestException @@ -113,11 +115,10 @@ public class SLCommandFactory extends SLUnmarshaller { DebugReader dr = null; if (log.isTraceEnabled() && source instanceof StreamSource) { - StreamSource streamSource = (StreamSource) source; - if (streamSource.getReader() != null) { - dr = new DebugReader(streamSource.getReader(), + if (source.getReader() != null) { + dr = new DebugReader(source.getReader(), "SLCommand unmarshalled from:\n"); - streamSource.setReader(dr); + source.setReader(dr); } } diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java index 827661b3..e78cc8a8 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertTrue; import iaik.xml.crypto.XSecProvider; import java.io.InputStream; +import java.io.InputStreamReader; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; @@ -93,7 +94,7 @@ public class CreateXMLSignatureComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/createxmlsignaturerequest/CreateXMLSignatureRequest.xml");
assertNotNull(inputStream);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof CreateXMLSignatureCommand);
SLCommandContext context = new SLCommandContext(stal, urlDereferencer); @@ -106,7 +107,7 @@ public class CreateXMLSignatureComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand);
}
@@ -115,7 +116,7 @@ public class CreateXMLSignatureComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommandImpl); SLCommandContext context = new SLCommandContext(stal, urlDereferencer); diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java index f230a58b..42cf0232 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java @@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.InputStream; +import java.io.InputStreamReader; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; @@ -92,7 +93,7 @@ public class InfoboxReadComandImplTest { SLCommandContext context = new SLCommandContext(stal, urlDereferencer); context.setSTAL(stal);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand);
SLResult result = command.execute(context);
@@ -104,7 +105,7 @@ public class InfoboxReadComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand);
}
@@ -113,7 +114,7 @@ public class InfoboxReadComandImplTest { assertNotNull(inputStream);
SLCommandContext context = new SLCommandContext(stal, urlDereferencer); - SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand); SLResult result = command.execute(context); diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java index 130e2272..9281efcb 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java @@ -31,6 +31,7 @@ import iaik.xml.crypto.XSecProvider; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; @@ -134,7 +135,7 @@ public class SVPersonendatenInfoboxImplTest { assertNotNull(inputStream);
SLCommandContext context = new SLCommandContext(stal, urlDereferencer);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand);
SLResult result = command.execute(context);
@@ -146,7 +147,7 @@ public class SVPersonendatenInfoboxImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand);
}
@@ -156,7 +157,7 @@ public class SVPersonendatenInfoboxImplTest { assertNotNull(inputStream);
SLCommandContext context = new SLCommandContext(stal, urlDereferencer); - SLCommand command = factory.createSLCommand(new StreamSource(inputStream));
+ SLCommand command = factory.createSLCommand(new StreamSource(new InputStreamReader(inputStream)));
assertTrue(command instanceof InfoboxReadCommand); SLResult result = command.execute(context); diff --git a/utils/src/main/java/at/gv/egiz/slbinding/SLUnmarshaller.java b/utils/src/main/java/at/gv/egiz/slbinding/SLUnmarshaller.java index c69fd681..518723d8 100644 --- a/utils/src/main/java/at/gv/egiz/slbinding/SLUnmarshaller.java +++ b/utils/src/main/java/at/gv/egiz/slbinding/SLUnmarshaller.java @@ -228,7 +228,13 @@ public class SLUnmarshaller { this.jaxbContext = createJAXBContext(packageNames); } - public Object unmarshal(StreamSource source) throws XMLStreamException, JAXBException { + /** + * @param source a StreamSource wrapping a Reader (!) for the marshalled Object + * @return the unmarshalled Object + * @throws XMLStreamException + * @throws JAXBException + */ +public Object unmarshal(StreamSource source) throws XMLStreamException, JAXBException { ReportingValidationEventHandler validationEventHandler = new ReportingValidationEventHandler(); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); diff --git a/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java b/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java index 43f2b5a0..99c11cbe 100644 --- a/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java +++ b/utils/src/test/java/at/gv/egiz/slbinding/UnmarshallCXSRTest.java @@ -26,6 +26,7 @@ package at.gv.egiz.slbinding; import java.io.InputStream; +import java.io.InputStreamReader; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; @@ -40,7 +41,7 @@ import static org.junit.Assert.*; public class UnmarshallCXSRTest { @Test - public void testUnmarshallCreateXMLSignatureResponse() throws XMLStreamException, JAXBException { + public void testUnmarshalCreateXMLSignatureResponse() throws XMLStreamException, JAXBException { ClassLoader cl = UnmarshallCXSRTest.class.getClassLoader(); InputStream s = cl.getResourceAsStream("at/gv/egiz/slbinding/CreateXMLSignatureResponse.xml"); @@ -48,7 +49,7 @@ public class UnmarshallCXSRTest { assertNotNull(s); SLUnmarshaller unmarshaller = new SLUnmarshaller(); - Object object = unmarshaller.unmarshal(new StreamSource(s)); + Object object = unmarshaller.unmarshal(new StreamSource(new InputStreamReader(s))); assertTrue(object.getClass().getName(), object instanceof JAXBElement<?>); |