test/unit/util/ResourceTest.java
author cli
Wed, 12 Aug 2009 13:03:23 +0200
changeset 7 0b76e099eb96
parent 1 6fceb66e1ad7
child 12 bb6990c0dd1a
permissions -rw-r--r--
PullFeeder sends an addition "MODE READER" to peers.
     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.unit.util;
    20 
    21 import junit.framework.TestCase;
    22 import org.sonews.util.io.Resource;
    23 
    24 /**
    25  * Unit test for class org.sonews.util.io.Resource.
    26  * @author Christian Lins
    27  * @see org.sonews.util.io.Resource
    28  * @since sonews/0.5.0
    29  */
    30 public class ResourceTest extends TestCase
    31 {
    32 
    33   public void testGetAsURL()
    34   {
    35     Object url;
    36     
    37     url = Resource.getAsURL(null);
    38     assertNull(url);
    39     
    40     url = Resource.getAsURL("this is absolutely bullshit");
    41     assertNull(url);
    42     
    43     // This file should exist
    44     url = Resource.getAsURL("org/sonews/daemon/Main.class");
    45     assertNotNull(url);
    46   }
    47   
    48   public void testGetAsStream()
    49   {
    50     Object stream;
    51     
    52     stream = Resource.getAsStream(null);
    53     assertNull(stream);
    54     
    55     stream = Resource.getAsStream("this is bullshit");
    56     assertNull(stream);
    57     
    58     stream = Resource.getAsStream("org/sonews/daemon/Main.class");
    59     assertNotNull(stream);
    60   }
    61   
    62   public void testGetAsString()
    63   {
    64     String str;
    65     
    66     str = Resource.getAsString(null, true);
    67     assertNull(str);
    68     
    69     str = Resource.getAsString("this is bullshit", true);
    70     assertNull(str);
    71     
    72     str = Resource.getAsString("org/sonews/daemon/Main.class", true);
    73     assertNotNull(str);
    74     
    75     str = Resource.getAsString("org/sonews/daemon/Main.class", false);
    76     assertNotNull(str);
    77     assertEquals(str.indexOf("\n"), -1);
    78   }
    79   
    80 }