1 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 INVALID_CONFIG1 = "junkscore: invalid"; 30 private final static String INVALID_CONFIG2 = "junk: 21"; 31 private final static String 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 e) { 40 exception1 = true; 41 } 42 43 assertTrue("Exception thrown", exception1); 44 45 try { 46 JunkScoreConfigUtil.getJunkScore(INVALID_CONFIG2); 47 } catch (IllegalArgumentException 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 |