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-08-22 16:26:37 -0700 (Fri, 22 Aug 2008) $'
9
 * '$Revision: 4300 $'
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 edu.ucsb.nceas.metacat.service.PropertyService;
31
import edu.ucsb.nceas.metacat.service.ServiceException;
32
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
33

    
34
/**
35
 * A base JUnit class for Metacat tests
36
 */
37
public class MCTestCase
38
    extends TestCase {
39
	
40
    private static boolean printDebug = false;
41
	
42
	static {
43
		try {
44
			PropertyService.getInstance("build/tests");
45
		    String printDebugString = PropertyService.getProperty("test.printdebug");
46
		    printDebug = Boolean.parseBoolean(printDebugString);
47
		} catch (PropertyNotFoundException pnfe) {
48
			System.err.println("Could not get property in static block: " 
49
					+ pnfe.getMessage());
50
		} catch (ServiceException se) {
51
			System.err.println("Could not get PropertyService instance in static block: " 
52
					+ se.getMessage());
53
		}
54
	}
55

    
56
    /**
57
     * Constructor to build the test
58
     */
59
    public MCTestCase() {
60
        super();
61
    }
62
	
63
    /**
64
     * Constructor to build the test
65
     *
66
     * @param name the name of the test method
67
     */
68
    public MCTestCase(String name) {
69
        super(name);
70
    }
71
    
72
    protected static void debug(String debugMessage) {
73
    	if (printDebug) {
74
    		System.err.println(debugMessage);
75
    	}
76
    }
77
}
    (1-1/1)