mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-07 13:41:08 +01:00
Enable PacketExtensions for IQs
This is actually only part one, i.e. with this commit if the user adds a PacketExtension to an IQ it will be included in IQ.toXml(). Which was previously only the case if the IQ subclass explicitly included packet extensions. The second part of the change is to change the IQ provider, so that packet extensions are automatically parsed. Cases where PacketExtensions are used for Message and IQ are slightly changed. The IQ sublcass now only has a field with this PacketExtension (see for example bytestreams.ibb.packet.DataPacketExtension). Also changed hoxt API: Removed unnecessary indirection and made the API more Smack idiomatic.
This commit is contained in:
parent
a9c798f3bb
commit
9e797c1b17
93 changed files with 1347 additions and 1438 deletions
|
|
@ -57,7 +57,7 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppResp);
|
||||
AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppResp) iq).getResp();
|
||||
HttpOverXmppResp body = ((HttpOverXmppResp) iq);
|
||||
|
||||
checkHeaders(body.getHeaders(), expectedHeaders);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppReq);
|
||||
AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppReq) iq).getReq();
|
||||
HttpOverXmppReq body = ((HttpOverXmppReq) iq);
|
||||
|
||||
checkHeaders(body.getHeaders(), expectedHeaders);
|
||||
}
|
||||
|
|
@ -180,14 +180,14 @@ public class AbstractHttpOverXmppProviderTest {
|
|||
assertEquals(sid, ibbValue.getSid());
|
||||
}
|
||||
|
||||
private AbstractHttpOverXmpp.AbstractBody parseAbstractBody(String string, String tag) throws Exception {
|
||||
// TODO The method name makes no sense after the HOXT re-design, change to parseHttpOverXmppResp()
|
||||
private HttpOverXmppResp parseAbstractBody(String string, String tag) throws Exception {
|
||||
HttpOverXmppRespProvider provider = new HttpOverXmppRespProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(string, tag);
|
||||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppResp);
|
||||
AbstractHttpOverXmpp.AbstractBody body = ((HttpOverXmppResp) iq).getResp();
|
||||
return body;
|
||||
return (HttpOverXmppResp) iq;
|
||||
}
|
||||
|
||||
private void checkHeaders(HeadersExtension headers, Map<String, String> expectedHeaders) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class HttpOverXmppReqProviderTest {
|
|||
@Test
|
||||
public void areAllReqAttributesCorrectlyParsed() throws Exception {
|
||||
String string = "<req xmlns='urn:xmpp:http' method='OPTIONS' resource='*' version='1.1'/>";
|
||||
HttpOverXmppReq.Req req = parseReq(string);
|
||||
HttpOverXmppReq req = parseReq(string);
|
||||
assertEquals(req.getVersion(), "1.1");
|
||||
assertEquals(req.getMethod(), HttpMethod.OPTIONS);
|
||||
assertEquals(req.getResource(), "*");
|
||||
|
|
@ -40,7 +40,7 @@ public class HttpOverXmppReqProviderTest {
|
|||
@Test
|
||||
public void areGetRequestAttributesCorrectlyParsed() throws Exception {
|
||||
String string = "<req xmlns='urn:xmpp:http' method='GET' resource='/rdf/xep' version='1.1'/>";
|
||||
HttpOverXmppReq.Req req = parseReq(string);
|
||||
HttpOverXmppReq req = parseReq(string);
|
||||
assertEquals(req.getVersion(), "1.1");
|
||||
assertEquals(req.getMethod(), HttpMethod.GET);
|
||||
assertEquals(req.getResource(), "/rdf/xep");
|
||||
|
|
@ -49,7 +49,7 @@ public class HttpOverXmppReqProviderTest {
|
|||
@Test
|
||||
public void getReqOptionAttributesCorrectlyParsed() throws Exception {
|
||||
String string = "<req xmlns='urn:xmpp:http' method='OPTIONS' resource='*' version='1.1' maxChunkSize='256' sipub='false' ibb='true' jingle='false'/>";
|
||||
HttpOverXmppReq.Req req = parseReq(string);
|
||||
HttpOverXmppReq req = parseReq(string);
|
||||
assertEquals(req.getMaxChunkSize(), 256);
|
||||
assertEquals(req.isSipub(), false);
|
||||
assertEquals(req.isIbb(), true);
|
||||
|
|
@ -59,18 +59,18 @@ public class HttpOverXmppReqProviderTest {
|
|||
@Test
|
||||
public void getReqOptionalAttributesDefaultValues() throws Exception {
|
||||
String string = "<req xmlns='urn:xmpp:http' method='OPTIONS' resource='*' version='1.1'/>";
|
||||
HttpOverXmppReq.Req req = parseReq(string);
|
||||
HttpOverXmppReq req = parseReq(string);
|
||||
assertEquals(req.isSipub(), true);
|
||||
assertEquals(req.isIbb(), true);
|
||||
assertEquals(req.isJingle(), true);
|
||||
}
|
||||
|
||||
private HttpOverXmppReq.Req parseReq(String string) throws Exception {
|
||||
private HttpOverXmppReq parseReq(String string) throws Exception {
|
||||
HttpOverXmppReqProvider provider = new HttpOverXmppReqProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(string);
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppReq);
|
||||
HttpOverXmppReq castedIq = (HttpOverXmppReq) iq;
|
||||
return castedIq.getReq();
|
||||
return castedIq;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ public class HttpOverXmppRespProviderTest {
|
|||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppResp);
|
||||
HttpOverXmppResp castedIq = (HttpOverXmppResp) iq;
|
||||
HttpOverXmppResp.Resp resp = castedIq.getResp();
|
||||
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
|
||||
|
||||
assertEquals(resp.getVersion(), "1.1");
|
||||
assertEquals(resp.getStatusCode(), 200);
|
||||
|
|
@ -55,8 +54,7 @@ public class HttpOverXmppRespProviderTest {
|
|||
|
||||
IQ iq = provider.parse(parser);
|
||||
assertTrue(iq instanceof HttpOverXmppResp);
|
||||
HttpOverXmppResp castedIq = (HttpOverXmppResp) iq;
|
||||
HttpOverXmppResp.Resp resp = castedIq.getResp();
|
||||
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
|
||||
|
||||
assertEquals(resp.getVersion(), "1.1");
|
||||
assertEquals(resp.getStatusCode(), 200);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue