Project

General

Profile

« Previous | Next » 

Revision 7693

Added by Jing Tao over 11 years ago

Add code to test title for the query result.

View differences:

test/edu/ucsb/nceas/metacat/dataone/SolrQueryAccessFilterTest.java
61 61
    private static final String INTRUSTCERTFILE = "test/test-credentials/test-user.pem";
62 62
    private static final String IDXPATH = "//response/result/doc/str[@name='id']/text()";
63 63
    private static final String TITLEPATH = "//response/result/doc/str[@name='title']/text()";
64
    private static final String TITLE = "Mollusc population abundance monitoring: Fall 2000 mid-marsh and creekbank infaunal and epifaunal mollusc abundance based on collections from GCE marsh, monitoring sites 1-10";
64 65
    
65 66
    /**
66 67
     * Build the test suite
......
119 120
        Document doc = generateDoc(input);
120 121
        String resultId  = extractElementValue(doc, IDXPATH);
121 122
        assertTrue("In the testPublicReadable method, the query result should have the id "+id.getValue()+ " rather than "+resultId, resultId.equals(id.getValue()));
123
        String title = extractElementValue(doc, TITLEPATH);
124
        assertTrue(title.equals(TITLE));
122 125
        Session querySession2 = getSession(QUERYUSER, null);
123 126
        input = query(querySession2, id);
124 127
        doc = generateDoc(input);
125 128
        String resultId2 = extractElementValue(doc, IDXPATH);
126 129
        assertTrue("In the testPublicReadable method, the query result should have the id "+id.getValue()+ " rather than "+resultId2, resultId2.equals(id.getValue()));
130
        title = extractElementValue(doc, TITLEPATH);
131
        assertTrue(title.equals(TITLE));
132
        
127 133
        archive(session, id);
128
        
129 134
        input = query(querySession2, id);
130 135
        doc = generateDoc(input);
131 136
        String resultId3 = extractElementValue(doc, IDXPATH);
......
156 161
        doc = generateDoc(input);
157 162
        resultId = extractElementValue(doc, IDXPATH);
158 163
        assertTrue("In the testOnlyUserReadable method, the query result for the user "+QUERYUSER+" should have the id "+id.getValue()+" rather than "+resultId, resultId.equals(id.getValue()));
164
        String title = extractElementValue(doc, TITLEPATH);
165
        assertTrue(title.equals(TITLE));
159 166
        archive(session, id);
160 167
    }
161 168
    
......
187 194
        doc = generateDoc(input);
188 195
        resultId = extractElementValue(doc, IDXPATH);
189 196
        assertTrue("In the testGroupReadable method, the query result for the user "+QUERYUSER+" which belong to the group should have the id "+id.getValue(), resultId.equals(id.getValue()));
197
        String title = extractElementValue(doc, TITLEPATH);
198
        assertTrue(title.equals(TITLE));
190 199
        archive(session, id);
191 200
    }
192 201
    
......
224 233
        doc = generateDoc(input);
225 234
        resultId = extractElementValue(doc, IDXPATH);
226 235
        assertTrue("In the testOnlyRightHolderReadable method, the query result for the creator "+CREATEUSER+" should be "+id.getValue(), id.getValue().equals(resultId));
236
        String title = extractElementValue(doc, TITLEPATH);
237
        assertTrue(title.equals(TITLE));
227 238
        archive(session, id);
228 239
    }
229 240
    
......
247 258
        InputStream input = query(querySession, id);
248 259
        Document doc = generateDoc(input);
249 260
        String resultId = extractElementValue(doc, IDXPATH);
250
        //assertTrue("In the testDistrustCertificate method, the query result id should be "+id.getValue(), id.getValue().equals(resultId));
261
        assertTrue("In the testDistrustCertificate method, the query result id should be "+id.getValue(), id.getValue().equals(resultId));
262
        String title = extractElementValue(doc, TITLEPATH);
263
        assertTrue(title.equals(TITLE));
251 264
        
252 265
        //Use the libclient without the session, the user shouldn't query the document since its certificate is distrusted and it will be considered as the public.
253 266
        org.dataone.service.types.v1.Node node = MNodeService.getInstance(request).getCapabilities();

Also available in: Unified diff