mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-06 13:11:08 +01:00
Make Objects.requireNonNull() throw IllegalArgumentException
and not NullPointerException. Altough this differs from java.util.Objects behavior, throwing an IllegalArgumentException appears more sensible and makes it easier to catch it in Smack's parsing function.
This commit is contained in:
parent
9bb36fc63c
commit
818ee8a727
5 changed files with 33 additions and 11 deletions
|
|
@ -20,10 +20,11 @@ import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class PresenceTest {
|
||||
|
|
@ -59,9 +60,11 @@ public class PresenceTest {
|
|||
assertXmlSimilar(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
@Test
|
||||
public void setNullPresenceTypeTest() {
|
||||
getNewPresence().setType(null);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
getNewPresence().setType(null)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -112,9 +115,11 @@ public class PresenceTest {
|
|||
assertXmlSimilar(control, presence.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void setIllegalPriorityTest() {
|
||||
getNewPresence().setPriority(Integer.MIN_VALUE);
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
getNewPresence().setPriority(Integer.MIN_VALUE)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue