Skip to content
Browse files

Added surefire plugin to pom. Read system props from pom in test class.

  • Loading branch information...
1 parent f803b4b commit ccb857df85e9b6874df34c10ff80403b06a17a13 @blainemincey committed
View
68 jax-rs-client/pom.xml
@@ -24,29 +24,47 @@
<version>4.10</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <version>2.2.2.GA</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.1.4</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <!-- Maven compiler plugin -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.1</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>2.2.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.1.4</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <!-- Maven compiler plugin -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>xmlUrl</name>
+ <value>http://localhost:8080/jboss-as-helloworld-rs/xml</value>
+ </property>
+ <property>
+ <name>jsonUrl</name>
+ <value>http://localhost:8080/jboss-as-helloworld-rs/json</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
View
28 jax-rs-client/src/test/java/org/jboss/as/quickstarts/jaxrsclient/JaxRsClientTest.java
@@ -18,6 +18,7 @@
import org.apache.http.client.ClientProtocolException;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
+import org.junit.BeforeClass;
import org.junit.Test;
@@ -25,16 +26,22 @@
* JUnit4 Test class which makes a request to the RESTful
* helloworld-rs web service.
*
- * @author bmincey
+ * @author bmincey (Blaine Mincey)
*
*/
public class JaxRsClientTest
{
/**
- * Request URLs of the RESTful web service
+ * Request URLs pulled from system properties in pom.xml
*/
- private static final String XML_URL = "http://localhost:8080/jboss-as-helloworld-rs/xml";
- private static final String JSON_URL = "http://localhost:8080/jboss-as-helloworld-rs/json";
+ private static String XML_URL;
+ private static String JSON_URL;
+
+ /**
+ * Property names used to pull values from system properties in pom.xml
+ */
+ private static final String XML_PROPERTY = "xmlUrl";
+ private static final String JSON_PROPERTY = "jsonUrl";
/**
* Responses of the RESTful web service
@@ -42,6 +49,12 @@
private static final String XML_RESPONSE = "<xml><result>Hello World!</result></xml>";
private static final String JSON_RESPONSE = "{\"result\":\"Hello World!\"}";
+ @BeforeClass
+ public static void beforeClass()
+ {
+ JaxRsClientTest.XML_URL = System.getProperty(JaxRsClientTest.XML_PROPERTY);
+ JaxRsClientTest.JSON_URL = System.getProperty(JaxRsClientTest.JSON_PROPERTY);
+ }
/**
* Test method which executes the runRequest method that calls the RESTful
@@ -50,8 +63,11 @@
@Test
public void test()
{
- assertEquals("XML Response", JaxRsClientTest.XML_RESPONSE, this.runRequest(JaxRsClientTest.XML_URL, MediaType.APPLICATION_XML_TYPE));
- assertEquals("JSON Response", JaxRsClientTest.JSON_RESPONSE, this.runRequest(JaxRsClientTest.JSON_URL, MediaType.APPLICATION_JSON_TYPE));
+ assertEquals("XML Response", JaxRsClientTest.XML_RESPONSE,
+ this.runRequest(JaxRsClientTest.XML_URL, MediaType.APPLICATION_XML_TYPE));
+
+ assertEquals("JSON Response", JaxRsClientTest.JSON_RESPONSE,
+ this.runRequest(JaxRsClientTest.JSON_URL, MediaType.APPLICATION_JSON_TYPE));
}
/**

0 comments on commit ccb857d

Please sign in to comment.
Something went wrong with that request. Please try again.