Project

General

Profile

1
/**
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: daigle $'
8
 *     '$Date: 2008-09-24 09:37:41 -0700 (Wed, 24 Sep 2008) $'
9
 * '$Revision: 4382 $'
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
import java.io.IOException;
31

    
32
import edu.ucsb.nceas.metacat.service.PropertyService;
33
import edu.ucsb.nceas.metacat.service.ServiceException;
34
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
35
import edu.ucsb.nceas.utilities.SortedProperties;
36

    
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
    
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
	
49
	protected boolean SUCCESS = true;
50
	protected boolean FAILURE = false;
51

    
52
	static {
53
		try {
54
			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
		    String printDebugString = PropertyService.getProperty("test.printdebug");
60
		    printDebug = Boolean.parseBoolean(printDebugString);
61
		} catch (IOException ioe) {
62
			System.err.println("Could not read property file in static block: " 
63
					+ ioe.getMessage());
64
		} 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

    
73
    /**
74
     * Constructor to build the test
75
     */
76
    public MCTestCase() {
77
        super();
78
    }
79
	
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
    protected static void debug(String debugMessage) {
90
    	if (printDebug) {
91
    		System.err.println(debugMessage);
92
    	}
93
    }
94
}
    (1-1/1)