exemple rest-easy

Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3c242501
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3c242501
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3c242501

Branch: refs/heads/master
Commit: 3c2425018c6d5413f8d97237c6601a34127ee807
Parents: 4763c81
Author: Daniel Dias <[email protected]>
Authored: Thu Dec 13 01:22:11 2018 -0200
Committer: Daniel Dias <[email protected]>
Committed: Fri Dec 21 01:52:26 2018 -0200

----------------------------------------------------------------------
 examples/mvc-cxf/README.adoc                    |  24 +++
 examples/mvc-cxf/README.md                      |  23 ---
 examples/mvc-resteasy/README.adoc               |  23 +++
 examples/mvc-resteasy/pom.xml                   | 160 +++++++++++++++++++
 .../superbiz/application/MVCApplication.java    |   6 +
 .../superbiz/controller/TomeeController.java    |  23 +++
 .../src/main/resources/META-INF/beans.xml       |   6 +
 .../src/main/webapp/WEB-INF/views/hello.jsp     |  28 ++++
 .../src/main/webapp/WEB-INF/web.xml             |  28 ++++
 examples/mvc-resteasy/src/main/webapp/index.jsp |  28 ++++
 .../src/test/java/org/superbiz/mvc/MVCTest.java |  45 ++++++
 examples/pom.xml                                |   1 +
 12 files changed, 372 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-cxf/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mvc-cxf/README.adoc b/examples/mvc-cxf/README.adoc
new file mode 100644
index 0000000..e38087f
--- /dev/null
+++ b/examples/mvc-cxf/README.adoc
@@ -0,0 +1,24 @@
+= MVC-CXF
+:index-group: Misc
+:jbake-type: page
+:jbake-status: published
+
+
+Simple example of using link:http://mvc-spec.org[http://mvc-spec.org] together 
with Deltaspike-Data to do CRUD operations.
+
+=== Steps to run the example
+
+Build and start the demo:
+
+    mvn clean install tomee:run
+
+Open:
+
+    http://localhost:8080/mvc-cxf
+
+==== Intro of Eclipse Krazo
+    
+https://projects.eclipse.org/proposals/eclipse-krazo[https://projects.eclipse.org/proposals/eclipse-krazo]
 is an implementation of action-based MVC specifiec by MVC 1.0 (JSR-371). 
+
+It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey 
and CXF with a well-defined SPI for other implementations.
+

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-cxf/README.md
----------------------------------------------------------------------
diff --git a/examples/mvc-cxf/README.md b/examples/mvc-cxf/README.md
deleted file mode 100644
index 0d09b4d..0000000
--- a/examples/mvc-cxf/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-index-group=Misc
-type=page
-status=published
-title=MVC-CXF
-~~~~~~
-
-
-Simple example of using [JSR-371](http://mvc-spec.org) together with 
Deltaspike-Data to do CRUD operations.
-
-<h2>Steps to run the example</h2>
-
-Build and start the demo:
-
-    mvn clean package
-
-Open:
-
-    http://localhost:8080/mvc-cxf
-
-<h2>Intro of Eclipse Krazo</h2>
-    
-[Eclipse Krazo](https://projects.eclipse.org/proposals/eclipse-krazo) is an 
implementation of action-based MVC specifiec by MVC 1.0 (JSR-371). 
-It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey 
and CXF with a well-defined SPI for other imlementations.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/README.adoc 
b/examples/mvc-resteasy/README.adoc
new file mode 100644
index 0000000..d38d459
--- /dev/null
+++ b/examples/mvc-resteasy/README.adoc
@@ -0,0 +1,23 @@
+= MVC-RestEasy
+:index-group: Misc
+:jbake-type: page
+:jbake-status: published
+
+Simple Hello World example of using 
link:http://mvc-spec.org[http://mvc-spec.org] together with Ozark-RestEasy 
Module .
+
+=== Steps to run the example
+
+Build and start the demo:
+
+    mvn clean install tomee:run
+
+Open:
+
+    http://localhost:8080/mvc-resteasy
+
+
+==== Intro of Eclipse Krazo
+    
+https://projects.eclipse.org/proposals/eclipse-krazo[https://projects.eclipse.org/proposals/eclipse-krazo]
 is an implementation of action-based MVC specifiec by MVC 1.0 (JSR-371). 
+
+It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey 
and CXF with a well-defined SPI for other implementations.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/pom.xml b/examples/mvc-resteasy/pom.xml
new file mode 100644
index 0000000..a722a19
--- /dev/null
+++ b/examples/mvc-resteasy/pom.xml
@@ -0,0 +1,160 @@
+<?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.superbiz</groupId>
+  <artifactId>mvc-resteasy</artifactId>
+  <packaging>war</packaging>
+  <name>OpenEJB :: Examples :: MVC (RestEasy-based)</name>
+  <description>OpenEJB :: Web Examples :: MVC 1.0 - RestEasy</description>
+  <version>8.0.0-SNAPSHOT</version>
+  <url>http://tomee.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <tomee.version>8.0.0-SNAPSHOT</tomee.version>
+    <version.ozark>1.0.0-m04</version.ozark>
+    <resteasy.version>3.6.1.Final</resteasy.version>
+    <version.arquillian>1.1.13.Final</version.arquillian>
+    <version.graphene.webdriver>2.3.1</version.graphene.webdriver>
+  </properties>
+
+  <build>
+    <finalName>mvc-resteasy</finalName>
+    <plugins>
+      <plugin>
+       <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.5.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>3.1.0</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.tomee.maven</groupId>
+        <artifactId>tomee-maven-plugin</artifactId>
+        <version>8.0.0-SNAPSHOT</version>
+        <configuration>
+          <args>-Xmx512m -XX:PermSize=256m</args>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>https://repository.apache.org/content/groups/snapshots</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>8.0</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- MVC 1.0(JSR 371) -->
+    <dependency>
+      <groupId>org.mvc-spec.ozark</groupId>
+      <artifactId>ozark-resteasy</artifactId>
+      <version>${version.ozark}</version>
+    </dependency>
+
+    <!-- RestEasy -->
+    <dependency>
+      <groupId>org.jboss.resteasy</groupId>
+      <artifactId>resteasy-cdi</artifactId>
+      <version>${resteasy.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.resteasy</groupId>
+      <artifactId>resteasy-validator-provider-11</artifactId>
+      <version>${resteasy.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.resteasy</groupId>
+      <artifactId>resteasy-servlet-initializer</artifactId>
+      <version>${resteasy.version}</version>
+    </dependency>
+
+     <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+      <version>${version.arquillian}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>arquillian-tomee-remote</artifactId>
+      <version>${tomee.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>apache-tomee</artifactId>
+      <version>${tomee.version}</version>
+      <classifier>webprofile</classifier>
+      <type>zip</type>
+    </dependency> -->
+    <dependency>
+      <groupId>org.jboss.arquillian.graphene</groupId>
+      <artifactId>graphene-webdriver</artifactId>
+      <version>${version.graphene.webdriver}</version>
+      <type>pom</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <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>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/java/org/superbiz/application/MVCApplication.java
----------------------------------------------------------------------
diff --git 
a/examples/mvc-resteasy/src/main/java/org/superbiz/application/MVCApplication.java
 
b/examples/mvc-resteasy/src/main/java/org/superbiz/application/MVCApplication.java
new file mode 100644
index 0000000..1cc2d0d
--- /dev/null
+++ 
b/examples/mvc-resteasy/src/main/java/org/superbiz/application/MVCApplication.java
@@ -0,0 +1,6 @@
+package org.superbiz.application;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("app")
+public class MVCApplication extends Application { }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/java/org/superbiz/controller/TomeeController.java
----------------------------------------------------------------------
diff --git 
a/examples/mvc-resteasy/src/main/java/org/superbiz/controller/TomeeController.java
 
b/examples/mvc-resteasy/src/main/java/org/superbiz/controller/TomeeController.java
new file mode 100644
index 0000000..1eecfa4
--- /dev/null
+++ 
b/examples/mvc-resteasy/src/main/java/org/superbiz/controller/TomeeController.java
@@ -0,0 +1,23 @@
+package org.superbiz.controller;
+
+import javax.inject.Inject;
+import javax.mvc.Models;
+import javax.mvc.Controller;
+import javax.mvc.View;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+@Controller
+@Path("hello")
+public class TomeeController {
+
+    @Inject
+    private Models models;
+
+    @GET
+    @View("hello.jsp")
+    public void getHello(@QueryParam("name") String name) {
+        this.models.put("hello", name);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml 
b/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..86b63b7
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<beans bean-discovery-mode="all" version="2.0"
+    xmlns="http://xmlns.jcp.org/xml/ns/javaee";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd";>
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/webapp/WEB-INF/views/hello.jsp
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/webapp/WEB-INF/views/hello.jsp 
b/examples/mvc-resteasy/src/main/webapp/WEB-INF/views/hello.jsp
new file mode 100644
index 0000000..615b717d
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/webapp/WEB-INF/views/hello.jsp
@@ -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.
+-->
+<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>MVC 1.0 - Apache TomEE</title>
+</head>
+<body>
+    <h1>Welcome ${hello} !</h1>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/webapp/WEB-INF/web.xml 
b/examples/mvc-resteasy/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..029261a
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xmlns="http://xmlns.jcp.org/xml/ns/javaee";
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd";
+         version="4.0">
+    <display-name>mvc-resteasy</display-name>
+    <context-param>
+        <param-name>resteasy.injector.factory</param-name>
+        <param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
+    </context-param>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/webapp/index.jsp 
b/examples/mvc-resteasy/src/main/webapp/index.jsp
new file mode 100644
index 0000000..9f8a2f1
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/webapp/index.jsp
@@ -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.
+-->
+<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>>MVC 1.0 - Apache TomEE</title>
+</head>
+<body>
+    <a href="app/hello?name=TomEE">app/hello?name=TomEE</a>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/MVCTest.java
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/MVCTest.java 
b/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/MVCTest.java
new file mode 100644
index 0000000..e13ae12
--- /dev/null
+++ b/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/MVCTest.java
@@ -0,0 +1,45 @@
+package org.superbiz.mvc;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.drone.api.annotation.Drone;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+@RunWith(Arquillian.class)
+public class MVCTest {
+
+    //@ArquillianResource
+    //private URL base;
+
+    @Drone
+    private WebDriver webDriver;
+
+    @Deployment
+    public static WebArchive createDeployment() {
+        return ShrinkWrap.create(WebArchive.class, 
"test.war").addClasses(MVCTest.class)
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @RunAsClient
+    public void test() {
+        webDriver.get("http://localhost:8080/mvc-resteasy/"; + 
"app/hello?name=TomEE");
+        WebElement h1 = webDriver.findElement(By.tagName("h1"));
+        assertNotNull(h1);
+        assertTrue(h1.getText().contains("Welcome TomEE !"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c242501/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 8cdcf19..ceadb34 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -177,6 +177,7 @@
     <module>concurrency-utils</module>
     <module>mvc-cxf</module>
     <module>mp-rest-client</module>
+    <module>mvc-resteasy</module>
   </modules>
 
   <dependencies>

Reply via email to