source: FCSEndpointTester/trunk/src/main/java/eu/clarin/fcs/tester/tests/TestScan3.java @ 7196

Last change on this file since 7196 was 7196, checked in by Oliver Schonefeld, 6 years ago
  • rewrite to use SRUClient instead of SRUSimpleClient
  • add Tests for Endpoint Description (FCS 1.0 and FCS 2.0)
  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/**
2 * This software is copyright (c) 2013 by
3 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
4 * This is free software. You can redistribute it
5 * and/or modify it under the terms described in
6 * the GNU General Public License v3 of which you
7 * should have received a copy. Otherwise you can download
8 * it from
9 *
10 *   http://www.gnu.org/licenses/gpl-3.0.txt
11 *
12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
13 *
14 * @license http://www.gnu.org/licenses/gpl-3.0.txt
15 *  GNU General Public License v3
16 */
17package eu.clarin.fcs.tester.tests;
18
19import eu.clarin.fcs.tester.FCSTest;
20import eu.clarin.fcs.tester.FCSTestCase;
21import eu.clarin.fcs.tester.FCSTestContext;
22import eu.clarin.fcs.tester.FCSTestProfile;
23import eu.clarin.fcs.tester.FCSTestResult;
24import eu.clarin.sru.client.SRUClient;
25import eu.clarin.sru.client.SRUClientException;
26import eu.clarin.sru.client.SRUScanRequest;
27import eu.clarin.sru.client.SRUScanResponse;
28
29@FCSTestCase(priority=2030, profiles = {
30        FCSTestProfile.CLARIN_FCS_LEGACY
31})
32public class TestScan3 extends FCSTest {
33
34    @Override
35    public String getName() {
36        return "Scan";
37    }
38
39
40    @Override
41    public String getDescription() {
42        return "Scan on 'fcs.resource = root' with 'maximumTerms' with value 1";
43    }
44
45
46    @Override
47    public String getExpected() {
48        return "Exactly one term returned within scan response";
49    }
50
51
52    @Override
53    public FCSTestResult perform(FCSTestContext context, SRUClient client) throws SRUClientException {
54        SRUScanRequest req = context.createScanRequest();
55        req.setScanClause("fcs.resource=root");
56        req.setMaximumTerms(1);
57        SRUScanResponse res = client.scan(req);
58
59        if (res.getDiagnosticsCount() > 0) {
60            if (findDiagnostic(res, "info:srw/diagnostic/1/4")) {
61                return makeWarning("Endpoint does not support 'scan' operation");
62            } else {
63                return makeWarningUnexpectedDiagnostics();
64            }
65        } else {
66            int count = getTermsCount(res);
67            if (count == 1) {
68                return makeSuccess();
69            } else if (count > 1) {
70                return makeWarning("Endpoint did not honor 'maximumTerms' argument");
71            }
72        }
73        return makeGenericError();
74    }
75
76}
Note: See TracBrowser for help on using the repository browser.