/java/

Guava throw exception

2014-05-30 00:14:45

    @Test(expected = NullPointerException.class)
    public void throwNullPointerException() {
        checkNotNull(null);
    }

    @Test(expected = IllegalStateException.class)
    public void throwIllegalStateException() {
        checkState(false);
    }

    @Test(expected = IllegalArgumentException.class)
    public void throwIllegalArgumentException() {
        checkArgument(1 == 2);
    }

<dependency>
<groupid>com.google.guava</groupid>
<artifactid>guava</artifactid>
<version>17.0</version>
</dependency>