2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
6 package twitter.hashtag;
8 import java.io.FileNotFoundException;
9 import java.io.IOException;
11 import java.util.logging.Level;
12 import java.util.logging.Logger;
13 import org.junit.After;
14 import org.junit.AfterClass;
15 import org.junit.Before;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import twitter.manage.TweetManager;
19 import static org.junit.Assert.*;
20 import twitter.util.MultiSortedMap;
26 public class HashtagSearcherTest {
28 private TweetManager manager = new TweetManager();
29 private HashtagSearcher searcher;
31 public HashtagSearcherTest() {
33 manager.loginTwitter();
34 } catch (FileNotFoundException ex) {
35 Logger.getLogger(HashtagSearcherTest.class.getName()).log(Level.SEVERE, null, ex);
36 } catch (IOException ex) {
37 Logger.getLogger(HashtagSearcherTest.class.getName()).log(Level.SEVERE, null, ex);
39 searcher = new HashtagSearcher(manager);
43 public static void setUpClass() throws Exception {
47 public static void tearDownClass() throws Exception {
55 public void tearDown() {
59 * Test of getDescendantHashtagCount method, of class HashtagSearcher.
62 public void testGetDescendantHashtagCount() {
63 System.out.println("getDescendantHashtagCount");
64 String searchWord = "シャナ";
65 HashtagSearcher instance = searcher;
68 MultiSortedMap<Integer, String> result = instance.getDescendantHashtagCount(searchWord);
69 for(Integer key : result.getKeys()) {
70 System.out.println("KEY:" + key + " value:" + result.get(key));
75 * Test of calcSearchedHashtagCount method, of class HashtagSearcher.
78 public void testCalcSearchedHashtagCount() {
79 System.out.println("calcSearchedHashtagCount");
80 String searchWord = "#FF15";
81 HashtagSearcher instance = searcher;
84 Map result = instance.calcSearchedHashtagCount(searchWord);
85 assertEquals(14, result.get("#FF15"));
89 * Test of getHashtagCount method, of class HashtagSearcher.
92 public void testGetHashtagCount() {
93 System.out.println("getHashtagCount");
94 String message = "これは#hashタグのテストです";
95 HashtagSearcher instance = searcher;
97 Map result = instance.getHashtagCount(message);
98 assertEquals(1, result.get("#hash") );
100 message = "これは#hashタグのテストです#hash,#fj";
101 result = instance.getHashtagCount(message);
102 assertEquals(2, result.get("#hash"));
103 assertEquals(1, result.get("#fj"));
104 assertEquals(null, result.get("#test"));