Revision 3278
Added by Jing Tao over 17 years ago
test/edu/ucsb/nceas/metacattest/MetaCatQueryPerformanceTest.java | ||
---|---|---|
1 |
package edu.ucsb.nceas.metacattest; |
|
2 |
|
|
3 |
|
|
4 |
import java.io.FileReader; |
|
5 |
import java.io.Reader; |
|
6 |
import edu.ucsb.nceas.metacat.client.Metacat; |
|
7 |
import edu.ucsb.nceas.metacat.client.MetacatAuthException; |
|
8 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
|
9 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
|
10 |
import edu.ucsb.nceas.utilities.IOUtil; |
|
11 |
import junit.framework.Test; |
|
12 |
import junit.framework.TestCase; |
|
13 |
import junit.framework.TestSuite; |
|
14 |
public class MetaCatQueryPerformanceTest extends TestCase{ |
|
15 |
|
|
16 |
/** |
|
17 |
* Create a suite of tests to be run together |
|
18 |
*/ |
|
19 |
public static Test suite() |
|
20 |
{ |
|
21 |
TestSuite suite = new TestSuite(); |
|
22 |
return suite; |
|
23 |
} |
|
24 |
|
|
25 |
public static void main(String[] arg) |
|
26 |
{ |
|
27 |
if (arg != null & arg.length == 2) |
|
28 |
{ |
|
29 |
String metacatURL = arg[0]; |
|
30 |
String queryFilePath = arg[1]; |
|
31 |
query(metacatURL, queryFilePath); |
|
32 |
} |
|
33 |
else |
|
34 |
{ |
|
35 |
System.out.println("Usage: java MetaCatQueryPerformance metacatURL queryFilePath"); |
|
36 |
} |
|
37 |
} |
|
38 |
public static void query(String metacatURL, String queryFile) |
|
39 |
{ |
|
40 |
try |
|
41 |
{ |
|
42 |
Thread.sleep(120000); |
|
43 |
Metacat m = MetacatFactory.createMetacatConnection(metacatURL);; |
|
44 |
FileReader fr = new FileReader(queryFile); |
|
45 |
Reader r = m.query(fr); |
|
46 |
//System.out.println("Starting query..."); |
|
47 |
String result = IOUtil.getAsString(r, true); |
|
48 |
//System.out.println("Query result:\n" + result); |
|
49 |
|
|
50 |
} catch (Exception e) { |
|
51 |
System.err.println("General exception:\n" + e.getMessage()); |
|
52 |
} |
|
53 |
} |
|
54 |
} |
|
0 | 55 |
Also available in: Unified diff
A query client to test metacat performance