openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1765670 - in /openwebbeans/microwave/trunk: ./ microwave-core/ microwave-junit/ microwave-maven-plugin/ microwave-maven-plugin/src/main/java/org/apache/microwave/maven/ microwave-maven-plugin/src/test/java/org/ microwave-maven-plugin/src/t...
Date Wed, 19 Oct 2016 16:08:18 GMT
Author: rmannibucau
Date: Wed Oct 19 16:08:18 2016
New Revision: 1765670

URL: http://svn.apache.org/viewvc?rev=1765670&view=rev
Log:
fixing maven mojo and adding a small test

Added:
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/MicrowaveRunMojoTest.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Endpoint.java
      - copied, changed from r1765660, openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/Endpoint.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Injectable.java
      - copied unchanged from r1765660, openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/Injectable.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/RsApp.java
      - copied unchanged from r1765660, openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/RsApp.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/pom.xml
Modified:
    openwebbeans/microwave/trunk/microwave-core/pom.xml
    openwebbeans/microwave/trunk/microwave-junit/pom.xml
    openwebbeans/microwave/trunk/microwave-maven-plugin/pom.xml
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
    openwebbeans/microwave/trunk/pom.xml

Modified: openwebbeans/microwave/trunk/microwave-core/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/pom.xml?rev=1765670&r1=1765669&r2=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-core/pom.xml Wed Oct 19 16:08:18 2016
@@ -164,7 +164,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.12</version>
+      <version>${junit.version}</version>
       <scope>provided</scope>
     </dependency>
   </dependencies>

