diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c04415a --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip diff --git a/citrus-remote-maven-plugin/pom.xml b/citrus-remote-maven-plugin/pom.xml index 9fbb69d..33d4999 100644 --- a/citrus-remote-maven-plugin/pom.xml +++ b/citrus-remote-maven-plugin/pom.xml @@ -1,11 +1,11 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 citrus-remote - com.consol.citrus - 3.5.0-SNAPSHOT + org.citrusframework + 4.4.0-SNAPSHOT ../pom.xml @@ -16,21 +16,21 @@ - com.consol.citrus + org.citrusframework citrus-remote-server ${project.version} - com.consol.citrus + org.citrusframework citrus-base - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 @@ -103,14 +103,14 @@ org.codehaus.plexus plexus-utils provided - 3.1.0 + 4.0.1 org.codehaus.plexus plexus-component-annotations provided - 1.7.1 + 2.2.0 @@ -157,4 +157,4 @@ - + \ No newline at end of file diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java similarity index 86% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java index 7e145e5..3bcce32 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteAssemblyMojo.java @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; +package org.citrusframework.remote.plugin; -import com.consol.citrus.remote.plugin.assembly.CitrusRemoteAssemblerConfigurationSource; -import com.consol.citrus.remote.plugin.config.*; import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -34,8 +32,14 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.shared.filtering.MavenReaderFilter; +import org.citrusframework.remote.plugin.assembly.CitrusRemoteAssemblerConfigurationSource; +import org.citrusframework.remote.plugin.config.AssemblyConfiguration; +import org.citrusframework.remote.plugin.config.AssemblyDescriptorConfiguration; +import org.citrusframework.remote.plugin.config.TestJarConfiguration; import java.io.File; +import java.nio.file.attribute.FileTime; +import java.time.Instant; import java.util.List; import java.util.Optional; @@ -72,7 +76,7 @@ public abstract class AbstractCitrusRemoteAssemblyMojo extends AbstractCitrusRem @Parameter(defaultValue = "${project.build.testOutputDirectory}", required = true, readonly = true) private File testClassesDirectory; - @Parameter( property = "citrus.remote.mainClass", required = true, defaultValue = "com.consol.citrus.remote.CitrusRemoteServer") + @Parameter( property = "citrus.remote.mainClass", required = true, defaultValue = "org.citrusframework.remote.CitrusRemoteServer") private String mainClass; /** @@ -96,16 +100,14 @@ public void doExecute() throws MojoExecutionException, MojoFailureException { protected void createDirs(AssemblyConfiguration assemblyConfig) { for (File dir : new File[] { assemblyConfig.getTemporaryRootDirectory(), assemblyConfig.getOutputDirectory(), assemblyConfig.getWorkingDirectory() }) { - if (!dir.exists()) { - if(!dir.mkdirs()) { - throw new IllegalArgumentException("Cannot create directory " + dir.getAbsolutePath()); - } + if (!dir.exists() && !dir.mkdirs()) { + throw new IllegalArgumentException("Cannot create directory " + dir.getAbsolutePath()); } } } private void initializeAssembly() { - if (!hasAssemblyConfiguration()) { + if (hasNoAssemblyConfiguration()) { assembly = Optional.ofNullable(assembly).orElse(new AssemblyConfiguration()); AssemblyDescriptorConfiguration descriptorConfiguration = new AssemblyDescriptorConfiguration(); descriptorConfiguration.setRef(getDefaultDescriptorRef()); @@ -127,15 +129,14 @@ private void initializeAssembly() { /** * Subclasses provide default descriptor reference. - * @return */ protected abstract String getDefaultDescriptorRef(); - protected boolean hasAssemblyConfiguration() { - return assembly != null && assembly.getDescriptor() != null && - (assembly.getDescriptor().getInline() != null || - assembly.getDescriptor().getFile() != null || - assembly.getDescriptor().getRef() != null); + protected boolean hasNoAssemblyConfiguration() { + return assembly == null || assembly.getDescriptor() == null || + (assembly.getDescriptor().getInline() == null && + assembly.getDescriptor().getFile() == null && + assembly.getDescriptor().getRef() == null); } protected void createAssemblyArchive(AssemblyConfiguration assemblyConfig) throws MojoExecutionException { @@ -144,7 +145,7 @@ protected void createAssemblyArchive(AssemblyConfiguration assemblyConfig) throw try { for (String format : assembly.getFormats()) { - assemblyArchiver.createArchive(assembly, finalName + "-" + assembly.getId(), format, source, false, "merge"); + assemblyArchiver.createArchive(assembly, finalName + "-" + assembly.getId(), format, source, FileTime.from(Instant.now())); } } catch (ArchiveCreationException | AssemblyFormattingException e) { throw new MojoExecutionException("Failed to create assembly for test jar", e); @@ -190,7 +191,7 @@ public void setAssembly(AssemblyConfiguration assembly) { * @return */ public AssemblyConfiguration getAssembly() { - if (!hasAssemblyConfiguration()) { + if (hasNoAssemblyConfiguration()) { initializeAssembly(); } @@ -229,4 +230,4 @@ public TestJarConfiguration getTestJar() { public String getFinalName() { return finalName; } -} +} \ No newline at end of file diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteMojo.java similarity index 68% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteMojo.java index 33b8cb9..0c88bff 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/AbstractCitrusRemoteMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/AbstractCitrusRemoteMojo.java @@ -14,17 +14,22 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; - -import com.consol.citrus.remote.plugin.config.ReportConfiguration; -import com.consol.citrus.remote.plugin.config.ServerConfiguration; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.HttpClients; +package org.citrusframework.remote.plugin; + +import org.apache.hc.client5.http.config.ConnectionConfig; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.core5.util.Timeout; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.*; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.citrusframework.remote.plugin.config.ReportConfiguration; +import org.citrusframework.remote.plugin.config.ServerConfiguration; import java.io.File; @@ -68,18 +73,28 @@ public abstract class AbstractCitrusRemoteMojo extends AbstractMojo { private ReportConfiguration report; /** Http client */ - private final HttpClient httpClient; + private final CloseableHttpClient httpClient; /** * Constructor using default client. */ - public AbstractCitrusRemoteMojo() { + protected AbstractCitrusRemoteMojo() { + Timeout timoutMillis = Timeout.ofMilliseconds(timeout); + + ConnectionConfig connectionConfig = ConnectionConfig.custom() + .setConnectTimeout(timoutMillis) + .build(); + + PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); + connectionManager.setDefaultConnectionConfig(connectionConfig); + httpClient = HttpClients.custom() - .setDefaultRequestConfig(RequestConfig.copy(RequestConfig.DEFAULT) - .setConnectionRequestTimeout(timeout) - .setConnectTimeout(timeout) - .setSocketTimeout(timeout) - .build()) + .setConnectionManager(connectionManager) + .setDefaultRequestConfig( + RequestConfig.custom() + .setConnectionRequestTimeout(timoutMillis) + .setResponseTimeout(timoutMillis) + .build()) .build(); } @@ -87,7 +102,7 @@ public AbstractCitrusRemoteMojo() { * Constructor using given client. * @param httpClient */ - public AbstractCitrusRemoteMojo(HttpClient httpClient) { + protected AbstractCitrusRemoteMojo(CloseableHttpClient httpClient) { this.httpClient = httpClient; } @@ -164,7 +179,7 @@ public File getOutputDirectory() { * * @return */ - public HttpClient getHttpClient() { + public CloseableHttpClient getHttpClient() { return httpClient; } } diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/RunTestMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/RunTestMojo.java similarity index 67% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/RunTestMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/RunTestMojo.java index e891f1e..4774324 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/RunTestMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/RunTestMojo.java @@ -14,44 +14,40 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; +package org.citrusframework.remote.plugin; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.hc.core5.http.*; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicHeader; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.citrusframework.TestClass; +import org.citrusframework.TestResult; +import org.citrusframework.TestSource; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.main.TestRunConfiguration; +import org.citrusframework.remote.model.RemoteResult; +import org.citrusframework.remote.plugin.config.RunConfiguration; +import org.citrusframework.report.*; import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; -import com.consol.citrus.TestClass; -import com.consol.citrus.exceptions.CitrusRuntimeException; -import com.consol.citrus.main.TestRunConfiguration; -import com.consol.citrus.remote.model.RemoteResult; -import com.consol.citrus.remote.plugin.config.RunConfiguration; -import com.consol.citrus.report.HtmlReporter; -import com.consol.citrus.report.JUnitReporter; -import com.consol.citrus.report.OutputStreamReporter; -import com.consol.citrus.report.SummaryReporter; -import com.consol.citrus.report.TestResults; -import com.consol.citrus.util.FileUtils; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.RequestBuilder; -import org.apache.http.client.utils.HttpClientUtils; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHeader; -import org.apache.http.util.EntityUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; +import static java.util.stream.Collectors.joining; /** * @author Christoph Deppisch @@ -75,7 +71,17 @@ public class RunTestMojo extends AbstractCitrusRemoteMojo { /** * Object mapper for JSON response to object conversion. */ - private ObjectMapper objectMapper = new ObjectMapper(); + private final ObjectMapper objectMapper = new ObjectMapper(); + + private static String parseResultToStringRepresentation(TestResult result) { + if (result.isSkipped()) { + return "x"; + } else if (result.isSuccess()) { + return "+"; + } + + return "-"; + } @Override public void doExecute() throws MojoExecutionException, MojoFailureException { @@ -107,7 +113,7 @@ private void runPackages(List packages) throws MojoExecutionException { runConfiguration.setPackages(packages); if (run.getIncludes() != null) { - runConfiguration.setIncludes(run.getIncludes().toArray(new String[run.getIncludes().size()])); + runConfiguration.setIncludes(run.getIncludes().toArray(new String[0])); } if (run.getSystemProperties() != null) { @@ -121,9 +127,12 @@ private void runClasses(List classes) throws MojoExecutionException { TestRunConfiguration runConfiguration = new TestRunConfiguration(); runConfiguration.setEngine(run.getEngine()); - runConfiguration.setTestClasses(classes.stream() - .map(TestClass::fromString) - .collect(Collectors.toList())); + + List testSources = classes.stream() + .map(TestClass::fromString) + .map(testClass -> (TestSource) testClass) + .toList(); + runConfiguration.setTestSources(testSources); if (run.getSystemProperties() != null) { runConfiguration.addDefaultProperties(run.getSystemProperties()); @@ -137,7 +146,7 @@ private void runAllTests() throws MojoExecutionException { runConfiguration.setEngine(run.getEngine()); if (run.getIncludes() != null) { - runConfiguration.setIncludes(run.getIncludes().toArray(new String[run.getIncludes().size()])); + runConfiguration.setIncludes(run.getIncludes().toArray(new String[0])); } if (run.getSystemProperties() != null) { @@ -152,19 +161,16 @@ private void runAllTests() throws MojoExecutionException { * that creates a new run job on the server. The test results are then polled with multiple requests instead of processing the single synchronous response. * * @param runConfiguration - * @return * @throws MojoExecutionException */ private void runTests(TestRunConfiguration runConfiguration) throws MojoExecutionException { - HttpResponse response = null; - try { - RequestBuilder requestBuilder; + ClassicRequestBuilder requestBuilder; if (run.isAsync()) { - requestBuilder = RequestBuilder.put(getServer().getUrl() + "/run"); + requestBuilder = ClassicRequestBuilder.put(getServer().getUrl() + "/run"); } else { - requestBuilder = RequestBuilder.post(getServer().getUrl() + "/run"); + requestBuilder = ClassicRequestBuilder.post(getServer().getUrl() + "/run"); } requestBuilder.addHeader(new BasicHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.getMimeType())); @@ -172,22 +178,19 @@ private void runTests(TestRunConfiguration runConfiguration) throws MojoExecutio StringEntity body = new StringEntity(new ObjectMapper().writeValueAsString(runConfiguration), ContentType.APPLICATION_JSON); requestBuilder.setEntity(body); - response = getHttpClient().execute(requestBuilder.build()); - - if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) { - throw new MojoExecutionException("Failed to run tests on remote server: " + EntityUtils.toString(response.getEntity())); - } + try (var response = getHttpClient().executeOpen(null, requestBuilder.build(), null)) { + if (HttpStatus.SC_OK != response.getCode()) { + throw new MojoExecutionException("Failed to run tests on remote server: " + EntityUtils.toString(response.getEntity())); + } - if (run.isAsync()) { - HttpClientUtils.closeQuietly(response); - handleTestResults(pollTestResults()); - } else { - handleTestResults(objectMapper.readValue(response.getEntity().getContent(), RemoteResult[].class)); + if (run.isAsync()) { + handleTestResults(pollTestResults()); + } else { + handleTestResults(objectMapper.readValue(response.getEntity().getContent(), RemoteResult[].class)); + } } - } catch (IOException e) { + } catch (IOException | ParseException e) { throw new MojoExecutionException("Failed to run tests on remote server", e); - } finally { - HttpClientUtils.closeQuietly(response); } } @@ -195,35 +198,42 @@ private void runTests(TestRunConfiguration runConfiguration) throws MojoExecutio * When using async test execution mode the client does not synchronously wait for test results as it might lead to read timeouts. Instead * this method polls for test results and waits for the test execution to completely finish. * - * @return * @throws MojoExecutionException */ - private RemoteResult[] pollTestResults() throws MojoExecutionException { - HttpResponse response = null; + private RemoteResult[] pollTestResults() throws MojoExecutionException, IOException { + ClassicHttpResponse response = null; try { do { - HttpClientUtils.closeQuietly(response); - response = getHttpClient().execute(RequestBuilder.get(getServer().getUrl() + "/results") + if (response != null) { + response.close(); + } + + ClassicHttpRequest httpRequest = ClassicRequestBuilder.get(getServer().getUrl() + "/results") .addHeader(new BasicHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.getMimeType())) .addParameter("timeout", String.valueOf(run.getPollingInterval())) - .build()); + .build(); + response = getHttpClient().executeOpen(null, httpRequest, null); - if (HttpStatus.SC_PARTIAL_CONTENT == response.getStatusLine().getStatusCode()) { + if (HttpStatus.SC_PARTIAL_CONTENT == response.getCode()) { getLog().info("Waiting for remote tests to finish ..."); getLog().info(Stream.of(objectMapper.readValue(response.getEntity().getContent(), RemoteResult[].class)) - .map(RemoteResult::toTestResult).map(result -> result.isSkipped() ? "x" : (result.isSuccess() ? "+" : "-")).collect(Collectors.joining())); + .map(RemoteResult::toTestResult) + .map(RunTestMojo::parseResultToStringRepresentation) + .collect(joining())); } - } while (HttpStatus.SC_PARTIAL_CONTENT == response.getStatusLine().getStatusCode()); + } while (HttpStatus.SC_PARTIAL_CONTENT == response.getCode()); - if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) { + if (HttpStatus.SC_OK != response.getCode()) { throw new MojoExecutionException("Failed to get test results from remote server: " + EntityUtils.toString(response.getEntity())); } return objectMapper.readValue(response.getEntity().getContent(), RemoteResult[].class); - } catch (IOException e) { + } catch (IOException | ParseException e) { throw new MojoExecutionException("Failed to get test results from remote server", e); } finally { - HttpClientUtils.closeQuietly(response); + if (response != null) { + response.close(); + } } } @@ -232,7 +242,7 @@ private RemoteResult[] pollTestResults() throws MojoExecutionException { * @param results * @throws IOException */ - private void handleTestResults(RemoteResult[] results) { + private void handleTestResults(RemoteResult[] results) throws IOException { StringWriter resultWriter = new StringWriter(); resultWriter.append(String.format("%n")); @@ -257,41 +267,34 @@ private void handleTestResults(RemoteResult[] results) { getAndSaveReports(); } - private void getAndSaveReports() { + private void getAndSaveReports() throws IOException { if (!getReport().isSaveReportFiles()) { return; } - HttpResponse response = null; - String[] reportFiles = {}; - try { - response = getHttpClient().execute(RequestBuilder.get(getServer().getUrl() + "/results/files") - .addHeader(new BasicHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_XML.getMimeType())) - .build()); + ClassicHttpRequest httpRequest = ClassicRequestBuilder.get(getServer().getUrl() + "/results/files") + .addHeader(new BasicHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_XML.getMimeType())) + .build(); - if (HttpStatus.SC_OK != response.getStatusLine().getStatusCode()) { + String[] reportFiles = {}; + try (var response = getHttpClient().executeOpen(null, httpRequest, null)){ + if (HttpStatus.SC_OK != response.getCode()) { getLog().warn("Failed to get test reports from remote server"); } reportFiles = objectMapper.readValue(response.getEntity().getContent(), String[].class); } catch (IOException e) { getLog().warn("Failed to get test reports from remote server", e); - } finally { - HttpClientUtils.closeQuietly(response); } File citrusReportsDirectory = new File(getOutputDirectory() + File.separator + getReport().getDirectory()); - if (!citrusReportsDirectory.exists()) { - if (!citrusReportsDirectory.mkdirs()) { - throw new CitrusRuntimeException("Unable to create reports output directory: " + citrusReportsDirectory.getPath()); - } + if (!citrusReportsDirectory.exists()&& !citrusReportsDirectory.mkdirs()) { + throw new CitrusRuntimeException("Unable to create reports output directory: " + citrusReportsDirectory.getPath()); } File junitReportsDirectory = new File(citrusReportsDirectory, "junitreports"); - if (!junitReportsDirectory.exists()) { - if (!junitReportsDirectory.mkdirs()) { - throw new CitrusRuntimeException("Unable to create JUnit reports directory: " + junitReportsDirectory.getPath()); - } + if (!junitReportsDirectory.exists() && !junitReportsDirectory.mkdirs()) { + throw new CitrusRuntimeException("Unable to create JUnit reports directory: " + junitReportsDirectory.getPath()); } JUnitReporter jUnitReporter = new JUnitReporter(); @@ -315,23 +318,20 @@ private void getAndSaveReports() { * @param contentType */ private void loadAndSaveReportFile(File reportFile, String serverUrl, String contentType) { - HttpResponse fileResponse = null; - try { - fileResponse = getHttpClient().execute(RequestBuilder.get(serverUrl) - .addHeader(new BasicHeader(HttpHeaders.ACCEPT, contentType)) - .build()); + ClassicHttpRequest httpRequest = ClassicRequestBuilder.get(serverUrl) + .addHeader(new BasicHeader(HttpHeaders.ACCEPT, contentType)) + .build(); - if (HttpStatus.SC_OK != fileResponse.getStatusLine().getStatusCode()) { + try (var fileResponse = getHttpClient().executeOpen(null, httpRequest, null)) { + if (HttpStatus.SC_OK != fileResponse.getCode()) { getLog().warn("Failed to get report file: " + reportFile.getName()); return; } getLog().info("Writing report file: " + reportFile); - FileUtils.writeToFile(fileResponse.getEntity().getContent(), reportFile); + Files.write(reportFile.toPath(), fileResponse.getEntity().getContent().readAllBytes(), StandardOpenOption.CREATE); } catch (IOException e) { getLog().warn("Failed to get report file: " + reportFile.getName(), e); - } finally { - HttpClientUtils.closeQuietly(fileResponse); } } diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestJarMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestJarMojo.java similarity index 98% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestJarMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestJarMojo.java index e8a2b49..7c04029 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestJarMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestJarMojo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; +package org.citrusframework.remote.plugin; import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.archiver.MavenArchiver; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestWarMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestWarMojo.java similarity index 80% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestWarMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestWarMojo.java index c580f42..81724c2 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/TestWarMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/TestWarMojo.java @@ -14,9 +14,12 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; +package org.citrusframework.remote.plugin; -import org.apache.maven.plugins.annotations.*; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; /** * @author Christoph Deppisch diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/VerifyMojo.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/VerifyMojo.java similarity index 90% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/VerifyMojo.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/VerifyMojo.java index fa07dbc..9e6caa2 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/VerifyMojo.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/VerifyMojo.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin; +package org.citrusframework.remote.plugin; -import com.consol.citrus.util.FileUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.*; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.citrusframework.util.FileUtils; import java.io.File; import java.io.IOException; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java similarity index 73% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java index 6a93642..2d35642 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/assembly/CitrusRemoteAssemblerConfigurationSource.java @@ -14,31 +14,36 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.assembly; +package org.citrusframework.remote.plugin.assembly; -import com.consol.citrus.remote.plugin.config.AssemblyConfiguration; import org.apache.maven.archiver.MavenArchiveConfiguration; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.assembly.AssemblerConfigurationSource; +import org.apache.maven.plugins.assembly.model.Assembly; import org.apache.maven.plugins.assembly.utils.InterpolationConstants; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.filtering.MavenReaderFilter; -import org.apache.maven.shared.utils.cli.CommandLineUtils; -import org.codehaus.plexus.interpolation.fixed.*; +import org.citrusframework.remote.plugin.config.AssemblyConfiguration; +import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator; +import org.codehaus.plexus.interpolation.fixed.PrefixedPropertiesValueSource; +import org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource; -import javax.annotation.Nonnull; +import jakarta.annotation.Nonnull; import java.io.File; -import java.util.*; +import java.util.List; +import java.util.Properties; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; /** * @since 2.7.4 */ public class CitrusRemoteAssemblerConfigurationSource implements AssemblerConfigurationSource { - private final MavenProject project; - private final MavenSession session; - private final MavenReaderFilter readerFilter; + private final MavenProject mavenProject; + private final MavenSession mavenSession; + private final MavenReaderFilter mavenReaderFilter; private final List reactorProjects; private final AssemblyConfiguration assemblyConfig; @@ -49,26 +54,27 @@ public class CitrusRemoteAssemblerConfigurationSource implements AssemblerConfig private FixedStringSearchInterpolator mainProjectInterpolator; public CitrusRemoteAssemblerConfigurationSource(AssemblyConfiguration assemblyConfig, - MavenProject project, - MavenSession session, - MavenReaderFilter readerFilter, + MavenProject mavenProject, + MavenSession mavenSession, + MavenReaderFilter mavenReaderFilter, List reactorProjects) { this.assemblyConfig = assemblyConfig; - this.project = project; - this.session = session; - this.readerFilter = readerFilter; + this.mavenProject = mavenProject; + this.mavenSession = mavenSession; + this.mavenReaderFilter = mavenReaderFilter; this.reactorProjects = reactorProjects; } @Override public String[] getDescriptors() { if (assemblyConfig != null) { - String descriptor = assemblyConfig.getDescriptor().getFile(); + String descriptor = assemblyConfig.getDescriptor().getFile(); - if (descriptor != null) { - return new String[] { new File(descriptor).getAbsolutePath() }; - } + if (descriptor != null) { + return new String[] { new File(descriptor).getAbsolutePath() }; + } } + return new String[0]; } @@ -80,7 +86,13 @@ public String[] getDescriptorReferences() { return new String[]{ descriptorRef }; } } - return null; + + return new String[0]; + } + + @Override + public List getInlineDescriptors() { + return emptyList(); } // ============================================================================================ @@ -105,24 +117,14 @@ public String getFinalName() { return "."; } - @Override - public ArtifactRepository getLocalRepository() { - return session.getLocalRepository(); - } - @Override public List getReactorProjects() { return reactorProjects; } - @Override - public List getRemoteRepositories() { - return project.getRemoteArtifactRepositories(); - } - @Override public MavenSession getMavenSession() { - return session; + return mavenSession; } @Override @@ -132,7 +134,7 @@ public MavenArchiveConfiguration getJarArchiveConfiguration() { @Override public String getEncoding() { - return project.getProperties().getProperty("project.build.sourceEncoding"); + return mavenProject.getProperties().getProperty("project.build.sourceEncoding"); } @Override @@ -142,7 +144,7 @@ public String getEscapeString() { @Override public List getDelimiters() { - return null; + return emptyList(); } @@ -181,14 +183,44 @@ public FixedStringSearchInterpolator getMainProjectInterpolator() return mainProjectInterpolator; } + @Override + public Integer getOverrideUid() { + return 0; + } + + @Override + public String getOverrideUserName() { + return ""; + } + + @Override + public Integer getOverrideGid() { + return 0; + } + + @Override + public String getOverrideGroupName() { + return mavenProject.getGroupId(); + } + + @Override + public boolean isRecompressZippedFiles() { + return false; + } + + @Override + public String getMergeManifestMode() { + return "merge"; + } + @Override public MavenProject getProject() { - return project; + return mavenProject; } @Override public File getBasedir() { - return project.getBasedir(); + return mavenProject.getBasedir(); } @Override @@ -203,7 +235,12 @@ public boolean isDryRun() { @Override public List getFilters() { - return Collections.emptyList(); + return emptyList(); + } + + @Override + public Properties getAdditionalProperties() { + return null; } @Override @@ -248,7 +285,7 @@ public String getArchiverConfig() { @Override public MavenReaderFilter getMavenReaderFilter() { - return readerFilter; + return mavenReaderFilter; } @Override @@ -256,11 +293,6 @@ public boolean isUpdateOnly() { return false; } - @Override - public boolean isUseJvmChmod() { - return false; - } - @Override public boolean isIgnorePermissions() { return false; @@ -274,12 +306,12 @@ private FixedStringSearchInterpolator mainProjectInterpolator(MavenProject mainP if (mainProject != null) { // 5 return FixedStringSearchInterpolator.create( - new org.codehaus.plexus.interpolation.fixed.PrefixedObjectValueSource( - InterpolationConstants.PROJECT_PREFIXES, mainProject, true ), + new org.codehaus.plexus.interpolation.fixed.PrefixedObjectValueSource( + InterpolationConstants.PROJECT_PREFIXES, mainProject, true ), - // 6 - new org.codehaus.plexus.interpolation.fixed.PrefixedPropertiesValueSource( - InterpolationConstants.PROJECT_PROPERTIES_PREFIXES, mainProject.getProperties(), true ) ); + // 6 + new org.codehaus.plexus.interpolation.fixed.PrefixedPropertiesValueSource( + InterpolationConstants.PROJECT_PROPERTIES_PREFIXES, mainProject.getProperties(), true ) ); } else { return FixedStringSearchInterpolator.empty(); @@ -291,13 +323,13 @@ private FixedStringSearchInterpolator createRepositoryInterpolator() final Properties settingsProperties = new Properties(); final MavenSession session = getMavenSession(); - if (getLocalRepository() != null) { - settingsProperties.setProperty("localRepository", getLocalRepository().getBasedir()); - settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir()); + if (mavenSession.getLocalRepository() != null) { + settingsProperties.setProperty("localRepository", mavenSession.getLocalRepository().getBasedir()); + settingsProperties.setProperty("settings.localRepository", mavenSession.getLocalRepository().getBasedir()); } else if (session != null && session.getSettings() != null) { settingsProperties.setProperty("localRepository", session.getSettings().getLocalRepository() ); - settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir() ); + settingsProperties.setProperty("settings.localRepository", mavenSession.getLocalRepository().getBasedir() ); } return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(settingsProperties)); } @@ -321,8 +353,10 @@ private FixedStringSearchInterpolator createCommandLinePropertiesInterpolator() } private FixedStringSearchInterpolator createEnvInterpolator() { - PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource(Collections.singletonList("env."), - CommandLineUtils.getSystemEnvVars(false), true ); - return FixedStringSearchInterpolator.create( envProps ); + PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource( + singletonList("env."), + System.getProperties(), + true); + return FixedStringSearchInterpolator.create(envProps); } -} +} \ No newline at end of file diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyConfiguration.java similarity index 96% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyConfiguration.java index 0fe5f76..476b833 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.plugins.annotations.Parameter; @@ -32,7 +32,7 @@ public class AssemblyConfiguration implements Serializable { private AssemblyDescriptorConfiguration descriptor; @Parameter - private MavenArchiveConfiguration archive; + private transient MavenArchiveConfiguration archive; @Parameter(property = "citrus.remote.test.jar.provided", defaultValue = "false") private boolean testJarProvided = false; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyDescriptorConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyDescriptorConfiguration.java similarity index 97% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyDescriptorConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyDescriptorConfiguration.java index 99914ff..3132ac1 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/AssemblyDescriptorConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/AssemblyDescriptorConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.assembly.model.Assembly; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ReportConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ReportConfiguration.java similarity index 98% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ReportConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ReportConfiguration.java index 31e737e..b7b2a14 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ReportConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ReportConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; import org.apache.maven.plugins.annotations.Parameter; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/RunConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/RunConfiguration.java similarity index 98% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/RunConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/RunConfiguration.java index 755a11d..5cbe352 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/RunConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/RunConfiguration.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; + +import org.apache.maven.plugins.annotations.Parameter; import java.util.List; import java.util.Map; -import org.apache.maven.plugins.annotations.Parameter; - /** * @author Christoph Deppisch * @since 2.7.4 diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ServerConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ServerConfiguration.java similarity index 96% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ServerConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ServerConfiguration.java index 3b23994..64e9fab 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/ServerConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/ServerConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; import org.apache.maven.plugins.annotations.Parameter; diff --git a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/TestJarConfiguration.java b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/TestJarConfiguration.java similarity index 98% rename from citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/TestJarConfiguration.java rename to citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/TestJarConfiguration.java index 619f8dd..a0588cd 100644 --- a/citrus-remote-maven-plugin/src/main/java/com/consol/citrus/remote/plugin/config/TestJarConfiguration.java +++ b/citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/config/TestJarConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.consol.citrus.remote.plugin.config; +package org.citrusframework.remote.plugin.config; import org.apache.maven.plugins.annotations.Parameter; diff --git a/citrus-remote-maven-plugin/src/main/resources/log4j2.xml b/citrus-remote-maven-plugin/src/main/resources/log4j2.xml index 3d53271..b275c86 100644 --- a/citrus-remote-maven-plugin/src/main/resources/log4j2.xml +++ b/citrus-remote-maven-plugin/src/main/resources/log4j2.xml @@ -28,7 +28,7 @@ - + diff --git a/citrus-remote-maven-plugin/src/test/resources/log4j2-test.xml b/citrus-remote-maven-plugin/src/test/resources/log4j2-test.xml index 3d53271..b275c86 100644 --- a/citrus-remote-maven-plugin/src/test/resources/log4j2-test.xml +++ b/citrus-remote-maven-plugin/src/test/resources/log4j2-test.xml @@ -28,7 +28,7 @@ - + diff --git a/citrus-remote-server/pom.xml b/citrus-remote-server/pom.xml index 79eb09f..34accf5 100644 --- a/citrus-remote-server/pom.xml +++ b/citrus-remote-server/pom.xml @@ -4,8 +4,8 @@ citrus-remote - com.consol.citrus - 3.5.0-SNAPSHOT + org.citrusframework + 4.4.0-SNAPSHOT ../pom.xml @@ -13,6 +13,75 @@ Citrus :: Tools :: Remote Server Citrus Remote Server + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + org.eclipse.jetty* + jakarta.servlet:jakarta.servlet-api + com.sparkjava* + org.citrusframework:citrus-remote + + + ${project.build.directory}/dependency-reduced-pom.xml + + + org.eclipse.jetty + shaded.org.eclipse.jetty + + META-INF/*.MF + + + + javax.servlet + shaded.javax.servlet + + + + + org.eclipse.jetty* + + META-INF/*.MF + META-INF/LICENSE + META-INF/NOTICE.txt + about.html + + + + jakarta.servlet + + META-INF/*.MF + + + + com.sparkjava* + + META-INF/*.MF + + + + + + + true + + + + + + + com.sparkjava @@ -34,11 +103,11 @@ - com.consol.citrus + org.citrusframework citrus-base - com.consol.citrus + org.citrusframework citrus-main diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/servlet/CitrusRemoteServletContainerInitializer.java b/citrus-remote-server/src/main/java/com/consol/citrus/remote/servlet/CitrusRemoteServletContainerInitializer.java deleted file mode 100644 index 5eea5ce..0000000 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/servlet/CitrusRemoteServletContainerInitializer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2006-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.consol.citrus.remote.servlet; - -import com.consol.citrus.remote.CitrusRemoteApplication; -import spark.servlet.SparkFilter; - -import javax.servlet.*; -import java.util.Set; - -/** - * @author Christoph Deppisch - * @since 2.7.4 - */ -public class CitrusRemoteServletContainerInitializer implements ServletContainerInitializer { - - @Override - public void onStartup(Set> c, ServletContext servletContext) throws ServletException { - FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("spark-filter", SparkFilter.class); - encodingFilter.setInitParameter(SparkFilter.APPLICATION_CLASS_PARAM, CitrusRemoteApplication.class.getName()); - encodingFilter.addMappingForUrlPatterns(null, false, "/*"); - } -} diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteApplication.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteApplication.java similarity index 73% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteApplication.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteApplication.java index f329ba0..2011285 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteApplication.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteApplication.java @@ -14,53 +14,41 @@ * limitations under the License. */ -package com.consol.citrus.remote; +package org.citrusframework.remote; + +import org.citrusframework.Citrus; +import org.citrusframework.CitrusInstanceManager; +import org.citrusframework.CitrusInstanceStrategy; +import org.citrusframework.TestClass; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.main.CitrusAppConfiguration; +import org.citrusframework.main.TestRunConfiguration; +import org.citrusframework.remote.controller.RunController; +import org.citrusframework.remote.job.RunJob; +import org.citrusframework.remote.model.RemoteResult; +import org.citrusframework.remote.reporter.RemoteTestResultReporter; +import org.citrusframework.remote.transformer.JsonRequestTransformer; +import org.citrusframework.remote.transformer.JsonResponseTransformer; +import org.citrusframework.report.JUnitReporter; +import org.citrusframework.report.LoggingReporter; +import org.citrusframework.util.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import spark.Filter; +import spark.servlet.SparkApplication; import java.io.File; import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; +import java.util.concurrent.*; import java.util.stream.Stream; -import com.consol.citrus.Citrus; -import com.consol.citrus.CitrusInstanceManager; -import com.consol.citrus.CitrusInstanceStrategy; -import com.consol.citrus.TestClass; -import com.consol.citrus.exceptions.CitrusRuntimeException; -import com.consol.citrus.main.CitrusAppConfiguration; -import com.consol.citrus.main.TestRunConfiguration; -import com.consol.citrus.remote.controller.RunController; -import com.consol.citrus.remote.job.RunJob; -import com.consol.citrus.remote.model.RemoteResult; -import com.consol.citrus.remote.reporter.RemoteTestResultReporter; -import com.consol.citrus.remote.transformer.JsonRequestTransformer; -import com.consol.citrus.remote.transformer.JsonResponseTransformer; -import com.consol.citrus.report.JUnitReporter; -import com.consol.citrus.report.LoggingReporter; -import com.consol.citrus.util.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.ClassUtils; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; -import spark.Filter; -import spark.servlet.SparkApplication; - -import static spark.Spark.before; -import static spark.Spark.exception; -import static spark.Spark.get; -import static spark.Spark.halt; -import static spark.Spark.path; -import static spark.Spark.post; -import static spark.Spark.put; +import static spark.Spark.*; /** * Remote application creates routes for this web application. @@ -71,13 +59,14 @@ public class CitrusRemoteApplication implements SparkApplication { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusRemoteApplication.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusRemoteApplication.class); /** Global url encoding */ private static final String ENCODING = "UTF-8"; /** Content types */ private static final String APPLICATION_JSON = "application/json"; private static final String APPLICATION_XML = "application/xml"; + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; /** Application configuration */ private final CitrusRemoteConfiguration configuration; @@ -95,6 +84,7 @@ public class CitrusRemoteApplication implements SparkApplication { /** * Default constructor using default configuration. */ + @SuppressWarnings("unused") public CitrusRemoteApplication() { this(new CitrusRemoteConfiguration()); } @@ -110,17 +100,29 @@ public CitrusRemoteApplication(CitrusRemoteConfiguration configuration) { @Override public void init() { CitrusInstanceManager.mode(CitrusInstanceStrategy.SINGLETON); - CitrusInstanceManager.addInstanceProcessor(citrus -> { - citrus.addTestReporter(remoteTestResultReporter); - }); + CitrusInstanceManager.addInstanceProcessor(citrus -> citrus.addTestReporter(remoteTestResultReporter)); - before((Filter) (request, response) -> LOG.info(request.requestMethod() + " " + request.url() + Optional.ofNullable(request.queryString()).map(query -> "?" + query).orElse(""))); + before((Filter) (request, response) -> logger.info("{} {}{}", request.requestMethod(), request.url(), Optional.ofNullable(request.queryString()).map(query -> "?" + query).orElse(""))); get("/health", (req, res) -> { res.type(APPLICATION_JSON); return "{ \"status\": \"UP\" }"; }); + get("/files/:name", (req, res) -> { + res.type(APPLICATION_OCTET_STREAM); + String fileName = req.params(":name"); + Path file = Path.of(fileName); + + if (Files.isRegularFile(file)) { + res.header( + "Content-Disposition", + "attachment; filename=\"" + file.getFileName() + "\""); + return Files.readAllBytes(file); + } + return null; + }); + path("/results", () -> { get("", APPLICATION_JSON, (req, res) -> { res.type(APPLICATION_JSON); @@ -149,7 +151,10 @@ public void init() { File junitReportsFolder = new File(getJUnitReportsFolder()); if (junitReportsFolder.exists()) { - return Stream.of(Optional.ofNullable(junitReportsFolder.list()).orElse(new String[] {})).collect(Collectors.toList()); + return Optional.ofNullable(junitReportsFolder.list()) + .stream(). + flatMap(Stream::of) + .toList(); } return Collections.emptyList(); @@ -192,7 +197,7 @@ public void init() { } if (req.queryParams().contains("includes")) { - runConfiguration.setIncludes(StringUtils.commaDelimitedListToStringArray(URLDecoder.decode(req.queryParams("includes"), ENCODING))); + runConfiguration.setIncludes(URLDecoder.decode(req.queryParams("includes"), ENCODING).split(",")); } if (req.queryParams().contains("package")) { @@ -200,7 +205,7 @@ public void init() { } if (req.queryParams().contains("class")) { - runConfiguration.setTestClasses(Collections.singletonList(TestClass.fromString(URLDecoder.decode(req.queryParams("class"), ENCODING)))); + runConfiguration.setTestSources(Collections.singletonList(TestClass.fromString(URLDecoder.decode(req.queryParams("class"), ENCODING)))); } res.type(APPLICATION_JSON); @@ -254,20 +259,20 @@ private List runTests(TestRunConfiguration runConfiguration) { runController.setEngine(runConfiguration.getEngine()); runController.setIncludes(runConfiguration.getIncludes()); - if (!CollectionUtils.isEmpty(runConfiguration.getDefaultProperties())) { + if (!runConfiguration.getDefaultProperties().isEmpty()) { runController.addDefaultProperties(runConfiguration.getDefaultProperties()); } - if (CollectionUtils.isEmpty(runConfiguration.getPackages()) && CollectionUtils.isEmpty(runConfiguration.getTestClasses())) { + if (runConfiguration.getPackages().isEmpty() && runConfiguration.getTestSources().isEmpty()) { runController.runAll(); } - if (!CollectionUtils.isEmpty(runConfiguration.getPackages())) { + if (!runConfiguration.getPackages().isEmpty()) { runController.runPackages(runConfiguration.getPackages()); } - if (!CollectionUtils.isEmpty(runConfiguration.getTestClasses())) { - runController.runClasses(runConfiguration.getTestClasses()); + if (!runConfiguration.getTestSources().isEmpty()) { + runController.runClasses(runConfiguration.getTestSources()); } List results = new ArrayList<>(); @@ -280,9 +285,10 @@ private List runTests(TestRunConfiguration runConfiguration) { * @return */ private String getJUnitReportsFolder() { - if (ClassUtils.isPresent("org.testng.annotations.Test", getClass().getClassLoader())) { + + if (isPresent("org.testng.annotations.Test")) { return "test-output" + File.separator + "junitreports"; - } else if (ClassUtils.isPresent("org.junit.Test", getClass().getClassLoader())) { + } else if (isPresent("org.junit.Test")) { JUnitReporter jUnitReporter = new JUnitReporter(); return jUnitReporter.getReportDirectory() + File.separator + jUnitReporter.getOutputDirectory(); } else { @@ -294,8 +300,19 @@ private String getJUnitReportsFolder() { public void destroy() { Optional citrus = CitrusInstanceManager.get(); if (citrus.isPresent()) { - LOG.info("Closing Citrus and its application context"); + logger.info("Closing Citrus and its application context"); citrus.get().close(); } } + + // TODO: Check if this is equivalent to + // https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/main/java/org/springframework/util/ClassUtils.java + private boolean isPresent(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } } diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteConfiguration.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteConfiguration.java similarity index 90% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteConfiguration.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteConfiguration.java index 9aa6068..95711c8 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteConfiguration.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteConfiguration.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.consol.citrus.remote; +package org.citrusframework.remote; -import com.consol.citrus.main.CitrusAppConfiguration; +import org.citrusframework.main.CitrusAppConfiguration; /** * @author Christoph Deppisch @@ -52,7 +52,7 @@ public void setPort(int port) { public void apply(CitrusAppConfiguration configuration) { setEngine(configuration.getEngine()); setPackages(configuration.getPackages()); - setTestClasses(configuration.getTestClasses()); + setTestSources(configuration.getTestSources()); setIncludes(configuration.getIncludes()); addDefaultProperties(configuration.getDefaultProperties()); } diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteOptions.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteOptions.java similarity index 87% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteOptions.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteOptions.java index 2b11948..867050b 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteOptions.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteOptions.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.consol.citrus.remote; +package org.citrusframework.remote; -import java.util.LinkedList; +import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.main.CitrusAppOptions; +import org.citrusframework.util.StringUtils; -import com.consol.citrus.exceptions.CitrusRuntimeException; -import com.consol.citrus.main.CitrusAppOptions; -import org.springframework.util.StringUtils; +import java.util.LinkedList; /** * @author Christoph Deppisch diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteServer.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteServer.java similarity index 90% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteServer.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteServer.java index ad68a19..076db9a 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/CitrusRemoteServer.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/CitrusRemoteServer.java @@ -14,18 +14,19 @@ * limitations under the License. */ -package com.consol.citrus.remote; +package org.citrusframework.remote; + +import org.citrusframework.remote.controller.RunController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import spark.Spark; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import com.consol.citrus.remote.controller.RunController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import spark.Spark; - +import static java.lang.Thread.currentThread; import static spark.Spark.port; /** @@ -34,7 +35,7 @@ public class CitrusRemoteServer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CitrusRemoteServer.class); + private static Logger logger = LoggerFactory.getLogger(CitrusRemoteServer.class); /** Endpoint configuration */ private final CitrusRemoteConfiguration configuration; @@ -76,6 +77,7 @@ public static void main(String[] args) { new CompletableFuture().get(server.configuration.getTimeToLive(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { server.stop(); + currentThread().interrupt(); } }); } @@ -134,7 +136,8 @@ public boolean waitForCompletion() { try { return completed.get(); } catch (InterruptedException | ExecutionException e) { - log.warn("Failed to wait for server completion", e); + logger.warn("Failed to wait for server completion", e); + currentThread().interrupt(); } return false; diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/controller/RunController.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/controller/RunController.java similarity index 71% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/controller/RunController.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/controller/RunController.java index c4d9fd9..36fe321 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/controller/RunController.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/controller/RunController.java @@ -14,18 +14,19 @@ * limitations under the License. */ -package com.consol.citrus.remote.controller; +package org.citrusframework.remote.controller; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import org.citrusframework.TestSource; +import org.citrusframework.main.CitrusApp; +import org.citrusframework.main.CitrusAppConfiguration; +import org.citrusframework.remote.CitrusRemoteConfiguration; +import org.citrusframework.spi.ResourcePathTypeResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import com.consol.citrus.TestClass; -import com.consol.citrus.main.CitrusApp; -import com.consol.citrus.main.CitrusAppConfiguration; -import com.consol.citrus.remote.CitrusRemoteConfiguration; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.util.*; /** * @author Christoph Deppisch @@ -33,6 +34,7 @@ */ public class RunController { + private static final Logger logger = LoggerFactory.getLogger(RunController.class); /** Test engine to run the tests */ private String engine; @@ -70,25 +72,36 @@ public void runPackages(List packages) { citrusAppConfiguration.setIncludes(Optional.ofNullable(includes).orElse(configuration.getIncludes())); citrusAppConfiguration.setPackages(packages); citrusAppConfiguration.setConfigClass(configuration.getConfigClass()); + citrusAppConfiguration.setTestJar(configuration.getTestJar()); citrusAppConfiguration.addDefaultProperties(configuration.getDefaultProperties()); citrusAppConfiguration.addDefaultProperties(defaultProperties); - run(citrusAppConfiguration); + try { + citrusAppConfiguration.setTestJar(Path.of(ResourcePathTypeResolver.ROOT.toURI()).toFile()); + run(citrusAppConfiguration); + } catch (URISyntaxException e) { + logger.error("Cannot transform URI {} to path", ResourcePathTypeResolver.ROOT, e); + } } /** * Run Citrus application with given test class names. - * @param testClasses + * @param testSources */ - public void runClasses(List testClasses) { + public void runClasses(List testSources) { CitrusAppConfiguration citrusAppConfiguration = new CitrusAppConfiguration(); citrusAppConfiguration.setEngine(engine); - citrusAppConfiguration.setTestClasses(testClasses); + citrusAppConfiguration.setTestSources(testSources); + citrusAppConfiguration.setTestJar(configuration.getTestJar()); citrusAppConfiguration.setConfigClass(configuration.getConfigClass()); citrusAppConfiguration.addDefaultProperties(configuration.getDefaultProperties()); citrusAppConfiguration.addDefaultProperties(defaultProperties); - - run(citrusAppConfiguration); + try { + citrusAppConfiguration.setTestJar(Path.of(ResourcePathTypeResolver.ROOT.toURI()).toFile()); + run(citrusAppConfiguration); + } catch (URISyntaxException e) { + logger.error("Cannot transform URI {} to path", ResourcePathTypeResolver.ROOT, e); + } } /** diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/job/RunJob.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/job/RunJob.java similarity index 86% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/job/RunJob.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/job/RunJob.java index 2602474..d43acbd 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/job/RunJob.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/job/RunJob.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.consol.citrus.remote.job; +package org.citrusframework.remote.job; -import com.consol.citrus.main.TestRunConfiguration; -import com.consol.citrus.remote.model.RemoteResult; +import org.citrusframework.main.TestRunConfiguration; +import org.citrusframework.remote.model.RemoteResult; import java.util.List; import java.util.concurrent.Callable; @@ -34,7 +34,7 @@ public abstract class RunJob implements Callable> { * Default constructor using run configuration. * @param runConfiguration */ - public RunJob(TestRunConfiguration runConfiguration) { + protected RunJob(TestRunConfiguration runConfiguration) { this.runConfiguration = runConfiguration; } diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/model/RemoteResult.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/model/RemoteResult.java similarity index 95% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/model/RemoteResult.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/model/RemoteResult.java index 29f950e..6d26271 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/model/RemoteResult.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/model/RemoteResult.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.consol.citrus.remote.model; +package org.citrusframework.remote.model; -import com.consol.citrus.TestResult; -import com.consol.citrus.exceptions.CitrusRuntimeException; +import org.citrusframework.TestResult; +import org.citrusframework.exceptions.CitrusRuntimeException; import java.io.PrintWriter; import java.io.StringWriter; @@ -85,9 +85,9 @@ public static TestResult toTestResult(RemoteResult remoteResult) { } else if (remoteResult.isSkipped()) { return TestResult.skipped(remoteResult.getTestName(), remoteResult.getTestClass()); } else if (remoteResult.isFailed()) { + // TODO: Check if this is fine, failure stack, failure type are never used in the new Citrus version return TestResult.failed(remoteResult.getTestName(), remoteResult.getTestClass(), remoteResult.getErrorMessage()) - .withFailureType(remoteResult.getCause()) - .withFailureStack(remoteResult.getFailureStack()); + .withFailureType(remoteResult.getCause()); } else { throw new CitrusRuntimeException("Unexpected test result state " + remoteResult.getTestName()); } diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/reporter/RemoteTestResultReporter.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/reporter/RemoteTestResultReporter.java similarity index 88% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/reporter/RemoteTestResultReporter.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/reporter/RemoteTestResultReporter.java index 68307b9..e91a7e8 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/reporter/RemoteTestResultReporter.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/reporter/RemoteTestResultReporter.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.consol.citrus.remote.reporter; +package org.citrusframework.remote.reporter; -import java.io.StringWriter; +import org.citrusframework.report.AbstractTestReporter; +import org.citrusframework.report.OutputStreamReporter; +import org.citrusframework.report.TestResults; -import com.consol.citrus.report.AbstractTestReporter; -import com.consol.citrus.report.OutputStreamReporter; -import com.consol.citrus.report.TestResults; +import java.io.StringWriter; /** * @author Christoph Deppisch diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonRequestTransformer.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonRequestTransformer.java similarity index 90% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonRequestTransformer.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonRequestTransformer.java index c62fc21..bbacc44 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonRequestTransformer.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonRequestTransformer.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.consol.citrus.remote.transformer; +package org.citrusframework.remote.transformer; -import com.consol.citrus.exceptions.CitrusRuntimeException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.citrusframework.exceptions.CitrusRuntimeException; import java.io.IOException; diff --git a/citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonResponseTransformer.java b/citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonResponseTransformer.java similarity index 93% rename from citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonResponseTransformer.java rename to citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonResponseTransformer.java index 171bdc5..b939809 100644 --- a/citrus-remote-server/src/main/java/com/consol/citrus/remote/transformer/JsonResponseTransformer.java +++ b/citrus-remote-server/src/main/java/org/citrusframework/remote/transformer/JsonResponseTransformer.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.consol.citrus.remote.transformer; +package org.citrusframework.remote.transformer; -import com.consol.citrus.exceptions.CitrusRuntimeException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import org.citrusframework.exceptions.CitrusRuntimeException; import spark.ResponseTransformer; /** diff --git a/citrus-remote-server/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer b/citrus-remote-server/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer deleted file mode 100644 index 99993cf..0000000 --- a/citrus-remote-server/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer +++ /dev/null @@ -1 +0,0 @@ -com.consol.citrus.remote.servlet.CitrusRemoteServletContainerInitializer \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index dd235ac..cda4787 100644 --- a/pom.xml +++ b/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - com.consol.citrus - 3.5.0-SNAPSHOT + org.citrusframework + 4.4.0-SNAPSHOT citrus-remote pom Citrus :: Tools :: Remote @@ -16,7 +16,7 @@ UTF-8 17 - 3.8.4 + 3.9.8 3.11.0 ${java.version} ${java.version} @@ -24,38 +24,38 @@ 3.0 3.2.0 - 3.0.0 - 3.1.1 + 3.1.0 + 3.7.1 2.12.1 - 3.0.0 - 3.0.2 - 3.1.0 + 3.3.1 + 3.6.0 + 3.1.1 2.22.2 1.6 - 3.0.0 - 2.5.2 - 3.0.2 - 3.3.1 + 3.4.0 + 3.1.1 + 3.3.0 + 3.5.0 1.6.13 - 3.7.1 - 3.6.2 - 2.5.3 - 3.0.2 - 1.11.1 + 3.13.1 + 3.9.0 + 3.0.1 + 3.0.2 + 1.11.2 3.0.1 2.22.2 - 3.1.0 + 3.4.0 2.7 - 0.13 + 0.15 - 3.4.0 + 4.3.1 1.1 - 1.2 - 4.5.14 - 2.14.2 + 1.3.3 + 5.3.1 + 2.17.2 + 2.22.1 + 2.0.11 4.0.4 - 2.20.0 - 2.0.6 2.9.4 @@ -110,19 +110,19 @@ - com.consol.citrus + org.citrusframework citrus-base ${citrus.version} - com.consol.citrus + org.citrusframework citrus-main ${citrus.version} - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${httpclient.version} @@ -205,12 +205,14 @@ ${maven.compat.version} provided + org.apache.maven maven-settings @@ -295,7 +297,7 @@ org.apache.maven.plugins maven-resources-plugin - ${maven.resource.plugin.version} + ${maven.resources.plugin.version} org.apache.maven.plugins