You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xi...@apache.org on 2010/12/03 02:05:28 UTC
svn commit: r1041662 - in
/geronimo/server/trunk/testsuite/javaee6-testsuite: ./ restful-test/
restful-test/src/ restful-test/src/main/ restful-test/src/main/java/
restful-test/src/main/java/org/ restful-test/src/main/java/org/apache/
restful-test/src/...
Author: xiaming
Date: Fri Dec 3 01:05:27 2010
New Revision: 1041662
URL: http://svn.apache.org/viewvc?rev=1041662&view=rev
Log:
GERONIMO-5666 a simple restful service test case, provided by Wang Guang Zhe
Added:
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java (with props)
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/
geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml (with props)
Modified:
geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml
Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml?rev=1041662&r1=1041661&r2=1041662&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml Fri Dec 3 01:05:27 2010
@@ -67,6 +67,7 @@
<!--<module>webbean1.0-test</module>-->
<module>ejb3.1-test</module>
<module>jpa2.0-test</module>
+ <!--<module>restful-test</module>-->
</modules>
</project>
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml Fri Dec 3 01:05:27 2010
@@ -0,0 +1,122 @@
+<?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. -->
+
+<!-- $Rev$ $Date$ -->
+
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.geronimo.testsuite</groupId>
+ <artifactId>javaee6-testsuite</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>restful-test</artifactId>
+ <name>Geronimo TestSuite :: Java EE 6 Testsuite :: restful web service-test</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.jsr311-api-1.1</artifactId>
+ <version>1.5.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <archiveClasses>false</archiveClasses>
+ <webResources>
+ <resource>
+ <directory>${project.build.outputDirectory}</directory>
+ <includes>
+ <include>META-INF/LICENSE*</include>
+ <include>META-INF/NOTICE*</include>
+ <include>META-INF/DISCLAIMER*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${pom.basedir}/src/main/webapp/WEB-INF</directory>
+ <targetPath>WEB-INF</targetPath>
+ <filtering>true</filtering>
+ <includes>
+ <include>*.xml</include>
+ </includes>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>it</id>
+ <activation>
+ <property>
+ <name>it</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.geronimo.buildsupport</groupId>
+ <artifactId>geronimo-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy-wars</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>deploy-module</goal>
+ </goals>
+ <configuration>
+ <moduleArchive>${project.build.directory}/${project.artifactId}-${project.version}.war</moduleArchive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>undeploy-war-as-moduleId</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>undeploy-module</goal>
+ </goals>
+ <configuration>
+ <moduleId>${project.groupId}/${project.artifactId}/${project.version}/car</moduleId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+ <suiteXmlFile>${project.build.testOutputDirectory}/testng.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ <systemPropertyVariables>
+ <appContext>${project.artifactId}</appContext>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java Fri Dec 3 01:05:27 2010
@@ -0,0 +1,20 @@
+/**
+ * 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.geronimo.testsuite.restful.app;
+@javax.ws.rs.ApplicationPath("resources")
+public class ApplicationConfig extends javax.ws.rs.core.Application {
+}
\ No newline at end of file
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/ApplicationConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java Fri Dec 3 01:05:27 2010
@@ -0,0 +1,114 @@
+/**
+ * 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.geronimo.testsuite.restful.app;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+public class Order {
+
+ private Integer id;
+
+ private String customer;
+
+ private String seller;
+
+ private String productname;
+
+ private Double price;
+
+ private Integer quantity;
+
+ public Order() {
+ }
+
+ public Order(Integer id) {
+ this.id = id;
+ }
+ @XmlAttribute
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+ @XmlElement
+ public String getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(String customer) {
+ this.customer = customer;
+ }
+ @XmlElement
+ public String getSeller() {
+ return seller;
+ }
+
+ public void setSeller(String seller) {
+ this.seller = seller;
+ }
+ @XmlElement
+ public String getProductname() {
+ return productname;
+ }
+
+ public void setProductname(String productname) {
+ this.productname = productname;
+ }
+ @XmlElement
+ public Double getPrice() {
+ return price;
+ }
+
+ public void setPrice(Double price) {
+ this.price = price;
+ }
+ @XmlElement
+ public Integer getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(Integer quantity) {
+ this.quantity = quantity;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof Order)) {
+ return false;
+ }
+ Order other = (Order) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/Order.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java Fri Dec 3 01:05:27 2010
@@ -0,0 +1,85 @@
+/**
+ * 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.geronimo.testsuite.restful.app;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+@Path("/orders")
+public class OrderResource {
+ private static Map<Integer, Order> orders = new ConcurrentHashMap<Integer, Order>();
+ private static AtomicInteger ids = new AtomicInteger();
+
+ @POST
+ @Consumes("application/xml")
+ public Response createOrder(Order order) {
+ order.setId(ids.incrementAndGet());
+
+ orders.put(order.getId(), order);
+
+ return Response.created(URI.create("/" + order.getId())).build();
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces("application/xml")
+ public Order getOrder(@PathParam("id") int id) {
+ Order order =orders.get(id);
+ if(order == null) {
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ }
+ return order;
+ }
+
+ @PUT
+ @Path("{id}")
+ @Consumes("application/xml")
+ public void updateOrder(@PathParam("id") int id, Order updateOrder) {
+ Order currentOrder = orders.get(id);
+ if (currentOrder == null)
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ //currentOrder.setId(updateOrder.getId());
+ currentOrder.setCustomer(updateOrder.getCustomer());
+ currentOrder.setProductname(updateOrder.getProductname());
+ currentOrder.setPrice(updateOrder.getPrice());
+ currentOrder.setQuantity(updateOrder.getQuantity());
+ currentOrder.setSeller(updateOrder.getSeller());
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void deleteOrder(@PathParam("id") int id) {
+ Order currentOrder =orders.get(id);
+ if (currentOrder == null)
+ throw new WebApplicationException(Response.Status.NOT_FOUND);
+ orders.remove(id);
+ }
+
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/java/org/apache/geronimo/testsuite/restful/app/OrderResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml Fri Dec 3 01:05:27 2010
@@ -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.
+-->
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"
+ xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
+ xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
+ xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
+
+ <sys:environment>
+ <sys:moduleId>
+ <sys:groupId>${project.groupId}</sys:groupId>
+ <sys:artifactId>${project.artifactId}</sys:artifactId>
+ <sys:version>${project.version}</sys:version>
+ <sys:type>car</sys:type>
+ </sys:moduleId>
+ <sys:dependencies/>
+ <sys:hidden-classes/>
+ <sys:non-overridable-classes/>
+ </sys:environment>
+
+ <context-root>/${project.artifactId}</context-root>
+
+</web-app>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml Fri Dec 3 01:05:27 2010
@@ -0,0 +1,31 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="el2.2-javaee6">
+
+ <description>Restful Web Service - javaee6 Servlet Sample</description>
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+</web-app>
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java Fri Dec 3 01:05:27 2010
@@ -0,0 +1,139 @@
+/**
+ * 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.geronimo.testsuite.restful;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.apache.geronimo.testsupport.TestSupport;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestRestful extends TestSupport {
+ private static String root;
+
+ @Test
+ public void testPost() throws IOException {
+ String contextroot = System.getProperty("appContext");
+ root = "http://localhost:8080/"+contextroot;
+
+ String order = "<order>"
+ + "<customer>wgz</customer>"
+ + "<productname>water</productname>"
+ + "<price>666</price>"
+ + "<quantity>1</quantity>"
+ + "<seller>shop</seller>"
+ + "</order>";
+ URL url = new URL(root + "/resources/orders");
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setDoOutput(true);
+ connection.setInstanceFollowRedirects(false);
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", "application/xml");
+ OutputStream os = connection.getOutputStream();
+ os.write(order.getBytes());
+ os.flush();
+ Assert.assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_CREATED);
+ connection.disconnect();
+ }
+
+ @Test(dependsOnMethods={"testPost"})
+ public void testGet() throws IOException {
+ String contextroot = System.getProperty("appContext");
+ URL url = new URL(root + "/resources/orders/1");
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Accept", "application/xml");
+ Assert.assertEquals(connection.getContentType(), "application/xml");
+ Assert.assertEquals(connection.getResponseCode(), 200);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+ String line = reader.readLine();
+ StringBuilder response = new StringBuilder();
+ while(line != null) {
+ System.out.println(line);
+ response.append(line);
+ line = reader.readLine();
+ }
+ String responseText = response.toString();
+ Assert.assertEquals(responseText,
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><order id=\"2\"><customer>wgz</customer><price>666.0</price><productname>water</productname><quantity>1</quantity><seller>shop</seller></order>");
+ connection.disconnect();
+
+ }
+
+ @Test(dependsOnMethods={"testGet"})
+ public void testPut() throws IOException {
+ String order = "<order>"
+ + "<customer>rafa</customer>"
+ + "<productname>water</productname>"
+ + "<price>666</price>"
+ + "<quantity>2</quantity>"
+ + "<seller>shop</seller>"
+ + "</order>";
+ URL url = new URL(root + "/resources/orders/1");
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("PUT");
+ connection.setRequestProperty("Content-Type", "application/xml");
+ OutputStream os = connection.getOutputStream();
+ os.write(order.getBytes());
+ os.flush();
+ Assert.assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_NO_CONTENT);
+ connection.disconnect();
+ connection = (HttpURLConnection)url.openConnection();
+
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Accept", "application/xml");
+ Assert.assertEquals(connection.getContentType(), "application/xml");
+ Assert.assertEquals(connection.getResponseCode(), 200);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+ String line = reader.readLine();
+ StringBuilder response = new StringBuilder();
+ while(line != null) {
+ System.out.println(line);
+ response.append(line);
+ line = reader.readLine();
+ }
+ String responseText = response.toString();
+ Assert.assertEquals(responseText,
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><order id=\"1\"><customer>rafa</customer><price>666.0</price><productname>water</productname><quantity>2</quantity><seller>shop</seller></order>");
+ connection.disconnect();
+ }
+
+ @Test(dependsOnMethods={"testPut"})
+ public void testDelete() throws IOException {
+ URL url = new URL(root + "/resources/orders/1");
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("DELETE");
+ Assert.assertEquals(connection.getResponseCode(), 204);
+ connection.disconnect();
+
+ connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Accept", "application/xml");
+
+ Assert.assertNotSame(connection.getContentType(), "application/xml");
+ }
+}
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/java/org/apache/geronimo/testsuite/restful/TestRestful.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml?rev=1041662&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml (added)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml Fri Dec 3 01:05:27 2010
@@ -0,0 +1,32 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+
+<suite name="Suite1" verbose="1">
+ <test name="Java EE 6-Restful-Testsuite">
+ <packages>
+ <package name="org.apache.geronimo.testsuite.restful"/>
+ </packages>
+ </test>
+</suite>
+
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/restful-test/src/test/resources/testng.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml