Skip to content

Commit 07b05d7

Browse files
committed
Fix for URL with spaces
1 parent 354029e commit 07b05d7

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

test/smoke/testApps/HttpClients/src/main/java/com/microsoft/applicationinsights/smoketestapp/HttpClientTestServlet.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ private int doGetInternal(HttpServletRequest req) throws Exception {
7575
}
7676

7777
private int apacheHttpClient4() throws IOException {
78-
String url = "https://www.bing.com";
78+
String url = "https://www.bing.com/search?q=spaces%20test";
7979
HttpGet get = new HttpGet(url);
8080
try (CloseableHttpResponse response = httpClient.execute(get)) {
8181
return response.getStatusLine().getStatusCode();
8282
}
8383
}
8484

8585
private int apacheHttpClient4WithResponseHandler() throws IOException {
86-
String url = "https://www.bing.com";
86+
String url = "https://www.bing.com/search?q=spaces%20test";
8787
HttpGet get = new HttpGet(url);
8888
return httpClient.execute(get, new ResponseHandler<Integer>() {
8989
@Override
@@ -97,15 +97,15 @@ private int apacheHttpClient3() throws IOException {
9797
HttpClient httpClient3 = new org.apache.commons.httpclient.HttpClient();
9898
CookiePolicy.registerCookieSpec("PermitAllCookiesSpec", PermitAllCookiesSpec.class);
9999
httpClient3.getParams().setCookiePolicy("PermitAllCookiesSpec");
100-
String url = "https://www.bing.com";
100+
String url = "https://www.bing.com/search?q=spaces%20test";
101101
GetMethod httpGet = new GetMethod(url);
102102
httpClient3.executeMethod(httpGet);
103103
httpGet.releaseConnection();
104104
return httpGet.getStatusCode();
105105
}
106106

107107
private int apacheHttpAsyncClient() throws ExecutionException, InterruptedException, IOException {
108-
HttpGet get = new HttpGet("https://www.bing.com");
108+
HttpGet get = new HttpGet("https://www.bing.com/search?q=spaces%20test");
109109
HttpResponse httpResponse = httpAsyncClient.execute(get, null).get();
110110
httpResponse.getEntity().getContent().close();
111111
return httpResponse.getStatusLine().getStatusCode();
@@ -114,7 +114,7 @@ private int apacheHttpAsyncClient() throws ExecutionException, InterruptedExcept
114114
private int okHttp3() throws IOException {
115115
okhttp3.OkHttpClient client = new okhttp3.OkHttpClient();
116116
okhttp3.Request request = new okhttp3.Request.Builder()
117-
.url("https://www.bing.com")
117+
.url("https://www.bing.com/search?q=spaces%20test")
118118
.build();
119119
okhttp3.Response response = client.newCall(request).execute();
120120
response.body().close();
@@ -124,7 +124,7 @@ private int okHttp3() throws IOException {
124124
private int okHttp2() throws IOException {
125125
com.squareup.okhttp.OkHttpClient client = new com.squareup.okhttp.OkHttpClient();
126126
com.squareup.okhttp.Request request = new com.squareup.okhttp.Request.Builder()
127-
.url("https://www.bing.com")
127+
.url("https://www.bing.com/search?q=spaces%20test")
128128
.build();
129129
com.squareup.okhttp.Response response = client.newCall(request).execute();
130130
response.body().close();
@@ -133,14 +133,14 @@ private int okHttp2() throws IOException {
133133

134134
private int springWebClient() {
135135
return WebClient.create().get()
136-
.uri("https://www.bing.com")
136+
.uri("https://www.bing.com/search?q=spaces%20test")
137137
.exchange()
138138
.map(response -> response.statusCode())
139139
.block().value();
140140
}
141141

142142
private int httpURLConnection() throws IOException {
143-
URL obj = new URL("https://www.bing.com");
143+
URL obj = new URL("https://www.bing.com/search?q=spaces%20test");
144144
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
145145
// calling getContentType() first, since this triggered a bug previously in the instrumentation previously
146146
connection.getContentType();

test/smoke/testApps/HttpClients/src/smokeTest/java/com/microsoft/applicationinsights/smoketestapp/HttpClientSmokeTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void testApacheHttpClient4() throws Exception {
2929
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
3030

3131
assertTrue(rd.getSuccess());
32-
assertEquals("GET /", rdd.getName());
32+
assertEquals("GET /search", rdd.getName());
3333
assertEquals("www.bing.com", rdd.getTarget());
3434
assertParentChild(rd, rdEnvelope, rddEnvelope);
3535
}
@@ -47,7 +47,7 @@ public void testApacheHttpClient4WithResponseHandler() throws Exception {
4747
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
4848

4949
assertTrue(rd.getSuccess());
50-
assertEquals("GET /", rdd.getName());
50+
assertEquals("GET /search", rdd.getName());
5151
assertEquals("www.bing.com", rdd.getTarget());
5252
assertParentChild(rd, rdEnvelope, rddEnvelope);
5353
}
@@ -65,7 +65,7 @@ public void testApacheHttpClient3() throws Exception {
6565
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
6666

6767
assertTrue(rd.getSuccess());
68-
assertEquals("GET /", rdd.getName());
68+
assertEquals("GET /search", rdd.getName());
6969
assertEquals("www.bing.com", rdd.getTarget());
7070
assertParentChild(rd, rdEnvelope, rddEnvelope);
7171
}
@@ -83,7 +83,7 @@ public void testApacheHttpAsyncClient() throws Exception {
8383
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
8484

8585
assertTrue(rd.getSuccess());
86-
assertEquals("GET /", rdd.getName());
86+
assertEquals("GET /search", rdd.getName());
8787
assertEquals("www.bing.com", rdd.getTarget());
8888
assertParentChild(rd, rdEnvelope, rddEnvelope);
8989
}
@@ -101,7 +101,7 @@ public void testOkHttp3() throws Exception {
101101
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
102102

103103
assertTrue(rd.getSuccess());
104-
assertEquals("GET /", rdd.getName());
104+
assertEquals("GET /search", rdd.getName());
105105
assertEquals("www.bing.com", rdd.getTarget());
106106
assertParentChild(rd, rdEnvelope, rddEnvelope);
107107
}
@@ -120,7 +120,7 @@ public void testOkHttp2() throws Exception {
120120
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
121121

122122
assertTrue(rd.getSuccess());
123-
assertEquals("GET /", rdd.getName());
123+
assertEquals("GET /search", rdd.getName());
124124
assertEquals("www.bing.com", rdd.getTarget());
125125
assertParentChild(rd, rdEnvelope, rddEnvelope);
126126
}
@@ -138,7 +138,7 @@ public void testHttpURLConnection() throws Exception {
138138
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();
139139

140140
assertTrue(rd.getSuccess());
141-
assertEquals("GET /", rdd.getName());
141+
assertEquals("GET /search", rdd.getName());
142142
assertEquals("www.bing.com", rdd.getTarget());
143143
assertParentChild(rd, rdEnvelope, rddEnvelope);
144144
}

0 commit comments

Comments
 (0)