Skip to content

Commit 2469a09

Browse files
authored
fix: Remove mockserver dependency (#1022)
1 parent 2a58a9f commit 2469a09

File tree

2 files changed

+0
-80
lines changed

2 files changed

+0
-80
lines changed

Diff for: pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,5 @@
493493
<version>3.0</version>
494494
<scope>test</scope>
495495
</dependency>
496-
<dependency>
497-
<groupId>org.mock-server</groupId>
498-
<artifactId>mockserver-junit-rule-no-dependencies</artifactId>
499-
<version>5.14.0</version>
500-
</dependency>
501496
</dependencies>
502497
</project>

Diff for: src/test/java/com/google/firebase/internal/ApacheHttp2TransportIT.java

-75
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
import static org.junit.Assert.assertNull;
2222
import static org.junit.Assert.assertTrue;
2323
import static org.junit.Assert.fail;
24-
import static org.mockserver.model.Header.header;
25-
import static org.mockserver.model.HttpForward.forward;
26-
import static org.mockserver.model.HttpRequest.request;
27-
import static org.mockserver.model.HttpResponse.response;
2824

2925
import com.google.api.client.http.GenericUrl;
3026
import com.google.api.client.http.HttpRequestFactory;
@@ -59,10 +55,6 @@
5955
import org.junit.BeforeClass;
6056
import org.junit.Test;
6157

62-
import org.mockserver.integration.ClientAndServer;
63-
import org.mockserver.model.HttpForward.Scheme;
64-
import org.mockserver.socket.PortFactory;
65-
6658
public class ApacheHttp2TransportIT {
6759
private static FirebaseApp app;
6860
private static final GoogleCredentials MOCK_CREDENTIALS = new MockGoogleCredentials("test_token");
@@ -79,9 +71,6 @@ public class ApacheHttp2TransportIT {
7971
private static Socket fillerSocket;
8072
private static int port;
8173

82-
private static ClientAndServer mockProxy;
83-
private static ClientAndServer mockServer;
84-
8574
@BeforeClass
8675
public static void setUpClass() throws IOException {
8776
// Start server socket with a backlog queue of 1 and a automatically assigned
@@ -109,14 +98,6 @@ public void cleanup() {
10998
app.delete();
11099
}
111100

112-
if (mockProxy != null && mockProxy.isRunning()) {
113-
mockProxy.close();
114-
}
115-
116-
if (mockServer != null && mockServer.isRunning()) {
117-
mockServer.close();
118-
}
119-
120101
System.clearProperty("http.proxyHost");
121102
System.clearProperty("http.proxyPort");
122103
System.clearProperty("https.proxyHost");
@@ -311,62 +292,6 @@ public void testVerifyProxyIsRespected() {
311292
}
312293
}
313294

314-
@Test(timeout = 10_000L)
315-
public void testProxyMockHttp() throws Exception {
316-
// Start MockServer
317-
mockProxy = ClientAndServer.startClientAndServer(PortFactory.findFreePort());
318-
mockServer = ClientAndServer.startClientAndServer(PortFactory.findFreePort());
319-
320-
System.setProperty("http.proxyHost", "localhost");
321-
System.setProperty("http.proxyPort", mockProxy.getPort().toString());
322-
323-
// Configure proxy to receieve requests and forward them to a mock destination
324-
// server
325-
mockProxy
326-
.when(
327-
request())
328-
.forward(
329-
forward()
330-
.withHost("localhost")
331-
.withPort(mockServer.getPort())
332-
.withScheme(Scheme.HTTP));
333-
334-
// Configure server to listen and respond
335-
mockServer
336-
.when(
337-
request())
338-
.respond(
339-
response()
340-
.withStatusCode(200)
341-
.withBody("Expected server response"));
342-
343-
// Send a request through the proxy
344-
app = FirebaseApp.initializeApp(FirebaseOptions.builder()
345-
.setCredentials(MOCK_CREDENTIALS)
346-
.setWriteTimeout(100)
347-
.build(), "test-app");
348-
ErrorHandlingHttpClient<FirebaseException> httpClient = getHttpClient(true, app);
349-
HttpRequestInfo request = HttpRequestInfo.buildGetRequest("http://www.google.com");
350-
IncomingHttpResponse response = httpClient.send(request);
351-
352-
// Verify that the proxy received request with destination host
353-
mockProxy.verify(
354-
request()
355-
.withMethod("GET")
356-
.withPath("/")
357-
.withHeader(header("Host", "www.google.com")));
358-
359-
// Verify the forwarded request is received by the server
360-
mockServer.verify(
361-
request()
362-
.withMethod("GET")
363-
.withPath("/"));
364-
365-
// Verify response
366-
assertEquals(200, response.getStatusCode());
367-
assertEquals(response.getContent(), "Expected server response");
368-
}
369-
370295
private static ErrorHandlingHttpClient<FirebaseException> getHttpClient(boolean authorized,
371296
FirebaseApp app) {
372297
HttpRequestFactory requestFactory;

0 commit comments

Comments
 (0)