openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1790512 - in /openwebbeans/meecrowave/trunk: ./ meecrowave-doc/src/main/jbake/content/ meecrowave-doc/src/main/jbake/content/meecrowave-core/ sample/ sample/src/ sample/src/main/ sample/src/main/java/ sample/src/main/java/com/ sample/src/m...
Date Fri, 07 Apr 2017 07:22:07 GMT
Author: rmannibucau
Date: Fri Apr  7 07:22:07 2017
New Revision: 1790512

URL: http://svn.apache.org/viewvc?rev=1790512&view=rev
Log:
MEECROWAVE-23 sample project and doc fix

Added:
    openwebbeans/meecrowave/trunk/sample/
    openwebbeans/meecrowave/trunk/sample/README.adoc
    openwebbeans/meecrowave/trunk/sample/pom.xml
    openwebbeans/meecrowave/trunk/sample/src/
    openwebbeans/meecrowave/trunk/sample/src/main/
    openwebbeans/meecrowave/trunk/sample/src/main/java/
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/Defaults.java
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/DefaultsProducer.java
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloApplication.java
    openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
    openwebbeans/meecrowave/trunk/sample/src/main/resources/
    openwebbeans/meecrowave/trunk/sample/src/test/
    openwebbeans/meecrowave/trunk/sample/src/test/java/
    openwebbeans/meecrowave/trunk/sample/src/test/java/com/
    openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/
    openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/
    openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/HelloEndpointTest.java
Modified:
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-core/configuration.adoc
    openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/start.adoc
    openwebbeans/meecrowave/trunk/pom.xml

Modified: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-core/configuration.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-core/configuration.adoc?rev=1790512&r1=1790511&r2=1790512&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-core/configuration.adoc
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/meecrowave-core/configuration.adoc
Fri Apr  7 07:22:07 2017
@@ -23,12 +23,13 @@ Example:
 
 [source,java]
 ----
-new Meecrowave(new Builder()
-        .randomHttpPort()
-        .setTomcatScanning(false)
-        .setTomcatAutoSetup(false)
-        .setRealm(new JAASRealm())
-        .user("admin", "secret"))
+new Meecrowave(new Builder() {{
+        randomHttpPort();
+        setTomcatScanning(false);
+        setTomcatAutoSetup(false);
+        setRealm(new JAASRealm());
+        user("admin", "secret");
+     }})
     .bake()
     .await();
 ----

Modified: openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/start.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/start.adoc?rev=1790512&r1=1790511&r2=1790512&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/start.adoc (original)
+++ openwebbeans/meecrowave/trunk/meecrowave-doc/src/main/jbake/content/start.adoc Fri Apr
 7 07:22:07 2017
@@ -87,4 +87,8 @@ Finally you can test it:
 [source,bash]
 ----
 curl http://localhost:8080/hello
-----
\ No newline at end of file
+----
+
+== Sample
+
+https://github.com/apache/meecrowave/tree/trunk/sample module is a ready to use hello world
using meecrowave.

Modified: openwebbeans/meecrowave/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/pom.xml?rev=1790512&r1=1790511&r2=1790512&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/pom.xml Fri Apr  7 07:22:07 2017
@@ -75,6 +75,7 @@
     <module>meecrowave-jta</module>
     <module>integration-tests</module>
     <module>meecrowave-oauth2</module>
+    <module>sample</module>
   </modules>
 
   <build>

Added: openwebbeans/meecrowave/trunk/sample/README.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/README.adoc?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/README.adoc (added)
+++ openwebbeans/meecrowave/trunk/sample/README.adoc Fri Apr  7 07:22:07 2017
@@ -0,0 +1,12 @@
+= Meecrowave Sample
+
+This project shows how to use meecrowave for simple applications.
+
+Here what it provides:
+
+0. A pom.xml with the dependencies for this sample and meecrowave-maven-plugin setup so you
can launch `mvn package meecrowave-run`.
+1. A sample JAX-RS application: in src/main/java/com/superbiz/sample/jaxrs
+2. A test using JAX-RS client API and the meecrowave mono rule (useful when you run multiple
tests) in src/test/java/com/superbiz/sample/jaxrs
+3. in src/main/java/com/superbiz/configuration/Defaults some enrichment of the meecrowave
Cli options for the application.
+
+To use it launch meecrowave main (org.apache.meecrowave.runner.Cli) with option `--app-default-name
foo`.

