test/TestBench.java
author František Kučera <franta-hg@frantovo.cz>
Tue, 18 Oct 2011 21:10:45 +0200
changeset 97 7520a9246ff5
parent 1 6fceb66e1ad7
permissions -rwxr-xr-x
Drupal: text/plain – podpora citací: cite.
     1 /*
     2  *   StarOffice News Server
     3  *   see AUTHORS for the list of contributors
     4  *
     5  *   This program is free software: you can redistribute it and/or modify
     6  *   it under the terms of the GNU General Public License as published by
     7  *   the Free Software Foundation, either version 3 of the License, or
     8  *   (at your option) any later version.
     9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 
    19 package test;
    20 
    21 import test.command.HelloQuitTest;
    22 import test.command.ArticleTest;
    23 import java.util.LinkedList;
    24 import java.util.List;
    25 import test.command.CapabilitiesTest;
    26 import test.command.GroupTest;
    27 import test.command.ListGroupTests;
    28 import test.command.ListTest;
    29 import test.command.NewGroupsTest;
    30 import test.command.NextTest;
    31 import test.command.OverTest;
    32 import test.command.PostTest;
    33 
    34 /**
    35  * Run this class to perform a full test.
    36  * @author Christian Lins
    37  * @since sonews/0.5.0
    38  */
    39 public final class TestBench 
    40 {
    41   
    42   public static void main(String[] args)
    43   {
    44     System.out.println("TestBench for NNTP (RFC3799) based servers ");
    45     if(args.length < 1)
    46     {
    47       System.out.println("Usage: TestBench <host>[:port]");
    48       return;
    49     }
    50     
    51     String[] hostport = args[0].split(":");
    52     String host = hostport[0];
    53     int    port = 119;
    54     if(hostport.length == 2)
    55     {
    56       port = Integer.parseInt(hostport[1]);
    57     }
    58 
    59     List<AbstractTest> tests = new LinkedList<AbstractTest>();
    60     
    61     // Add tests to perform
    62     tests.add(new HelloQuitTest());
    63     tests.add(new PostTest());    // Post before Article
    64     tests.add(new ArticleTest());
    65     tests.add(new CapabilitiesTest());
    66     tests.add(new GroupTest());
    67     tests.add(new ListGroupTests());
    68     tests.add(new ListTest());
    69     tests.add(new NewGroupsTest());
    70     tests.add(new NextTest());
    71     tests.add(new OverTest());
    72     
    73     // Perform all tests
    74     for(AbstractTest test : tests)
    75     {
    76       try
    77       {
    78         test.connect(host, port);
    79         int result = test.runTest();
    80         System.out.print(test.getClass().getName() + " finished with exit code " + result + "\t => ");
    81         if(result == 0)
    82         {
    83           System.out.println("SUCCESS");
    84         }
    85         else
    86         {
    87           System.out.println("FAILURE");
    88         }
    89       }
    90       catch(Exception ex)
    91       {
    92         System.out.println("Test " + test.getClass().getName() + " failed: " + ex.getLocalizedMessage());
    93         ex.printStackTrace();
    94       }
    95     }
    96   }
    97   
    98 }