Revision 4384
Added by daigle about 16 years ago
test/edu/ucsb/nceas/metacattest/AuthLdapTest.java | ||
---|---|---|
24 | 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
25 | 25 |
*/ |
26 | 26 |
package edu.ucsb.nceas.metacattest; |
27 |
import java.io.File; |
|
28 | 27 |
|
28 |
import edu.ucsb.nceas.MCTestCase; |
|
29 | 29 |
import edu.ucsb.nceas.metacat.AuthLdap; |
30 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
|
31 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
|
32 | 30 |
import junit.framework.Test; |
33 |
import junit.framework.TestCase; |
|
34 | 31 |
import junit.framework.TestSuite; |
35 | 32 |
|
36 | 33 |
|
37 | 34 |
/* |
38 | 35 |
* A junit test class to test public methods in AuthLdap class. |
39 | 36 |
*/ |
40 |
public class AuthLdapTest extends TestCase |
|
37 |
public class AuthLdapTest extends MCTestCase
|
|
41 | 38 |
{ |
42 | 39 |
// Constants |
43 | 40 |
private static final String USER = "uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org"; |
44 | 41 |
private static final String PASS = "kepler"; |
45 | 42 |
|
46 |
|
|
47 |
private MetaCatUtil util; |
|
48 |
/* Initialize properties*/ |
|
49 |
static |
|
50 |
{ |
|
51 |
try |
|
52 |
{ |
|
53 |
PropertyService.getInstance("build/tests"); |
|
54 |
} |
|
55 |
catch(Exception e) |
|
56 |
{ |
|
57 |
System.err.println("Exception in initialize option in MetacatServletNetTest "+e.getMessage()); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 | 43 |
/** |
62 | 44 |
* Constructor to build the test |
63 | 45 |
* |
test/edu/ucsb/nceas/metacattest/SitemapTest.java | ||
---|---|---|
30 | 30 |
import java.io.FileReader; |
31 | 31 |
import java.io.IOException; |
32 | 32 |
|
33 |
import edu.ucsb.nceas.MCTestCase; |
|
33 | 34 |
import edu.ucsb.nceas.metacat.DBConnectionPool; |
34 | 35 |
import edu.ucsb.nceas.metacat.Sitemap; |
35 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
|
36 |
import edu.ucsb.nceas.metacat.service.ServiceException; |
|
37 | 36 |
|
38 |
import junit.framework.TestCase; |
|
39 |
|
|
40 | 37 |
/** |
41 | 38 |
* Test the Sitemap class by generating the sitemaps in a separate directory. |
42 | 39 |
* |
43 | 40 |
* @author Matt Jones |
44 | 41 |
*/ |
45 |
public class SitemapTest extends TestCase { |
|
42 |
public class SitemapTest extends MCTestCase {
|
|
46 | 43 |
|
47 | 44 |
private String directoryName = "/tmp/sitemaps"; |
48 | 45 |
|
... | ... | |
51 | 48 |
*/ |
52 | 49 |
protected void setUp() throws Exception { |
53 | 50 |
super.setUp(); |
54 |
try { |
|
55 |
PropertyService.getInstance("build/tests"); |
|
56 |
DBConnectionPool pool = DBConnectionPool.getInstance(); |
|
57 |
} catch (ServiceException se) { |
|
58 |
fail(se.getMessage()); |
|
59 |
} |
|
51 |
|
|
52 |
DBConnectionPool pool = DBConnectionPool.getInstance(); |
|
60 | 53 |
} |
61 | 54 |
|
62 | 55 |
/** |
test/edu/ucsb/nceas/metacattest/SubTreeTest.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
package edu.ucsb.nceas.metacattest; |
28 | 28 |
|
29 |
import edu.ucsb.nceas.MCTestCase; |
|
29 | 30 |
import edu.ucsb.nceas.metacat.*; |
30 | 31 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
31 | 32 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
33 |
|
|
32 | 34 |
import junit.framework.Test; |
33 |
import junit.framework.TestCase; |
|
34 |
import junit.framework.TestResult; |
|
35 | 35 |
import junit.framework.TestSuite; |
36 |
|
|
36 | 37 |
import org.apache.commons.logging.Log; |
37 | 38 |
import org.apache.commons.logging.LogFactory; |
38 | 39 |
|
... | ... | |
42 | 43 |
/** |
43 | 44 |
* A JUnit test for testing Step class processing |
44 | 45 |
*/ |
45 |
public class SubTreeTest extends TestCase |
|
46 |
public class SubTreeTest extends MCTestCase
|
|
46 | 47 |
{ |
47 | 48 |
private SubTree tree = null; |
48 | 49 |
private static final Log log = LogFactory.getLog("edu.ucsb.nceas.metacattest.ReplicationServerListTest"); |
... | ... | |
51 | 52 |
{ |
52 | 53 |
try |
53 | 54 |
{ |
54 |
PropertyService.getInstance("build/tests"); |
|
55 | 55 |
MetaCatUtil.pathsForIndexing |
56 | 56 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths")); |
57 | 57 |
} |
test/edu/ucsb/nceas/metacattest/QueryResultBuilderTest.java | ||
---|---|---|
28 | 28 |
import java.util.Enumeration; |
29 | 29 |
import java.util.Hashtable; |
30 | 30 |
|
31 |
import edu.ucsb.nceas.MCTestCase; |
|
31 | 32 |
import edu.ucsb.nceas.metacat.DBConnection; |
32 | 33 |
import edu.ucsb.nceas.metacat.DBConnectionPool; |
33 | 34 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
34 | 35 |
|
35 | 36 |
import junit.framework.Test; |
36 |
import junit.framework.TestCase; |
|
37 | 37 |
import junit.framework.TestSuite; |
38 | 38 |
|
39 | 39 |
|
... | ... | |
43 | 43 |
* Test class for getting idea how long it will take - to build |
44 | 44 |
* records xml_queryresult table for a given return fields |
45 | 45 |
*/ |
46 |
public class QueryResultBuilderTest extends TestCase |
|
46 |
public class QueryResultBuilderTest extends MCTestCase
|
|
47 | 47 |
{ |
48 | 48 |
/** DBConnection pool*/ |
49 | 49 |
private DBConnectionPool connPool = null; |
... | ... | |
52 | 52 |
/** Return field id value for above return field string in xml_returnfield*/ |
53 | 53 |
private int returnFieldId =11; |
54 | 54 |
|
55 |
static |
|
56 |
{ |
|
57 |
try |
|
58 |
{ |
|
59 |
PropertyService.getInstance("build/tests"); |
|
60 |
} |
|
61 |
catch(Exception e) |
|
62 |
{ |
|
63 |
System.err.println("Exception in initialize option in MetacatServletNetTest "+e.getMessage()); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 | 55 |
/** |
68 | 56 |
* Create a suite of tests to be run together |
69 | 57 |
*/ |
test/edu/ucsb/nceas/metacattest/QueryGroupTest.java | ||
---|---|---|
24 | 24 |
package edu.ucsb.nceas.metacattest; |
25 | 25 |
|
26 | 26 |
import junit.framework.Test; |
27 |
import junit.framework.TestCase; |
|
28 | 27 |
import junit.framework.TestSuite; |
29 | 28 |
|
29 |
import edu.ucsb.nceas.MCTestCase; |
|
30 | 30 |
import edu.ucsb.nceas.metacat.QueryGroup; |
31 | 31 |
import edu.ucsb.nceas.metacat.QueryTerm; |
32 | 32 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
... | ... | |
37 | 37 |
* |
38 | 38 |
* Test the output of the QuerySpecification class |
39 | 39 |
*/ |
40 |
public class QueryGroupTest extends TestCase |
|
40 |
public class QueryGroupTest extends MCTestCase
|
|
41 | 41 |
{ |
42 | 42 |
private QueryGroup group = null; |
43 | 43 |
/* Initialize properties*/ |
... | ... | |
45 | 45 |
{ |
46 | 46 |
try |
47 | 47 |
{ |
48 |
PropertyService.getInstance("build/tests"); |
|
49 | 48 |
MetaCatUtil.pathsForIndexing |
50 | 49 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths")); |
51 | 50 |
} |
test/edu/ucsb/nceas/metacattest/VersionTest.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package edu.ucsb.nceas.metacattest; |
25 | 25 |
|
26 |
import edu.ucsb.nceas.MCTestCase; |
|
26 | 27 |
import edu.ucsb.nceas.metacat.MetaCatVersion; |
27 | 28 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
28 |
import edu.ucsb.nceas.metacat.service.ServiceException; |
|
29 | 29 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
30 | 30 |
|
31 |
import junit.framework.TestCase; |
|
32 | 31 |
|
33 | 32 |
|
34 | 33 |
/** |
... | ... | |
36 | 35 |
* |
37 | 36 |
* Test class for the Version class. |
38 | 37 |
*/ |
39 |
public class VersionTest extends TestCase |
|
38 |
public class VersionTest extends MCTestCase
|
|
40 | 39 |
{ |
41 | 40 |
/* |
42 | 41 |
* @see TestCase#setUp() |
... | ... | |
44 | 43 |
protected void setUp() throws Exception |
45 | 44 |
{ |
46 | 45 |
super.setUp(); |
47 |
try { |
|
48 |
PropertyService.getInstance("build/tests"); |
|
49 |
} catch (ServiceException se) { |
|
50 |
fail(se.getMessage()); |
|
51 |
} |
|
52 | 46 |
} |
53 | 47 |
|
54 | 48 |
/** |
test/edu/ucsb/nceas/metacattest/BuildIndexTest.java | ||
---|---|---|
34 | 34 |
import java.util.SimpleTimeZone; |
35 | 35 |
import java.util.TimeZone; |
36 | 36 |
|
37 |
import edu.ucsb.nceas.MCTestCase; |
|
37 | 38 |
import edu.ucsb.nceas.metacat.DocumentImpl; |
38 | 39 |
import edu.ucsb.nceas.metacat.McdbException; |
39 | 40 |
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException; |
... | ... | |
49 | 50 |
import edu.ucsb.nceas.utilities.IOUtil; |
50 | 51 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
51 | 52 |
import junit.framework.Test; |
52 |
import junit.framework.TestCase; |
|
53 | 53 |
import junit.framework.TestSuite; |
54 | 54 |
|
55 | 55 |
/** |
56 | 56 |
* A JUnit test for testing the indexing routines for XML Paths |
57 | 57 |
*/ |
58 |
public class BuildIndexTest extends TestCase |
|
59 |
{ |
|
60 |
private static String metacatUrl; |
|
61 |
private static String username; |
|
58 |
public class BuildIndexTest extends MCTestCase { |
|
59 |
private static String metacatUrl; |
|
60 |
private static String username; |
|
62 | 61 |
private static String password; |
63 | 62 |
static { |
64 | 63 |
try { |
65 |
PropertyService.getInstance("build/tests"); |
|
66 |
metacatUrl = PropertyService.getProperty("test.metacatUrl"); |
|
64 |
metacatUrl = PropertyService.getProperty("test.metacatUrl"); |
|
67 | 65 |
username = PropertyService.getProperty("test.mcUser"); |
68 | 66 |
password = PropertyService.getProperty("test.mcPassword"); |
69 | 67 |
} catch (PropertyNotFoundException pnfe) { |
70 |
System.err.println("Could not get property in static block: "
|
|
68 |
System.err.println("Could not get property in static block: " |
|
71 | 69 |
+ pnfe.getMessage()); |
72 |
} catch (ServiceException se) { |
|
73 |
System.err.println("Could not get PropertyService instance in static block: " |
|
74 |
+ se.getMessage()); |
|
75 | 70 |
} |
76 | 71 |
} |
77 | 72 |
|
... | ... | |
80 | 75 |
private String testfile = "test/eml-sample.xml"; |
81 | 76 |
private String testdocument = ""; |
82 | 77 |
private Metacat m; |
83 |
/* Initialize properties */ |
|
84 |
static |
|
85 |
{ |
|
86 |
try |
|
87 |
{ |
|
88 |
PropertyService.getInstance("build/tests"); |
|
89 |
MetaCatUtil.pathsForIndexing |
|
90 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths")); |
|
91 |
} |
|
92 |
catch(Exception e) |
|
93 |
{ |
|
94 |
System.err.println("Exception in initialize option in MetacatServletNetTest "+e.getMessage()); |
|
95 |
} |
|
96 |
} |
|
78 |
/* Initialize properties */ |
|
79 |
static { |
|
80 |
try { |
|
81 |
PropertyService.getInstance("build/tests"); |
|
82 |
MetaCatUtil.pathsForIndexing = MetaCatUtil.getOptionList(PropertyService |
|
83 |
.getProperty("xml.indexPaths")); |
|
84 |
} catch (Exception e) { |
|
85 |
System.err.println("Exception in initialize option in MetacatServletNetTest " |
|
86 |
+ e.getMessage()); |
|
87 |
} |
|
88 |
} |
|
97 | 89 |
|
98 |
/**
|
|
99 |
* Constructor to build the test
|
|
100 |
*
|
|
101 |
* @param name the name of the test method
|
|
102 |
*/
|
|
103 |
public BuildIndexTest(String name)
|
|
104 |
{
|
|
105 |
super(name);
|
|
106 |
newdocid = generateDocid();
|
|
107 |
}
|
|
90 |
/**
|
|
91 |
* Constructor to build the test
|
|
92 |
*
|
|
93 |
* @param name
|
|
94 |
* the name of the test method
|
|
95 |
*/
|
|
96 |
public BuildIndexTest(String name) {
|
|
97 |
super(name);
|
|
98 |
newdocid = generateDocid();
|
|
99 |
}
|
|
108 | 100 |
|
109 |
/** |
|
110 |
* Establish a testing framework by initializing appropriate objects |
|
111 |
*/ |
|
112 |
public void setUp() |
|
113 |
{ |
|
114 |
try { |
|
115 |
DatabaseService.getInstance(); |
|
116 |
PropertyService.getInstance("build/tests"); |
|
117 |
metacatUrl = PropertyService.getProperty("test.metacatUrl"); |
|
118 |
} catch (ServiceException se) { |
|
119 |
fail(se.getMessage()); |
|
120 |
} catch (PropertyNotFoundException pnfe) { |
|
121 |
fail (pnfe.getMessage()); |
|
122 |
} |
|
101 |
/** |
|
102 |
* Establish a testing framework by initializing appropriate objects |
|
103 |
*/ |
|
104 |
public void setUp() { |
|
105 |
try { |
|
106 |
DatabaseService.getInstance(); |
|
107 |
PropertyService.getInstance("build/tests"); |
|
108 |
metacatUrl = PropertyService.getProperty("test.metacatUrl"); |
|
109 |
} catch (ServiceException se) { |
|
110 |
fail(se.getMessage()); |
|
111 |
} catch (PropertyNotFoundException pnfe) { |
|
112 |
fail(pnfe.getMessage()); |
|
113 |
} |
|
123 | 114 |
|
124 |
try {
|
|
125 |
FileReader fr = new FileReader(testfile);
|
|
126 |
testdocument = IOUtil.getAsString(fr, true);
|
|
127 |
} catch (IOException ioe) {
|
|
128 |
fail("Can't read test data to run the test: " + testfile);
|
|
129 |
}
|
|
130 |
}
|
|
115 |
try {
|
|
116 |
FileReader fr = new FileReader(testfile);
|
|
117 |
testdocument = IOUtil.getAsString(fr, true);
|
|
118 |
} catch (IOException ioe) {
|
|
119 |
fail("Can't read test data to run the test: " + testfile);
|
|
120 |
}
|
|
121 |
}
|
|
131 | 122 |
|
132 |
/** |
|
133 |
* Release any objects after tests are complete |
|
134 |
*/ |
|
135 |
public void tearDown() |
|
136 |
{ |
|
137 |
} |
|
123 |
/** |
|
124 |
* Release any objects after tests are complete |
|
125 |
*/ |
|
126 |
public void tearDown() { |
|
127 |
} |
|
138 | 128 |
|
139 |
/** |
|
140 |
* Create a suite of tests to be run together |
|
141 |
*/ |
|
142 |
public static Test suite() |
|
143 |
{ |
|
144 |
TestSuite suite = new TestSuite(); |
|
145 |
suite.addTest(new BuildIndexTest("initialize")); |
|
146 |
suite.addTest(new BuildIndexTest("read")); |
|
147 |
suite.addTest(new BuildIndexTest("buildIndex")); |
|
148 |
return suite; |
|
149 |
} |
|
129 |
/** |
|
130 |
* Create a suite of tests to be run together |
|
131 |
*/ |
|
132 |
public static Test suite() { |
|
133 |
TestSuite suite = new TestSuite(); |
|
134 |
suite.addTest(new BuildIndexTest("initialize")); |
|
135 |
suite.addTest(new BuildIndexTest("read")); |
|
136 |
suite.addTest(new BuildIndexTest("buildIndex")); |
|
137 |
return suite; |
|
138 |
} |
|
150 | 139 |
|
151 |
/** |
|
152 |
* Run an initial test that always passes to check that the test |
|
153 |
* harness is working. |
|
154 |
*/ |
|
155 |
public void initialize() |
|
156 |
{ |
|
157 |
assertTrue(1 == 1); |
|
158 |
} |
|
140 |
/** |
|
141 |
* Run an initial test that always passes to check that the test harness is |
|
142 |
* working. |
|
143 |
*/ |
|
144 |
public void initialize() { |
|
145 |
assertTrue(1 == 1); |
|
146 |
} |
|
159 | 147 |
|
160 |
/** |
|
161 |
* Test the read() function with a known document |
|
162 |
*/ |
|
163 |
public void read() |
|
164 |
{ |
|
165 |
try { |
|
166 |
System.err.println("Test Metacat: " + metacatUrl); |
|
167 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
|
168 |
String identifier = newdocid + ".1"; |
|
169 |
m.login(username, password); |
|
170 |
String response = m.insert(identifier, |
|
171 |
new StringReader(testdocument), null); |
|
172 |
System.err.println(response); |
|
173 |
Reader r = m.read(newdocid+".1"); |
|
174 |
String doc = IOUtil.getAsString(r, true); |
|
175 |
//doc = doc +"\n"; |
|
176 |
System.err.println(doc); |
|
177 |
//assertTrue(doc.equals(testdocument)); |
|
178 |
} catch (MetacatInaccessibleException mie) { |
|
179 |
System.err.println("Metacat is: " + metacatUrl); |
|
180 |
fail("Metacat connection failed." + mie.getMessage()); |
|
181 |
} catch (MetacatAuthException mae) { |
|
182 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
183 |
} catch (InsufficientKarmaException ike) { |
|
184 |
assertTrue(1 == 1); |
|
185 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
186 |
} catch (MetacatException me) { |
|
187 |
fail("Metacat Error:\n" + me.getMessage()); |
|
188 |
} catch (Exception e) { |
|
189 |
fail("General exception:\n" + e.getMessage()); |
|
190 |
} |
|
191 |
} |
|
148 |
/** |
|
149 |
* Test the read() function with a known document |
|
150 |
*/ |
|
151 |
public void read() { |
|
152 |
try { |
|
153 |
System.err.println("Test Metacat: " + metacatUrl); |
|
154 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
|
155 |
String identifier = newdocid + ".1"; |
|
156 |
m.login(username, password); |
|
157 |
String response = m.insert(identifier, new StringReader(testdocument), null); |
|
158 |
System.err.println(response); |
|
159 |
Reader r = m.read(newdocid + ".1"); |
|
160 |
String doc = IOUtil.getAsString(r, true); |
|
161 |
// doc = doc +"\n"; |
|
162 |
System.err.println(doc); |
|
163 |
// assertTrue(doc.equals(testdocument)); |
|
164 |
} catch (MetacatInaccessibleException mie) { |
|
165 |
System.err.println("Metacat is: " + metacatUrl); |
|
166 |
fail("Metacat connection failed." + mie.getMessage()); |
|
167 |
} catch (MetacatAuthException mae) { |
|
168 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
169 |
} catch (InsufficientKarmaException ike) { |
|
170 |
assertTrue(1 == 1); |
|
171 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
172 |
} catch (MetacatException me) { |
|
173 |
fail("Metacat Error:\n" + me.getMessage()); |
|
174 |
} catch (Exception e) { |
|
175 |
fail("General exception:\n" + e.getMessage()); |
|
176 |
} |
|
177 |
} |
|
192 | 178 |
|
193 |
/** |
|
194 |
* Test the buildIndex() function with a known document |
|
195 |
*/ |
|
196 |
public void buildIndex() |
|
197 |
{ |
|
198 |
DocumentImpl d = null; |
|
199 |
try { |
|
200 |
d = new DocumentImpl(newdocid+".1", false); |
|
201 |
d.buildIndex(); |
|
202 |
} catch (McdbException me) { |
|
203 |
System.err.println("Caught McdbException (1): " + me.getMessage()); |
|
204 |
} |
|
205 |
} |
|
179 |
/** |
|
180 |
* Test the buildIndex() function with a known document |
|
181 |
*/ |
|
182 |
public void buildIndex() { |
|
183 |
DocumentImpl d = null; |
|
184 |
try { |
|
185 |
d = new DocumentImpl(newdocid + ".1", false); |
|
186 |
d.buildIndex(); |
|
187 |
} catch (McdbException me) { |
|
188 |
System.err.println("Caught McdbException (1): " + me.getMessage()); |
|
189 |
} |
|
190 |
} |
|
206 | 191 |
|
207 |
/** |
|
208 |
* Create a hopefully unique docid for testing insert and update. Does |
|
209 |
* not include the 'revision' part of the id. |
|
210 |
* |
|
211 |
* @return a String docid based on the current date and time |
|
212 |
*/ |
|
213 |
private String generateDocid() |
|
214 |
{ |
|
215 |
StringBuffer docid = new StringBuffer(prefix); |
|
216 |
docid.append("."); |
|
192 |
/** |
|
193 |
* Create a hopefully unique docid for testing insert and update. Does not |
|
194 |
* include the 'revision' part of the id. |
|
195 |
* |
|
196 |
* @return a String docid based on the current date and time |
|
197 |
*/ |
|
198 |
private String generateDocid() { |
|
199 |
StringBuffer docid = new StringBuffer(prefix); |
|
200 |
docid.append("."); |
|
217 | 201 |
|
218 |
// Create a calendar to get the date formatted properly
|
|
219 |
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
|
|
220 |
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
|
|
221 |
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000);
|
|
222 |
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
|
|
223 |
Calendar calendar = new GregorianCalendar(pdt);
|
|
224 |
Date trialTime = new Date();
|
|
225 |
calendar.setTime(trialTime);
|
|
226 |
docid.append(calendar.get(Calendar.YEAR));
|
|
227 |
docid.append(calendar.get(Calendar.DAY_OF_YEAR));
|
|
228 |
docid.append(calendar.get(Calendar.HOUR_OF_DAY));
|
|
229 |
docid.append(calendar.get(Calendar.MINUTE));
|
|
230 |
docid.append(calendar.get(Calendar.SECOND));
|
|
202 |
// Create a calendar to get the date formatted properly
|
|
203 |
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
|
|
204 |
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
|
|
205 |
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
|
|
206 |
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
|
|
207 |
Calendar calendar = new GregorianCalendar(pdt);
|
|
208 |
Date trialTime = new Date();
|
|
209 |
calendar.setTime(trialTime);
|
|
210 |
docid.append(calendar.get(Calendar.YEAR));
|
|
211 |
docid.append(calendar.get(Calendar.DAY_OF_YEAR));
|
|
212 |
docid.append(calendar.get(Calendar.HOUR_OF_DAY));
|
|
213 |
docid.append(calendar.get(Calendar.MINUTE));
|
|
214 |
docid.append(calendar.get(Calendar.SECOND));
|
|
231 | 215 |
|
232 |
return docid.toString();
|
|
233 |
}
|
|
216 |
return docid.toString();
|
|
217 |
}
|
|
234 | 218 |
} |
test/edu/ucsb/nceas/metacattest/ReplicationServerListTest.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
package edu.ucsb.nceas.metacattest; |
28 | 28 |
|
29 |
import edu.ucsb.nceas.MCTestCase; |
|
29 | 30 |
import edu.ucsb.nceas.metacat.*; |
30 | 31 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
31 | 32 |
import edu.ucsb.nceas.metacat.util.MetaCatUtil; |
32 |
//import edu.ucsb.nceas.morpho.framework.*; |
|
33 | 33 |
import junit.framework.Test; |
34 |
import junit.framework.TestCase; |
|
35 |
import junit.framework.TestResult; |
|
36 | 34 |
import junit.framework.TestSuite; |
37 | 35 |
import org.apache.commons.logging.Log; |
38 | 36 |
import org.apache.commons.logging.LogFactory; |
39 | 37 |
|
40 | 38 |
import java.io.*; |
41 | 39 |
import java.net.*; |
42 |
import java.util.*; |
|
43 | 40 |
|
44 |
|
|
45 | 41 |
/** |
46 | 42 |
* A JUnit test for testing Step class processing |
47 | 43 |
*/ |
48 |
public class ReplicationServerListTest extends TestCase |
|
44 |
public class ReplicationServerListTest extends MCTestCase
|
|
49 | 45 |
{ |
50 | 46 |
private static String metacatReplicationURL; |
51 | 47 |
/* Initialize properties*/ |
... | ... | |
55 | 51 |
{ |
56 | 52 |
metacatReplicationURL= |
57 | 53 |
PropertyService.getProperty("junitreplicationurl"); |
58 |
PropertyService.getInstance("build/tests"); |
|
59 | 54 |
MetaCatUtil.pathsForIndexing |
60 | 55 |
= MetaCatUtil.getOptionList(PropertyService.getProperty("xml.indexPaths")); |
61 | 56 |
} |
Also available in: Unified diff
Convert remainder of tests that use PropertyService to extend the MCTestCase class