test/util/mlgw/DispatcherTest.java
author cli
Fri, 25 Dec 2009 15:42:46 +0100
changeset 25 dd05c3f2fa24
parent 12 bb6990c0dd1a
permissions -rw-r--r--
Fix for too early disconnects on slow client connections. (#563)
cli@12
     1
/*
cli@12
     2
 *   SONEWS News Server
cli@12
     3
 *   see AUTHORS for the list of contributors
cli@12
     4
 *
cli@12
     5
 *   This program is free software: you can redistribute it and/or modify
cli@12
     6
 *   it under the terms of the GNU General Public License as published by
cli@12
     7
 *   the Free Software Foundation, either version 3 of the License, or
cli@12
     8
 *   (at your option) any later version.
cli@12
     9
 *
cli@12
    10
 *   This program is distributed in the hope that it will be useful,
cli@12
    11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
cli@12
    12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cli@12
    13
 *   GNU General Public License for more details.
cli@12
    14
 *
cli@12
    15
 *   You should have received a copy of the GNU General Public License
cli@12
    16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
cli@12
    17
 */
cli@12
    18
cli@12
    19
package test.util.mlgw;
cli@12
    20
cli@12
    21
import java.lang.reflect.InvocationTargetException;
cli@12
    22
import java.lang.reflect.Method;
cli@12
    23
import junit.framework.TestCase;
cli@12
    24
import org.sonews.mlgw.Dispatcher;
cli@12
    25
cli@12
    26
/**
cli@12
    27
 * Tests the methods of class org.sonews.mlgw.Dispatcher.
cli@12
    28
 * @author Christian Lins
cli@12
    29
 * @since sonews/1.0.3
cli@12
    30
 */
cli@12
    31
public class DispatcherTest extends TestCase
cli@12
    32
{
cli@12
    33
cli@12
    34
  public DispatcherTest()
cli@12
    35
  {
cli@12
    36
    super("DispatcherTest");
cli@12
    37
  }
cli@12
    38
cli@12
    39
  public void testChunkListPost()
cli@12
    40
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
cli@12
    41
  {
cli@12
    42
    Dispatcher disp = new Dispatcher();
cli@12
    43
cli@12
    44
    Class  clazz             = disp.getClass();
cli@12
    45
    Method methChunkListPost = clazz.getDeclaredMethod("chunkListPost", String.class);
cli@12
    46
    methChunkListPost.setAccessible(true);
cli@12
    47
cli@12
    48
    try
cli@12
    49
    {
cli@12
    50
      // disp.chunkListPost(null)
cli@12
    51
      methChunkListPost.invoke(disp, null);
cli@12
    52
      fail("Should have raised an IllegalArgumentException");
cli@12
    53
    }
cli@12
    54
    catch(IllegalArgumentException ex){}
cli@12
    55
cli@12
    56
    // disp.chunkListPost("")
cli@12
    57
    Object obj = methChunkListPost.invoke(disp, "");
cli@12
    58
    assertNull(obj);
cli@12
    59
cli@12
    60
    // disp.chunkListPost("listPostValue is of form <mailto:dev@openoffice.org>")
cli@12
    61
    obj = methChunkListPost.invoke(disp, "listPostValue is of form <mailto:dev@openoffice.org>");
cli@12
    62
    assertNotNull(obj);
cli@12
    63
    assertEquals("dev@openoffice.org", (String)obj);
cli@12
    64
cli@12
    65
    // disp.chunkListPost("<mailto:frisbee-users@fun.rec.uk.sun.com")
cli@12
    66
    obj = methChunkListPost.invoke(disp, "<mailto:frisbee-users@fun.rec.uk.sun.com");
cli@12
    67
    assertNotNull(obj);
cli@12
    68
    assertEquals("frisbee-users@fun.rec.uk.sun.com", (String)obj);
cli@12
    69
  }
cli@12
    70
cli@12
    71
}