Project

General

Profile

1
/**
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: costa $'
10
 *     '$Date: 2004-05-04 09:29:51 -0700 (Tue, 04 May 2004) $'
11
 * '$Revision: 2158 $'
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
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
import junit.framework.Test;
37
import junit.framework.TestCase;
38
import junit.framework.TestSuite;
39

    
40
/**
41
 * Test HarvestDetailLog code using JUnit. Not yet implemented. The test
42
 * contained herein is just a placeholder for the actual tests to be
43
 * added.
44
 *
45
 * @author  costa
46
 */
47
public class HarvestDetailLogTest extends TestCase {
48

    
49
  private Harvester harvester;
50
  private HarvestDetailLog harvestDetailLog;
51
  private HarvestDocument harvestDocument;
52
  private HarvestSiteSchedule harvestSiteSchedule;
53
  
54

    
55
  public HarvestDetailLogTest(String name) {
56
    super(name);
57
  }
58
  
59
  
60
  protected void setUp() {
61
    Connection conn;
62
    String contactEmail = "jdoe@institution.edu";
63
    String dateLastHarvest = "2004-04-01 00:00:00.0";
64
    String dateNextHarvest = "2004-05-01 00:00:00.0";
65
    int detailLogID;
66
    String documentListURL = 
67
                 "http://www.institution.edu/~jdoe/public_html/harvestList.xml";
68
    String documentType = "eml://ecoinformatics.org/eml-2.0.0";
69
    String documentURL = 
70
                   "http://www.institution.edu/~jdoe/public_html/document1.xml";
71
    String errorMessage = "JUnit testing";
72
    int harvestLogID;
73
    int identifier = 1;
74
    String ldapDN = "uid=jdoe,o=lter,dc=ecoinformatics,dc=org";
75
    String ldapPwd = "secretpassword";
76
    int revision = 1;
77
    String scope = "docname";
78
    int siteScheduleID = 1;
79
    boolean test = true;
80
    String unit = "months";
81
    int updateFrequency = 1;
82
  
83
    harvester = new Harvester();
84
    Harvester.loadOptions(test);
85
    conn = harvester.getConnection();  // initializes the database connection
86
    harvester.initLogIDs();
87
    harvestLogID = harvester.getHarvestLogID();
88
    detailLogID = harvester.getDetailLogID();
89

    
90
    harvestSiteSchedule = new HarvestSiteSchedule(harvester,
91
                                                  siteScheduleID,
92
                                                  documentListURL,
93
                                                  ldapDN,
94
                                                  ldapPwd,
95
                                                  dateNextHarvest,
96
                                                  dateLastHarvest,
97
                                                  updateFrequency,
98
                                                  unit,
99
                                                  contactEmail
100
                                                 );
101

    
102
    harvestDocument = new HarvestDocument(harvester,
103
                                          harvestSiteSchedule,
104
                                          scope,
105
                                          identifier,
106
                                          revision,
107
                                          documentType,
108
                                          documentURL
109
                                        );
110
    
111
    harvestDetailLog = new HarvestDetailLog(harvester, conn, harvestLogID, 
112
                                            detailLogID, harvestDocument, 
113
                                            errorMessage);
114
  }
115
  
116
  
117
  protected void tearDown() {
118
    harvester.closeConnection();
119
  }
120

    
121

    
122
  /**
123
   * Tests that the harvestDetailLog object was constructed.
124
   */
125
  public void testHarvestDetailLogObject() {
126
    assertTrue(harvestDetailLog != null);
127
  }
128
  
129
  
130
  /**
131
   * Tests the printOutput() method.
132
   */
133
  public void testPrintOutput() {
134
    harvestDetailLog.printOutput(System.out);
135
  }
136
  
137
  
138
  /**
139
   * Returns the test suite. The test suite consists of all methods in this
140
   * class whose names start with "test".
141
   * 
142
   * @return  a TestSuite object
143
   */
144
  public static Test suite() {
145
    return new TestSuite(HarvestDetailLogTest.class);
146
  }
147
  
148

    
149
  /**
150
   * The main program. Runs the test suite.
151
   * 
152
   * @param args   command line argument array.
153
   */
154
  public static void main(String args[]) {
155
    junit.textui.TestRunner.run(suite());
156
  }
157

    
158
}
(1-1/5)