Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengxin Zhu2011-09-02 03:18:09 -0400
committerMengxin Zhu2011-09-02 04:07:23 -0400
commitdf0e3ecefa5df573f6b51a49155442d83fdb2a5f (patch)
tree726a1f93126212e5816f9b178f17cff618876b6c /bundles/org.eclipse.equinox.p2.testserver
parent8c591f781927fc324e96d166f1af22d125c8372a (diff)
downloadrt.equinox.p2-df0e3ecefa5df573f6b51a49155442d83fdb2a5f.tar.gz
rt.equinox.p2-df0e3ecefa5df573f6b51a49155442d83fdb2a5f.tar.xz
rt.equinox.p2-df0e3ecefa5df573f6b51a49155442d83fdb2a5f.zip
fix 350014 to use a system property to set the retrying number if socketv20110902-0807
timeout happened Change-Id: I1bab6db693a3ee739e058bda1a4d00fbc8bd1eb8
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.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java83
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/artifacts.xml52
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirror-two/plugins/HelloWorldText_1.0.0.txt1
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirrors.xml5
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/plugins/HelloWorldText_1.0.0.txt1
-rw-r--r--bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/readme.txt12
7 files changed, 157 insertions, 0 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 746d63487..90cbd16ac 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
@@ -17,6 +17,7 @@ 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.IntermittentTimeout;
import org.eclipse.equinox.p2.testserver.servlets.LastModifiedLier;
import org.eclipse.equinox.p2.testserver.servlets.Redirector;
import org.eclipse.equinox.p2.testserver.servlets.StatusCodeResponse;
@@ -70,9 +71,11 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
httpService.registerResources("/private", "/webfiles", secureHttpContext); //$NON-NLS-1$ //$NON-NLS-2$
httpService.registerResources("/never", "/webfiles", alwaysFail); //$NON-NLS-1$ //$NON-NLS-2$
httpService.registerResources("/flipflop", "/webfiles", flipFlop); //$NON-NLS-1$ //$NON-NLS-2$
+ // httpService.registerResources("/mirrorrequest", "/webfiles/emptyJarRepo", null); //$NON-NLS-1$ //$NON-NLS-2$
httpService.registerServlet("/status", new StatusCodeResponse(), null, null); //$NON-NLS-1$
httpService.registerServlet("/timeout", new TimeOut(), null, null); //$NON-NLS-1$
+ httpService.registerServlet("/mirrorrequest", new IntermittentTimeout("/mirrorrequest", URI.create("http://localhost:" + System.getProperty("org.osgi.service.http.port", "8080") + "/public/emptyJarRepo")), null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
httpService.registerServlet("/redirect", new Redirector(), null, null); //$NON-NLS-1$
httpService.registerServlet("/truncated", new Truncator("/truncated", URI.create("/webfiles"), 50), null, null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
diff --git a/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java
new file mode 100644
index 000000000..ac17e7ad5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/src/org/eclipse/equinox/p2/testserver/servlets/IntermittentTimeout.java
@@ -0,0 +1,83 @@
+package org.eclipse.equinox.p2.testserver.servlets;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URLConnection;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.eclipse.equinox.p2.testserver.HttpConstants;
+
+public class IntermittentTimeout extends BasicResourceDelivery {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2216234319571297257L;
+ int count = 1;
+
+ public IntermittentTimeout(String theAlias, URI thePath) {
+ super(theAlias, thePath);
+ }
+
+ protected void doDeliver(URLConnection conn, InputStream in, String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // set when the resource was modified
+ addDateHeader(response, HttpConstants.LAST_MODIFIED, getLastModified(conn));
+ int statusCode = HttpHeaderToStatus(conn.getHeaderField(0));
+
+ response.setStatus(statusCode != -1 ? HttpServletResponse.SC_OK : statusCode);
+
+ int contentlength = getContentLength(conn);
+ if (contentlength >= 0) {
+ response.setContentLength(contentlength);
+
+ String mimeType = computeMimeType(filename, conn);
+ response.setContentType(mimeType);
+
+ // We want to use a writer if we are sending text
+ if (mimeType.startsWith("text/")) //$NON-NLS-1$
+ {
+ PrintWriter writer = response.getWriter();
+
+ writer.flush(); /* write the headers and unbuffer the output */
+
+ doDelay(filename, 150);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+
+ char buffer[] = new char[4096];
+ int read;
+ while ((read = reader.read(buffer, 0, buffer.length)) != -1) {
+ writer.write(buffer, 0, read);
+ }
+ } else {
+ ServletOutputStream out = response.getOutputStream();
+
+ out.flush(); /* write the headers and unbuffer the output */
+
+ doDelay(filename, 150);
+
+ byte buffer[] = new byte[4096];
+ int read;
+ while ((read = in.read(buffer, 0, buffer.length)) != -1) {
+ out.write(buffer, 0, read);
+ out.flush();
+ }
+ }
+ }
+ }
+
+ private void doDelay(String filename, int seconds) {
+ if (filename.endsWith("emptyJarRepo/plugins/HelloWorldText_1.0.0.txt") && (count++ % 3 != 0)) {//$NON-NLS-1$
+ try {
+ Thread.sleep(1000 * seconds);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/artifacts.xml b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/artifacts.xml
new file mode 100644
index 000000000..914362402
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/artifacts.xml
@@ -0,0 +1,52 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository class='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='1.0.0'?>
+<repository name='HelloWorld Artifacts' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1.0.0'>
+ <properties size='5'>
+ <property name='publishPackFilesAsSiblings' value='true'/>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1222368069078'/>
+ <property name='eclipse.p2.force.threading' value='true'/>
+ <property name='p2.mirrorsURL' value='mirrors.xml'/>
+ </properties>
+ <mappings size='6'>
+ <rule filter='(&amp; (classifier=osgi.bundle) (format=packed))' output='${repoUrl}/plugins/${id}_${version}.jar.pack.gz'/>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=test.txt) (format=packed))' output='${repoUrl}/plugins/${id}_${version}.txt.pack.gz'/>
+ <rule filter='(&amp; (classifier=test.txt))' output='${repoUrl}/plugins/${id}_${version}.txt'/>
+ </mappings>
+ <artifacts size='4'>
+ <artifact classifier='org.eclipse.update.feature' id='HelloWorldFeature' version='1.0.0'>
+ <properties size='2'>
+ <property name='artifact.size' value='0'/>
+ <property name='download.size' value='0'/>
+ </properties>
+ </artifact>
+ <artifact classifier='test.txt' id='HelloWorldText' version='1.0.0'>
+ <properties size='3'>
+ <property name='artifact.size' value='12'/>
+ <property name='download.size' value='12'/>
+ <property name='download.md5' value='ed076287532e86365e841e92bfc50d8c'/>
+ </properties>
+ </artifact>
+ <artifact classifier='test.txt' id='fail_to_canonical' version='1.0.0'>
+ <properties size='3'>
+ <property name='artifact.size' value='12'/>
+ <property name='download.size' value='12'/>
+ <property name='download.md5' value='ed076287532e86365e841e92bfc50d8c'/>
+ </properties>
+ </artifact>
+ <artifact classifier='test.txt' id='fail_to_canonical' version='1.0.0'>
+ <processing size='1'>
+ <step id='org.eclipse.equinox.p2.processing.Pack200Unpacker' required='true'/>
+ </processing>
+ <properties size='4'>
+ <property name='artifact.size' value='12'/>
+ <property name='download.size' value='12'/>
+ <property name='download.md5' value='ed076287532e86365e841e92bfc50d8c'/>
+ <property name='format' value='packed'/>
+ </properties>
+ </artifact>
+ </artifacts>
+</repository> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirror-two/plugins/HelloWorldText_1.0.0.txt b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirror-two/plugins/HelloWorldText_1.0.0.txt
new file mode 100644
index 000000000..c57eff55e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirror-two/plugins/HelloWorldText_1.0.0.txt
@@ -0,0 +1 @@
+Hello World! \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirrors.xml b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirrors.xml
new file mode 100644
index 000000000..9faec8f17
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/mirrors.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<mirrors>
+ <mirror url="mirror-one" label="MirrorOne" />
+ <mirror url="mirror-two" label="MirrorTwo" />
+</mirrors> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/plugins/HelloWorldText_1.0.0.txt b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/plugins/HelloWorldText_1.0.0.txt
new file mode 100644
index 000000000..c57eff55e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/plugins/HelloWorldText_1.0.0.txt
@@ -0,0 +1 @@
+Hello World! \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/readme.txt b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/readme.txt
new file mode 100644
index 000000000..133499d32
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.testserver/webfiles/emptyJarRepo/readme.txt
@@ -0,0 +1,12 @@
+
+Artifact: test.txt,HelloWorldText,1.0.0
+ Used by MirrorRequestTest2#testRetryMirrorAfterTimeout()
+ Mirror one: missing file
+ Mirror two: get it
+ Main: intermittent timeout
+
+Artifact: test.txt,HelloWorldText,1.0.0
+ Used by MirrorRequestTest2#testTimeoutForgivableAfterTimeout()
+ Mirror one: missing file
+ Mirror two: won't use
+ Main: intermittent timeout \ No newline at end of file

Back to the top