Project

General

Profile

1 2134 costa
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2004 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis,
5
 *              and the University of New Mexico
6
 *
7
 *  Purpose: To test the HarvestDetailLog class by using JUnit
8
 *
9
 *   '$Author$'
10
 *     '$Date$'
11
 * '$Revision$'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
28
package edu.ucsb.nceas.metacattest.harvesterClient;
29
30
import edu.ucsb.nceas.metacat.harvesterClient.Harvester;
31 2143 costa
import edu.ucsb.nceas.metacat.harvesterClient.HarvestDetailLog;
32
import edu.ucsb.nceas.metacat.harvesterClient.HarvestDocument;
33
import edu.ucsb.nceas.metacat.harvesterClient.HarvestSiteSchedule;
34
import java.io.File;
35
import java.sql.Connection;
36 2134 costa
import junit.framework.Test;
37
import junit.framework.TestCase;
38
import junit.framework.TestSuite;
39
40
/**
41 2254 costa
 * Test HarvestDetailLog code using JUnit.
42 2134 costa
 *
43
 * @author  costa
44
 */
45
public class HarvestDetailLogTest extends TestCase {
46
47
  private Harvester harvester;
48 2143 costa
  private HarvestDetailLog harvestDetailLog;
49
  private HarvestDocument harvestDocument;
50
  private HarvestSiteSchedule harvestSiteSchedule;
51 2134 costa
52
53
  public HarvestDetailLogTest(String name) {
54
    super(name);
55
  }
56
57
58
  protected void setUp() {
59 2143 costa
    Connection conn;
60
    String contactEmail = "jdoe@institution.edu";
61
    String dateLastHarvest = "2004-04-01 00:00:00.0";
62
    String dateNextHarvest = "2004-05-01 00:00:00.0";
63
    int detailLogID;
64
    String documentListURL =
65
                 "http://www.institution.edu/~jdoe/public_html/harvestList.xml";
66
    String documentType = "eml://ecoinformatics.org/eml-2.0.0";
67
    String documentURL =
68
                   "http://www.institution.edu/~jdoe/public_html/document1.xml";
69
    String errorMessage = "JUnit testing";
70
    int harvestLogID;
71
    int identifier = 1;
72
    String ldapDN = "uid=jdoe,o=lter,dc=ecoinformatics,dc=org";
73
    String ldapPwd = "secretpassword";
74
    int revision = 1;
75
    String scope = "docname";
76
    int siteScheduleID = 1;
77 2158 costa
    boolean test = true;
78 2143 costa
    String unit = "months";
79
    int updateFrequency = 1;
80
81 2134 costa
    harvester = new Harvester();
82 2158 costa
    Harvester.loadOptions(test);
83 2143 costa
    conn = harvester.getConnection();  // initializes the database connection
84
    harvester.initLogIDs();
85
    harvestLogID = harvester.getHarvestLogID();
86
    detailLogID = harvester.getDetailLogID();
87
88
    harvestSiteSchedule = new HarvestSiteSchedule(harvester,
89
                                                  siteScheduleID,
90
                                                  documentListURL,
91
                                                  ldapDN,
92
                                                  ldapPwd,
93
                                                  dateNextHarvest,
94
                                                  dateLastHarvest,
95
                                                  updateFrequency,
96
                                                  unit,
97
                                                  contactEmail
98
                                                 );
99
100
    harvestDocument = new HarvestDocument(harvester,
101
                                          harvestSiteSchedule,
102
                                          scope,
103
                                          identifier,
104
                                          revision,
105
                                          documentType,
106
                                          documentURL
107
                                        );
108
109
    harvestDetailLog = new HarvestDetailLog(harvester, conn, harvestLogID,
110
                                            detailLogID, harvestDocument,
111
                                            errorMessage);
112 2134 costa
  }
113
114
115
  protected void tearDown() {
116 2143 costa
    harvester.closeConnection();
117 2134 costa
  }
118
119
120
  /**
121 2143 costa
   * Tests that the harvestDetailLog object was constructed.
122 2134 costa
   */
123 2143 costa
  public void testHarvestDetailLogObject() {
124
    assertTrue(harvestDetailLog != null);
125 2134 costa
  }
126
127
128
  /**
129 2143 costa
   * Tests the printOutput() method.
130
   */
131
  public void testPrintOutput() {
132
    harvestDetailLog.printOutput(System.out);
133
  }
134
135
136
  /**
137 2134 costa
   * Returns the test suite. The test suite consists of all methods in this
138
   * class whose names start with "test".
139
   *
140
   * @return  a TestSuite object
141
   */
142
  public static Test suite() {
143
    return new TestSuite(HarvestDetailLogTest.class);
144
  }
145
146
147
  /**
148
   * The main program. Runs the test suite.
149
   *
150
   * @param args   command line argument array.
151
   */
152
  public static void main(String args[]) {
153
    junit.textui.TestRunner.run(suite());
154
  }
155
156
}