jakarta-ecs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-ecs/example TestBed.java
Date Wed, 28 Mar 2001 20:46:52 GMT
rdonkin     01/03/28 12:46:52

  Modified:    example  TestBed.java
  Log:
  restructured class as proposed by Mason Ham <mlham@alphawolf.com>. this application
now takes a parameter.
  
  Revision  Changes    Path
  1.14      +97 -73    jakarta-ecs/example/TestBed.java
  
  Index: TestBed.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ecs/example/TestBed.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestBed.java	2001/01/31 20:03:16	1.13
  +++ TestBed.java	2001/03/28 20:46:52	1.14
  @@ -64,11 +64,15 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Attr;
  +import org.apache.ecs.xhtml.*;
   
   /**
  -    This class is used for development/regression testing
  +    This class is used for development/regression testing.
  +    Call this application with a single parameter.
  +    Pass the method name if you want that to be tested
  +    or 'all' to call all test methods in turn.
   
  -    @version $Id: TestBed.java,v 1.13 2001/01/31 20:03:16 snagy Exp $
  +    @version $Id: TestBed.java,v 1.14 2001/03/28 20:46:52 rdonkin Exp $
       @author <a href="mailto:snagy@servletapi.com">Stephan Nagy</a>
       @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
   */
  @@ -1082,79 +1086,99 @@
           System.out.println (big.toString());
       }
   
  +    public void testXhtmlFrameSet()
  +    {
  +        XhtmlFrameSetDocument doc = new XhtmlFrameSetDocument();
  +// methods not present in 1.4.1 commented out so that i can do comparative testing
  +//        doc.setDoctype(new org.apache.ecs.Doctype.XHtml10Frameset());
  +        doc.appendTitle("title");
  +// methods not present in 1.4.1 commented out so that i can do comparative testing
  +//        doc.appendHead(new org.apache.ecs.xhtml.meta("keywords","test,org.apache.ecs"));
  +        doc.appendBody(new org.apache.ecs.xhtml.hr());
  +        doc.appendBody("The body part of this document goes into the noframes bit.");
  +        doc.appendBody(new org.apache.ecs.xhtml.hr());
  +        doc.appendFrameSet("This is a stringy append to the frameset bit.");
  +        doc.appendFrameSet(new org.apache.ecs.xhtml.frame(
  +            "This is the frame element bit",
  +            "theFrameName",
  +            "frame.html"));
  +        System.out.println(doc.toString());
  +    }
  +
  +//-------------------------
  +    /**
  +    this method prints up the usage.
  +    */
  +    private static void printUsage(TestBed instance)
  +    {            
  +        System.out.println("TesBed usage:");
  +        System.out.println("\tjava TestBed all");
  +        System.out.println("OR");
  +        System.out.println("\tjava TestBed <method>");
  +        System.out.println("\twhere <method> is one of:");
  +        java.lang.reflect.Method[] methods= instance.getClass().getMethods();
  +        for (int i=0; i<methods.length;i++)
  +        {
  +            if (methods[i].getDeclaringClass().equals(instance.getClass())&&methods[i].getParameterTypes().length==0)
  +            {
  +                System.out.println("\t\t"+ methods[i].getName());
  +            }
  +        }
  +    }
  +
  +    /**
  +    this calls all test methods in turn.
  +    the name of the method is printed out before the method is called.
  +    (actually it calls all methods strictly in this class which has no
  +    parameters - so you'll need to avoid parameter-based test methods
  +    if you want this method to find them!)
  +    */
  +    private static void testAll(TestBed instance)
  +    {            
  +        java.lang.reflect.Method[] methods= instance.getClass().getMethods();
  +        for (int i=0; i<methods.length;i++)
  +        {
  +            if (methods[i].getDeclaringClass().equals(instance.getClass())&&methods[i].getParameterTypes().length==0)
  +            {
  +                System.out.println();
  +                System.out.println(methods[i].getName()+":");
  +                try { 
  +                    methods[i].invoke(instance,new Class[]{});
  +                } catch (Exception ex) {
  +                    ex.printStackTrace();
  +                }
  +            }
  +        }
  +    }
  +    
  +    /**
  +    pass a single parameter to this class.
  +    for example <code> java TestBed arg</code> where <code>arg</code>
  +    is either <code>all</code> (which will call every test method in this class
in turn)
  +    or <code><method></code> (which calls the test method called <method>
in this class). 
  +    */
       public static void main(String[] args)
       {
           TestBed tb = new TestBed();
  -        // tb.testBR1();
  -        // tb.testBR2();
  -        // tb.testBR3();
  -        // tb.testImg1();
  -        // tb.testImg2();
  -        // tb.testImg3();
  -        // tb.testTitle1();
  -        // tb.testA1();
  -        // tb.testHtml1();
  -        // tb.testHtml2();
  -        // tb.testHtml3();
  -        // tb.testHtml4();
  -        // tb.testHtml5();
  -        // tb.testDocument();
  -        // tb.testDocument1();
  -        // tb.testP();
  -        // tb.testULLI();
  -        // tb.testOLLI();
  -        // tb.testDLDTDD();
  -        // tb.testDLDTDD1();
  -        // tb.test();
  -        // tb.testPRE();
  -        // tb.testNOBR();
  -        // tb.testHR();
  -        // tb.testB();
  -        // tb.testU();
  -        // tb.testI();
  -        // tb.testBlink();
  -        // tb.testCenter();
  -        // tb.testBlockQuote();
  -        // tb.testMap();
  -        // tb.testCaption();
  -        // tb.testArea();
  -        // tb.testInput();
  -        // tb.testSelect();
  -        // tb.testSelectOption();
  -        // tb.testSelectOptGroup();
  -        // tb.testBase();
  -        // tb.testScript();
  -        // tb.testTable();
  -        // tb.testFilter();
  -        // tb.testForm();
  -        // tb.testComment();
  -        // tb.testTextArea();
  -        // tb.moreXMLTest();
  -        // tb.testLabel();
  -        // tb.testFieldSet();
  -        // tb.testLegend();
  -        // tb.testFontStuff();
  -        // tb.moreXMLTest();
  -        // tb.testFrames();
  -        // tb.testStyle();
  -        // tb.testApplet();
  -        // tb.testBaseFont();
  -        // tb.testObject();
  -        // tb.testS();
  -        // tb.testStrike();
  -        // tb.testLink();
  -        // tb.testButton();
  -        // tb.test1();
  -        // tb.homepageTest();
  -        // tb.testWordFilter();
  -        // tb.testElementContainer();
  -        // tb.testStringElement();
  -        // tb.testFilter1();
  -        // tb.testFrameSetDocument();
  -        // tb.testPrettyPrint();
  -        // tb.testDocBug();
  -        // tb.testStringBug();
  -        // tb.testBigMouseEvents();
  -        // tb.testDOMFactory();
  +        if (args.length!=1)
  +        {
  +            printUsage(tb);
  +        } else {
  +            String method=args[0];
  +            if (method.equalsIgnoreCase("all"))
  +            {
  +                testAll(tb);
  +            } else {
  +                try { 
  +                    java.lang.reflect.Method meth=tb.getClass().getMethod(method, new Class[]{});
  +                    meth.invoke(tb,new Class[]{});
  +                } catch (NoSuchMethodException ex) {
  +                    System.out.println("Bad parameter!");
  +                    printUsage(tb);
  +                } catch (Exception ex) {
  +                    ex.printStackTrace();
  +                }
  +            }
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-dev-help@jakarta.apache.org


Mime
View raw message