1 package tests.jfun.yan; 2 3 import junit.framework.TestCase; 4 import junit.framework.TestSuite; 5 import jfun.yan.containers.*; 6 import jfun.yan.*; 7 8 import java.awt.event.ActionEvent ; 9 import java.awt.event.ActionListener ; 10 import java.awt.event.MouseEvent ; 11 import java.awt.event.MouseListener ; 12 13 public class ProxyComponentTestCase extends TestCase { 14 public static void main(String [] args){ 15 tests.jfun.yan.Utils.runTest(suite()); 16 } 17 private static TestSuite suite(){ 18 return new TestSuite(ProxyComponentTestCase.class); 19 } 20 public void testMultipleInterfacesCanBeHidden() { 21 Component ca = Components.ctor(Footle.class); 22 23 Component ihca = 24 ca.proxy(new Class []{ActionListener .class, MouseListener .class}); 25 Object comp = ihca.create(null); 26 assertNotNull(comp); 27 assertTrue(comp instanceof ActionListener ); 28 assertTrue(comp instanceof MouseListener ); 29 } 30 31 public void testNonInterfaceInArrayCantBeHidden() { 32 Component ca = Components.ctor(Footle.class); 33 34 try { 35 36 Component ihca = 37 ca.proxy(new Class []{String .class}); 38 ihca.create(null); 39 fail("Oh no."); 40 } catch (IllegalArgumentException e) { 41 } 42 } 43 54 public class Footle implements ActionListener , MouseListener { 55 public void actionPerformed(ActionEvent e) { 56 } 57 58 public void mouseClicked(MouseEvent e) { 59 } 60 61 public void mouseEntered(MouseEvent e) { 62 } 63 64 public void mouseExited(MouseEvent e) { 65 } 66 67 public void mousePressed(MouseEvent e) { 68 } 69 70 public void mouseReleased(MouseEvent e) { 71 } 72 73 } 74 } 75 | Popular Tags |