Skip to content

Commit

Permalink
Added openshift-express test profile
Browse files Browse the repository at this point in the history
  • Loading branch information
jharting committed Oct 6, 2011
1 parent ea48cb1 commit 7cc3273
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 36 deletions.
17 changes: 17 additions & 0 deletions examples/exceptions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>openshift-express</id>
<activation>
<property>
<name>arquillian</name>
<value>openshift-express</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.seam.test</groupId>
<artifactId>openshift-express</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<!-- Dist profile -->
<profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.jboss.seam.rest.examples.exceptions.ftest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.net.URL;

Expand All @@ -13,9 +16,6 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@RunWith(Arquillian.class)
public abstract class AbstractExceptionHandlingTest {
private HttpClient client = new HttpClient();
Expand All @@ -24,6 +24,7 @@ public abstract class AbstractExceptionHandlingTest {
URL contextPath;

public static final String ARCHIVE_NAME = "rest-exceptions.war";
public static final String CONTEXT_PATH = "/rest-exceptions/";
public static final String BUILD_DIRECTORY = "target";

@Deployment(testable = false)
Expand All @@ -37,7 +38,7 @@ protected void checkResponse(String url, int expectedStatus, String expectedBody
}

protected void checkResponse(String urlSuffix, String accept, int expectedStatus, String expectedBody) throws Exception {
String url = contextPath + urlSuffix;
String url = new URL(contextPath, CONTEXT_PATH + urlSuffix).toString();
GetMethod get = new GetMethod(url);
get.setRequestHeader("Accept", accept);
assertEquals(expectedStatus, client.executeMethod(get));
Expand Down
1 change: 1 addition & 0 deletions examples/exceptions/src/test/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 17 additions & 0 deletions examples/tasks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,23 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>openshift-express</id>
<activation>
<property>
<name>arquillian</name>
<value>openshift-express</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.seam.test</groupId>
<artifactId>openshift-express</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>distribution</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class AbstractPage {
public static final JavaScript JQUERY_IDLE_CONNECTION = new JavaScript(
"selenium.browserbot.getCurrentWindow().jQuery.active===0");
public static final JQueryLocator PAGE_INITIALIZED = jq("body");
private static final String APP_NAME = "/rest-tasks/";

protected AjaxSelenium selenium;
protected URL contextPath;
Expand All @@ -42,7 +43,7 @@ public AbstractPage(AjaxSelenium selenium, URL contextPath) {

public void reload() {

URL url = URLUtils.buildUrl(contextPath, getPageSuffix());
URL url = URLUtils.buildUrl(contextPath, APP_NAME + getPageSuffix());

// firefox sometimes freezes, if that happens, let's give it two more tries
for (int i = 0; i < 3; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.io.File;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.importer.ZipImporter;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
@RunAsClient
public abstract class AbstractPageTest {

public static final String ARCHIVE_NAME = "rest-tasks.war";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.jboss.seam.rest.examples.tasks.ftest;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.net.URL;

import org.jboss.arquillian.ajocado.framework.AjaxSelenium;
Expand All @@ -11,9 +14,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Tests for the category page (categories.html)
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.jboss.seam.rest.examples.tasks.test;

import java.net.URL;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.jboss.arquillian.ajocado.utils.URLUtils;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.seam.rest.examples.tasks.ftest.AbstractPageTest;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -17,77 +21,81 @@
*/
@RunWith(Arquillian.class)
public class XmlRepresentationTest extends AbstractPageTest {

@ArquillianResource
private URL contextPath;

private HttpClient client = new HttpClient();

private String getRepresentation(String url, String accept) throws Exception {
GetMethod get = new GetMethod(url);
private String getRepresentation(String segment, String accept) throws Exception {
GetMethod get = new GetMethod(URLUtils.buildUrl(contextPath, segment).toString());
get.setRequestHeader("Accept", accept);
assertEquals(200, client.executeMethod(get));
return get.getResponseBodyAsString();
}

@Test
public void testTask() throws Exception {
String representation = getRepresentation("http://localhost:8080/rest-tasks/api/task/2", "application/task+xml");
String representation = getRepresentation("/rest-tasks/api/task/2", "application/task+xml");
assertTrue(representation.contains("<name>Build the Turing machine</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/task/2\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/task/2\"/>"));
assertTrue(representation
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"http://localhost:8080/rest-tasks/api/task/2/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"http://localhost:8080/rest-tasks/api/task/2\"/>"));
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"/rest-tasks/api/task/2/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"/rest-tasks/api/task/2\"/>"));
assertTrue(representation.contains("<resolved>false</resolved>"));
}

@Test
public void testTasks() throws Exception {
String representation = getRepresentation("http://localhost:8080/rest-tasks/api/task?start=4&limit=1",
String representation = getRepresentation("/rest-tasks/api/task?start=4&limit=1",
"application/tasks+xml");
assertTrue(representation
.contains("<link href=\"self\" href=\"http://localhost:8080/rest-tasks/api/task?start=4&limit=1\"/>"));
.contains("<link href=\"self\" href=\"/rest-tasks/api/task?start=4&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"next\" href=\"http://localhost:8080/rest-tasks/api/task?start=5&limit=1\"/>"));
.contains("<link href=\"next\" href=\"/rest-tasks/api/task?start=5&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"previous\" href=\"http://localhost:8080/rest-tasks/api/task?start=3&limit=1\"/>"));
.contains("<link href=\"previous\" href=\"/rest-tasks/api/task?start=3&limit=1\"/>"));
assertTrue(representation.contains("<name>Pick up meal tickets</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/task/8\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/task/8\"/>"));
assertTrue(representation
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"http://localhost:8080/rest-tasks/api/task/8/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"http://localhost:8080/rest-tasks/api/task/8\"/>"));
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"/rest-tasks/api/task/8/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"/rest-tasks/api/task/8\"/>"));
}

@Test
public void testCategories() throws Exception {
String representation = getRepresentation("http://localhost:8080/rest-tasks/api/category?start=1&limit=1",
String representation = getRepresentation("/rest-tasks/api/category?start=1&limit=1",
"application/categories+xml");
assertTrue(representation
.contains("<link href=\"self\" href=\"http://localhost:8080/rest-tasks/api/category?start=1&limit=1\"/>"));
.contains("<link href=\"self\" href=\"/rest-tasks/api/category?start=1&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"next\" href=\"http://localhost:8080/rest-tasks/api/category?start=2&limit=1\"/>"));
.contains("<link href=\"next\" href=\"/rest-tasks/api/category?start=2&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"previous\" href=\"http://localhost:8080/rest-tasks/api/category?start=0&limit=1\"/>"));
.contains("<link href=\"previous\" href=\"/rest-tasks/api/category?start=0&limit=1\"/>"));
assertTrue(representation.contains("<name>Work</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/category/Work\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/category/Work\"/>"));
assertTrue(representation.contains("<name>Pick up meal tickets</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/task/8\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/task/8\"/>"));
assertTrue(representation
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"http://localhost:8080/rest-tasks/api/task/8/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"http://localhost:8080/rest-tasks/api/task/8\"/>"));
.contains("<link rel=\"http://sfwk.org/rest/tasks/move\" href=\"/rest-tasks/api/task/8/move?category={category-name}\"/>"));
assertTrue(representation.contains("<link rel=\"edit\" href=\"/rest-tasks/api/task/8\"/>"));
assertTrue(representation.contains("<resolved>false</resolved>"));
}

@Test
public void testCategoriesShort() throws Exception {
String representation = getRepresentation("http://localhost:8080/rest-tasks/api/category?start=1&limit=1",
String representation = getRepresentation("/rest-tasks/api/category?start=1&limit=1",
"application/categories-short+xml");
assertTrue(representation
.contains("<link href=\"self\" href=\"http://localhost:8080/rest-tasks/api/category?start=1&limit=1\"/>"));
.contains("<link href=\"self\" href=\"/rest-tasks/api/category?start=1&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"next\" href=\"http://localhost:8080/rest-tasks/api/category?start=2&limit=1\"/>"));
.contains("<link href=\"next\" href=\"/rest-tasks/api/category?start=2&limit=1\"/>"));
assertTrue(representation
.contains("<link href=\"previous\" href=\"http://localhost:8080/rest-tasks/api/category?start=0&limit=1\"/>"));
.contains("<link href=\"previous\" href=\"/rest-tasks/api/category?start=0&limit=1\"/>"));
assertTrue(representation.contains("<name>Work</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/category/Work\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/category/Work\"/>"));
assertTrue(representation.contains("<name>Pick up meal tickets</name>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"http://localhost:8080/rest-tasks/api/task/8\"/>"));
assertTrue(representation.contains("<link rel=\"self\" href=\"/rest-tasks/api/task/8\"/>"));
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.seam</groupId>
<artifactId>seam-parent</artifactId>
<version>15</version>
<version>16-SNAPSHOT</version>
</parent>

<groupId>org.jboss.seam.rest</groupId>
Expand Down

0 comments on commit 7cc3273

Please sign in to comment.