You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/12/21 13:01:09 UTC
[5/6] tomee git commit: add exemple mvc-resteasy-hello
add exemple mvc-resteasy-hello
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b2a656e8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b2a656e8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b2a656e8
Branch: refs/heads/master
Commit: b2a656e8cd4da444ece331740f23af6c1826c815
Parents: af3362a
Author: Daniel Dias <da...@gmail.com>
Authored: Sat Dec 15 01:57:41 2018 -0200
Committer: Daniel Dias <da...@gmail.com>
Committed: Fri Dec 21 01:52:26 2018 -0200
----------------------------------------------------------------------
examples/mvc-resteasy/README.adoc | 2 +-
examples/mvc-resteasy/pom.xml | 64 ++++-----------
.../superbiz/application/MVCApplication.java | 6 --
.../superbiz/application/TomeeController.java | 22 ------
.../java/org/superbiz/mvc/MVCApplication.java | 22 ++++++
.../java/org/superbiz/mvc/TomeeController.java | 38 +++++++++
.../src/main/resources/META-INF/beans.xml | 17 ++++
.../src/test/java/org/superbiz/mvc/MVCTest.java | 57 --------------
.../superbiz/mvc/util/WebArchiveBuilder.java | 83 --------------------
.../src/test/resources/arquillian.xml | 35 ---------
10 files changed, 94 insertions(+), 252 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/examples/mvc-resteasy/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/README.adoc b/examples/mvc-resteasy/README.adoc
index d38d459..6bf5847 100644
--- a/examples/mvc-resteasy/README.adoc
+++ b/examples/mvc-resteasy/README.adoc
@@ -13,7 +13,7 @@ Build and start the demo:
Open:
- http://localhost:8080/mvc-resteasy
+ http://localhost:8080/mvc-resteasy/app/hello?name=TomEE
==== Intro of Eclipse Krazo
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/examples/mvc-resteasy/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/pom.xml b/examples/mvc-resteasy/pom.xml
index 6221d5a..a4a0c3d 100644
--- a/examples/mvc-resteasy/pom.xml
+++ b/examples/mvc-resteasy/pom.xml
@@ -34,8 +34,6 @@
<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>
@@ -79,13 +77,6 @@
<groupId>org.mvc-spec.ozark</groupId>
<artifactId>ozark-resteasy</artifactId>
<version>${version.ozark}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.mvc</groupId>
- <artifactId>javax.mvc-api</artifactId>
- <version>1.0-pfd</version>
</dependency>
<!-- RestEasy -->
@@ -104,44 +95,21 @@
<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>
- <scope>test</scope>
- <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>
- <dependency>
- <groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit</artifactId>
- <version>2.32</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>
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/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
deleted file mode 100644
index 1cc2d0d..0000000
--- a/examples/mvc-resteasy/src/main/java/org/superbiz/application/MVCApplication.java
+++ /dev/null
@@ -1,6 +0,0 @@
-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/b2a656e8/examples/mvc-resteasy/src/main/java/org/superbiz/application/TomeeController.java
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/java/org/superbiz/application/TomeeController.java b/examples/mvc-resteasy/src/main/java/org/superbiz/application/TomeeController.java
deleted file mode 100644
index c739a54..0000000
--- a/examples/mvc-resteasy/src/main/java/org/superbiz/application/TomeeController.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.superbiz.application;
-
-import javax.inject.Inject;
-import javax.mvc.Controller;
-import javax.mvc.Models;
-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
- public String getHello(@QueryParam("name") String name) {
- this.models.put("hello", name);
- return "hello.jsp";
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/MVCApplication.java
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/MVCApplication.java b/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/MVCApplication.java
new file mode 100644
index 0000000..6303690
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/MVCApplication.java
@@ -0,0 +1,22 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.mvc;
+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/b2a656e8/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/TomeeController.java
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/TomeeController.java b/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/TomeeController.java
new file mode 100644
index 0000000..9ca4ecf
--- /dev/null
+++ b/examples/mvc-resteasy/src/main/java/org/superbiz/mvc/TomeeController.java
@@ -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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.mvc;
+
+import javax.inject.Inject;
+import javax.mvc.Controller;
+import javax.mvc.Models;
+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
+ public String getHello(@QueryParam("name") String name) {
+ this.models.put("hello", name);
+ return "hello.jsp";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/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
index 86b63b7..13ea327 100644
--- a/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml
+++ b/examples/mvc-resteasy/src/main/resources/META-INF/beans.xml
@@ -1,4 +1,21 @@
<?xml version="1.0"?>
+<!--
+
+ 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.
+-->
<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"
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/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
deleted file mode 100644
index 3d2ed85..0000000
--- a/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/MVCTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.superbiz.mvc;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URL;
-import java.nio.file.Paths;
-
-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.asset.FileAsset;
-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(testable = true)
- public static WebArchive createDeployment() {
- final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
- .addAsWebInfResource(new FileAsset(Paths.get("src/main/webapp/WEB-INF/").resolve("views/hello.jsp").toFile()), "views/" + "hello.jsp");
-
-
- System.out.println(webArchive.toString(true));
-
- return webArchive;
- }
-
-
-
- @Test
- @RunAsClient
- public void test() {
- webDriver.get(base + "app/hello?name=TomEE");
- System.out.println(webDriver.getCurrentUrl());
- WebElement h1 = webDriver.findElement(By.tagName("h1"));
- System.out.println(h1.getText());
- assertNotNull(h1);
- assertTrue(h1.getText().contains("Welcome TomEE !"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/util/WebArchiveBuilder.java
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/util/WebArchiveBuilder.java b/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/util/WebArchiveBuilder.java
deleted file mode 100644
index 61f34a4..0000000
--- a/examples/mvc-resteasy/src/test/java/org/superbiz/mvc/util/WebArchiveBuilder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright © 2017 Ivar Grimstad (ivar.grimstad@gmail.com)
- *
- * 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 org.superbiz.mvc.util;
-
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.FileAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;
-import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
-import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates;
-import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies;
-import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-
-public class WebArchiveBuilder {
-
- private final WebArchive archive = ShrinkWrap.create(WebArchive.class);
- private List<MavenDependency> additionalDependencies = new ArrayList<>();
-
- public WebArchiveBuilder addPackage(String packageName) {
- archive.addPackage(packageName);
- return this;
- }
-
- public WebArchiveBuilder addView(Asset asset, String name) {
- archive.addAsWebInfResource(asset, "views/" + name);
- return this;
- }
-
- public WebArchiveBuilder addView(File file, String name) {
- return this.addView(new FileAsset(file), name);
- }
-
- public WebArchiveBuilder addBeansXml() {
- archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
- return this;
- }
-
- public WebArchiveBuilder addDependencies(MavenDependency... dependencies) {
- this.additionalDependencies.addAll(Arrays.asList(dependencies));
- return this;
- }
-
- public WebArchiveBuilder addDependency(String coordinates) {
- addDependencies(MavenDependencies.createDependency(coordinates, ScopeType.RUNTIME,false));
- return this;
- }
-
- public WebArchive build() {
- PomEquippedResolveStage stage = Maven.configureResolver().workOffline()
- .withClassPathResolution(true)
- .loadPomFromFile("pom.xml")
- .importCompileAndRuntimeDependencies();
-
- if (!this.additionalDependencies.isEmpty()) {
- stage = stage.addDependencies(this.additionalDependencies);
- }
-
- return archive.addAsLibraries(stage.resolve().withTransitivity().asFile());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b2a656e8/examples/mvc-resteasy/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/mvc-resteasy/src/test/resources/arquillian.xml b/examples/mvc-resteasy/src/test/resources/arquillian.xml
deleted file mode 100644
index cec14c8..0000000
--- a/examples/mvc-resteasy/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-
- 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.
--->
-<arquillian xmlns="http://jboss.org/schema/arquillian"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
- <container qualifier="tomee" default="true">
- <configuration>
- <property name="httpPort">-1</property>
- <property name="stopPort">-1</property>
- <property name="ajpPort">-1</property>
- <property name="dir">target/tomee</property>
- <property name="appWorkingDir">target/arquillian-dump-dir</property>
- </configuration>
-
- </container>
- <extension qualifier="webdriver">
- <property name="browser">htmlunit</property>
- </extension>
-</arquillian>