[jitsi-dev] [libjitsi-commits] sctp_data_channels: Protects against JVM crash when closed SCTP socket is used by checking for null pointer and throwing IOException. Adds unit tests for SCTP wrapper. (98701f4)


#1

+ @Test
+ public void testNPEinConstructor()
+ {
+ try
+ {
+ new PublicSctpSocket(0, 0);
+
+ fail("No NPE thrown");
+ }
+ catch (NullPointerException e)
+ {
+ // OK
+ }
+ }

Any reason not to write this as follows?

@Test(expected = NullPointerException.class)
public void testNPEinConstructor()
{
  new PublicSctpSocket(0, 0);
}

Ingo


#2

Hi Ingo,

···

On Fri, May 9, 2014 at 2:02 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

+ @Test
+ public void testNPEinConstructor()
+ {
+ try
+ {
+ new PublicSctpSocket(0, 0);
+
+ fail("No NPE thrown");
+ }
+ catch (NullPointerException e)
+ {
+ // OK
+ }
+ }

Any reason not to write this as follows?

@Test(expected = NullPointerException.class)
public void testNPEinConstructor()
{
        new PublicSctpSocket(0, 0);
}

Nope, I've just started playing with JUnit4. Thanks for hint.

Cheers,
Pawel