mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-15 03:59:38 +02:00
's;^\s+$;;' on all source files
And add checkstyle test for lines containing only whitespace characters.
This commit is contained in:
parent
05c97c494b
commit
0fde39fa45
193 changed files with 1066 additions and 1062 deletions
|
@ -665,5 +665,5 @@ public class InBandBytestreamSessionTest {
|
|||
protocol.verifyAll();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CloseTest {
|
|||
close.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
|
||||
close.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||
close.setStanzaId("us71g45j");
|
||||
|
||||
|
||||
assertXMLEqual(control, close.toXML().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class DataPacketExtensionTest {
|
|||
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }));
|
||||
assertNull(data.getDecodedData());
|
||||
}
|
||||
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
|
|
|
@ -56,7 +56,7 @@ public class DataTest {
|
|||
@Test
|
||||
public void shouldReturnValidIQStanzaXML() throws Exception {
|
||||
String encodedData = Base64.encode("Test");
|
||||
|
||||
|
||||
String control = XMLBuilder.create("iq")
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
|
@ -74,7 +74,7 @@ public class DataTest {
|
|||
data.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
|
||||
data.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||
data.setStanzaId("kr91n475");
|
||||
|
||||
|
||||
assertXMLEqual(control, data.toXML().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class OpenTest {
|
|||
assertEquals(4096, open.getBlockSize());
|
||||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
|
@ -99,9 +99,9 @@ public class OpenTest {
|
|||
open.setFrom(JidCreate.from("romeo@montague.lit/orchard"));
|
||||
open.setTo(JidCreate.from("juliet@capulet.lit/balcony"));
|
||||
open.setStanzaId("jn3h8g65");
|
||||
|
||||
|
||||
assertXMLEqual(control, open.toXML().toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ public class OpenIQProviderTest {
|
|||
.a("sid", "i781hf64")
|
||||
.a("stanza", "iq")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = oip.parse(getParser(control));
|
||||
|
||||
|
||||
assertEquals(StanzaType.IQ, open.getStanza());
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,10 @@ public class OpenIQProviderTest {
|
|||
.a("sid", "i781hf64")
|
||||
.a("stanza", "message")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
OpenIQProvider oip = new OpenIQProvider();
|
||||
Open open = oip.parse(getParser(control));
|
||||
|
||||
|
||||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
GregorianCalendar calendar = new GregorianCalendar(2002, 9 - 1, 10, 23, 8, 25);
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Date date = calendar.getTime();
|
||||
|
||||
|
||||
control = XMLBuilder.create("x")
|
||||
.a("xmlns", "jabber:x:delay")
|
||||
.a("from", "capulet.com")
|
||||
|
@ -70,7 +70,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
delayInfo = (DelayInformation) p.parse(parser);
|
||||
|
||||
|
||||
assertEquals("capulet.com", delayInfo.getFrom());
|
||||
assertEquals(date, delayInfo.getStamp());
|
||||
assertEquals("Offline Storage", delayInfo.getReason());
|
||||
|
@ -101,7 +101,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
DelayInformationProvider p = new DelayInformationProvider();
|
||||
DelayInformation delayInfo;
|
||||
String control;
|
||||
|
||||
|
||||
// XEP-0082 date format
|
||||
control = XMLBuilder.create("delay")
|
||||
.a("xmlns", "urn:xmpp:delay")
|
||||
|
@ -110,7 +110,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.asString(outputProperties);
|
||||
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
|
||||
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
|
||||
cal.add(Calendar.MILLISECOND, 120);
|
||||
assertEquals(cal.getTime(), delayInfo.getStamp());
|
||||
|
@ -132,9 +132,9 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("from", "capulet.com")
|
||||
.a("stamp", "2002-9-10T23:08:25Z")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
}
|
||||
|
||||
|
@ -151,9 +151,9 @@ public class DelayInformationTest extends InitExtensions {
|
|||
.a("from", "capulet.com")
|
||||
.a("stamp", "20020910T23:08:25")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
|
||||
|
||||
assertEquals(calendar.getTime(), delayInfo.getStamp());
|
||||
|
||||
// XEP-0091 date format without leading 0 in month
|
||||
|
@ -165,7 +165,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
}
|
||||
dateInPast.add(Calendar.DAY_OF_MONTH, -3);
|
||||
dateInPast.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
|
||||
control = XMLBuilder.create("x")
|
||||
.a("xmlns", "jabber:x:delay")
|
||||
.a("from", "capulet.com")
|
||||
|
@ -185,7 +185,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
|
||||
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
|
||||
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
|
||||
|
||||
|
||||
assertEquals(controlDate, delayInfo.getStamp());
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ public class DelayInformationTest extends InitExtensions {
|
|||
+ "<delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:41:07Z'/></presence>";
|
||||
|
||||
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
|
||||
|
||||
|
||||
DelayInformation delay = DelayInformationManager.getXep203DelayInformation(presence);
|
||||
assertNotNull(delay);
|
||||
Date date = XmppDateTime.parseDate("2002-09-10T23:41:07Z");
|
||||
|
|
|
@ -44,19 +44,19 @@ public class ForwardedTest {
|
|||
XmlPullParser parser;
|
||||
String control;
|
||||
Forwarded fwd;
|
||||
|
||||
|
||||
control = XMLBuilder.create("forwarded")
|
||||
.a("xmlns", "urn:xmpp:forwarded:0")
|
||||
.e("message")
|
||||
.a("from", "romeo@montague.com")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
fwd = (Forwarded) new ForwardedProvider().parse(parser);
|
||||
|
||||
// no delay in packet
|
||||
assertEquals(null, fwd.getDelayInformation());
|
||||
|
||||
|
||||
// check message
|
||||
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedPacket().getFrom()));
|
||||
|
||||
|
@ -97,11 +97,11 @@ public class ForwardedTest {
|
|||
public void forwardedEmptyTest() throws Exception {
|
||||
XmlPullParser parser;
|
||||
String control;
|
||||
|
||||
|
||||
control = XMLBuilder.create("forwarded")
|
||||
.a("xmlns", "urn:xmpp:forwarded:0")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
new ForwardedProvider().parse(parser);
|
||||
}
|
||||
|
|
|
@ -92,13 +92,13 @@ public class PingTest extends InitExtensions {
|
|||
@Test
|
||||
public void checkSuccessfulPing() throws Exception {
|
||||
ThreadedDummyConnection threadedCon = getAuthentiactedDummyConnection();
|
||||
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(threadedCon);
|
||||
|
||||
boolean pingSuccess = pinger.ping(DUMMY_AT_EXAMPLE_ORG);
|
||||
|
||||
|
||||
assertTrue(pingSuccess);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ public class PingTest extends InitExtensions {
|
|||
}
|
||||
fail();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Server returns an exception for entity.
|
||||
* @throws Exception
|
||||
|
@ -144,17 +144,17 @@ public class PingTest extends InitExtensions {
|
|||
PingManager pinger = PingManager.getInstanceFor(threadedCon);
|
||||
|
||||
boolean pingSuccess = pinger.ping(DUMMY_AT_EXAMPLE_ORG);
|
||||
|
||||
|
||||
assertFalse(pingSuccess);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkPingToServerSuccess() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
||||
boolean pingSuccess = pinger.pingMyServer();
|
||||
|
||||
|
||||
assertTrue(pingSuccess);
|
||||
}
|
||||
|
||||
|
@ -180,10 +180,10 @@ public class PingTest extends InitExtensions {
|
|||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
||||
boolean pingSuccess = pinger.pingMyServer();
|
||||
|
||||
|
||||
assertTrue(pingSuccess);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkPingToServerTimeout() throws SmackException, IOException, XMPPException, InterruptedException {
|
||||
DummyConnection con = getAuthenticatedDummyConnectionWithoutIqReplies();
|
||||
|
@ -198,7 +198,7 @@ public class PingTest extends InitExtensions {
|
|||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.addFeature(Ping.NAMESPACE);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
String reply =
|
||||
"<iq type='result' id='qrzSp-16' to='test@myserver.com'>" +
|
||||
|
@ -211,7 +211,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
|
||||
|
||||
|
||||
assertTrue(pingSupported);
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ public class PingTest extends InitExtensions {
|
|||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.addFeature(Ping.NAMESPACE);
|
||||
|
||||
|
||||
//@formatter:off
|
||||
String reply =
|
||||
"<iq type='result' id='qrzSp-16' to='test@myserver.com'>" +
|
||||
|
@ -233,7 +233,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
|
||||
|
||||
|
||||
assertFalse(pingSupported);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
// @formatter:on
|
||||
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
assertTrue(iqPrivacyList instanceof Privacy);
|
||||
|
||||
|
||||
Privacy privacyList = (Privacy) iqPrivacyList;
|
||||
List<PrivacyItem> pl = privacyList.getPrivacyList("public");
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
assertEquals("tybalt@example.com", first.getValue());
|
||||
assertEquals(false, first.isAllow());
|
||||
assertEquals(1, first.getOrder());
|
||||
|
||||
|
||||
PrivacyItem second = pl.get(1);
|
||||
assertEquals(true, second.isAllow());
|
||||
assertEquals(2, second.getOrder());
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ConfigureFormTest
|
|||
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
|
||||
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException, InterruptedException
|
||||
{
|
||||
|
@ -59,14 +59,14 @@ public class ConfigureFormTest
|
|||
Identity ident = new Identity("pubsub", null, "leaf");
|
||||
info.addIdentity(ident);
|
||||
con.addIQReply(info);
|
||||
|
||||
|
||||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
|
||||
PubSub errorIq = new PubSub();
|
||||
XMPPError error = new XMPPError(Condition.forbidden);
|
||||
errorIq.setError(error);
|
||||
con.addIQReply(errorIq);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
node.getNodeConfiguration();
|
||||
|
@ -86,12 +86,12 @@ public class ConfigureFormTest
|
|||
Identity ident = new Identity("pubsub", null, "leaf");
|
||||
info.addIdentity(ident);
|
||||
con.addIQReply(info);
|
||||
|
||||
|
||||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
|
||||
SmackConfiguration.setDefaultPacketReplyTimeout(100);
|
||||
con.setTimeout();
|
||||
|
||||
|
||||
node.getNodeConfiguration();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,17 +102,17 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"</items>" +
|
||||
"</event>" +
|
||||
"</message>");
|
||||
|
||||
|
||||
Stanza message = PacketParserUtils.parseMessage(parser);
|
||||
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
|
||||
|
||||
|
||||
assertTrue(eventExt instanceof EventElement);
|
||||
EventElement event = (EventElement) eventExt;
|
||||
assertEquals(EventElementType.items, event.getEventType());
|
||||
assertEquals(1, event.getExtensions().size());
|
||||
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
|
||||
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
|
||||
|
||||
|
||||
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
|
||||
assertTrue(itemExt instanceof Item);
|
||||
assertEquals("testid1", ((Item)itemExt).getId());
|
||||
|
@ -122,7 +122,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
public void parseSimplePayloadItem() throws Exception
|
||||
{
|
||||
String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
|
@ -133,7 +133,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"</items>" +
|
||||
"</event>" +
|
||||
"</message>");
|
||||
|
||||
|
||||
Stanza message = PacketParserUtils.parseMessage(parser);
|
||||
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
|
||||
EventElement event = (EventElement) eventExt;
|
||||
|
@ -141,10 +141,10 @@ public class ItemValidationTest extends InitExtensions {
|
|||
|
||||
assertTrue(itemExt instanceof PayloadItem<?>);
|
||||
PayloadItem<?> item = (PayloadItem<?>)itemExt;
|
||||
|
||||
|
||||
assertEquals("testid1", item.getId());
|
||||
assertTrue(item.getPayload() instanceof SimplePayload);
|
||||
|
||||
|
||||
SimplePayload payload = (SimplePayload) item.getPayload();
|
||||
assertEquals("foo", payload.getElementName());
|
||||
assertEquals("smack:test", payload.getNamespace());
|
||||
|
@ -169,7 +169,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"<published>2003-12-13T18:30:02Z</published>" +
|
||||
"<updated>2003-12-13T18:30:02Z</updated>" +
|
||||
"</entry>";
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
|
@ -180,7 +180,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"</items>" +
|
||||
"</event>" +
|
||||
"</message>");
|
||||
|
||||
|
||||
Stanza message = PacketParserUtils.parseMessage(parser);
|
||||
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
|
||||
EventElement event = (EventElement) eventExt;
|
||||
|
@ -188,10 +188,10 @@ public class ItemValidationTest extends InitExtensions {
|
|||
|
||||
assertTrue(itemExt instanceof PayloadItem<?>);
|
||||
PayloadItem<?> item = (PayloadItem<?>)itemExt;
|
||||
|
||||
|
||||
assertEquals("testid1", item.getId());
|
||||
assertTrue(item.getPayload() instanceof SimplePayload);
|
||||
|
||||
|
||||
SimplePayload payload = (SimplePayload) item.getPayload();
|
||||
assertEquals("entry", payload.getElementName());
|
||||
assertEquals("http://www.w3.org/2005/Atom", payload.getNamespace());
|
||||
|
@ -202,7 +202,7 @@ public class ItemValidationTest extends InitExtensions {
|
|||
public void parseEmptyTag() throws Exception
|
||||
{
|
||||
String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(
|
||||
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
|
||||
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
|
||||
|
@ -213,24 +213,24 @@ public class ItemValidationTest extends InitExtensions {
|
|||
"</items>" +
|
||||
"</event>" +
|
||||
"</message>");
|
||||
|
||||
|
||||
Stanza message = PacketParserUtils.parseMessage(parser);
|
||||
ExtensionElement eventExt = message.getExtension(PubSubNamespace.EVENT.getXmlns());
|
||||
|
||||
|
||||
assertTrue(eventExt instanceof EventElement);
|
||||
EventElement event = (EventElement) eventExt;
|
||||
assertEquals(EventElementType.items, event.getEventType());
|
||||
assertEquals(1, event.getExtensions().size());
|
||||
assertTrue(event.getExtensions().get(0) instanceof ItemsExtension);
|
||||
assertEquals(1, ((ItemsExtension)event.getExtensions().get(0)).items.size());
|
||||
|
||||
|
||||
ExtensionElement itemExt = ((ItemsExtension)event.getExtensions().get(0)).items.get(0);
|
||||
assertTrue(itemExt instanceof PayloadItem<?>);
|
||||
PayloadItem<?> item = (PayloadItem<?>)itemExt;
|
||||
|
||||
|
||||
assertEquals("testid1", item.getId());
|
||||
assertTrue(item.getPayload() instanceof SimplePayload);
|
||||
|
||||
|
||||
assertXMLEqual(itemContent, ((SimplePayload)item.getPayload()).toXML().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,13 +50,13 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
public void receiptTest() throws Exception {
|
||||
XmlPullParser parser;
|
||||
String control;
|
||||
|
||||
|
||||
control = XMLBuilder.create("message")
|
||||
.a("from", "romeo@montague.com")
|
||||
.e("request")
|
||||
.a("xmlns", "urn:xmpp:receipts")
|
||||
.asString(outputProperties);
|
||||
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
Message p = PacketParserUtils.parseMessage(parser);
|
||||
|
||||
|
|
|
@ -54,15 +54,15 @@ public class DataFormTest {
|
|||
df.addInstruction(instruction);
|
||||
FormField field = new FormField("testField1");
|
||||
df.addField(field);
|
||||
|
||||
|
||||
assertNotNull( df.toXML());
|
||||
String output = df.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_1, output);
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(output);
|
||||
|
||||
|
||||
df = pr.parse(parser);
|
||||
|
||||
|
||||
assertNotNull(df);
|
||||
assertNotNull(df.getFields());
|
||||
assertEquals(1 , df.getFields().size() );
|
||||
|
@ -81,7 +81,7 @@ public class DataFormTest {
|
|||
df.addInstruction(instruction);
|
||||
FormField field = new FormField("testField1");
|
||||
df.addField(field);
|
||||
|
||||
|
||||
DataLayout layout = new DataLayout("Label");
|
||||
Fieldref reffield = new Fieldref("testField1");
|
||||
layout.getPageLayout().add(reffield);
|
||||
|
@ -89,25 +89,25 @@ public class DataFormTest {
|
|||
section.getSectionLayout().add(new Text("SectionText"));
|
||||
layout.getPageLayout().add(section);
|
||||
layout.getPageLayout().add(new Text("PageText"));
|
||||
|
||||
|
||||
df.addExtensionElement(layout);
|
||||
|
||||
|
||||
|
||||
|
||||
assertNotNull( df.toXML());
|
||||
String output = df.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_2, output);
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(output);
|
||||
|
||||
|
||||
df = pr.parse(parser);
|
||||
|
||||
|
||||
assertNotNull(df);
|
||||
assertNotNull(df.getExtensionElements());
|
||||
assertEquals(1 , df.getExtensionElements().size() );
|
||||
Element element = df.getExtensionElements().get(0);
|
||||
assertNotNull(element);
|
||||
layout = (DataLayout) element;
|
||||
|
||||
|
||||
assertEquals(3 , layout.getPageLayout().size());
|
||||
|
||||
assertNotNull( df.toXML());
|
||||
|
@ -126,22 +126,22 @@ public class DataFormTest {
|
|||
|
||||
ValidateElement dv = new RangeValidateElement("xs:integer","1111", "9999");
|
||||
field.setValidateElement(dv);
|
||||
|
||||
|
||||
assertNotNull( df.toXML());
|
||||
String output = df.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_3, output);
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(output);
|
||||
|
||||
|
||||
df = pr.parse(parser);
|
||||
|
||||
|
||||
assertNotNull(df);
|
||||
assertNotNull(df.getFields());
|
||||
assertEquals(1 , df.getFields().size() );
|
||||
Element element = df.getFields().get(0).getValidateElement();
|
||||
assertNotNull(element);
|
||||
dv = (ValidateElement) element;
|
||||
|
||||
|
||||
assertEquals("xs:integer" , dv.getDatatype());
|
||||
|
||||
assertNotNull( df.toXML());
|
||||
|
|
|
@ -55,15 +55,15 @@ public class DataLayoutTest {
|
|||
section.getSectionLayout().add(new Text("SectionText"));
|
||||
layout.getPageLayout().add(section);
|
||||
layout.getPageLayout().add(new Text( "PageText"));
|
||||
|
||||
|
||||
assertNotNull( layout.toXML());
|
||||
String output = layout.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_2, output);
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(output);
|
||||
|
||||
|
||||
layout = DataLayoutProvider.parse(parser);
|
||||
|
||||
|
||||
assertEquals(3 , layout.getPageLayout().size());
|
||||
assertEquals("Label", layout.getLabel());
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class DataLayoutTest {
|
|||
|
||||
@Test
|
||||
public void testLayoutSpecialCharacters() throws XmlPullParserException, IOException, SmackException {
|
||||
|
||||
|
||||
DataLayout layout = new DataLayout("Label - & \u00E9 \u00E1 ");
|
||||
Fieldref reffield = new Fieldref("testField1");
|
||||
layout.getPageLayout().add(reffield);
|
||||
|
@ -82,22 +82,22 @@ public class DataLayoutTest {
|
|||
section.getSectionLayout().add(new Text( "SectionText - & \u00E9 \u00E1 "));
|
||||
layout.getPageLayout().add(section);
|
||||
layout.getPageLayout().add(new Text( "PageText - & \u00E9 \u00E1 "));
|
||||
|
||||
|
||||
section = new Section("<html>Number of Persons by<br/> Nationality and Status</html>");
|
||||
section.getSectionLayout().add(new Reportedref());
|
||||
layout.getPageLayout().add(section);
|
||||
|
||||
layout.getPageLayout().add(new Text( "<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>"));
|
||||
|
||||
|
||||
|
||||
assertNotNull( layout.toXML());
|
||||
String output = layout.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(output);
|
||||
|
||||
|
||||
layout = DataLayoutProvider.parse(parser);
|
||||
|
||||
|
||||
assertEquals(5 , layout.getPageLayout().size());
|
||||
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
|
||||
section = (Section) layout.getPageLayout().get(1);
|
||||
|
@ -109,7 +109,7 @@ public class DataLayoutTest {
|
|||
text = (Text) layout.getPageLayout().get(4);
|
||||
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
||||
|
||||
|
||||
|
||||
assertNotNull( layout.toXML());
|
||||
output = layout.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||
|
@ -118,17 +118,17 @@ public class DataLayoutTest {
|
|||
@Test
|
||||
public void testLayoutFromFile() throws Exception {
|
||||
DataFormProvider pr = new DataFormProvider();
|
||||
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.newXmppParser();
|
||||
parser.setInput(new InputStreamReader(this.getClass().getResourceAsStream(TEST_INPUT_1), "UTF-8"));
|
||||
parser.next();
|
||||
|
||||
|
||||
DataForm form = pr.parse(parser);
|
||||
assertNotNull( form);
|
||||
assertEquals(1 , form.getExtensionElements().size());
|
||||
|
||||
|
||||
DataLayout layout = (DataLayout) form.getExtensionElements().get(0);
|
||||
|
||||
|
||||
assertEquals(5 , layout.getPageLayout().size());
|
||||
assertEquals("Label - & \u00E9 \u00E1 ", layout.getLabel());
|
||||
Section section = (Section) layout.getPageLayout().get(1);
|
||||
|
@ -140,7 +140,7 @@ public class DataLayoutTest {
|
|||
text = (Text) layout.getPageLayout().get(4);
|
||||
assertEquals("<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>", text.getText());
|
||||
|
||||
|
||||
|
||||
assertNotNull( layout.toXML());
|
||||
String output = layout.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_SPECIAL, output);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class DataValidationHelperTest {
|
|||
catch (ValidationConsistencyException e) {
|
||||
assertEquals("Field type 'jid-single' is not consistent with validation method 'basic'.", e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
new ListRange(-1L, 1L);
|
||||
fail("No correct check on consistency");
|
||||
|
@ -56,7 +56,7 @@ public class DataValidationHelperTest {
|
|||
catch (IllegalArgumentException e) {
|
||||
assertEquals("unsigned 32-bit integers can't be negative", e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
element.setListRange(new ListRange(10L, 100L));
|
||||
try {
|
||||
element.checkConsistency(field);
|
||||
|
|
|
@ -46,21 +46,21 @@ public class DataValidationTest {
|
|||
|
||||
@Test
|
||||
public void testMin() throws XmlPullParserException, IOException, SmackException {
|
||||
|
||||
|
||||
ValidateElement dv = new BasicValidateElement(null);
|
||||
|
||||
|
||||
assertNotNull( dv.toXML());
|
||||
String output = dv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_MIN, output);
|
||||
|
||||
XmlPullParser parser = getParser(TEST_INPUT_MIN);
|
||||
|
||||
|
||||
dv = DataValidationProvider.parse(parser);
|
||||
|
||||
assertNotNull(dv);
|
||||
assertEquals("xs:string", dv.getDatatype());
|
||||
assertTrue( dv instanceof BasicValidateElement);
|
||||
|
||||
|
||||
assertNotNull( dv.toXML());
|
||||
output = dv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_MIN, output);
|
||||
|
@ -68,18 +68,18 @@ public class DataValidationTest {
|
|||
|
||||
@Test
|
||||
public void testRange() throws XmlPullParserException, IOException, SmackException {
|
||||
|
||||
|
||||
ValidateElement dv = new RangeValidateElement("xs:string", "min-val", "max-val");
|
||||
|
||||
|
||||
ListRange listRange = new ListRange(111L, 999L);
|
||||
dv.setListRange(listRange );
|
||||
|
||||
|
||||
assertNotNull( dv.toXML());
|
||||
String output = dv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_RANGE, output);
|
||||
|
||||
XmlPullParser parser = getParser(output);
|
||||
|
||||
|
||||
dv = DataValidationProvider.parse(parser);
|
||||
|
||||
assertNotNull(dv);
|
||||
|
@ -91,8 +91,8 @@ public class DataValidationTest {
|
|||
assertNotNull(rdv.getListRange());
|
||||
assertEquals(new Long(111), rdv.getListRange().getMin());
|
||||
assertEquals(999, rdv.getListRange().getMax().intValue());
|
||||
|
||||
|
||||
|
||||
|
||||
assertNotNull( dv.toXML());
|
||||
output = dv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_RANGE, output);
|
||||
|
@ -100,15 +100,15 @@ public class DataValidationTest {
|
|||
|
||||
@Test
|
||||
public void testRange2() throws XmlPullParserException, IOException, SmackException {
|
||||
|
||||
|
||||
ValidateElement dv = new RangeValidateElement(null, null, null);
|
||||
|
||||
|
||||
assertNotNull( dv.toXML());
|
||||
String output = dv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_RANGE2, output);
|
||||
|
||||
XmlPullParser parser = getParser(output);
|
||||
|
||||
|
||||
dv = DataValidationProvider.parse(parser);
|
||||
|
||||
assertNotNull(dv);
|
||||
|
@ -117,7 +117,7 @@ public class DataValidationTest {
|
|||
RangeValidateElement rdv = (RangeValidateElement) dv;
|
||||
assertEquals(null, rdv.getMin());
|
||||
assertEquals(null, rdv.getMax());
|
||||
|
||||
|
||||
assertNotNull( rdv.toXML());
|
||||
output = rdv.toXML().toString();
|
||||
assertEquals(TEST_OUTPUT_RANGE2, output);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue