KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > util > junkscore > JunkScoreConfigUtilTest


1 /****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one *
3  * or more contributor license agreements. See the NOTICE file *
4  * distributed with this work for additional information *
5  * regarding copyright ownership. The ASF licenses this file *
6  * to you under the Apache License, Version 2.0 (the *
7  * "License"); you may not use this file except in compliance *
8  * with the License. You may obtain a copy of the License at *
9  * *
10  * http://www.apache.org/licenses/LICENSE-2.0 *
11  * *
12  * Unless required by applicable law or agreed to in writing, *
13  * software distributed under the License is distributed on an *
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15  * KIND, either express or implied. See the License for the *
16  * specific language governing permissions and limitations *
17  * under the License. *
18  ****************************************************************/

19
20
21
22
23 package org.apache.james.util.junkscore;
24
25 import junit.framework.TestCase;
26
27 public class JunkScoreConfigUtilTest extends TestCase {
28
29     private final static String JavaDoc INVALID_CONFIG1 = "junkscore: invalid";
30     private final static String JavaDoc INVALID_CONFIG2 = "junk: 21";
31     private final static String JavaDoc VALID_CONFIG = "junkscore: 21";
32     
33     public void testgetJunkScoreConfig() {
34         boolean exception1 = false;
35         boolean exception2 = false;
36     
37         try {
38             JunkScoreConfigUtil.getJunkScore(INVALID_CONFIG1);
39         } catch (IllegalArgumentException JavaDoc e) {
40             exception1 = true;
41         }
42     
43         assertTrue("Exception thrown", exception1);
44     
45         try {
46             JunkScoreConfigUtil.getJunkScore(INVALID_CONFIG2);
47         } catch (IllegalArgumentException JavaDoc e) {
48             exception2 = true;
49         }
50     
51         assertTrue("Exception thrown", exception2);
52         
53         assertEquals("JunkScore extracted", JunkScoreConfigUtil.getJunkScore(VALID_CONFIG),21.0,0d);
54     
55     }
56     
57     public void testIsValidJunkScoreConfig() {
58         assertFalse("Invalid Config", JunkScoreConfigUtil.isValidJunkScoreConfig(INVALID_CONFIG1));
59         assertFalse("Invalid Config", JunkScoreConfigUtil.isValidJunkScoreConfig(INVALID_CONFIG2));
60         assertTrue("Valid Config", JunkScoreConfigUtil.isValidJunkScoreConfig(VALID_CONFIG));
61     }
62 }
63
Popular Tags