KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.james.util.junkscore;
23
24 import junit.framework.TestCase;
25
26 public class JunkScoreImplTest extends TestCase {
27
28     private final static String JavaDoc KEY1 = "KEY1";
29     private final static double SCORE1 = 20.0;
30     private final static String JavaDoc KEY2 = "KEY2";
31     private final static double SCORE2 = 2.0;
32     
33     public void testJunkScoreImpl() {
34         JunkScore junk = new JunkScoreImpl();
35     
36         assertEquals("Empty", junk.getCompleteStoredScores(), 0.0, 0d);
37
38         assertEquals("No previous stored score", junk.setStoredScore(KEY1, SCORE1), 0.0, 0d);
39         assertEquals("No previous stored score", junk.setStoredScore(KEY2, SCORE1), 0.0, 0d);
40     
41         assertEquals("Return the previous stored score", junk.setStoredScore(KEY2, SCORE2), SCORE1, 0d);
42     
43         assertEquals("Summarize score", junk.getCompleteStoredScores(), SCORE1 + SCORE2, 0d);
44     
45         assertEquals("Get stored score", junk.getStoredScore(KEY1), SCORE1, 0d);
46         assertEquals("Get stored score", junk.getStoredScore(KEY2), SCORE2, 0d);
47     
48         assertEquals("Get Map", junk.getStoredScores().size(), 2);
49     
50         assertEquals("Reset Score", junk.resetStoredScores(), SCORE1 + SCORE2, 0d);
51      
52         assertEquals("No Score", junk.getCompleteStoredScores(), 0.0, 0d);
53         assertEquals("Empty Map", junk.getStoredScores().size(), 0);
54     }
55     
56 }
57
Popular Tags