Added: openwebbeans/meecrowave/trunk/sample/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/pom.xml?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/pom.xml (added)
+++ openwebbeans/meecrowave/trunk/sample/pom.xml Fri Apr  7 07:22:07 2017
@@ -0,0 +1,83 @@
+<?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">
+  <parent>
+    <artifactId>meecrowave</artifactId>
+    <groupId>org.apache.meecrowave</groupId>
+    <version>0.3.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>sample</artifactId>
+  <name>Meecrowave Sample</name>
+  <description>A project showing some of the meecrowave features.</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.meecrowave</groupId>
+      <artifactId>meecrowave-core</artifactId>
+      <version>0.3.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.3.1</version>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.meecrowave</groupId>
+      <artifactId>meecrowave-junit</artifactId>
+      <version>0.3.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.meecrowave</groupId>
+        <artifactId>meecrowave-maven-plugin</artifactId>
+        <version>0.3.1-SNAPSHOT</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>

Added: openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/Defaults.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/Defaults.java?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/Defaults.java
(added)
+++ openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/Defaults.java
Fri Apr  7 07:22:07 2017
@@ -0,0 +1,31 @@
+/*
+ * 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 com.superbiz.configuration;
+
+import org.apache.meecrowave.runner.Cli;
+import org.apache.meecrowave.runner.cli.CliOption;
+
+public class Defaults implements Cli.Options {
+    @CliOption(name = "app-default-name", description = "The name used to say hello if not
set")
+    private String name = "default value";
+
+    public String getName() {
+        return name;
+    }
+}

Added: openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/DefaultsProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/DefaultsProducer.java?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/DefaultsProducer.java
(added)
+++ openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/configuration/DefaultsProducer.java
Fri Apr  7 07:22:07 2017
@@ -0,0 +1,38 @@
+/*
+ * 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 com.superbiz.configuration;
+
+import org.apache.meecrowave.Meecrowave;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+@Dependent
+public class DefaultsProducer {
+    @Inject
+    private Meecrowave.Builder builder;
+
+    @Produces
+    @ApplicationScoped
+    public Defaults defaults() {
+        return builder.getExtension(Defaults.class);
+    }
+}

Added: openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloApplication.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloApplication.java?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloApplication.java
(added)
+++ openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloApplication.java
Fri Apr  7 07:22:07 2017
@@ -0,0 +1,28 @@
+/*
+ * 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 com.superbiz.jaxrs;
+
+import javax.enterprise.context.Dependent;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@Dependent
+@ApplicationPath("api")
+public class HelloApplication extends Application {
+}

Added: openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
(added)
+++ openwebbeans/meecrowave/trunk/sample/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
Fri Apr  7 07:22:07 2017
@@ -0,0 +1,67 @@
+/*
+ * 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 com.superbiz.jaxrs;
+
+import com.superbiz.configuration.Defaults;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+
+import static java.util.Optional.ofNullable;
+
+@Path("hello")
+@ApplicationScoped
+public class HelloEndpoint {
+    @Inject
+    private Defaults defaults;
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Hello sayHi(@QueryParam("name") final String name) {
+        return new Hello(ofNullable(name).orElse(defaults.getName()));
+    }
+
+    public static class Hello {
+        private String name;
+
+        public Hello() {
+            // no-op
+        }
+
+        private Hello(final String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(final String name) {
+            this.name = name;
+        }
+    }
+}

Added: openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/HelloEndpointTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/HelloEndpointTest.java?rev=1790512&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/HelloEndpointTest.java
(added)
+++ openwebbeans/meecrowave/trunk/sample/src/test/java/com/superbiz/jaxrs/HelloEndpointTest.java
Fri Apr  7 07:22:07 2017
@@ -0,0 +1,52 @@
+/*
+ * 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 com.superbiz.jaxrs;
+
+import org.apache.meecrowave.Meecrowave;
+import org.apache.meecrowave.junit.MonoMeecrowave;
+import org.apache.meecrowave.testing.ConfigurationInject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(MonoMeecrowave.Runner.class)
+public class HelloEndpointTest {
+    @ConfigurationInject
+    private Meecrowave.Builder configuration;
+
+    @Test
+    public void hello() {
+        final Client client = ClientBuilder.newClient();
+        try {
+            assertEquals("me", client.target("http://localhost:" + configuration.getHttpPort())
+                    .path("api/hello")
+                    .queryParam("name", "me")
+                    .request(APPLICATION_JSON_TYPE)
+                    .get(HelloEndpoint.Hello.class)
+                    .getName());
+        } finally {
+            client.close();
+        }
+    }
+}



Mime
View raw message