ORC tests: added logging; use GET instead of POST for country list

This commit is contained in:
Axel Uhl committed 2021-01-13 17:01:15 +01:00
1 parent c502b862f0
commit cc67e94db3
2 files changed
+8 -4

No files matched your search

@@ -10,6 +10,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.StreamSupport;
import javax.xml.parsers.ParserConfigurationException;
@@ -51,6 +52,8 @@ import com.sap.sse.common.impl.DegreeBearingImpl;
*
*/
public class TestORCPerformanceCurve {
private static final Logger logger = Logger.getLogger(TestORCPerformanceCurve.class.getName());
// set true to see all the differences i
private final boolean collectErrors = true;
@@ -97,7 +100,7 @@ public class TestORCPerformanceCurve {
legs.add(new ORCPerformanceCurveLegImpl(new NauticalMileDistance(1.03), new DegreeBearingImpl(15)));
legs.add(new ORCPerformanceCurveLegImpl(new NauticalMileDistance(1.03), new DegreeBearingImpl(165)));
legs.add(new ORCPerformanceCurveLegImpl(new NauticalMileDistance(1.17), new DegreeBearingImpl(180)));
alturaCourse = new ORCPerformanceCurveCourseImpl(legs); //this course is the same course as seen in the Altura "IMS Explanation" sheet
alturaCourse = new ORCPerformanceCurveCourseImpl(legs); // this course is the same course as seen in the Altura "IMS Explanation" sheet
// Local File:
File fileGER = new File(RESOURCES + "GER2019.json");
importerLocal = new ORCCertificatesJsonImporter().read(new FileInputStream(fileGER));
@@ -109,6 +112,7 @@ public class TestORCPerformanceCurve {
.stream(ORCPublicCertificateDatabaseImpl.INSTANCE.getCountriesWithValidCertificates().spliterator(),
/* parallel */ false)
.max((c1, c2) -> c1.getCertCount() - c2.getCertCount()).get().getIssuingCountry();
logger.info("Trying to read country certificates for "+countryWithMostValidCertificates);
importerOnline = new ORCCertificatesJsonImporter().read(new URL("https://data.orc.org/public/WPub.dll?action=DownBoatRMS&CountryId="+
countryWithMostValidCertificates.getThreeLetterIOCCode()+"&ext=json").openStream());
}
@@ -391,10 +391,10 @@ public class ORCPublicCertificateDatabaseImpl implements ORCPublicCertificateDat
final Set<ORCPublicCertificateDatabase.CountryOverview> result = new HashSet<>();
final HttpClient client = HttpClientBuilder.create().build();
final List<NameValuePair> params = new ArrayList<>();
final HttpPost postRequest = new HttpPost(COUNTRY_OVERVIEW_URL);
addAuthorizationHeader(postRequest);
final HttpGet getRequest = new HttpGet(COUNTRY_OVERVIEW_URL);
addAuthorizationHeader(getRequest);
logger.fine(()->"Searching for "+params+"...");
final HttpResponse processorResponse = client.execute(postRequest);
final HttpResponse processorResponse = client.execute(getRequest);
final InputStream content = processorResponse.getEntity().getContent();
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document document = builder.parse(content);