You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by aw...@apache.org on 2009/02/06 02:21:07 UTC
svn commit: r741361 - in /incubator/shindig/trunk/java/server/src/test:
java/org/apache/shindig/server/endtoend/ resources/endtoend/
Author: awiner
Date: Fri Feb 6 01:21:06 2009
New Revision: 741361
URL: http://svn.apache.org/viewvc?rev=741361&view=rev
Log:
SHINDIG-895: Add end-to-end test for data pipelining
Also fix a warning in the end-to-end tests
Added:
incubator/shindig/trunk/java/server/src/test/resources/endtoend/pipeliningTest.xml
incubator/shindig/trunk/java/server/src/test/resources/endtoend/test.json
Modified:
incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndModule.java
incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
Modified: incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndModule.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndModule.java?rev=741361&r1=741360&r2=741361&view=diff
==============================================================================
--- incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndModule.java (original)
+++ incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndModule.java Fri Feb 6 01:21:06 2009
@@ -32,13 +32,13 @@
import org.apache.shindig.social.opensocial.service.DataServiceServletFetcher;
import org.apache.shindig.social.opensocial.service.PersonHandler;
-import com.google.common.collect.Lists;
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
-import java.util.List;
-
/**
* Guice module for the end-to-end tests.
*/
@@ -66,7 +66,7 @@
AuthenticationHandlerProvider.class);
bind(List.class).annotatedWith(Names.named("org.apache.shindig.handlers"))
- .toInstance(Lists.immutableList(ActivityHandler.class, AppDataHandler.class,
+ .toInstance(ImmutableList.of(ActivityHandler.class, AppDataHandler.class,
PersonHandler.class));
bind(ContainerConfig.class).to(JsonContainerConfig.class);
Modified: incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java?rev=741361&r1=741360&r2=741361&view=diff
==============================================================================
--- incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java (original)
+++ incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java Fri Feb 6 01:21:06 2009
@@ -17,6 +17,7 @@
*/
package org.apache.shindig.server.endtoend;
+import org.apache.commons.io.IOUtils;
import org.apache.shindig.auth.AuthenticationServletFilter;
import org.apache.shindig.common.PropertiesModule;
import org.apache.shindig.common.servlet.GuiceServletContextListener;
@@ -45,6 +46,8 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
@@ -132,6 +135,10 @@
ServletHolder concatHolder = new ServletHolder(new ConcatProxyServlet());
context.addServlet(concatHolder, CONCAT_BASE);
+ // Attach an EchoServlet, used to test proxied rendering
+ ServletHolder echoHolder = new ServletHolder(new EchoServlet());
+ context.addServlet(echoHolder, "/echo");
+
return newServer;
}
@@ -168,4 +175,16 @@
proxiedServlet.destroy();
}
}
+
+ static private class EchoServlet extends HttpServlet {
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ req.setCharacterEncoding("UTF-8");
+ resp.setContentType(req.getContentType());
+
+ IOUtils.copy(req.getReader(), resp.getWriter());
+ }
+
+ }
}
Modified: incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java?rev=741361&r1=741360&r2=741361&view=diff
==============================================================================
--- incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java (original)
+++ incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java Fri Feb 6 01:21:06 2009
@@ -20,19 +20,15 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.shindig.auth.BasicSecurityToken;
import org.apache.shindig.auth.BasicSecurityTokenDecoder;
import org.apache.shindig.auth.SecurityToken;
import org.apache.shindig.common.crypto.BlobCrypterException;
-
-import com.gargoylesoftware.htmlunit.CollectingAlertHandler;
-import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -41,9 +37,17 @@
import java.io.IOException;
import java.net.URLEncoder;
+import java.util.Map;
import javax.servlet.http.HttpServletResponse;
+import com.gargoylesoftware.htmlunit.CollectingAlertHandler;
+import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.google.common.collect.Maps;
+
/**
* Base class for end-to-end tests.
*/
@@ -123,6 +127,27 @@
executeAllPageTests("opensocial-templates/ost_test");
}
+ @Test
+ public void testPipelining() throws Exception {
+ HtmlPage page = executePageTest("pipeliningTest", null);
+ JSONArray array = new JSONArray(page.asText());
+ assertEquals(2, array.length());
+ Map<String, JSONObject> jsonObjects = Maps.newHashMap();
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject jsonObj = array.getJSONObject(i);
+ assertTrue(jsonObj.has("id"));
+
+ jsonObjects.put(jsonObj.getString("id"), jsonObj);
+ }
+
+ JSONObject me = jsonObjects.get("me").getJSONObject("data");
+ assertEquals("Digg", me.getJSONObject("name").getString("familyName"));
+
+ JSONObject json = jsonObjects.get("json").getJSONObject("data");
+ JSONObject expected = new JSONObject("{key: 'value'}");
+ assertEquals(expected.toString(), json.toString());
+ }
+
@BeforeClass
public static void setUpOnce() throws Exception {
server = new EndToEndServer();
@@ -186,7 +211,10 @@
String url = EndToEndServer.GADGET_BASEURL + "?url=" + URLEncoder.encode(gadgetUrl, "UTF-8");
BasicSecurityTokenDecoder decoder = new BasicSecurityTokenDecoder();
url += "&st=" + URLEncoder.encode(decoder.encodeToken(token), "UTF-8");
- url += "&testMethod=" + URLEncoder.encode(testMethod, "UTF-8");
+ if (testMethod != null) {
+ url += "&testMethod=" + URLEncoder.encode(testMethod, "UTF-8");
+ }
+
url += "&nocache=1";
if (language != null) {
url += "&lang=" + language;
Added: incubator/shindig/trunk/java/server/src/test/resources/endtoend/pipeliningTest.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/resources/endtoend/pipeliningTest.xml?rev=741361&view=auto
==============================================================================
--- incubator/shindig/trunk/java/server/src/test/resources/endtoend/pipeliningTest.xml (added)
+++ incubator/shindig/trunk/java/server/src/test/resources/endtoend/pipeliningTest.xml Fri Feb 6 01:21:06 2009
@@ -0,0 +1,33 @@
+<?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.
+-->
+<Module xmlns:os="http://ns.opensocial.org/2008/markup">
+ <ModulePrefs title="EndToEndTest">
+ <Require feature="views" />
+ <Optional feature="content-rewrite">
+ <Param name="exclude-urls">.*</Param>
+ </Optional>
+ </ModulePrefs>
+ <Content type="html" href="http://localhost:9003/echo">
+ <!-- Load the canonical user -->
+ <os:PeopleRequest key="me" userId="canonical"/>
+ <!-- Load a JSON file -->
+ <os:MakeRequest key="json" href="test.json"/>
+ </Content>
+</Module>
Added: incubator/shindig/trunk/java/server/src/test/resources/endtoend/test.json
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/resources/endtoend/test.json?rev=741361&view=auto
==============================================================================
--- incubator/shindig/trunk/java/server/src/test/resources/endtoend/test.json (added)
+++ incubator/shindig/trunk/java/server/src/test/resources/endtoend/test.json Fri Feb 6 01:21:06 2009
@@ -0,0 +1 @@
+{'key': 'value'}
\ No newline at end of file