1   package org.bejug.javacareers.feeder;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   import org.bejug.javacareers.jobs.model.JobOffer;
9   import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
10  
11  /***
12   Copyright (C) 2005 The Java Community
13  
14   This program is free software; you can redistribute it and/or modify  it under
15   the terms of the GNU General Public License as published by  the Free Software
16   Foundation; either version 2 of the License, or  (at your option) any later
17   version.
18  
19   This program is distributed in the hope that it will be useful,  but WITHOUT
20   ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
21   FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
22  
23   You should have received a copy of the GNU General Public License  along with
24   this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
25   Place, Suite 330, Boston, MA 02111-1307 USA.
26   */
27  
28  /***
29   * @author Bavo Bruylandt (Last modified by $Author: shally $)
30   * @version $Revision: 1.7 $ - $Date: 2005/12/21 11:38:42 $
31   */
32  public class AggregatorFeederTaskTests extends AbstractDependencyInjectionSpringContextTests {
33  
34      private FeederDaemonConfig feederDaemonConfig;
35      private AggregatorFeederTask aggregatorFeederTask;
36      private static final Log LOG =
37              LogFactory.getLog(AggregatorFeederTaskTests.class);
38  
39  
40      /***
41       * @see org.springframework.test.AbstractDependencyInjectionSpringContextTests#getConfigLocations()
42       * @return locations
43       */
44      protected String[] getConfigLocations() {
45          return new String[]{"/org/bejug/javacareers/applicationContext-test.xml", "/org/bejug/javacareers/applicationContext-feeder.xml"};
46      }
47  
48  
49      /***
50       * @param config FeederDaemonConfig.
51       */
52      public void setFeederDaemonConfig(FeederDaemonConfig config) {
53          this.feederDaemonConfig = config;
54      }
55  
56      /***
57       * 
58       */
59      public void testSetFeederDaemonConfig() {
60  
61          assertNotNull(feederDaemonConfig);
62      }
63  
64      /***
65       * @throws FeederException if an error.
66       */
67      public void testProcessFeeds() throws FeederException {
68          LOG.info("Debug: Starting processing");
69          ArrayList lists = aggregatorFeederTask.processFeeds();
70          aggregatorFeederTask.addListsToDataBase(lists);
71          LOG.info("Debug: Done processing");
72      }
73  
74      /***
75       * 
76       */
77      public void testIsValid() {
78          boolean result = false;
79  
80          List keywords = new ArrayList();
81          keywords.add("Java");
82  
83          JobOffer offer1 = new JobOffer();
84          offer1.setTitle("Java programmer");
85          offer1.setDescription("foo");
86          result = aggregatorFeederTask.isValid(offer1, keywords);
87          assertTrue(result);
88  
89          offer1.setTitle("Java/J2EE programmer");
90          result = aggregatorFeederTask.isValid(offer1, keywords);
91          assertTrue(result);
92  
93          offer1.setTitle("1.Java-/J2EE programmer");
94          result = aggregatorFeederTask.isValid(offer1, keywords);
95          assertTrue(result);
96  
97          offer1.setTitle("J2EE programmer Java");
98          result = aggregatorFeederTask.isValid(offer1, keywords);
99          assertTrue(result);
100 
101         offer1.setTitle("Javascript programmer");
102         result = aggregatorFeederTask.isValid(offer1, keywords);
103         assertFalse(result);
104 
105         offer1.setTitle("Djava");
106         result = aggregatorFeederTask.isValid(offer1, keywords);
107         assertFalse(result);
108 
109     }
110 
111     /***
112      * @return AggregatorFeederTask.
113      */
114     public AggregatorFeederTask getAggregatorFeederTask() {
115         return aggregatorFeederTask;
116     }
117 
118     /***
119      * @param aggregatorFeederTask AggregatorFeederTask.
120      */
121     public void setAggregatorFeederTask(AggregatorFeederTask aggregatorFeederTask) {
122         this.aggregatorFeederTask = aggregatorFeederTask;
123     }
124 }
125 
126 /***
127  * $Log: AggregatorFeederTaskTests.java,v $
128  * Revision 1.7  2005/12/21 11:38:42  shally
129  * *** empty log message ***
130  *
131  * Revision 1.6  2005/09/30 14:38:08  bavo_jcs
132  * Fixed URL
133  *
134  * Revision 1.5  2005/07/20 11:05:24  ge0ffrey
135  * JAVACAREERS-137
136  *
137  * Revision 1.4  2005/06/29 09:00:25  psong09
138  * comment component updated
139  *
140  * Revision 1.3  2005/06/14 12:05:53  schauwvliege
141  * CheckStyle and fixing tests
142  *
143  * Revision 1.2  2005/06/09 08:19:03  bejug_cc
144  * Fix initial import
145  *
146  * Revision 1.4  2005/06/07 13:03:10  bbr
147  * Keyword filtering
148  *
149  * Revision 1.3  2005/06/06 14:13:23  bbr
150  * lowercased context files
151  *
152  * Revision 1.2  2005/05/31 13:30:49  bbr
153  * reorganized contexts for tests
154  *
155  * Revision 1.1  2005/05/24 15:33:27  bbr
156  * Using spring sheduling
157  *
158  */