Project

General

Profile

« Previous | Next » 

Revision 1787

Added by Jing Tao over 20 years ago

Add a test case for query method.

View differences:

test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java
51 51
    private String failpass = "uidfnkj43987yfdn";
52 52
    private String docid = "jones.204.22";
53 53
    private String testfile = "test/jones.204.22.xml";
54
    private String queryFile = "test/query.xml";
54 55
    //private String docid = "Gramling.61.26";
55 56
    private String testdocument = "";
56 57
    
......
103 104
        suite.addTest(new MetacatClientTest("invalidLogin"));
104 105
        suite.addTest(new MetacatClientTest("login"));
105 106
        suite.addTest(new MetacatClientTest("read"));
107
        suite.addTest(new MetacatClientTest("query"));
106 108
        return suite;
107 109
    }
108 110
  
......
166 168
            fail("General exception:\n" + e.getMessage());
167 169
        }
168 170
    }
169

  
171
    
172
    /**
173
     * Test the query() function with a known document
174
     */
175
    public void query()
176
    {
177
        try {
178
            FileReader fr = new FileReader(queryFile);
179
            Reader r = m.query(fr);
180
            String result = readerToString(r);
181
            assertTrue(result.indexOf("obfs.100.3")!=-1);
182
        } catch (MetacatAuthException mae) {
183
            fail("Authorization failed:\n" + mae.getMessage());
184
        } catch (MetacatInaccessibleException mie) {
185
            fail("Metacat Inaccessible:\n" + mie.getMessage());
186
        } catch (Exception e) {
187
            fail("General exception:\n" + e.getMessage());
188
        }
189
    }
190
    
170 191
/*
171 192
 * PRIVATE METHODS
172 193
 */

Also available in: Unified diff