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
 *
6
 *   '$Author: daigle $'
7
 *     '$Date: 2008-07-06 21:25:34 -0700 (Sun, 06 Jul 2008) $'
8
 * '$Revision: 4080 $'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24
package edu.ucsb.nceas.metacattest;
25

    
26
import java.io.File;
27
import java.io.FileNotFoundException;
28
import java.io.IOException;
29

    
30
import edu.ucsb.nceas.metacat.MetaCatVersion;
31
import edu.ucsb.nceas.metacat.service.PropertyService;
32
import edu.ucsb.nceas.utilities.Options;
33
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
34

    
35
import junit.framework.TestCase;
36

    
37

    
38
/**
39
 * @author jones
40
 *
41
 * Test class for the Version class.
42
 */
43
public class VersionTest extends TestCase
44
{
45
    /*
46
     * @see TestCase#setUp()
47
     */
48
    protected void setUp() throws Exception
49
    {
50
        super.setUp();
51
        try {
52
            File propertyFile = new File("./lib/metacat.properties");
53
            Options options = Options.initialize(propertyFile);
54
        } catch (FileNotFoundException e) {
55
            fail(e.getMessage());
56
        } catch (IOException e) {
57
            fail(e.getMessage());
58
        }
59
    }
60
    
61
    /**
62
     * Test the "getVersion" method by printing its output.
63
     */
64
    public void testGetVersion()
65
    {
66
    	try {
67
            assertTrue(PropertyService.getProperty("application.metacatVersion").equals(MetaCatVersion.getVersionID()));
68
            System.out.println(MetaCatVersion.getVersionID());
69
    	} catch (PropertyNotFoundException pnfe) {
70
    		fail ("Could not get metacat version property; " + pnfe.getMessage());
71
    	}
72

    
73
    }
74

    
75
    /**
76
     * Test the "printVersionAsXml" method by printing its output.
77
     */
78
    public void testPrintVersionAsXml()
79
    {
80
    	try {
81
        System.out.println(MetaCatVersion.getVersionAsXml());
82
        assertTrue(MetaCatVersion.getVersionAsXml().indexOf(
83
                PropertyService.getProperty("application.metacatVersion")) != -1);
84
    	} catch (PropertyNotFoundException pnfe) {
85
    		fail ("Could not get metacat version property; " + pnfe.getMessage());
86
    	}
87
    }
88

    
89
}
(18-18/18)