1 |
9241
|
tao
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2010 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author: jones $'
|
7 |
|
|
* '$Date: 2010-02-03 17:58:12 -0900 (Wed, 03 Feb 2010) $'
|
8 |
|
|
* '$Revision: 5211 $'
|
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 |
|
|
|
25 |
|
|
package edu.ucsb.nceas.metacattest;
|
26 |
|
|
|
27 |
|
|
import java.io.ByteArrayInputStream;
|
28 |
|
|
import java.io.InputStream;
|
29 |
|
|
import java.sql.SQLException;
|
30 |
|
|
import java.io.File;
|
31 |
|
|
|
32 |
|
|
import junit.framework.Test;
|
33 |
|
|
import junit.framework.TestSuite;
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
import edu.ucsb.nceas.MCTestCase;
|
38 |
|
|
import edu.ucsb.nceas.metacat.AccessionNumber;
|
39 |
|
|
import edu.ucsb.nceas.metacat.AccessionNumberException;
|
40 |
|
|
import edu.ucsb.nceas.metacat.IdentifierManager;
|
41 |
|
|
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
|
42 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatAuthException;
|
43 |
|
|
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
|
44 |
|
|
|
45 |
|
|
import org.apache.commons.io.FileUtils;
|
46 |
|
|
|
47 |
|
|
public class ISO119139Test extends MCTestCase {
|
48 |
|
|
|
49 |
|
|
public ISO119139Test(String name) {
|
50 |
|
|
super(name);
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Create a suite of tests to be run together
|
55 |
|
|
*/
|
56 |
|
|
public static Test suite() {
|
57 |
|
|
TestSuite suite = new TestSuite();
|
58 |
|
|
// Test basic functions
|
59 |
|
|
suite.addTest(new ISO119139Test("TestInsertDocument"));
|
60 |
|
|
return suite;
|
61 |
|
|
}
|
62 |
|
|
/**
|
63 |
|
|
* Initialize the connection to metacat, and insert a document to be
|
64 |
|
|
* used for testing with a known docid.
|
65 |
|
|
*/
|
66 |
|
|
public void setUp() throws Exception{
|
67 |
|
|
metacatConnectionNeeded = true;
|
68 |
|
|
super.setUp();
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
/**
|
76 |
|
|
* Insert a test document, returning the docid that was used.
|
77 |
|
|
*/
|
78 |
|
|
public void TestInsertDocument() throws Exception {
|
79 |
|
|
String xml = FileUtils.readFileToString(new File("./test/isoTestNodc1.xml"), "UTF-8");
|
80 |
|
|
String docid = generateDocumentId() + ".1";
|
81 |
|
|
try {
|
82 |
|
|
m.login(username, password);
|
83 |
|
|
String response = insertDocumentId(docid, xml, true, false);
|
84 |
|
|
} catch (MetacatAuthException e) {
|
85 |
|
|
fail(e.getMessage());
|
86 |
|
|
} catch (MetacatInaccessibleException e) {
|
87 |
|
|
fail(e.getMessage());
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
}
|