Author: scottbw
Date: Thu Feb 23 22:22:22 2012
New Revision: 1292993
URL: http://svn.apache.org/viewvc?rev=1292993&view=rev
Log:
Added functional tests for /widgets/{widget_uri} calls
Modified:
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
Modified:
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java?rev=1292993&r1=1292992&r2=1292993&view=diff
==============================================================================
---
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
(original)
+++
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
Thu Feb 23 22:22:22 2012
@@ -18,6 +18,7 @@ import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
+import java.net.URLEncoder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
@@ -70,6 +71,39 @@ public class WidgetsControllerTest exten
get.releaseConnection();
}
+ /**
+ * Test we can GET a widget using its URI as a resource path
+ * @throws IOException
+ * @throws HttpException
+ */
+ @Test
+ public void getSpecificWidgetByUri() throws HttpException, IOException{
+ HttpClient client = new HttpClient();
+ GetMethod get = new
GetMethod(TEST_WIDGETS_SERVICE_URL_VALID+"/"+URLEncoder.encode("http://notsupported","UTF-8"));
+ client.executeMethod(get);
+ int code = get.getStatusCode();
+ assertEquals(200,code);
+ String response = get.getResponseBodyAsString();
+ assertTrue(response.contains("<widget id=\"1\"
identifier=\"http://notsupported\""));
+ get.releaseConnection();
+ }
+ /**
+ * Test we can GET a widget using its URI as a resource path
+ * @throws IOException
+ * @throws HttpException
+ */
+ @Test
+ public void getSpecificWidgetByUri2() throws HttpException, IOException{
+ HttpClient client = new HttpClient();
+ GetMethod get = new
GetMethod(TEST_WIDGETS_SERVICE_URL_VALID+"/http://notsupported");
+ client.executeMethod(get);
+ int code = get.getStatusCode();
+ assertEquals(200,code);
+ String response = get.getResponseBodyAsString();
+ assertTrue(response.contains("<widget id=\"1\"
identifier=\"http://notsupported\""));
+ get.releaseConnection();
+ }
+
/**
* Test that a request for a non-existing widget ID gets a 404
* @throws IOException