Author: struberg
Date: Sun Apr 1 10:51:24 2018
New Revision: 1828139
URL: http://svn.apache.org/viewvc?rev=1828139&view=rev
Log:
improve samples. Add trivial sample
Thanks to Sven Ruppert for the patch!
fixes: #6
Added:
openwebbeans/meecrowave/trunk/sample/rest/ (with props)
openwebbeans/meecrowave/trunk/sample/rest-trivial/ (with props)
openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml (with props)
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
(with props)
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java
(with props)
openwebbeans/meecrowave/trunk/sample/rest/pom.xml (with props)
openwebbeans/meecrowave/trunk/sample/rest/src/
- copied from r1828138, openwebbeans/meecrowave/trunk/sample/src/
Removed:
openwebbeans/meecrowave/trunk/sample/src/
Modified:
openwebbeans/meecrowave/trunk/sample/pom.xml
openwebbeans/meecrowave/trunk/sample/rest/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
Modified: openwebbeans/meecrowave/trunk/sample/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/pom.xml?rev=1828139&r1=1828138&r2=1828139&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/sample/pom.xml Sun Apr 1 10:51:24 2018
@@ -17,63 +17,70 @@
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>1.2.2-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>1.2.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>${commons-cli.version}</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>1.2.2-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
+ 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>
- <artifactId>meecrowave-maven-plugin</artifactId>
<version>1.2.2-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>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>samples</artifactId>
+ <packaging>pom</packaging>
+ <name>Meecrowave Samples</name>
+ <description>A project showing some of the meecrowave
features.</description>
+
+ <modules>
+ <module>rest-trivial</module>
+ <module>rest</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.meecrowave</groupId>
+ <artifactId>meecrowave-core</artifactId>
+ <version>1.2.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>${commons-cli.version}</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>1.2.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.meecrowave</groupId>
+ <artifactId>meecrowave-maven-plugin</artifactId>
+ <version>1.2.2-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>
Propchange: openwebbeans/meecrowave/trunk/sample/rest/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 1 10:51:24 2018
@@ -0,0 +1,14 @@
+target
+.metadata
+.classpath
+.project
+.settings
+*.iml
+*.ipr
+*.iws
+.idea
+.git
+.gitignore
+*.log
+*.patch
+*.diff
Propchange: openwebbeans/meecrowave/trunk/sample/rest-trivial/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 1 10:51:24 2018
@@ -0,0 +1,14 @@
+target
+.metadata
+.classpath
+.project
+.settings
+*.iml
+*.ipr
+*.iws
+.idea
+.git
+.gitignore
+*.log
+*.patch
+*.diff
Added: openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml?rev=1828139&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml (added)
+++ openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml Sun Apr 1
10:51:24 2018
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.apache.meecrowave</groupId>
+ <version>1.2.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>samples-rest-trivial</artifactId>
+ <name>Meecrowave Samples - REST (trivial)</name>
+
+</project>
\ No newline at end of file
Propchange: openwebbeans/meecrowave/trunk/sample/rest-trivial/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java?rev=1828139&view=auto
==============================================================================
---
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
(added)
+++
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
Sun Apr 1 10:51:24 2018
@@ -0,0 +1,36 @@
+/*
+ * 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.ApplicationScoped;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("hello")
+@ApplicationScoped
+public class HelloEndpoint {
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String sayHi() {
+ return "Hello World";
+ }
+}
Propchange:
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java?rev=1828139&view=auto
==============================================================================
---
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java
(added)
+++
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java
Sun Apr 1 10:51:24 2018
@@ -0,0 +1,51 @@
+/*
+ * 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 junit.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("Hello World", client.target("http://localhost:" +
configuration.getHttpPort())
+ .path("/hello")
+ .request(APPLICATION_JSON_TYPE)
+ .get(String.class));
+ } finally {
+ client.close();
+ }
+ }
+}
Propchange:
openwebbeans/meecrowave/trunk/sample/rest-trivial/src/test/java/junit/com/superbiz/jaxrs/HelloEndpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/meecrowave/trunk/sample/rest/pom.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/rest/pom.xml?rev=1828139&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/sample/rest/pom.xml (added)
+++ openwebbeans/meecrowave/trunk/sample/rest/pom.xml Sun Apr 1 10:51:24 2018
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.apache.meecrowave</groupId>
+ <version>1.2.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>samples-rest</artifactId>
+ <name>Meecrowave Samples - REST</name>
+
+</project>
\ No newline at end of file
Propchange: openwebbeans/meecrowave/trunk/sample/rest/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openwebbeans/meecrowave/trunk/sample/rest/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
URL:
http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/sample/rest/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java?rev=1828139&r1=1828138&r2=1828139&view=diff
==============================================================================
---
openwebbeans/meecrowave/trunk/sample/rest/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
(original)
+++
openwebbeans/meecrowave/trunk/sample/rest/src/main/java/com/superbiz/jaxrs/HelloEndpoint.java
Sun Apr 1 10:51:24 2018
@@ -21,14 +21,11 @@ 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;
@@ -42,7 +39,8 @@ public class HelloEndpoint {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Hello sayHi(@QueryParam("name") final String name) {
- return new Hello(ofNullable(name).orElse(defaults.getName()));
+ return new Hello(ofNullable(name)
+ .orElse(defaults.getName()));
}
public static class Hello {