package com.googlecode.jslint4java;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.io.IOException;

import org.junit.Test;

public class OptionParserTest {

    /** For generating exceptions. */
    private static class Foo {
        // Invoked via reflection.
        @SuppressWarnings("unused")
        public static Foo valueOf(String s) throws IOException {
            throw new IOException("burble");
        }
    }

    private final OptionParser optionParser = new OptionParser();

    @Test(expected = RuntimeException.class)
    public void testNoSuchMethod() throws Exception {
        optionParser.parse(System.class, "foo");
    }

    @Test
    public void testParseBoolean() throws Exception {
        assertThat(optionParser.parse(Boolean.class, "true"), is(Boolean.TRUE));
    }

    @Test
    public void testParseInteger() throws Exception {
        assertThat(optionParser.parse(Integer.class, "2"), is(2));
    }

    @Test(expected = NumberFormatException.class)
    public void testParseIntegerFailure() throws Exception {
        optionParser.parse(Integer.class, "foo");
    }

    @Test(expected = RuntimeException.class)
    public void testRuntimeExceptionWrapping() throws Exception {
        optionParser.parse(Foo.class, "foo");
    }
}

@@ -154,20 +154,85 @@
 g.junit.
-Test
+Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException
 ;%0A%0Apubli
@@ -602,101 +602,236 @@
    @
-Test(expected = RuntimeException.class)%0A    public void testNoSuchMethod() throws Exception %7B
+Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A    @Test%0A    public void testNoSuchMethod() throws Exception %7B%0A        thrown.expect(RuntimeException.class);%0A        thrown.expectMessage(%22System.valueOf%22);
 %0A   
@@ -1186,48 +1186,8 @@
 Test
-(expected = NumberFormatException.class)
 %0A   
@@ -1236,32 +1236,84 @@
 ows Exception %7B%0A
+        thrown.expect(NumberFormatException.class);%0A
         optionPa
@@ -1366,43 +1366,8 @@
 Test
-(expected = RuntimeException.class)
 %0A   
@@ -1421,32 +1421,132 @@
 ows Exception %7B%0A
+        thrown.expect(RuntimeException.class);%0A        thrown.expectMessage(%22IOException: burble%22);%0A
         optionPa

Use ExpectedException in tests.