Skip to content

Commit

Permalink
[urldata] Follow-up on initial merge of XEP-0103/0104 support
Browse files Browse the repository at this point in the history
This is a follow-up on 198c513 ("Add initial support for XEP-0103
and XEP-0104: URL Address Information"), which
1. adds the entries to the support XEPs table
2. registers the provider
3. renames the package from url_address_information to urldata (aka.
   the shortname of XEP-0130).
  • Loading branch information
Flowdalic committed Dec 16, 2023
1 parent 8425671 commit 1ad394f
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.element;
package org.jivesoftware.smackx.urldata.element;

import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.element;
package org.jivesoftware.smackx.urldata.element;

import org.jivesoftware.smack.packet.NamedElement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.element;
package org.jivesoftware.smackx.urldata.element;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -25,10 +25,14 @@
import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.url_address_information.http.element.CookieElement;
import org.jivesoftware.smackx.url_address_information.http.element.HeaderElement;
import org.jivesoftware.smackx.url_address_information.http.element.HttpAuthElement;

import org.jivesoftware.smackx.urldata.http.element.CookieElement;
import org.jivesoftware.smackx.urldata.http.element.HeaderElement;
import org.jivesoftware.smackx.urldata.http.element.HttpAuthElement;

/**
* The url-data element.
*/
public class UrlDataElement implements ExtensionElement {

public static final String ELEMENT = "url-data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
*
* @see <a href="https://xmpp.org/extensions/xep-0103.html"> XEP-0103 - URL Address Information</a>.
*/
package org.jivesoftware.smackx.url_address_information.element;
package org.jivesoftware.smackx.urldata.element;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;

import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.EqualsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;

import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.EqualsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;

import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.EqualsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -23,7 +23,8 @@
import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.url_address_information.element.MetaInformationElement;

import org.jivesoftware.smackx.urldata.element.MetaInformationElement;

public final class HttpAuthElement implements MetaInformationElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;

import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.url_address_information.element.MetaInformationElement;

import org.jivesoftware.smackx.urldata.element.MetaInformationElement;

public abstract class NameValuePairElement implements MetaInformationElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
/**
* Element classes for XEP-0104.
*/
package org.jivesoftware.smackx.url_address_information.http.element;
package org.jivesoftware.smackx.urldata.http.element;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
*
* @see <a href="https://xmpp.org/extensions/xep-0104.html"> XEP-0104 - HTTP Scheme for URL Address Information</a>
*/
package org.jivesoftware.smackx.url_address_information.http;
package org.jivesoftware.smackx.urldata.http;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
/**
* Smack's API for <a href="https://xmpp.org/extensions/xep-0103.html"> XEP-0103 - URL Address Information</a>.
*/
package org.jivesoftware.smackx.url_address_information;
package org.jivesoftware.smackx.urldata;
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information.provider;
package org.jivesoftware.smackx.urldata.provider;

import static org.jivesoftware.smackx.url_address_information.element.UrlDataElement.ATTR_SID;
import static org.jivesoftware.smackx.url_address_information.element.UrlDataElement.ATTR_TARGET;
import static org.jivesoftware.smackx.urldata.element.UrlDataElement.ATTR_SID;
import static org.jivesoftware.smackx.urldata.element.UrlDataElement.ATTR_TARGET;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -29,15 +29,15 @@
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.url_address_information.element.UrlDataElement;
import org.jivesoftware.smackx.url_address_information.http.element.AuthParamElement;
import org.jivesoftware.smackx.url_address_information.http.element.CookieElement;
import org.jivesoftware.smackx.url_address_information.http.element.HeaderElement;
import org.jivesoftware.smackx.url_address_information.http.element.HttpAuthElement;

import org.jivesoftware.smackx.urldata.element.UrlDataElement;
import org.jivesoftware.smackx.urldata.http.element.AuthParamElement;
import org.jivesoftware.smackx.urldata.http.element.CookieElement;
import org.jivesoftware.smackx.urldata.http.element.HeaderElement;
import org.jivesoftware.smackx.urldata.http.element.HttpAuthElement;

public class UrlDataElementProvider extends ExtensionElementProvider<UrlDataElement> {

public static UrlDataElementProvider INSTANCE = new UrlDataElementProvider();
@Override
public UrlDataElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
String target = parser.getAttributeValue(ATTR_TARGET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
*
* @see <a href="https://xmpp.org/extensions/xep-0103.html"> XEP-0103 - URL Address Information</a>.
*/
package org.jivesoftware.smackx.url_address_information.provider;
package org.jivesoftware.smackx.urldata.provider;
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@
<className>org.jivesoftware.smackx.si.provider.StreamInitiationProvider</className>
</iqProvider>

<!-- XEP-0103: URL Address Information -->
<extensionProvider>
<elementName>url-data</elementName>
<namespace>http://jabber.org/protocol/url-data</namespace>
<className>org.jivesoftware.smackx.urldata.provider.UrlDataElementProvider</className>
</extensionProvider>

<!-- XEP-0107: User Mood -->
<extensionProvider>
<elementName>mood</elementName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.url_address_information;
package org.jivesoftware.smackx.urldata;

import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -27,16 +27,19 @@
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.url_address_information.element.UrlDataElement;
import org.jivesoftware.smackx.url_address_information.http.element.CookieElement;
import org.jivesoftware.smackx.url_address_information.http.element.HeaderElement;
import org.jivesoftware.smackx.url_address_information.http.element.HttpAuthElement;
import org.jivesoftware.smackx.url_address_information.provider.UrlDataElementProvider;

import org.jivesoftware.smackx.urldata.element.UrlDataElement;
import org.jivesoftware.smackx.urldata.http.element.CookieElement;
import org.jivesoftware.smackx.urldata.http.element.HeaderElement;
import org.jivesoftware.smackx.urldata.http.element.HttpAuthElement;
import org.jivesoftware.smackx.urldata.provider.UrlDataElementProvider;

import org.junit.jupiter.api.Test;

public class UrlDataElementTest extends SmackTestSuite {

public static final UrlDataElementProvider URL_DATA_ELEMENT_PROVIDER = new UrlDataElementProvider();

@Test
public void simpleSerializationTest() throws XmlPullParserException, IOException, SmackParsingException {
UrlDataElement urlDataElement = new UrlDataElement("http://www.jabber.org/members/index.php",
Expand All @@ -52,7 +55,7 @@ public void simpleSerializationTest() throws XmlPullParserException, IOException
"</url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand Down Expand Up @@ -80,7 +83,7 @@ public void additionalAuthParamTest() throws XmlPullParserException, IOException
" </url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand All @@ -93,7 +96,7 @@ public void simpleUrlWithSidTest() throws XmlPullParserException, IOException, S
" target='http://pass.jabber.org:8519/test.txt'/>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand All @@ -106,7 +109,7 @@ public void simpleUrlNoChildrenTest() throws XmlPullParserException, IOException
" target='http://festhall.outer-planes.net/d20M/announce/latest/'/>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand All @@ -126,7 +129,7 @@ public void simpleCookieTest() throws XmlPullParserException, IOException, Smack
"</url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand Down Expand Up @@ -161,7 +164,7 @@ public void additionalParametersCookieTest() throws XmlPullParserException, IOEx
"</url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand All @@ -181,7 +184,7 @@ public void simpleHeaderTest() throws XmlPullParserException, IOException, Smack
" </url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}

Expand Down Expand Up @@ -210,7 +213,7 @@ public void multiChildTest() throws XmlPullParserException, IOException, SmackPa
" </url-data>";
assertXmlSimilar(expectedXml, urlDataElement.toXML().toString());

UrlDataElement parsed = UrlDataElementProvider.INSTANCE.parse(TestUtils.getParser(expectedXml));
UrlDataElement parsed = URL_DATA_ELEMENT_PROVIDER.parse(TestUtils.getParser(expectedXml));
assertEquals(urlDataElement, parsed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@
* <td>Transfer files between two users over XMPP.</td>
* </tr>
* <tr>
* <td>URL Address Information</td>
* <td><a href="https://xmpp.org/extensions/xep-0103.html">XEP-0103</a></td>
* <td>{@link org.jivesoftware.smackx.urldata.element}</td>
* <td>Provide information about an Uniform Resource Locator (URL), and a protocol signaling retrieval states.</td>
* </tr>
* <tr>
* <td>HTTP Scheme for URL Data</td>
* <td><a href="https://xmpp.orf/extensions/xep-0104.html">XEP-0104</a></td>
* <td></td>
* <td>A schema description for detailed information about HTTP URLs.</td>
* </tr>
* <tr>
* <td>User Mood</td>
* <td><a href="https://xmpp.org/extensions/xep-0107.html">XEP-0107</a></td>
* <td></td>
Expand Down

0 comments on commit 1ad394f

Please sign in to comment.