1 5 package org.easymock.classextension.tests; 6 7 import org.easymock.MockControl; 8 import org.easymock.classextension.MockClassControl; 9 10 import junit.framework.TestCase; 11 12 15 public class LimitationsTest extends TestCase { 16 17 public static class MyClass { 18 public final int foo() { 19 throw new RuntimeException (); 20 } 21 } 22 23 public static class PrivateClass { 24 private PrivateClass() { 25 } 26 } 27 28 public void testFinalClass() { 29 try { 30 MockClassControl.createControl(String .class); 31 fail("Magic, we can mock a final class"); 32 } catch (Exception e) { 33 } 34 } 35 36 public void testAbstractClass() { 37 MockControl ctrl = MockClassControl.createControl(TestCase.class); 38 assertTrue(ctrl.getMock() instanceof TestCase); 39 } 40 41 public void testMockFinalMethod() { 42 MockControl ctrl = MockClassControl.createControl(MyClass.class); 43 MyClass c = (MyClass) ctrl.getMock(); 44 45 try { 46 c.foo(); 47 fail("Final method shouldn't be mocked"); 48 } catch (Exception e) { 49 } 50 } 51 52 public void testPrivateConstructor() { 53 MockClassControl.createControl(PrivateClass.class); 54 } 55 } 56 | Popular Tags |