Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lindberg2009-05-05 20:38:38 -0400
committerHenrik Lindberg2009-05-05 20:38:38 -0400
commit80872bc58feb585302ea2d72b361fbcd7a9de8a6 (patch)
treeabc6493b06cec1b9a170b4f913cbae08a6e62624 /bundles/org.eclipse.equinox.p2.testserver
parente21f56d665aefe6f0d03ff6b910bfcacd867b54f (diff)
downloadrt.equinox.p2-80872bc58feb585302ea2d72b361fbcd7a9de8a6.tar.gz
rt.equinox.p2-80872bc58feb585302ea2d72b361fbcd7a9de8a6.tar.xz
rt.equinox.p2-80872bc58feb585302ea2d72b361fbcd7a9de8a6.zip
Added more services - see index.html
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.testserver')
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/index.html15
4 files changed, 45 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
index 81da587ba..8882e3972 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/Activator.java
@@ -15,7 +15,9 @@ import java.net.URI;
import javax.servlet.ServletException;
import org.eclipse.equinox.p2.testserver.servlets.BasicResourceDelivery;
import org.eclipse.equinox.p2.testserver.servlets.ChopAndDelay;
+import org.eclipse.equinox.p2.testserver.servlets.ContentLengthLier;
import org.eclipse.equinox.p2.testserver.servlets.FileMolester;
+import org.eclipse.equinox.p2.testserver.servlets.LastModifiedLier;
import org.eclipse.equinox.p2.testserver.servlets.StatusCodeResponse;
import org.eclipse.equinox.p2.testserver.servlets.TimeOut;
import org.eclipse.equinox.p2.testserver.servlets.Truncator;
@@ -78,6 +80,18 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
httpService.registerServlet("/proxy/molested", new FileMolester("/proxy/molested", URI.create(SITE), 40), null, null); //$NON-NLS-1$//$NON-NLS-2$
httpService.registerServlet("/proxy/decelerate", new ChopAndDelay("/proxy/decelerate", URI.create(SITE), 3, new LinearChange(0, 5, 100, 0)), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ // lie about modified time
+ httpService.registerServlet("/proxy/modified/zero", new LastModifiedLier("/proxy/modified/zero", URI.create(SITE), LastModifiedLier.TYPE_ZERO), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/modified/old", new LastModifiedLier("/proxy/modified/old", URI.create(SITE), LastModifiedLier.TYPE_OLD), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/modified/now", new LastModifiedLier("/proxy/modified/now", URI.create(SITE), LastModifiedLier.TYPE_NOW), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/modified/future", new LastModifiedLier("/proxy/modified/future", URI.create(SITE), LastModifiedLier.TYPE_FUTURE), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/modified/bad", new LastModifiedLier("/proxy/modified/bad", URI.create(SITE), LastModifiedLier.TYPE_BAD), null, null); //$NON-NLS-1$//$NON-NLS-2$
+
+ // lie about length
+ httpService.registerServlet("/proxy/length/zero", new ContentLengthLier("/proxy/length/zero", URI.create(SITE), 0), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/length/less", new ContentLengthLier("/proxy/length/less", URI.create(SITE), 90), null, null); //$NON-NLS-1$//$NON-NLS-2$
+ httpService.registerServlet("/proxy/length/more", new ContentLengthLier("/proxy/length/more", URI.create(SITE), 200), null, null); //$NON-NLS-1$//$NON-NLS-2$
+
} catch (NamespaceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
index 62cf0a9f0..ff5eaeb4f 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/BasicResourceDelivery.java
@@ -118,9 +118,8 @@ public class BasicResourceDelivery extends HttpServlet {
* @throws IOException - on errors
*/
protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
- long modified = conn.getLastModified();
// set when the resource was modified
- addDateHeader(response, HttpConstants.LAST_MODIFIED, modified);
+ addDateHeader(response, HttpConstants.LAST_MODIFIED, getLastModified(conn));
int contentlength = getContentLength(conn);
if (contentlength >= 0) {
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java
index 4b7da6cbe..84d568ca1 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/LastModifiedLier.java
@@ -13,6 +13,7 @@ package org.eclipse.equinox.p2.testserver.servlets;
import java.net.URI;
import java.net.URLConnection;
+import javax.servlet.http.HttpServletResponse;
/**
* Manipulates the last modified time of serviced files.
@@ -20,6 +21,7 @@ import java.net.URLConnection;
* to the current time if TYPE_NOW is used, and a value 24 hours into the future if TYPE_FUTURE is used.
* (Future values are not allowed in HTTP - the server should guard against them and force the value
* to be no bigger than the response date).
+ * The TYPE_BAD will produce a HTTP header with wrong format for the date value (fails date parsing).
*
*/
public class LastModifiedLier extends BasicResourceDelivery {
@@ -28,12 +30,14 @@ public class LastModifiedLier extends BasicResourceDelivery {
public static final int TYPE_OLD = 2;
public static final int TYPE_NOW = 3;
public static final int TYPE_FUTURE = 4;
+ public static final int TYPE_BAD = 5;
+ private static final int TYPE_LAST = TYPE_BAD;
private int type;
/**
- * The ContentLengthLier sets the content length to a percentage of the original length.
- * Values between 0 and 200 can be used (to lie about files being both smaller < 100, or larger > 100).
+ * The LastModifiedLier returns a last modified time according to the parameter timeType.
+ * It can be TYPE_ZERO, TYPE_OLD, TYPE_NOW, TYPE_FUTURE, or TYPE_BAD.
*
* @param theAlias
* @param thePath
@@ -41,7 +45,7 @@ public class LastModifiedLier extends BasicResourceDelivery {
*/
public LastModifiedLier(String theAlias, URI thePath, int timeType) {
super(theAlias, thePath);
- if (timeType < TYPE_ZERO || timeType > TYPE_FUTURE)
+ if (timeType < TYPE_ZERO || timeType > TYPE_LAST)
throw new IllegalArgumentException("unknown timeType, was:" + Integer.valueOf(timeType)); //$NON-NLS-1$
type = timeType;
}
@@ -58,7 +62,7 @@ public class LastModifiedLier extends BasicResourceDelivery {
case TYPE_ZERO :
return 0L;
case TYPE_OLD :
- return 1L;
+ return 1000L;
case TYPE_NOW :
return System.currentTimeMillis();
case TYPE_FUTURE :
@@ -67,4 +71,12 @@ public class LastModifiedLier extends BasicResourceDelivery {
// should not happen
return 0L;
}
+
+ public void addDateHeader(HttpServletResponse response, String name, long timestamp) {
+ if (type != TYPE_BAD)
+ super.addDateHeader(response, name, timestamp);
+ else
+ response.setHeader(name, "intentionally-bad-date"); //$NON-NLS-1$
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/index.html b/bundles/org.eclipse.equinox.p2.testserver/webfiles/index.html
index ce54eb75c..888e71d1d 100644
--- a/bundles/org.eclipse.equinox.p2.testserver/webfiles/index.html
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/index.html
@@ -14,7 +14,20 @@ log in. The credentials are: user: <b>Aladdin</b>, password: <b>open sesame</b>.
<li>/proxy/truncated - goes to updates/3.4, but truncates all files</li>
<li>/proxy/molested - goes to updates/3.4, but generates gibberish for all files</li>
<li>/proxy/decelerate - goes to updates/3.4, but delivers files in very small delayed packets - delay increases.</li>
-<li>
+<li>/proxy/modified/... - goes to updates/3.4, but delivers various errors in "last modified" (see below)
+ <ul><li>.../zero - all times are returned as 0</li>
+ <li>.../old - all times are very old</li>
+ <li>.../now - all times are the same as the request time</li>
+ <li>.../future - all times are in the future (which is illegal in HTTP)</li>
+ <li>.../bad - the time is not a date at all - the client should throw an error</li>
+ </ul>
+</li>
+<li>/proxy/length/... - goes to updates/3.4, but delivers various content length errors (see below)
+ <ul><li>.../zero - length is reported as 0 (but all content written to stream)</li>
+ <li>.../less - less than the correct size is reported (all content written)</li>
+ <li>.../more - double the correct size is reported (but only available content is written)</li>
+ </ul>
+</li>
</ul>
<p>The content listed below is also available and can be accessed under:
<ul><li>/public</li>

Back to the top