Created
August 4, 2008 23:19
-
-
Save nkpart/3993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vlc.common.test.util; | |
import au.net.netstorm.boost.nursery.reflect.checker.AssertThrows; | |
import au.net.netstorm.boost.nursery.reflect.checker.DefaultAssertThrows; | |
public final class ExceptionTestChecker { | |
private static final AssertThrows ASSERT_THROWS = new DefaultAssertThrows(); | |
private ExceptionTestChecker() { | |
throw new UnsupportedOperationException(); | |
} | |
public static <T extends Throwable> Throwable expectException(final Class<T> expectedException, final String message, final Runnable block) { | |
return ASSERT_THROWS.assertThrows(expectedException, message, block); | |
} | |
public static <T extends Throwable> Throwable expectException(final Class<T> expectedException, final Runnable block) { | |
return ASSERT_THROWS.assertThrows(expectedException, block); | |
} | |
public static void expectMessageContains(final Throwable t, final String fragment) { | |
ASSERT_THROWS.assertMessageContains(t, fragment); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Specification | |
public void shouldThrowOnInvalidLines() { | |
expectException(VlcRuntimeException.class, "Invalid dimension definition, expected 3 tokens: 200-12", new Runnable() { | |
public void run() { | |
dimensionCreator.apply(invalidLine1); | |
} | |
}); | |
expectException(VlcRuntimeException.class, "Invalid dimension definition, types incorrect: 200-12-A", new Runnable() { | |
public void run() { | |
dimensionCreator.apply(invalidLine2); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment