3333import java .util .stream .Collectors ;
3434
3535import static org .junit .jupiter .api .Assertions .*;
36-
36+ import static org . vcell . util . network . ClientDownloader . downloadBytes ;
3737
3838
3939@ Tag ("Fast" )
@@ -55,6 +55,8 @@ public static void tearDown() {
5555 }
5656
5757 /*
58+ Given a reactome pathway id, it downloads a pathway as xml document
59+
5860 pathway = {Pathway@14156} "[Pathway: primaryId="http://bioregistry.io/reactome:R-HSA-5683177"; name="Defective ABCC8 can cause hypo- and hyper-glycemias";\ndataSource=[DataSource: primaryId="pc14:reactome"; name="pc14:reactome"]]"
5961 primaryId = "http://bioregistry.io/reactome:R-HSA-5683177"
6062 name = "Defective ABCC8 can cause hypo- and hyper-glycemias"
@@ -108,46 +110,6 @@ public void searchTest() throws IOException {
108110
109111 // --- Utilities ---------------------------------------------------------------------------------------------------
110112
111- private static String downloadBytes (final URL url , Duration timeout ) {
112- try {
113- boolean bIgnoreHostMismatch = PropertyLoader .getBooleanProperty (PropertyLoader .sslIgnoreHostMismatch , false );
114- boolean bIgnoreCertProblems = PropertyLoader .getBooleanProperty (PropertyLoader .sslIgnoreCertProblems , false );
115- boolean ignoreCertProblems = bIgnoreCertProblems || bIgnoreHostMismatch ;
116-
117- HttpClient client ;
118- if (ignoreCertProblems ) {
119- // create a trust manager that does not validate certificate chains
120- TrustManager [] trustAllCerts = new TrustManager [] {
121- new X509TrustManager () {
122- public X509Certificate [] getAcceptedIssuers () { return new X509Certificate [0 ]; }
123- public void checkClientTrusted (X509Certificate [] certs , String authType ) { }
124- public void checkServerTrusted (X509Certificate [] certs , String authType ) { }
125- }
126- };
127-
128- // Install the all-trusting trust manager
129- SSLContext sslContext = SSLContext .getInstance ("SSL" );
130- sslContext .init (null , trustAllCerts , new java .security .SecureRandom ());
131-
132- // Create an HttpClient that uses the custom SSL context
133- client = HttpClient .newBuilder ()
134- .sslContext (sslContext )
135- .build ();
136- } else {
137- // Use default SSL verification
138- client = HttpClient .newHttpClient ();
139- }
140-
141- // Send a GET request
142- java .net .http .HttpRequest request = java .net .http .HttpRequest .newBuilder ().uri (url .toURI ()).timeout (timeout ).GET ().build ();
143- java .net .http .HttpResponse <String > response = client .send (request , java .net .http .HttpResponse .BodyHandlers .ofString ());
144-
145- return response .body ();
146- } catch (NoSuchAlgorithmException | KeyManagementException | URISyntaxException | IOException | InterruptedException e ) {
147- throw new RuntimeException (e );
148- }
149- }
150-
151113 // wrapper to get a jdom2 Document
152114 private static org .jdom2 .Document downloadAndParseXml (URL url , Duration timeout ) {
153115 String xmlContent = downloadBytes (url , timeout );
0 commit comments