You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/03/15 22:11:18 UTC
svn commit: r1301203 -
/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
Author: scottbw
Date: Thu Mar 15 21:11:18 2012
New Revision: 1301203
URL: http://svn.apache.org/viewvc?rev=1301203&view=rev
Log:
Added a test case for WOOKIE-324
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=1301203&r1=1301202&r2=1301203&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 Mar 15 21:11:18 2012
@@ -15,6 +15,7 @@
package org.apache.wookie.tests.functional;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -34,7 +35,10 @@ import org.apache.wookie.w3c.W3CWidget;
import org.apache.wookie.w3c.W3CWidgetFactory;
import org.apache.wookie.w3c.exceptions.BadManifestException;
import org.apache.wookie.w3c.exceptions.BadWidgetZipFileException;
+import org.jdom.Document;
+import org.jdom.Element;
import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
import org.junit.AfterClass;
import org.junit.Test;
@@ -183,6 +187,49 @@ public class WidgetsControllerTest exten
post.releaseConnection();
}
+
+ @Test
+ public void importWidgetWithDefaultIcon() throws HttpException, IOException, JDOMException{
+ HttpClient client = new HttpClient();
+ //
+ // Use admin credentials
+ //
+ setAuthenticationCredentials(client);
+
+ PostMethod post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID);
+
+ //
+ // Use upload test widget
+ //
+ File file = new File("src-tests/testdata/upload-test-2.wgt");
+ assertTrue(file.exists());
+
+ //
+ // Add test wgt file to POST
+ //
+ Part[] parts = { new FilePart(file.getName(), file) };
+ post.setRequestEntity(new MultipartRequestEntity(parts, post
+ .getParams()));
+
+ //
+ // POST the file to /widgets and check we get 201 (Created)
+ //
+ client.executeMethod(post);
+ int code = post.getStatusCode();
+ assertEquals(201,code);
+
+ //
+ // Lets take a look at the metadata...
+ //
+ SAXBuilder builder = new SAXBuilder();
+ Document doc = builder.build(post.getResponseBodyAsStream());
+ Element iconElement = doc.getRootElement().getChild("icon");
+ assertNotNull(iconElement);
+ assertEquals("http://localhost:8080/wookie/wservices/uploadtest_2/icon.png", iconElement.getAttributeValue("src"));
+ post.releaseConnection();
+ }
+
+
@Test
public void downloadWidgetPackage() throws BadWidgetZipFileException, BadManifestException, Exception{
HttpClient client = new HttpClient();