Modified: openwebbeans/microwave/trunk/microwave-junit/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-junit/pom.xml?rev=1765670&r1=1765669&r2=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-junit/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-junit/pom.xml Wed Oct 19 16:08:18 2016
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.12</version>
+      <version>${junit.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.microwave</groupId>

Modified: openwebbeans/microwave/trunk/microwave-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/pom.xml?rev=1765670&r1=1765669&r2=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/pom.xml Wed Oct 19 16:08:18 2016
@@ -31,9 +31,10 @@
 
   <artifactId>microwave-maven-plugin</artifactId>
   <name>Microwave :: Maven</name>
+  <packaging>maven-plugin</packaging>
 
   <properties>
-    <maven.version>3.0</maven.version>
+    <maven.version>3.3.9</maven.version>
   </properties>
 
   <dependencies>
@@ -41,11 +42,23 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>${maven.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.enterprise</groupId>
+          <artifactId>cdi-api</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>${maven.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.inject</groupId>
+          <artifactId>javax.inject</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
@@ -58,6 +71,31 @@
       <artifactId>microwave-core</artifactId>
       <version>${project.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.maven.plugin-testing</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>3.3.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-compat</artifactId>
+      <version>${maven.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>ziplock</artifactId>
+      <version>7.0.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java?rev=1765670&r1=1765669&r2=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
(original)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
Wed Oct 19 16:08:18 2016
@@ -51,58 +51,58 @@ import static org.apache.maven.plugins.a
 
 @Mojo(name = "run", requiresDependencyResolution = RUNTIME_PLUS_SYSTEM)
 public class MicrowaveRunMojo extends AbstractMojo {
-    @Parameter(name = "microwave.http", defaultValue = "8080")
+    @Parameter(property = "microwave.http", defaultValue = "8080")
     private int httpPort;
 
-    @Parameter(name = "microwave.https", defaultValue = "8443")
+    @Parameter(property = "microwave.https", defaultValue = "8443")
     private int httpsPort;
 
-    @Parameter(name = "microwave.stop", defaultValue = "8005")
+    @Parameter(property = "microwave.stop", defaultValue = "8005")
     private int stopPort;
 
-    @Parameter(name = "microwave.host", defaultValue = "localhost")
+    @Parameter(property = "microwave.host", defaultValue = "localhost")
     private String host;
 
-    @Parameter(name = "microwave.dir")
+    @Parameter(property = "microwave.dir")
     protected String dir;
 
-    @Parameter(name = "microwave.serverXml")
+    @Parameter(property = "microwave.serverXml")
     private File serverXml;
 
-    @Parameter(name = "microwave.keepServerXmlAsThis")
+    @Parameter(property = "microwave.keepServerXmlAsThis")
     private boolean keepServerXmlAsThis;
 
     @Parameter
     private Map<String, String> properties;
 
-    @Parameter(name = "microwave.quickSession", defaultValue = "true")
+    @Parameter(property = "microwave.quickSession", defaultValue = "true")
     private boolean quickSession;
 
-    @Parameter(name = "microwave.skipHttp")
+    @Parameter(property = "microwave.skipHttp")
     private boolean skipHttp;
 
-    @Parameter(name = "microwave.ssl")
+    @Parameter(property = "microwave.ssl")
     private boolean ssl;
 
-    @Parameter(name = "microwave.keystoreFile")
+    @Parameter(property = "microwave.keystoreFile")
     private String keystoreFile;
 
-    @Parameter(name = "microwave.keystorePass")
+    @Parameter(property = "microwave.keystorePass")
     private String keystorePass;
 
-    @Parameter(name = "microwave.keystoreType", defaultValue = "JKS")
+    @Parameter(property = "microwave.keystoreType", defaultValue = "JKS")
     private String keystoreType;
 
-    @Parameter(name = "microwave.clientAuth")
+    @Parameter(property = "microwave.clientAuth")
     private String clientAuth;
 
-    @Parameter(name = "microwave.keyAlias")
+    @Parameter(property = "microwave.keyAlias")
     private String keyAlias;
 
-    @Parameter(name = "microwave.sslProtocol")
+    @Parameter(property = "microwave.sslProtocol")
     private String sslProtocol;
 
-    @Parameter(name = "microwave.webXml")
+    @Parameter(property = "microwave.webXml")
     private String webXml;
 
     @Parameter
@@ -117,31 +117,31 @@ public class MicrowaveRunMojo extends Ab
     @Parameter
     private Map<String, String> roles;
 
-    @Parameter(name = "microwave.http2")
+    @Parameter(property = "microwave.http2")
     private boolean http2;
 
-    @Parameter(name = "microwave.tempDir")
+    @Parameter(property = "microwave.tempDir")
     private String tempDir;
 
-    @Parameter(name = "microwave.webResourceCached", defaultValue = "true")
+    @Parameter(property = "microwave.webResourceCached", defaultValue = "true")
     private boolean webResourceCached;
 
-    @Parameter(name = "microwave.conf")
+    @Parameter(property = "microwave.conf")
     private String conf;
 
-    @Parameter(name = "microwave.deleteBaseOnStartup", defaultValue = "true")
+    @Parameter(property = "microwave.deleteBaseOnStartup", defaultValue = "true")
     private boolean deleteBaseOnStartup;
 
-    @Parameter(name = "microwave.jaxrsMapping", defaultValue = "/*")
+    @Parameter(property = "microwave.jaxrsMapping", defaultValue = "/*")
     private String jaxrsMapping;
 
-    @Parameter(name = "microwave.cdiConversation", defaultValue = "true")
+    @Parameter(property = "microwave.cdiConversation", defaultValue = "true")
     private boolean cdiConversation;
 
-    @Parameter(name = "microwave.skip")
+    @Parameter(property = "microwave.skip")
     private boolean skip;
 
-    @Parameter(name = "microwave.jaxrs-provider-setup", defaultValue = "true")
+    @Parameter(property = "microwave.jaxrs-provider-setup", defaultValue = "true")
     private boolean jaxrsProviderSetup;
 
     @Parameter
@@ -156,10 +156,10 @@ public class MicrowaveRunMojo extends Ab
     @Parameter(defaultValue = "${project}", readonly = true, required = true)
     private MavenProject project;
 
-    @Parameter(name = "microwave.context", defaultValue = "")
+    @Parameter(property = "microwave.context", defaultValue = "")
     private String context;
 
-    @Parameter(name = "microwave.webapp")
+    @Parameter(property = "microwave.webapp")
     private File webapp;
 
     @Override

Added: openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/MicrowaveRunMojoTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/MicrowaveRunMojoTest.java?rev=1765670&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/MicrowaveRunMojoTest.java
(added)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/apache/microwave/maven/MicrowaveRunMojoTest.java
Wed Oct 19 16:08:18 2016
@@ -0,0 +1,121 @@
+/*
+ * 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
+ *
+ * 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 org.apache.microwave.maven;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.testing.MojoRule;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ServerSocket;
+import java.net.URL;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.ziplock.JarLocation.jarLocation;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class MicrowaveRunMojoTest {
+    @Rule
+    public final MojoRule mojo = new MojoRule();
+
+    @Test
+    public void run() throws Exception {
+        final File moduleBase = jarLocation(MicrowaveRunMojoTest.class).getParentFile().getParentFile();
+        final File basedir = new File(moduleBase, "src/test/resources/" + getClass().getSimpleName());
+        final File pom = new File(basedir, "pom.xml");
+        final MavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        request.setBaseDirectory(basedir);
+        final ProjectBuildingRequest configuration = request.getProjectBuildingRequest();
+        final DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
+                .newInstance(repositorySession, new LocalRepository(new File(moduleBase,
"target/fake"), "")));
+        configuration.setRepositorySession(repositorySession);
+        final MavenProject project = mojo.lookup(ProjectBuilder.class).build(pom, configuration).getProject();
+        final MavenSession session = mojo.newMavenSession(project);
+        final int port;
+        try (final ServerSocket serverSocket = new ServerSocket(0)) {
+            port = serverSocket.getLocalPort();
+        }
+        final MojoExecution execution = mojo.newMojoExecution("run");
+        execution.getConfiguration().addChild(new Xpp3Dom("httpPort") {{
+            setValue(Integer.toString(port));
+        }});
+        final InputStream in = System.in;
+        final CountDownLatch latch = new CountDownLatch(1);
+        System.setIn(new InputStream() {
+            private int val = 2; // just to not return nothing
+
+            @Override
+            public int read() throws IOException {
+                try {
+                    latch.await();
+                } catch (final InterruptedException e) {
+                    Thread.interrupted();
+                    fail(e.getMessage());
+                }
+                return val--;
+            }
+        });
+        final Thread runner = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    mojo.executeMojo(session, project, execution);
+                } catch (final Exception e) {
+                    fail(e.getMessage());
+                }
+            }
+        };
+        try {
+            runner.start();
+            for (int i = 0; i < 120; i++) {
+                try {
+                    assertEquals("simple", IOUtils.toString(new URL("http://localhost:" +
port + "/api/test")));
+                    latch.countDown();
+                    break;
+                } catch (final Exception | AssertionError e) {
+                    Thread.sleep(500);
+                }
+            }
+        } finally {
+            runner.join(TimeUnit.MINUTES.toMillis(1));
+            System.setIn(in);
+            if (runner.isAlive()) {
+                runner.interrupt();
+                fail("Runner didn't terminate properly");
+            }
+        }
+    }
+}

Copied: openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Endpoint.java
(from r1765660, openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/Endpoint.java)
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Endpoint.java?p2=openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Endpoint.java&p1=openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/Endpoint.java&r1=1765660&r2=1765670&rev=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-junit/src/test/java/org/app/Endpoint.java (original)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/java/org/app/Endpoint.java
Wed Oct 19 16:08:18 2016
@@ -36,31 +36,4 @@ public class Endpoint {
     public String simple() {
         return Boolean.parseBoolean(injectable.injected()) ? "simple" : "fail";
     }
-
-    @GET
-    @Path("json")
-    @Produces(MediaType.APPLICATION_JSON)
-    public Simple json() {
-        return new Simple("test");
-    }
-
-    public static class Simple {
-        private String name;
-
-        public Simple() {
-            // no-op
-        }
-
-        public Simple(final String name) {
-            this.name = name;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(final String name) {
-            this.name = name;
-        }
-    }
 }

Added: openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/pom.xml?rev=1765670&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/pom.xml
(added)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/test/resources/MicrowaveRunMojoTest/pom.xml
Wed Oct 19 16:08:18 2016
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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
+
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="
+            http://maven.apache.org/POM/4.0.0
+            http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.microwave.test</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.microwave</groupId>
+        <artifactId>microwave-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Modified: openwebbeans/microwave/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/pom.xml?rev=1765670&r1=1765669&r2=1765670&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/pom.xml (original)
+++ openwebbeans/microwave/trunk/pom.xml Wed Oct 19 16:08:18 2016
@@ -37,6 +37,10 @@
   <name>Microwave</name>
   <description>A Microprofile server @ ASF</description>
 
+  <properties>
+    <junit.version>4.12</junit.version>
+  </properties>
+
   <modules>
     <module>microwave-core</module>
     <module>microwave-maven-plugin</module>



Mime
View raw message