@@ -236,10 +236,10 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
236236 }
237237 // Load remote artifacts before local ones.
238238 if (mainRemoteArtifactsToImport != null && !mainRemoteArtifactsToImport .isEmpty ()) {
239- mainRemoteArtifactsToImport .forEach (remoteArtifact -> this . downloadArtifact (remoteArtifact , true ));
239+ mainRemoteArtifactsToImport .forEach (remoteArtifact -> downloadArtifact (getHttpEndpoint (), remoteArtifact , true ));
240240 }
241241 if (secondaryRemoteArtifactsToImport != null && !secondaryRemoteArtifactsToImport .isEmpty ()) {
242- secondaryRemoteArtifactsToImport .forEach (remoteArtifact -> this . downloadArtifact (remoteArtifact , false ));
242+ secondaryRemoteArtifactsToImport .forEach (remoteArtifact -> downloadArtifact (getHttpEndpoint (), remoteArtifact , false ));
243243 }
244244 // Load local ones that may override remote ones.
245245 if (mainArtifactsToImport != null && !mainArtifactsToImport .isEmpty ()) {
@@ -655,7 +655,7 @@ public static List<UnidirectionalEvent> getEventMessagesForTestCase(String micro
655655 * @throws ArtifactLoadException If artifact cannot be correctly downloaded in container (probably not found)
656656 */
657657 public void downloadAsMainRemoteArtifact (String remoteArtifactUrl ) throws ArtifactLoadException {
658- downloadArtifact (new RemoteArtifact (remoteArtifactUrl , null ), true );
658+ downloadArtifact (getHttpEndpoint (), new RemoteArtifact (remoteArtifactUrl , null ), true );
659659 }
660660
661661 /**
@@ -664,7 +664,27 @@ public void downloadAsMainRemoteArtifact(String remoteArtifactUrl) throws Artifa
664664 * @throws ArtifactLoadException If artifact cannot be correctly downloaded in container (probably not found)
665665 */
666666 public void downloadAsSecondaryRemoteArtifact (String remoteArtifactUrl ) throws ArtifactLoadException {
667- downloadArtifact (new RemoteArtifact (remoteArtifactUrl , null ), false );
667+ downloadArtifact (getHttpEndpoint (), new RemoteArtifact (remoteArtifactUrl , null ), false );
668+ }
669+
670+ /**
671+ * Download a remote artifact as a primary or main one within the Microcks container.
672+ * @param microcksContainerHttpEndpoint The Http endpoint where to reach running MicrocksContainer
673+ * @param remoteArtifactUrl The URL to remote artifact (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
674+ * @throws ArtifactLoadException If artifact cannot be correctly downloaded in container (probably not found)
675+ */
676+ public static void downloadAsMainRemoteArtifact (String microcksContainerHttpEndpoint , String remoteArtifactUrl ) throws ArtifactLoadException {
677+ downloadArtifact (microcksContainerHttpEndpoint , new RemoteArtifact (remoteArtifactUrl , null ), true );
678+ }
679+
680+ /**
681+ * Download a remote artifact as a secondary one within the Microcks container.
682+ * @param microcksContainerHttpEndpoint The Http endpoint where to reach running MicrocksContainer
683+ * @param remoteArtifactUrl The URL to remote artifact (OpenAPI, Postman collection, Protobuf, GraphQL schema, ...)
684+ * @throws ArtifactLoadException If artifact cannot be correctly downloaded in container (probably not found)
685+ */
686+ public static void downloadAsSecondaryRemoteArtifact (String microcksContainerHttpEndpoint , String remoteArtifactUrl ) throws ArtifactLoadException {
687+ downloadArtifact (microcksContainerHttpEndpoint , new RemoteArtifact (remoteArtifactUrl , null ), false );
668688 }
669689
670690 /**
@@ -833,10 +853,10 @@ private void importArtifact(String artifactPath, boolean mainArtifact) {
833853 }
834854 }
835855
836- private void downloadArtifact (RemoteArtifact remoteArtifact , boolean mainArtifact ) throws ArtifactLoadException {
856+ private static void downloadArtifact (String microcksContainerHttpEndpoint , RemoteArtifact remoteArtifact , boolean mainArtifact ) throws ArtifactLoadException {
837857 try {
838858 // Use the artifact/download endpoint to download the artifact.
839- URL url = new URL (getHttpEndpoint () + "/api/artifact/download " );
859+ URL url = new URL (microcksContainerHttpEndpoint + "/api/import " );
840860 HttpURLConnection httpConn = (HttpURLConnection ) url .openConnection ();
841861 httpConn .setUseCaches (false );
842862 httpConn .setRequestMethod ("POST" );
0 commit comments