Revision 2079
Added by Matt Jones over 20 years ago
test/edu/ucsb/nceas/metacattest/VersionTest.java | ||
---|---|---|
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$' |
|
7 |
* '$Date$' |
|
8 |
* '$Revision$' |
|
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.MetaCatUtil; |
|
31 |
import edu.ucsb.nceas.metacat.Version; |
|
32 |
import edu.ucsb.nceas.utilities.Options; |
|
33 |
|
|
34 |
import junit.framework.TestCase; |
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* @author jones |
|
39 |
* |
|
40 |
* Test class for the Version class. |
|
41 |
*/ |
|
42 |
public class VersionTest extends TestCase |
|
43 |
{ |
|
44 |
/* |
|
45 |
* @see TestCase#setUp() |
|
46 |
*/ |
|
47 |
protected void setUp() throws Exception |
|
48 |
{ |
|
49 |
super.setUp(); |
|
50 |
try { |
|
51 |
File propertyFile = new File("./lib/metacat.properties"); |
|
52 |
Options options = Options.initialize(propertyFile); |
|
53 |
MetaCatUtil util = new MetaCatUtil(); |
|
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 |
assertTrue(MetaCatUtil.getOption("version").equals(Version.getVersion())); |
|
67 |
System.out.println(Version.getVersion()); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Test the "printVersionAsXml" method by printing its output. |
|
72 |
*/ |
|
73 |
public void testPrintVersionAsXml() |
|
74 |
{ |
|
75 |
System.out.println(Version.getVersionAsXml()); |
|
76 |
assertTrue(Version.getVersionAsXml().indexOf( |
|
77 |
MetaCatUtil.getOption("version")) != -1); |
|
78 |
} |
|
79 |
|
|
80 |
} |
|
0 | 81 |
lib/metacat.properties | ||
---|---|---|
4 | 4 |
# '$Id$' |
5 | 5 |
# |
6 | 6 |
configured=false |
7 |
version=1.3.1+ |
|
7 | 8 |
user=@user@ |
8 | 9 |
password=@password@ |
9 | 10 |
defaultDB=@jdbc-connect@ |
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
438 | 438 |
PrintWriter out = response.getWriter(); |
439 | 439 |
handleGetRevisionAndDocTypeAction(out, params); |
440 | 440 |
out.close(); |
441 |
} else if (action.equals("getversion")) { |
|
442 |
PrintWriter out = response.getWriter(); |
|
443 |
out.println(Version.getVersionAsXml()); |
|
444 |
out.close(); |
|
441 | 445 |
} else if (action.equals("login") || action.equals("logout")) { |
442 | 446 |
} else if (action.equals("protocoltest")) { |
443 | 447 |
String testURL = "metacat://dev.nceas.ucsb.edu/NCEAS.897766.9"; |
src/edu/ucsb/nceas/metacat/Version.java | ||
---|---|---|
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$' |
|
7 |
* '$Date$' |
|
8 |
* '$Revision$' |
|
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.metacat; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @author jones |
|
29 |
* |
|
30 |
* Version represents the current version information for this Metacat instance. |
|
31 |
*/ |
|
32 |
public class Version |
|
33 |
{ |
|
34 |
/** |
|
35 |
* Get the current version string for this metacat instance. |
|
36 |
* It is currently stored in the metacat.properties file. |
|
37 |
* |
|
38 |
* @return a string indicating the version of Metacat running |
|
39 |
*/ |
|
40 |
public static String getVersion() |
|
41 |
{ |
|
42 |
String version = MetaCatUtil.getOption("version"); |
|
43 |
return version; |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Get the version number in an XML document. |
|
48 |
* |
|
49 |
* @return the version wrapped in an XML document |
|
50 |
*/ |
|
51 |
public static String getVersionAsXml() |
|
52 |
{ |
|
53 |
StringBuffer sb = new StringBuffer(); |
|
54 |
sb.append("<?xml version=\"1.0\"?>"); |
|
55 |
sb.append("<version>"); |
|
56 |
sb.append(Version.getVersion()); |
|
57 |
sb.append("</version>"); |
|
58 |
return sb.toString(); |
|
59 |
} |
|
60 |
} |
|
0 | 61 |
Also available in: Unified diff
Added a simple action for finding out the current metacat version. The information is pulled from the property file, so be sure to update the version in the property file before shipping a release.