mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
[core] Align behavior of getParserFor(InputStream) and getParserFor(Reader)
Reported-by: Ingo Bauersachs <ingo@jitsi.org>
This commit is contained in:
parent
cad63bc107
commit
11cc2d8d77
3 changed files with 3 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2019 Florian Schmaus.
|
||||
* Copyright 2003-2007 Jive Software, 2019-2021 Florian Schmaus.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -76,9 +76,9 @@ public class PacketParserUtils {
|
|||
return getParserFor(new StringReader(stanza));
|
||||
}
|
||||
|
||||
public static XmlPullParser getParserFor(InputStream inputStream) throws XmlPullParserException {
|
||||
public static XmlPullParser getParserFor(InputStream inputStream) throws XmlPullParserException, IOException {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
return SmackXmlParser.newXmlParser(inputStreamReader);
|
||||
return getParserFor(inputStreamReader);
|
||||
}
|
||||
|
||||
public static XmlPullParser getParserFor(Reader reader) throws XmlPullParserException, IOException {
|
||||
|
|
|
@ -67,7 +67,6 @@ public class AMPExtensionTest {
|
|||
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(INCORRECT_RECEIVING_STANZA_STREAM);
|
||||
|
||||
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
|
||||
ExtensionElement extension = ampProvider.parse(parser);
|
||||
|
@ -85,7 +84,6 @@ public class AMPExtensionTest {
|
|||
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(CORRECT_SENDING_STANZA_STREAM);
|
||||
|
||||
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
|
||||
assertEquals(AMPExtension.ELEMENT, parser.getName());
|
||||
ExtensionElement extension = ampProvider.parse(parser);
|
||||
assertTrue(extension instanceof AMPExtension);
|
||||
|
|
|
@ -39,7 +39,6 @@ public class XHTMLExtensionProviderTest {
|
|||
public void parsesWell() throws IOException, XmlPullParserException {
|
||||
InputStream inputStream = getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME);
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(inputStream);
|
||||
parser.next();
|
||||
|
||||
XHTMLExtensionProvider provider = new XHTMLExtensionProvider();
|
||||
ExtensionElement extension = provider.parse(parser, parser.getDepth(), null);
|
||||
|
|
Loading…
Reference in a new issue