1 |
4142
|
daigle
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2008 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
* Purpose: To test the Access Controls in metacat by JUnit
|
6 |
|
|
*
|
7 |
|
|
* '$Author$'
|
8 |
|
|
* '$Date$'
|
9 |
|
|
* '$Revision$'
|
10 |
|
|
*
|
11 |
|
|
* This program is free software; you can redistribute it and/or modify
|
12 |
|
|
* it under the terms of the GNU General Public License as published by
|
13 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
14 |
|
|
* (at your option) any later version.
|
15 |
|
|
*
|
16 |
|
|
* This program is distributed in the hope that it will be useful,
|
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
|
|
* GNU General Public License for more details.
|
20 |
|
|
*
|
21 |
|
|
* You should have received a copy of the GNU General Public License
|
22 |
|
|
* along with this program; if not, write to the Free Software
|
23 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
package edu.ucsb.nceas;
|
27 |
|
|
|
28 |
|
|
import junit.framework.TestCase;
|
29 |
|
|
|
30 |
4382
|
daigle
|
import java.io.IOException;
|
31 |
|
|
|
32 |
4142
|
daigle
|
import edu.ucsb.nceas.metacat.service.PropertyService;
|
33 |
|
|
import edu.ucsb.nceas.metacat.service.ServiceException;
|
34 |
|
|
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
35 |
4382
|
daigle
|
import edu.ucsb.nceas.utilities.SortedProperties;
|
36 |
4142
|
daigle
|
|
37 |
|
|
/**
|
38 |
|
|
* A base JUnit class for Metacat tests
|
39 |
|
|
*/
|
40 |
|
|
public class MCTestCase
|
41 |
|
|
extends TestCase {
|
42 |
|
|
|
43 |
|
|
private static boolean printDebug = false;
|
44 |
4355
|
daigle
|
|
45 |
|
|
protected static String EML2_0_0 = "EML2_0_0";
|
46 |
|
|
protected static String EML2_0_1 = "EML2_0_1";
|
47 |
|
|
protected static String EML2_1_0 = "EML2_1_0";
|
48 |
4142
|
daigle
|
|
49 |
4355
|
daigle
|
protected boolean SUCCESS = true;
|
50 |
|
|
protected boolean FAILURE = false;
|
51 |
|
|
|
52 |
4142
|
daigle
|
static {
|
53 |
|
|
try {
|
54 |
4382
|
daigle
|
SortedProperties testProperties =
|
55 |
|
|
new SortedProperties("build/tests/test.properties");
|
56 |
|
|
testProperties.load();
|
57 |
|
|
String metacatContextDir = testProperties.getProperty("metacat.contextDir");
|
58 |
|
|
PropertyService.getInstance(metacatContextDir + "/WEB-INF");
|
59 |
4142
|
daigle
|
String printDebugString = PropertyService.getProperty("test.printdebug");
|
60 |
|
|
printDebug = Boolean.parseBoolean(printDebugString);
|
61 |
4382
|
daigle
|
} catch (IOException ioe) {
|
62 |
|
|
System.err.println("Could not read property file in static block: "
|
63 |
|
|
+ ioe.getMessage());
|
64 |
4142
|
daigle
|
} catch (PropertyNotFoundException pnfe) {
|
65 |
|
|
System.err.println("Could not get property in static block: "
|
66 |
|
|
+ pnfe.getMessage());
|
67 |
|
|
} catch (ServiceException se) {
|
68 |
|
|
System.err.println("Could not get PropertyService instance in static block: "
|
69 |
|
|
+ se.getMessage());
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
4148
|
daigle
|
|
73 |
|
|
/**
|
74 |
|
|
* Constructor to build the test
|
75 |
|
|
*/
|
76 |
|
|
public MCTestCase() {
|
77 |
|
|
super();
|
78 |
|
|
}
|
79 |
4142
|
daigle
|
|
80 |
|
|
/**
|
81 |
|
|
* Constructor to build the test
|
82 |
|
|
*
|
83 |
|
|
* @param name the name of the test method
|
84 |
|
|
*/
|
85 |
|
|
public MCTestCase(String name) {
|
86 |
|
|
super(name);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
4300
|
daigle
|
protected static void debug(String debugMessage) {
|
90 |
4142
|
daigle
|
if (printDebug) {
|
91 |
|
|
System.err.println(debugMessage);
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
}
|