@@ -0,0 +1,2858 @@
+/**%0A *%0A * Copyright 2020 Paul Schaub%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.jivesoftware.smackx.nick;%0A%0Aimport static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertThrows;%0A%0Aimport java.io.IOException;%0A%0Aimport org.jivesoftware.smack.parsing.SmackParsingException;%0Aimport org.jivesoftware.smack.test.util.SmackTestUtil;%0Aimport org.jivesoftware.smack.xml.XmlPullParserException;%0Aimport org.jivesoftware.smackx.nick.packet.Nick;%0Aimport org.jivesoftware.smackx.nick.provider.NickProvider;%0A%0Aimport org.junit.Test;%0Aimport org.junit.jupiter.params.ParameterizedTest;%0Aimport org.junit.jupiter.params.provider.EnumSource;%0A%0Apublic class NickTest %7B%0A    /**%0A     * see %3Ca href=%22https://xmpp.org/extensions/xep-0172.html#example-3%22%3EXEP-0172: User Nickname - Example 3%3C/a%3E%0A     */%0A    private static final String XML = %22%3Cnick xmlns='http://jabber.org/protocol/nick'%3EIshmael%3C/nick%3E%22;%0A%0A    @Test%0A    public void disallowEmptyNickTest() %7B%0A        assertThrows(%22Empty String as argument MUST cause IllegalArgumentException.%22,%0A                IllegalArgumentException.class, () -%3E new Nick(%22%22));%0A    %7D%0A%0A    @Test%0A    public void disallowNullNickTest() %7B%0A        assertThrows(%22Null argument MUST cause IllegalArgumentException.%22,%0A                IllegalArgumentException.class, () -%3E new Nick(null));%0A    %7D%0A%0A%0A    @Test%0A    public void serializationTest() %7B%0A        Nick nick = new Nick(%22Ishmael%22);%0A%0A        assertXmlSimilar(XML, nick.toXML());%0A    %7D%0A%0A    @ParameterizedTest%0A    @EnumSource(SmackTestUtil.XmlPullParserKind.class)%0A    public void deserializationTest(SmackTestUtil.XmlPullParserKind parserKind)%0A            throws XmlPullParserException, IOException, SmackParsingException %7B%0A        Nick nick = SmackTestUtil.parse(XML, NickProvider.class, parserKind);%0A%0A        assertNotNull(nick);%0A        assertEquals(%22Ishmael%22, nick.getName());%0A    %7D%0A%0A    @Test%0A    public void nicksAreEscapedTest() %7B%0A        String name = %22%3C/nick%3E%5C%22'&%22;%0A%0A        Nick nick = new Nick(name);%0A%0A        assertXmlSimilar(%22%3Cnick xmlns='http://jabber.org/protocol/nick'%3E%22 +%0A                %22&lt;/nick&gt;&quot;&apos;&amp;%22 +%0A                %22%3C/nick%3E%22, nick.toXML());%0A        assertEquals(name, nick.getName());%0A    %7D%0A%7D%0A

Add Nick JUnit test