test/util/mlgw/DispatcherTest.java
author cli
Sat, 01 May 2010 14:27:30 +0200
changeset 28 15d14b110240
parent 12 bb6990c0dd1a
permissions -rw-r--r--
Make mailinglist gateway more reliable, probably.
     1 /*
     2  *   SONEWS 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.util.mlgw;
    20 
    21 import java.lang.reflect.InvocationTargetException;
    22 import java.lang.reflect.Method;
    23 import junit.framework.TestCase;
    24 import org.sonews.mlgw.Dispatcher;
    25 
    26 /**
    27  * Tests the methods of class org.sonews.mlgw.Dispatcher.
    28  * @author Christian Lins
    29  * @since sonews/1.0.3
    30  */
    31 public class DispatcherTest extends TestCase
    32 {
    33 
    34   public DispatcherTest()
    35   {
    36     super("DispatcherTest");
    37   }
    38 
    39   public void testChunkListPost()
    40     throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
    41   {
    42     Dispatcher disp = new Dispatcher();
    43 
    44     Class  clazz             = disp.getClass();
    45     Method methChunkListPost = clazz.getDeclaredMethod("chunkListPost", String.class);
    46     methChunkListPost.setAccessible(true);
    47 
    48     try
    49     {
    50       // disp.chunkListPost(null)
    51       methChunkListPost.invoke(disp, null);
    52       fail("Should have raised an IllegalArgumentException");
    53     }
    54     catch(IllegalArgumentException ex){}
    55 
    56     // disp.chunkListPost("")
    57     Object obj = methChunkListPost.invoke(disp, "");
    58     assertNull(obj);
    59 
    60     // disp.chunkListPost("listPostValue is of form <mailto:dev@openoffice.org>")
    61     obj = methChunkListPost.invoke(disp, "listPostValue is of form <mailto:dev@openoffice.org>");
    62     assertNotNull(obj);
    63     assertEquals("dev@openoffice.org", (String)obj);
    64 
    65     // disp.chunkListPost("<mailto:frisbee-users@fun.rec.uk.sun.com")
    66     obj = methChunkListPost.invoke(disp, "<mailto:frisbee-users@fun.rec.uk.sun.com");
    67     assertNotNull(obj);
    68     assertEquals("frisbee-users@fun.rec.uk.sun.com", (String)obj);
    69   }
    70 
    71 }