1 | /*
|
---|
2 | * Created on Nov 18, 2004
|
---|
3 | * Copyright (C) Andrea Schweer, 2004
|
---|
4 | *
|
---|
5 | * This file is part of the Greenstone Alerting Service.
|
---|
6 | * Refer to the COPYING file in the base directory of this package
|
---|
7 | * for licensing information.
|
---|
8 | */
|
---|
9 | package org.greenstone.gsdlas;
|
---|
10 |
|
---|
11 | import java.net.URL;
|
---|
12 | import java.util.*;
|
---|
13 |
|
---|
14 | import junit.framework.TestCase;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * @author schweer
|
---|
18 | *
|
---|
19 | * TODO To change the template for this generated type comment go to
|
---|
20 | * Window - Preferences - Java - Code Style - Code Templates
|
---|
21 | */
|
---|
22 | public class ProfileStoreTest extends TestCase {
|
---|
23 |
|
---|
24 | public static void main(String[] args) {
|
---|
25 | junit.textui.TestRunner.run(ProfileStoreTest.class);
|
---|
26 | }
|
---|
27 |
|
---|
28 | public final void testAddSubscription() {
|
---|
29 | try {
|
---|
30 | addSubscriptions();
|
---|
31 | } catch (Exception e) {
|
---|
32 | e.printStackTrace();
|
---|
33 | fail(e.getMessage());
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public final void testFilter() {
|
---|
38 | try {
|
---|
39 | addSubscriptions();
|
---|
40 |
|
---|
41 | URL url = new URL("http://localhost:8080/soap/servlet/rpcrouter");
|
---|
42 | GreenstoneCommunicator gsComm = new GreenstoneCommunicator(url);
|
---|
43 |
|
---|
44 | Map event = new TreeMap();
|
---|
45 |
|
---|
46 | event.put("documentID", "20041118:5");
|
---|
47 | event.put("collectionID", "gs3mgdemo");
|
---|
48 | event.put("host", "http://localhost:8080/soap/servlet/rpcrouter");
|
---|
49 |
|
---|
50 | Set result = ProfileStore.getInstance().filter(event, gsComm);
|
---|
51 |
|
---|
52 | System.out.println(result.size());
|
---|
53 |
|
---|
54 | } catch (Exception e) {
|
---|
55 | e.printStackTrace();
|
---|
56 | fail(e.getMessage());
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | private void addSubscriptions() throws Exception {
|
---|
61 | Map valueMap = new TreeMap();
|
---|
62 |
|
---|
63 | valueMap.put("collectionID", "gs3mgdemo");
|
---|
64 | valueMap.put("document_content", "Tomatensalat");
|
---|
65 |
|
---|
66 | addSubscription(valueMap);
|
---|
67 |
|
---|
68 | valueMap.clear();
|
---|
69 |
|
---|
70 | valueMap.put("collectionID", "gs3mgdemo");
|
---|
71 | valueMap.put("document_content", "Water+Buffalo");
|
---|
72 |
|
---|
73 | addSubscription(valueMap);
|
---|
74 |
|
---|
75 | valueMap.clear();
|
---|
76 |
|
---|
77 | valueMap.put("collectionID", "gs3mgdemo");
|
---|
78 | valueMap.put("document_content", "gender+equality");
|
---|
79 |
|
---|
80 | addSubscription(valueMap);
|
---|
81 | }
|
---|
82 |
|
---|
83 | private void addSubscription(Map valueMap) throws Exception {
|
---|
84 | ProfileStore.getInstance().createSubscription(valueMap);
|
---|
85 | }
|
---|
86 |
|
---|
87 | }
|
---|