Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Ladenberger2013-03-12 08:17:40 +0000
committerLukas Ladenberger2013-03-12 08:17:40 +0000
commit648953c951f206691fc89375dc2f9c277314f132 (patch)
tree370d329781da64d5065fd7fbab7de054f011c3f5
parent0871d8aa99c059b8e7c5b235c33f3272fd42b54b (diff)
downloadorg.eclipse.rmf-648953c951f206691fc89375dc2f9c277314f132.tar.gz
org.eclipse.rmf-648953c951f206691fc89375dc2f9c277314f132.tar.xz
org.eclipse.rmf-648953c951f206691fc89375dc2f9c277314f132.zip
open connection only once and use eclispe proxy settings
-rw-r--r--org.eclipse.rmf.reqif10.pror.editor.tests/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/CachingTests.java63
1 files changed, 41 insertions, 22 deletions
diff --git a/org.eclipse.rmf.reqif10.pror.editor.tests/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/CachingTests.java b/org.eclipse.rmf.reqif10.pror.editor.tests/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/CachingTests.java
index 393e43a5..19e4f266 100644
--- a/org.eclipse.rmf.reqif10.pror.editor.tests/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/CachingTests.java
+++ b/org.eclipse.rmf.reqif10.pror.editor.tests/src/org/eclipse/rmf/reqif10/pror/editor/agilegrid/CachingTests.java
@@ -12,7 +12,6 @@
package org.eclipse.rmf.reqif10.pror.editor.agilegrid;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import java.io.BufferedReader;
import java.io.IOException;
@@ -41,6 +40,8 @@ import org.eclipse.rmf.reqif10.pror.configuration.Column;
import org.eclipse.rmf.reqif10.pror.configuration.ConfigurationFactory;
import org.eclipse.rmf.reqif10.pror.configuration.ProrSpecViewConfiguration;
import org.eclipse.rmf.reqif10.pror.util.ConfigurationUtil;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -50,6 +51,41 @@ import org.junit.Test;
*/
public class CachingTests extends AbstractContentProviderTests {
+ private final String httpURL = "http://cobra.cs.uni-duesseldorf.de:8000/result/add/";
+ private HttpURLConnection con = null;
+
+ @Before
+ public void setup() {
+
+ try {
+
+ System.setProperty("http.proxyHost", "proxy.eclipse.org");
+ System.setProperty("http.proxyPort", "9898");
+
+ URL myurl = new URL(httpURL);
+ con = null;
+
+ System.out.println("TRY TO OPEN CONNECTION");
+ con = (HttpURLConnection) myurl.openConnection();
+ System.out.println("CONNECTION ESTABLISHED");
+ con.setDoOutput(true);
+ con.setRequestMethod("POST");
+ con.setRequestProperty("Content-Type",
+ "application/x-www-form-urlencoded");
+ con.connect();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @After
+ public void cleanup() {
+ if (con != null)
+ con.disconnect();
+ }
+
private long getCpuTime() {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
return bean.isCurrentThreadCpuTimeSupported() ? bean
@@ -60,11 +96,12 @@ public class CachingTests extends AbstractContentProviderTests {
try {
InputStream s = CachingTests.class
.getResourceAsStream("/commit-id");
- BufferedReader in = new BufferedReader(new InputStreamReader(s));
- return in.readLine();
+ if (s != null) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(s));
+ return in.readLine();
+ }
} catch (IOException e) {
System.out.println("Could not get commit-id");
- fail(e.getMessage());
}
return null;
}
@@ -74,18 +111,13 @@ public class CachingTests extends AbstractContentProviderTests {
if (commitId == null)
return;
- String httpURL = "http://cobra.cs.uni-duesseldorf.de:8000/result/add/";
-
StringBuilder query = new StringBuilder();
- HttpURLConnection con = null;
OutputStreamWriter wr = null;
BufferedReader rr = null;
try {
- URL myurl = new URL(httpURL);
-
query.append("commitid=").append(
URLEncoder.encode(commitId, "UTF-8"));
query.append("&branch=").append(
@@ -101,17 +133,6 @@ public class CachingTests extends AbstractContentProviderTests {
query.append("&result_value=").append(
URLEncoder.encode("" + value, "UTF-8"));
- System.out.println("TRY TO OPEN CONNECTION");
- con = (HttpURLConnection) myurl.openConnection();
- System.out.println("CONNECTION ESTABLISHED");
- con.setDoOutput(true);
- con.setRequestMethod("POST");
- con.setRequestProperty("Content-Type",
- "application/x-www-form-urlencoded");
- con.setRequestProperty("Content-Length",
- String.valueOf(query.toString().length()));
- con.connect();
-
wr = new OutputStreamWriter(con.getOutputStream());
wr.write(query.toString());
wr.flush();
@@ -135,8 +156,6 @@ public class CachingTests extends AbstractContentProviderTests {
} catch (IOException e) {
e.printStackTrace();
}
- if (con != null)
- con.disconnect();
}
}

Back to the top