Changeset 7169 for FCSEndpointTester


Ignore:
Timestamp:
02/01/18 10:49:20 (6 years ago)
Author:
Oliver Schonefeld
Message:
  • tweak auto-detect algorithm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FCSEndpointTester/trunk/src/main/java/eu/clarin/fcs/tester/FCSEndpointTester.java

    r7116 r7169  
    225225                if (ed.getVersion() == 1) {
    226226                    profile = FCSTestProfile.CLARIN_FCS_1_0;
    227                 } else if (ed.getVersion() == 2) {
    228                     throw new SRUClientException("CLARIN-FCS version 2.0 " +
    229                             "MUST use SRU 2.0. Endpoint used SRU 1.2 " +
    230                             "but claimed to support FCS 2.0 in it's " +
    231                             "endpoint description!");
    232227                }
    233228            } else {
     229                logger.debug("assume legacy");
    234230                profile = FCSTestProfile.CLARIN_FCS_LEGACY;
    235231            }
     
    243239                        ClarinFCSConstants.TRUE);
    244240                request.setParseRecordDataEnabled(true);
    245                 response = client.explain(request);
    246 
    247                 ed = response.getFirstExtraResponseData(
    248                                 ClarinFCSEndpointDescription.class);
    249                 if (ed != null) {
    250                     if (ed.getVersion() == 2) {
    251                         profile = FCSTestProfile.CLARIN_FCS_2_0;
     241                try {
     242                    response = client.explain(request);
     243
     244                    ed = response.getFirstExtraResponseData(
     245                            ClarinFCSEndpointDescription.class);
     246                    if (ed != null) {
     247                        if (ed.getVersion() == 2) {
     248                            profile = FCSTestProfile.CLARIN_FCS_2_0;
     249                        }
     250                    }
     251                } catch (SRUClientException e) {
     252                    if ((e.getMessage() != null) && (e.getMessage()
     253                            .contains("responded with different version"))) {
     254                        throw new SRUClientException(
     255                                "Seriously broken Endpoint: when trying to " +
     256                                "detect FCS 2.0 the Endpoint illegally " +
     257                                "responded with a SRU 1.2 reponse to a " +
     258                                "SRU 2.0 request!");
     259                    } else {
     260                        throw e;
    252261                    }
    253262                }
     
    325334            try {
    326335                handler.reset();
     336                logcapturehandler.publish(new LogRecord(Level.FINE,
     337                        "running test class " + test.getClass().getName()));
    327338                result = test.perform(context, client, handler);
    328339                result.setLogRecords(logcapturehandler.getLogRecords());
Note: See TracChangeset for help on using the changeset viewer.