mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 22:11:07 +01:00
Replace XPP3 by XmlPullParser interface wrapping StAX and XPP3
Introducing Smack's own XmlPullParser interface which tries to stay as compatible as possible to XPP3. The interface is used to either wrap StAX's XMLStreamReader if Smack is used on Java SE, and XPP3's XmlPullParser if Smack is used on on Android. Fixes SMACK-591. Also introduce JUnit 5 and non-strict javadoc projects.
This commit is contained in:
parent
b3646abecd
commit
4133eb175c
414 changed files with 3855 additions and 2041 deletions
|
|
@ -16,10 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FileTooLargeErrorCreateTest {
|
||||
private static final String fileTooLargeErrorExtensionExample
|
||||
|
|
@ -31,8 +32,8 @@ public class FileTooLargeErrorCreateTest {
|
|||
public void checkFileTooLargeErrorExtensionCreation() {
|
||||
FileTooLargeError fileTooLargeError = new FileTooLargeError(20000);
|
||||
|
||||
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
Assert.assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML().toString());
|
||||
assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML().toString());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class SlotCreateTest {
|
||||
|
|
@ -39,9 +39,9 @@ public class SlotCreateTest {
|
|||
Slot slot = new Slot(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"));
|
||||
|
||||
Assert.assertEquals(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
assertEquals(new URL("https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
slot.getPutUrl());
|
||||
Assert.assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
assertEquals(new URL("https://download.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my_juliet.png"),
|
||||
slot.getGetUrl());
|
||||
|
||||
assertXMLEqual(testSlot, slot.getChildElementXML().toString());
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.SlotRequest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
|
@ -46,9 +47,9 @@ public class SlotRequestCreateTest {
|
|||
public void checkSlotRequestCreation() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 23456, "image/jpeg");
|
||||
|
||||
Assert.assertEquals("my_juliet.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(23456, slotRequest.getSize());
|
||||
Assert.assertEquals("image/jpeg", slotRequest.getContentType());
|
||||
assertEquals("my_juliet.png", slotRequest.getFilename());
|
||||
assertEquals(23456, slotRequest.getSize());
|
||||
assertEquals("image/jpeg", slotRequest.getContentType());
|
||||
|
||||
assertXMLEqual(testRequest, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
|
@ -57,20 +58,22 @@ public class SlotRequestCreateTest {
|
|||
public void checkSlotRequestCreationWithoutContentType() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_romeo.png", 52523);
|
||||
|
||||
Assert.assertEquals("my_romeo.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(52523, slotRequest.getSize());
|
||||
Assert.assertEquals(null, slotRequest.getContentType());
|
||||
assertEquals("my_romeo.png", slotRequest.getFilename());
|
||||
assertEquals(52523, slotRequest.getSize());
|
||||
assertEquals(null, slotRequest.getContentType());
|
||||
|
||||
assertXMLEqual(testRequestWithoutContentType, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void checkSlotRequestCreationNegativeSize() {
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", -23456, "image/jpeg");
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", -23456, "image/jpeg"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void checkSlotRequestCreationZeroSize() {
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 0, "image/jpeg");
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 0, "image/jpeg"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FileTooLargeErrorProviderTest {
|
||||
|
||||
|
|
@ -52,9 +53,9 @@ public class FileTooLargeErrorProviderTest {
|
|||
public void checkSlotErrorFileToLarge() throws Exception {
|
||||
IQ fileTooLargeErrorIQ = PacketParserUtils.parseStanza(slotErrorFileToLarge);
|
||||
|
||||
Assert.assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
|
||||
assertEquals(IQ.Type.error, fileTooLargeErrorIQ.getType());
|
||||
|
||||
FileTooLargeError fileTooLargeError = FileTooLargeError.from(fileTooLargeErrorIQ);
|
||||
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.httpfileupload.element.Slot;
|
||||
import org.jivesoftware.smackx.httpfileupload.element.Slot_V0_2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class SlotProviderTest {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue