Package net.sourceforge.purrpackage.recording

Examples of net.sourceforge.purrpackage.recording.MockCoberturaManager


        assertEquals( "zoo00", trans.makeUnique( "zoo", x ));
    }
   
    @Test
    public void testThings() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> stClass = loadInstrumentedClass( "jcr.SampleTest" );
        Object st = stClass.newInstance();
        Method m = stClass.getMethod( "testMarked" );
        m.invoke( st );
        List<String> expected = new ArrayList<String>();
        expected.add( "jcr" );
        assertEquals( expected, cm.getMessages(), "compare " + expected + " v. " + cm.getMessages() );
        m = stClass.getMethod( "methodNotMarked" );
        m.invoke( st );
        assertEquals( expected, cm.getMessages() );

        m = stClass.getMethod( "methodMarkedNestedException" );
        try {
            m.invoke( st );
            fail();
        }
        catch( InvocationTargetException e ) {
            assertEquals( "as requested", e.getTargetException().getMessage() );
        }
        expected.add( "jcr" );
        assertEquals( expected, cm.getMessages() );
        m = stClass.getMethod( "methodMarked", String.class, Boolean.TYPE);
        String result = (String) m.invoke( st, "historic", false );
        assertEquals( "prehistoric", result );
        expected.add( "jcr" );
        assertEquals( expected, cm.getMessages() );
        try {
            m.invoke( st, "notmatter", true );
            fail();
        }
        catch( InvocationTargetException e ) {
            assertEquals( "as requested", e.getTargetException().getMessage() );           
        }
        expected.add( "jcr" );
        assertEquals( expected, cm.getMessages() );
       
        m = stClass.getMethod( "testTooSimple" );
        m.invoke( st );
        expected.add( "jcr" );
        assertEquals( expected, cm.getMessages() );
    }
View Full Code Here


        assertEquals( expected, cm.getMessages() );
    }

    @Test
    public void testTestCaseSubclassInstrumentation() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> stClass = loadInstrumentedClass("jcr.OldStyleSampleTest");
        Object st = stClass.newInstance();
        Method m = stClass.getMethod("setUp");
        m.invoke(st);
        List<String> expected = new ArrayList<String>();
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());
    }
View Full Code Here

        assertEquals(expected, cm.getMessages());
    }
   
    @Test
    public void testThrowCatchBug() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> stClass = loadInstrumentedClass("jcr.ThrowCatchBugTest");
        Object st = stClass.newInstance();
        Method m = stClass.getMethod( "catchBug", Double.TYPE );
        try {
            m.invoke( st, 4.1 );
        }
        catch( Exception e ) {
            e.printStackTrace();
        }
        List<String> expected = new ArrayList<String>();
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());      

        m = stClass.getMethod( "testIncrement");
        m.invoke( st );
        expected.add( "jcr" );       
        assertEquals(expected, cm.getMessages());      

        m = stClass.getMethod( "testArraysBad" );
        m.invoke( st );
        expected.add( "jcr" );
        assertEquals(expected, cm.getMessages());          

        m = stClass.getMethod( "testArraysGood" );
        m.invoke( st );
        expected.add( "jcr" );
        assertEquals(expected, cm.getMessages());          

        m = stClass.getMethod( "testLongConsts" );
        m.invoke( st );
        expected.add( "jcr" );
        assertEquals(expected, cm.getMessages());          
    }
View Full Code Here

        assertEquals(expected, cm.getMessages());          
    }
   
    @Test
    public void testTestNGClassAnnotationInstrumentation() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> testngClass = loadInstrumentedClass("jcr.TestNGClassTest");
        Object st = testngClass.newInstance();
        Method m = testngClass.getMethod("publicMethod");
        m.invoke(st);
        List<String> expected = new ArrayList<String>();
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());
    }
View Full Code Here

            return true;
        }
    }
    @Test
    public void testSelectorIssues() throws Exception {
       MockCoberturaManager cm = new MockCoberturaManager();
       cm.replaceCoberturaManagerSingleton();
       try {
            new StaticAroundAdviceTransformer( "zoot", this );
            fail();
        }
        catch( Exception e ) {
View Full Code Here

        assertTrue( new TrivialSelector().shouldVisit( null, null ));
    }

    @Test
    public void testGroovyBug() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> stClass = loadInstrumentedClass("jcr.GroovySample");
        List<String> expected = new ArrayList<String>();
        assertEquals( expected,  cm.getMessages() );
        Method m = stClass.getMethod("staticInstrumentedMethod", Closure.class);
        try {
            m.invoke(stClass, (Closure<?>) null);
            fail();
        } catch (InvocationTargetException e) {
          assertEquals( e.getCause().getMessage(), "too nullish" );
//          e.printStackTrace();
        }
        // Expect that it was recorded despite the exception.
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());

        Object st = stClass.newInstance();
        m = stClass.getMethod("instrumentedMethod", String.class);
        m.invoke(st, "asdflkjas");
        // again, expect it was recorded ok.
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());
    }
View Full Code Here

        assertEquals(expected, cm.getMessages());
    }
   
    @Test
    public void testStaticStackBug() throws Exception {
        MockCoberturaManager cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();
        Class<?> stClass = loadInstrumentedClass( "jcr.SampleTest" );
        Method m = stClass.getMethod( "afterClass" );
        m.invoke( stClass );
        List<String> expected = new ArrayList<String>();
        expected.add("jcr");
        assertEquals(expected, cm.getMessages());
    }
View Full Code Here

public class CoberturaManagerAdapterTest extends Assert {

    MockCoberturaManager cm;
    @BeforeMethod
    public void setup() throws Exception {
        cm = new MockCoberturaManager();
        cm.replaceCoberturaManagerSingleton();       
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.purrpackage.recording.MockCoberturaManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.