You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/04/15 14:03:38 UTC
svn commit: r528968 - in
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket:
WicketTestCase.java protocol/http/WebExternalResourceTest.java
protocol/http/index.html
Author: jbq
Date: Sun Apr 15 05:03:35 2007
New Revision: 528968
URL: http://svn.apache.org/viewvc?view=rev&rev=528968
Log:
Test WebExternalResourceRequestTarget and WebExternalResourceStream
Added:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java (with props)
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html (with props)
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/WicketTestCase.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/WicketTestCase.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/WicketTestCase.java?view=diff&rev=528968&r1=528967&r2=528968
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/WicketTestCase.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/WicketTestCase.java Sun Apr 15 05:03:35 2007
@@ -118,8 +118,11 @@
protected String getContentType()
{
- return ((MockHttpServletResponse)tester.getWicketResponse().getHttpServletResponse())
- .getHeader("Content-Type");
+ String contentType = ((MockHttpServletResponse)tester.getWicketResponse()
+ .getHttpServletResponse()).getHeader("Content-Type");
+ if (contentType == null)
+ throw new WicketRuntimeException("No Content-Type header found");
+ return contentType;
}
protected int getContentLength()
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java?view=auto&rev=528968
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java Sun Apr 15 05:03:35 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+package org.apache.wicket.protocol.http;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.protocol.http.request.WebExternalResourceRequestTarget;
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.util.io.Streams;
+import org.apache.wicket.util.resource.WebExternalResourceStream;
+import org.apache.wicket.util.tester.WicketTester;
+import org.apache.wicket.util.tester.WicketTester.DummyWebApplication;
+
+/**
+ * Test WebExternalResourceRequestTarget and WebExternalResourceStream
+ *
+ * @author <a href="mailto:jbq@apache.org">Jean-Baptiste Quenot</a>
+ */
+public class WebExternalResourceTest extends WicketTestCase
+{
+ protected void setUp() throws Exception
+ {
+ File tempDir = new File("target/webapp");
+ tempDir.mkdir();
+ File tempFile = new File(tempDir, "index.html");
+ FileOutputStream out = new FileOutputStream(tempFile);
+ InputStream in = WebExternalResourceTest.class.getResourceAsStream("index.html");
+ Streams.copy(in, out);
+ in.close();
+ out.close();
+ tester = new WicketTester(new DummyWebApplication(), tempDir.getPath());
+ }
+
+ public void testWebExternalResourceRequestTarget() throws Exception
+ {
+ WebExternalResourceRequestTarget rt = new WebExternalResourceRequestTarget("/index.html");
+ tester.setupRequestAndResponse();
+ WebRequestCycle cycle = tester.createRequestCycle();
+ cycle.setRequestTarget(rt);
+ tester.processRequestCycle(cycle);
+ assertTrue(getContentType().startsWith("text/html"));
+ // FIXME WebExternalResourceRequestTarget does not set Content-Length
+ // assertEquals(23, getContentLength());
+ }
+
+ // FIXME WebExternalResourceStream does not implement length()
+ public void bugTestWebExternalResource() throws Exception
+ {
+ WebExternalResourceStream resource = new WebExternalResourceStream("/index.html");
+ ResourceStreamRequestTarget rt = new ResourceStreamRequestTarget(resource);
+ tester.setupRequestAndResponse();
+ WebRequestCycle cycle = tester.createRequestCycle();
+ cycle.setRequestTarget(rt);
+ tester.processRequestCycle(cycle);
+ assertTrue(getContentType().startsWith("text/html"));
+ assertEquals(23, getContentLength());
+ }
+}
Propchange: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebExternalResourceTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html?view=auto&rev=528968
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html Sun Apr 15 05:03:35 2007
@@ -0,0 +1 @@
+<h1>Hello, World!</h1>
Propchange: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/index.html
------------------------------------------------------------------------------
svn:eol-style = native