diff --git a/pom.xml b/pom.xml
index eba4c1fe..af4e5f3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,17 @@
3.6.4
provided
+
+ org.apache.maven.wagon
+ wagon-http
+ 3.5.3
+
+
+ org.apache.maven
+ maven-compat
+ ${maven.version}
+ provided
+
com.google.guava
guava
@@ -172,12 +183,6 @@
3.3.0
test
-
- org.apache.maven
- maven-compat
- ${maven.version}
- test
-
org.apache.wink
wink-component-test-support
diff --git a/src/main/java/ch/ivyteam/ivy/maven/InstallEngineMojo.java b/src/main/java/ch/ivyteam/ivy/maven/InstallEngineMojo.java
index d53e67ae..22b6bd2c 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/InstallEngineMojo.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/InstallEngineMojo.java
@@ -32,6 +32,7 @@
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
@@ -49,7 +50,7 @@
*
* Command line invocation is supported. E.g.
*
- *
+ *
*
* mvn com.axonivy.ivy.ci:project-build-plugin:9.1.0:installEngine
* -Divy.engine.directory=c:/axonviy/engine
@@ -76,7 +77,7 @@ public class InstallEngineMojo extends AbstractEngineMojo {
* it must be published manually to an accessible plugin repository. The
* expected artifact descriptor is:
*
- *
+ *
*
* groupId=com.axonivy.ivy
* artifactId=engine
@@ -84,7 +85,7 @@ public class InstallEngineMojo extends AbstractEngineMojo {
* classifier=!osArchitecture! (e.g. Slim_All_x64)
* extension=zip
*
- *
+ *
* @since 7.4
*/
@Parameter(property = "ivy.engine.download.from.maven", defaultValue = "false")
@@ -141,6 +142,10 @@ public class InstallEngineMojo extends AbstractEngineMojo {
@Parameter(property = "ivy.engine.auto.install", defaultValue = "true")
boolean autoInstallEngine;
+ @Component
+ @SuppressWarnings("deprecation")
+ org.apache.maven.artifact.manager.WagonManager wagonManager;
+
@Override
public void execute() throws MojoExecutionException {
getLog().info("Provide engine for ivy version " + ivyVersion);
@@ -159,7 +164,7 @@ private void ensureEngineIsInstalled() throws MojoExecutionException {
ArtifactVersion installedEngineVersion = getInstalledEngineVersion(getRawEngineDirectory());
if (installedEngineVersion == null ||
- !ivyVersionRange.containsVersion(installedEngineVersion)) {
+ !ivyVersionRange.containsVersion(installedEngineVersion)) {
handleWrongIvyVersion(installedEngineVersion);
}
}
@@ -221,10 +226,12 @@ public EngineDownloader getDownloader() throws MojoExecutionException {
if (downloadUsingMaven) {
return new MavenEngineDownloader(getLog(), ivyVersion, osArchitecture, pluginRepositories,
repositorySystem, repositorySession);
- } else {
- return new URLEngineDownloader(engineDownloadUrl, engineListPageUrl, osArchitecture, ivyVersion,
- getIvyVersionRange(), getLog(), getDownloadDirectory());
}
+
+ @SuppressWarnings("deprecation")
+ ProxyInfoProvider proxies = wagonManager::getProxy;
+ return new URLEngineDownloader(engineDownloadUrl, engineListPageUrl, osArchitecture, ivyVersion,
+ getIvyVersionRange(), getLog(), getDownloadDirectory(), proxies);
}
static String ivyEngineVersionOfZip(String engineZipFileName) {
diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java b/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
index 60f2ad29..71fbc720 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
@@ -6,7 +6,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
+import java.nio.file.Path;
import java.util.Scanner;
import java.util.regex.Pattern;
@@ -16,21 +16,27 @@
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.wagon.providers.http.HttpWagon;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
+import org.apache.maven.wagon.repository.Repository;
import ch.ivyteam.ivy.maven.engine.EngineVersionEvaluator;
public class URLEngineDownloader implements EngineDownloader {
+
+ private final URL engineDownloadUrl;
+ private final URL engineListPageUrl;
+ private final String osArchitecture;
+ private final String ivyVersion;
+ private final VersionRange ivyVersionRange;
+ private final Log log;
+ private final File downloadDirectory;
private String zipFileName = null;
- private URL engineDownloadUrl = null;
- private URL engineListPageUrl = null;
- private String osArchitecture = null;
- private String ivyVersion = null;
- private VersionRange ivyVersionRange;
- private Log log;
- private File downloadDirectory;
+ public ProxyInfoProvider proxies;
public URLEngineDownloader(URL engineDownloadUrl, URL engineListPageUrl, String osArchitecture,
- String ivyVersion, VersionRange ivyVersionRange, Log log, File downloadDirectory) {
+ String ivyVersion, VersionRange ivyVersionRange, Log log, File downloadDirectory,
+ ProxyInfoProvider proxies) {
this.engineDownloadUrl = engineDownloadUrl;
this.engineListPageUrl = engineListPageUrl;
this.osArchitecture = osArchitecture;
@@ -38,38 +44,49 @@ public URLEngineDownloader(URL engineDownloadUrl, URL engineListPageUrl, String
this.ivyVersionRange = ivyVersionRange;
this.log = log;
this.downloadDirectory = downloadDirectory;
+ this.proxies = proxies;
}
@Override
public File downloadEngine() throws MojoExecutionException {
- URL downloadUrlToUse = (engineDownloadUrl != null) ? engineDownloadUrl
- : findEngineDownloadUrlFromListPage();
+ URL downloadUrlToUse = engineDownloadUrl;
+ if (downloadUrlToUse == null) {
+ downloadUrlToUse = findEngineDownloadUrlFromListPage();
+ }
return downloadEngineFromUrl(downloadUrlToUse);
}
private URL findEngineDownloadUrlFromListPage() throws MojoExecutionException {
- try (InputStream pageStream = new UrlRedirectionResolver().followRedirections(engineListPageUrl)) {
- return findEngineDownloadUrl(pageStream);
+ try {
+ var repo = new Repository("engine.list.page", engineListPageUrl.toExternalForm());
+ Path index = Files.createTempFile("page", ".html");
+ wagonDownload(repo, "", index);
+ try (InputStream pageStream = Files.newInputStream(index)) {
+ return findEngineDownloadUrl(pageStream);
+ } finally {
+ Files.deleteIfExists(index);
+ }
} catch (IOException ex) {
- throw new MojoExecutionException(
- "Failed to find engine download link in list page " + engineListPageUrl, ex);
+ throw new MojoExecutionException("Failed to find engine download link in list page " + engineListPageUrl, ex);
}
}
private File downloadEngineFromUrl(URL engineUrl) throws MojoExecutionException {
+ File downloadZip = evaluateTargetFile(engineUrl);
try {
- File downloadZip = evaluateTargetFile(engineUrl);
log.info("Starting engine download from " + engineUrl);
- Files.copy(engineUrl.openStream(), downloadZip.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ var repo = new Repository("engine.repo", StringUtils.substringBeforeLast(engineUrl.toExternalForm(), "/"));
+ var resource = StringUtils.substringAfterLast(engineUrl.getPath(), "/");
+ wagonDownload(repo, resource, downloadZip.toPath());
return downloadZip;
- } catch (IOException ex) {
+ } catch (Exception ex) {
throw new MojoExecutionException("Failed to download engine from '" + engineUrl + "' to '"
+ downloadDirectory + "'", ex);
}
}
private File evaluateTargetFile(URL engineUrl) {
- zipFileName = StringUtils.substringAfterLast(engineUrl.toExternalForm(), "/");
+ zipFileName = StringUtils.substringAfterLast(engineUrl.getPath(), "/");
File downloadZip = new File(downloadDirectory, zipFileName);
int tempFileSuffix = 0;
while (downloadZip.exists()) {
@@ -80,6 +97,18 @@ private File evaluateTargetFile(URL engineUrl) {
return downloadZip;
}
+ private void wagonDownload(Repository repo, String resource, Path target) throws MojoExecutionException {
+ HttpWagon wagon = new HttpWagon();
+ try {
+ wagon.connect(repo, null, proxies);
+ wagon.get(resource, target.toFile());
+ } catch (Exception ex) {
+ throw new MojoExecutionException("Download failed from repo " + repo + " with resource " + resource, ex);
+ } finally {
+ wagon.closeConnection();
+ }
+ }
+
/**
* Extracts the name of the engine zip-file from the url used to download the
* engine. The zip-file name is only known after downloading the
diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/download/UrlRedirectionResolver.java b/src/main/java/ch/ivyteam/ivy/maven/engine/download/UrlRedirectionResolver.java
deleted file mode 100644
index dc0e89cd..00000000
--- a/src/main/java/ch/ivyteam/ivy/maven/engine/download/UrlRedirectionResolver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package ch.ivyteam.ivy.maven.engine.download;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-public class UrlRedirectionResolver {
- public List openedUrls = new ArrayList<>();
-
- public InputStream followRedirections(URL url) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- openedUrls.add(url);
- while (isRedirected(connection.getResponseCode())) {
- String newUrl = connection.getHeaderField("Location");
- url = new URL(newUrl);
- closeHttpUrlConnectionSilently(connection);
- connection = (HttpURLConnection) url.openConnection();
- openedUrls.add(url);
- }
- return connection.getInputStream();
- }
-
- public List getOpenedUrls() {
- return openedUrls;
- }
-
- private static boolean isRedirected(int httpStatusCode) {
- return httpStatusCode == HttpURLConnection.HTTP_MOVED_TEMP
- || httpStatusCode == HttpURLConnection.HTTP_MOVED_PERM
- || httpStatusCode == HttpURLConnection.HTTP_SEE_OTHER
- || httpStatusCode == 307
- || httpStatusCode == 308;
- }
-
- private static void closeHttpUrlConnectionSilently(HttpURLConnection connection) {
- try {
- if (connection != null && connection.getInputStream() != null) {
- connection.getInputStream().close();
- }
- } catch (IOException e) {
- // silently
- }
- }
-
-}
diff --git a/src/site/apt/examples.apt b/src/site/apt/examples.apt
index 5b8ed411..11de8cd0 100644
--- a/src/site/apt/examples.apt
+++ b/src/site/apt/examples.apt
@@ -34,4 +34,11 @@ Snapshots
+------------------------------------------------------------------------------------+
mvn clean install -Divy.engine.list.url=https://dev.axonivy.com/download/nightly
+------------------------------------------------------------------------------------+
-
\ No newline at end of file
+
+Proxy
+
+ If your environment enforces the usage of a proxy to access the web, configure it in your settings.xml
+ as described here {{https://maven.apache.org/guides/mini/guide-proxies.html}}.
+
+ The maven proxy configuration is considered, when downloading the IvyEngine to compile projects.
+
diff --git a/src/site/apt/faq.apt b/src/site/apt/faq.apt
index 7ce6bf48..2822a16e 100644
--- a/src/site/apt/faq.apt
+++ b/src/site/apt/faq.apt
@@ -2,4 +2,4 @@ Frequently asked questions
The Axon Ivy Community is strong and able to provide solutions for daily issues.
- Be part of it: {{https://answers.axonivy.com/tags/project-build-plugin/}}
+ Be part of it: {{https://community.axonivy.com/?q=project-build-plugin}}
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index 3d43c339..109c53c6 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -14,4 +14,4 @@ Introduction
Ivy Documentation
- {{https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.concepts.html#ivy-ci}}
\ No newline at end of file
+ {{https://developer.axonivy.com/doc/latest/designer-guide/how-to/continuous-integration.html}}
\ No newline at end of file
diff --git a/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java b/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
index 71f370cb..35baf3db 100644
--- a/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
+++ b/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
@@ -15,12 +15,13 @@
*/
package ch.ivyteam.ivy.maven;
+import static ch.ivyteam.ivy.maven.AbstractEngineMojo.DEFAULT_VERSION;
+import static ch.ivyteam.ivy.maven.InstallEngineMojo.DEFAULT_ARCH;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -29,7 +30,11 @@
import org.apache.commons.io.IOUtils;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.wink.client.MockHttpServer;
+import org.apache.wink.client.MockHttpServer.MockHttpServerResponse;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,6 +46,7 @@
import net.lingala.zip4j.model.ZipParameters;
public class TestInstallEngineMojo {
+
private InstallEngineMojo mojo;
@Rule
@@ -53,48 +59,57 @@ protected void before() throws Throwable {
}
};
+ private MockHttpServer mockServer;
+ private String mockBaseUrl;
+
+ @Before
+ public void startHttp() {
+ mockServer = new MockHttpServer(3333);
+ mockServer.startServer();
+ mockBaseUrl = "http://localhost:" + mockServer.getServerPort();
+ }
+
+ @After
+ public void stopHttp() {
+ mockServer.stopServer();
+ }
+
+ private URL mockEngineZip() throws MalformedURLException {
+ return new URL(mockBaseUrl+"/fakeEngine.zip");
+ }
+
@Test
public void testEngineDownload_defaultBehaviour() throws Exception {
- MockHttpServer mockServer = new MockHttpServer(3333);
- try {
- mockServer.startServer();
- String baseUrl = "http://localhost:" + mockServer.getServerPort();
- MockHttpServer.MockHttpServerResponse listPageResponse = new MockHttpServer.MockHttpServerResponse();
- String defaultEngineName = "AxonIvyEngine" + AbstractEngineMojo.DEFAULT_VERSION + ".46949_"
- + InstallEngineMojo.DEFAULT_ARCH;
- listPageResponse.setMockResponseContent(
- "the engine!");
- File engineZip = createFakeEngineZip(mojo.ivyVersion);
- MockHttpServer.MockHttpServerResponse engineZipResponse = createFakeZipResponse(engineZip);
- mockServer.setMockHttpServerResponses(listPageResponse, engineZipResponse);
-
- // test setup can not expand expression ${settings.localRepository}: so we
- // setup an explicit temp dir!
- mojo.engineCacheDirectory = Files.createTempDirectory("tmpRepo").toFile();
- mojo.engineListPageUrl = new URL(baseUrl + "/listPageUrl.html");
-
- File defaultEngineDir = new File(mojo.engineCacheDirectory, AbstractEngineMojo.DEFAULT_VERSION);
- assertThat(defaultEngineDir).doesNotExist();
- assertThat(mojo.engineDownloadUrl)
- .as("Default config should favour to download an engine from the 'list page url'.").isNull();
- assertThat(mojo.autoInstallEngine).isTrue();
+ var listPageResponse = new MockHttpServerResponse();
+ String defaultEngineName = "AxonIvyEngine" + DEFAULT_VERSION + ".46949_" + DEFAULT_ARCH;
+ listPageResponse.setMockResponseContent(
+ "the engine!");
+ mockServer.setMockHttpServerResponses(listPageResponse, createFakeZipResponse(createFakeEngineZip(mojo.ivyVersion)));
+
+ // test setup can not expand expression ${settings.localRepository}: so we
+ // setup an explicit temp dir!
+ mojo.engineCacheDirectory = Files.createTempDirectory("tmpRepo").toFile();
+ mojo.engineListPageUrl = new URL(mockBaseUrl + "/listPageUrl.html");
+
+ File defaultEngineDir = new File(mojo.engineCacheDirectory, DEFAULT_VERSION);
+ assertThat(defaultEngineDir).doesNotExist();
+ assertThat(mojo.engineDownloadUrl)
+ .as("Default config should favour to download an engine from the 'list page url'.")
+ .isNull();
+ assertThat(mojo.autoInstallEngine).isTrue();
- mojo.execute();
+ mojo.execute();
- assertThat(defaultEngineDir)
- .as("Engine must be automatically downloaded")
- .exists().isDirectory();
- assertThat(defaultEngineDir)
- .as("Engine directory should automatically be set to subdir of the local repository cache.")
- .isEqualTo(mojo.getRawEngineDirectory());
- } finally {
- mockServer.stopServer();
- }
+ assertThat(defaultEngineDir)
+ .as("Engine must be automatically downloaded")
+ .exists().isDirectory();
+ assertThat(defaultEngineDir)
+ .as("Engine directory should automatically be set to subdir of the local repository cache.")
+ .isEqualTo(mojo.getRawEngineDirectory());
}
- private static MockHttpServer.MockHttpServerResponse createFakeZipResponse(File zip)
- throws IOException, FileNotFoundException {
- MockHttpServer.MockHttpServerResponse engineZipResponse = new MockHttpServer.MockHttpServerResponse();
+ private static MockHttpServerResponse createFakeZipResponse(File zip) throws Exception {
+ var engineZipResponse = new MockHttpServerResponse();
engineZipResponse.setMockResponseContentType("application/zip");
FileInputStream fis = new FileInputStream(zip);
byte[] zipBytes = IOUtils.toByteArray(fis);
@@ -143,6 +158,8 @@ public void testEngineDownload_alreadyInstalledVersionWithinRange() throws Excep
@Test
public void testEngineDownload_alreadyInstalledVersionTooOld() throws Exception {
+ mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(DEFAULT_VERSION)));
+
final String outdatedVersion = "6.5.1";
mojo.engineDirectory = createFakeEngineDir(outdatedVersion);
assertThat(mojo.engineDirectory).isDirectory();
@@ -150,13 +167,12 @@ public void testEngineDownload_alreadyInstalledVersionTooOld() throws Exception
mojo.ivyVersion = "[9.1.0,11.0.0)";
mojo.autoInstallEngine = true;
- final String downloadVersion = AbstractEngineMojo.DEFAULT_VERSION;
- mojo.engineDownloadUrl = createFakeEngineZip(downloadVersion).toURI().toURL();
+ mojo.engineDownloadUrl = mockEngineZip();
mojo.execute();
assertThat(mojo.engineDirectory.listFiles()).isNotEmpty();
assertThat(new File(mojo.engineDirectory, getFakeLibraryPath(outdatedVersion))).doesNotExist();
- assertThat(new File(mojo.engineDirectory, getFakeLibraryPath(downloadVersion))).exists();
+ assertThat(new File(mojo.engineDirectory, getFakeLibraryPath(DEFAULT_VERSION))).exists();
}
@Test
@@ -166,7 +182,8 @@ public void testEngineDownload_ifNotExisting() throws Exception {
assertThat(mojo.engineDirectory.listFiles()).isEmpty();
mojo.autoInstallEngine = true;
- mojo.engineDownloadUrl = createFakeEngineZip(mojo.ivyVersion).toURI().toURL();
+ mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(mojo.ivyVersion)));
+ mojo.engineDownloadUrl = mockEngineZip();
mojo.execute();
assertThat(mojo.engineDirectory.listFiles()).isNotEmpty();
@@ -196,19 +213,55 @@ public void testEngineDownload_existingTmpFileNotOverwritten() throws Exception
alreadyExistingFile.createNewFile();
mojo.autoInstallEngine = true;
- mojo.engineDownloadUrl = createFakeEngineZip(mojo.ivyVersion).toURI().toURL();
+ mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(DEFAULT_VERSION)));
+ mojo.engineDownloadUrl = mockEngineZip();
mojo.execute();
assertThat(alreadyExistingFile).exists();
}
+ @Test
+ public void testEngineDownload_overProxy() throws Exception {
+ mojo.engineDirectory = createTempDir("tmpEngine");
+
+ File alreadyExistingFile = new File(mojo.getDownloadDirectory(), "fakeEngine.zip");
+ alreadyExistingFile.createNewFile();
+
+ mojo.autoInstallEngine = true;
+ mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(DEFAULT_VERSION)));
+
+ mojo.engineDownloadUrl = new URL("http://localhost:7123/fakeEngine.zip"); // not reachable: but proxy knows how :)
+ var downloader = (URLEngineDownloader) mojo.getDownloader();
+ try {
+ downloader.downloadEngine();
+ failBecauseExceptionWasNotThrown(MojoExecutionException.class);
+ } catch (MojoExecutionException ex) {
+ assertThat(ex).hasMessageStartingWith("Failed to download engine from 'http://localhost");
+ }
+
+ downloader.proxies = this::localTestProxy;
+ File downloaded = downloader.downloadEngine();
+ assertThat(downloaded)
+ .as("served file via proxy")
+ .exists();
+ }
+
+ private ProxyInfo localTestProxy(@SuppressWarnings("unused") String protocol) {
+ var proxy = new ProxyInfo();
+ proxy.setHost("localhost");
+ proxy.setPort(mockServer.getServerPort());
+ proxy.setType("http");
+ return proxy;
+ }
+
@Test
public void testEngineDownload_validatesDownloadedVersion() throws Exception {
mojo.engineDirectory = createTempDir("tmpEngine");
mojo.autoInstallEngine = true;
mojo.ivyVersion = "9999.0.0";
- mojo.engineDownloadUrl = createFakeEngineZip(AbstractEngineMojo.DEFAULT_VERSION).toURI().toURL();
+ mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(DEFAULT_VERSION)));
+ mojo.engineDownloadUrl = mockEngineZip();
try {
mojo.execute();
@@ -236,10 +289,8 @@ public void testEngineLinkFinder_absolute_http() throws Exception {
mojo.ivyVersion = "[7.0.0,7.1.0]";
mojo.restrictVersionToMinimalCompatible = false;
mojo.osArchitecture = "Windows_x86";
- assertThat(findLink(
- "the latest engine"))
- .isEqualTo(
- "http://developer.axonivy.com/download/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
+ assertThat(findLink("the latest engine"))
+ .isEqualTo("http://developer.axonivy.com/download/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
}
@Test
@@ -247,10 +298,8 @@ public void testEngineLinkFinder_absolute_https() throws Exception {
mojo.ivyVersion = "[7.0.0,7.1.0]";
mojo.restrictVersionToMinimalCompatible = false;
mojo.osArchitecture = "Windows_x86";
- assertThat(findLink(
- "the latest engine"))
- .isEqualTo(
- "https://developer.axonivy.com/download/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
+ assertThat(findLink("the latest engine"))
+ .isEqualTo("https://developer.axonivy.com/download/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
}
@Test
@@ -260,7 +309,7 @@ public void testEngineLinkFinder_relative() throws Exception {
mojo.osArchitecture = "Windows_x86";
mojo.engineListPageUrl = new URL("http://localhost/");
assertThat(findLink("the latest engine"))
- .isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
+ .isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
}
@Test
@@ -270,34 +319,33 @@ public void testEngineLinkFinder_sprintVersionQualifier() throws Exception {
mojo.osArchitecture = "Windows_x64";
assertThat(findLink(
"Axon Ivy Engine Windows x64"))
- .isEqualTo(
- "http://www.ivyteam.ch/downloads/XIVY/Saentis/7.0.0-S2/AxonIvyEngine7.0.0.47245.S2_Windows_x64.zip");
+ .isEqualTo("http://www.ivyteam.ch/downloads/XIVY/Saentis/7.0.0-S2/AxonIvyEngine7.0.0.47245.S2_Windows_x64.zip");
}
@Test
public void testEngineLinkFinder_wrongVersion() throws Exception {
- mojo.ivyVersion = AbstractEngineMojo.DEFAULT_VERSION;
+ mojo.ivyVersion = DEFAULT_VERSION;
mojo.osArchitecture = "Windows_x86";
try {
findLink("the latest engine");
failBecauseExceptionWasNotThrown(MojoExecutionException.class);
} catch (MojoExecutionException ex) {
assertThat(ex).hasMessageStartingWith(
- "Could not find a link to engine for version '" + AbstractEngineMojo.DEFAULT_VERSION + "'");
+ "Could not find a link to engine for version '" + DEFAULT_VERSION + "'");
}
}
@Test
public void testEngineLinkFinder_wrongArchitecture() throws Exception {
- mojo.ivyVersion = AbstractEngineMojo.DEFAULT_VERSION;
+ mojo.ivyVersion = DEFAULT_VERSION;
mojo.osArchitecture = "Linux_x86";
try {
- findLink("the latest engine");
+ findLink("the latest engine");
failBecauseExceptionWasNotThrown(MojoExecutionException.class);
} catch (MojoExecutionException ex) {
assertThat(ex).hasMessageStartingWith(
- "Could not find a link to engine for version '" + AbstractEngineMojo.DEFAULT_VERSION + "'");
+ "Could not find a link to engine for version '" + DEFAULT_VERSION + "'");
}
}
@@ -311,12 +359,11 @@ public void testEngineLinkFinder_multipleLinks() throws Exception {
assertThat(findLink(
"the latest engine" // windows
+ "the latest engine")) // linux
- .isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Linux_x86.zip");
+ .isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Linux_x86.zip");
}
private String findLink(String html) throws MojoExecutionException, MalformedURLException {
- return getUrlDownloader().findEngineDownloadUrl(IOUtils.toInputStream(html, StandardCharsets.UTF_8))
- .toExternalForm();
+ return getUrlDownloader().findEngineDownloadUrl(IOUtils.toInputStream(html, StandardCharsets.UTF_8)).toExternalForm();
}
@Test
@@ -326,13 +373,12 @@ public void testDefaultListPage_isAvailable() throws Exception {
return;
}
- String engineUrl = getUrlDownloader().findEngineDownloadUrl(mojo.engineListPageUrl.openStream())
- .toExternalForm();
+ String engineUrl = getUrlDownloader().findEngineDownloadUrl(mojo.engineListPageUrl.openStream()).toExternalForm();
assertThat(engineUrl)
- .as("The default engine list page url '" + mojo.engineListPageUrl.toExternalForm() + "' "
- + "must provide an engine for the current default engine version '" + mojo.ivyVersion
- + "'.")
- .contains(mojo.ivyVersion);
+ .as("The default engine list page url '" + mojo.engineListPageUrl.toExternalForm() + "' "
+ + "must provide an engine for the current default engine version '" + mojo.ivyVersion
+ + "'.")
+ .contains(mojo.ivyVersion);
}
private URLEngineDownloader getUrlDownloader() throws MojoExecutionException {
@@ -353,14 +399,14 @@ public void testIvyVersion_mustMatchMinimalPluginVersion() {
@Test
public void testZipFileEngineVersionParser() {
assertThat(InstallEngineMojo.ivyEngineVersionOfZip("AxonIvyEngine6.1.1.51869_Linux_x64.zip"))
- .isEqualTo("6.1.1");
+ .isEqualTo("6.1.1");
assertThat(InstallEngineMojo.ivyEngineVersionOfZip("AxonIvyEngine6.2_Windows_x64.zip"))
- .isEqualTo("6.2");
+ .isEqualTo("6.2");
assertThat(InstallEngineMojo
- .ivyEngineVersionOfZip("AxonIvyDesigner6.1.1-SNAPSHOT.51869-win32.win32.x86_64.zip"))
- .isEqualTo("6.1.1");
+ .ivyEngineVersionOfZip("AxonIvyDesigner6.1.1-SNAPSHOT.51869-win32.win32.x86_64.zip"))
+ .isEqualTo("6.1.1");
assertThat(InstallEngineMojo.ivyEngineVersionOfZip("AxonIvyEngine_Linux_x64.zip"))
- .isEqualTo("AxonIvyEngine_Linux_x64.zip"); // do not return null!
+ .isEqualTo("AxonIvyEngine_Linux_x64.zip"); // do not return null!
}
private static String getFakeLibraryPath(final String version) {
diff --git a/src/test/java/ch/ivyteam/ivy/maven/util/TestUrlRedirectionResolver.java b/src/test/java/ch/ivyteam/ivy/maven/util/TestUrlRedirectionResolver.java
deleted file mode 100644
index 85c8f275..00000000
--- a/src/test/java/ch/ivyteam/ivy/maven/util/TestUrlRedirectionResolver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package ch.ivyteam.ivy.maven.util;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.junit.Test;
-
-import ch.ivyteam.ivy.maven.engine.download.UrlRedirectionResolver;
-
-/**
- * Url: developer.axonivy.com/download/maven.html must be available for http and
- * https without any redirections. Old versions of project-build-plugin relies
- * on that behavior.
- */
-public class TestUrlRedirectionResolver {
- @Test
- public void no_redirections() throws IOException {
- assertRedirection("http://developer.axonivy.com/download/maven.html",
- "http://developer.axonivy.com/download/maven.html");
- assertRedirection("https://developer.axonivy.com/download/maven.html",
- "https://developer.axonivy.com/download/maven.html");
- assertRedirection("https://developer.axonivy.com/download", "https://developer.axonivy.com/download");
- }
-
- @Test
- public void redirections() throws IOException {
- assertRedirection("http://answers.axonivy.com/", "http://answers.axonivy.com/",
- "https://answers.axonivy.com/");
- }
-
- private static void assertRedirection(String initUrl, String... openendUrls) throws IOException {
- URL url = new URL(initUrl);
- UrlRedirectionResolver resolver = new UrlRedirectionResolver();
- InputStream stream = resolver.followRedirections(url);
- stream.close();
-
- for (int i = 0; i < openendUrls.length; i++) {
- assertThat(resolver.getOpenedUrls().get(i).toExternalForm()).isEqualTo(openendUrls[i]);
- }
- }
-
-}