Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 603092504
Change-Id: I9bc1013f8511dcaa0b54666ae75e3df14f4259c6
  • Loading branch information
cpovirk authored and copybara-github committed Jan 31, 2024
1 parent 1a3312d commit d2cd068
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package com.google.tsunami.common.config;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.truth.Truth8;
import java.util.List;
import java.util.Map;
import org.junit.After;
Expand Down Expand Up @@ -56,12 +56,12 @@ public void fromYamlData_whenNullYamlData_createEmptyConfigData() {
public void getSystemProperty_whenPropertyExists_returnsPropertyValue() {
System.setProperty(TEST_PROPERTY, "Test value");

assertThat(TsunamiConfig.getSystemProperty(TEST_PROPERTY)).hasValue("Test value");
Truth8.assertThat(TsunamiConfig.getSystemProperty(TEST_PROPERTY)).hasValue("Test value");
}

@Test
public void getSystemProperty_whenPropertyNotExists_returnsEmptyOptional() {
assertThat(TsunamiConfig.getSystemProperty(TEST_PROPERTY)).isEmpty();
Truth8.assertThat(TsunamiConfig.getSystemProperty(TEST_PROPERTY)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package com.google.tsunami.common.net;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.tsunami.common.net.UrlUtils.allSubPaths;
import static com.google.tsunami.common.net.UrlUtils.removeLeadingSlashes;
import static com.google.tsunami.common.net.UrlUtils.removeTrailingSlashes;
import static com.google.tsunami.common.net.UrlUtils.urlEncode;

import com.google.common.truth.Truth8;
import okhttp3.HttpUrl;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -127,42 +127,44 @@ public void removeTrailingSlashes_whenMultipleTrailingSlashes_removesTrailingSla

@Test
public void urlEncode_whenEmptyString_returnsOriginal() {
assertThat(urlEncode("")).hasValue("");
Truth8.assertThat(urlEncode("")).hasValue("");
}

@Test
public void urlEncode_whenNothingToEncode_returnsOriginal() {
assertThat(urlEncode("abcdefghijklmnopqrstuvwxyz")).hasValue("abcdefghijklmnopqrstuvwxyz");
assertThat(urlEncode("ABCDEFGHIJKLMNOPQRSTUVWXYZ")).hasValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
assertThat(urlEncode("0123456789")).hasValue("0123456789");
assertThat(urlEncode("-_.*")).hasValue("-_.*");
Truth8.assertThat(urlEncode("abcdefghijklmnopqrstuvwxyz"))
.hasValue("abcdefghijklmnopqrstuvwxyz");
Truth8.assertThat(urlEncode("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
.hasValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
Truth8.assertThat(urlEncode("0123456789")).hasValue("0123456789");
Truth8.assertThat(urlEncode("-_.*")).hasValue("-_.*");
}

@Test
public void urlEncode_whenNotEncoded_returnsEncoded() {
assertThat(urlEncode(" ")).hasValue("+");
assertThat(urlEncode("()[]{}<>")).hasValue("%28%29%5B%5D%7B%7D%3C%3E");
assertThat(urlEncode("?!@#$%^&=+,;:'\"`/\\|~"))
Truth8.assertThat(urlEncode(" ")).hasValue("+");
Truth8.assertThat(urlEncode("()[]{}<>")).hasValue("%28%29%5B%5D%7B%7D%3C%3E");
Truth8.assertThat(urlEncode("?!@#$%^&=+,;:'\"`/\\|~"))
.hasValue("%3F%21%40%23%24%25%5E%26%3D%2B%2C%3B%3A%27%22%60%2F%5C%7C%7E");
}

@Test
public void urlEncode_whenAlreadyEncoded_encodesAgain() {
assertThat(urlEncode("%2F")).hasValue("%252F");
assertThat(urlEncode("%252F")).hasValue("%25252F");
Truth8.assertThat(urlEncode("%2F")).hasValue("%252F");
Truth8.assertThat(urlEncode("%252F")).hasValue("%25252F");
}

@Test
public void urlEncode_whenComplexEncoding_encodesCorrectly() {
assertThat(urlEncode("£")).hasValue("%C2%A3");
assertThat(urlEncode("つ")).hasValue("%E3%81%A4");
assertThat(urlEncode("äëïöüÿ")).hasValue("%C3%A4%C3%AB%C3%AF%C3%B6%C3%BC%C3%BF");
assertThat(urlEncode("ÄËÏÖÜŸ")).hasValue("%C3%84%C3%8B%C3%8F%C3%96%C3%9C%C5%B8");
Truth8.assertThat(urlEncode("£")).hasValue("%C2%A3");
Truth8.assertThat(urlEncode("つ")).hasValue("%E3%81%A4");
Truth8.assertThat(urlEncode("äëïöüÿ")).hasValue("%C3%A4%C3%AB%C3%AF%C3%B6%C3%BC%C3%BF");
Truth8.assertThat(urlEncode("ÄËÏÖÜŸ")).hasValue("%C3%84%C3%8B%C3%8F%C3%96%C3%9C%C5%B8");
}

@Test
public void urlEncode_whenUnicode_encodesOriginal() {
// EURO sign
assertThat(urlEncode("\u20AC")).hasValue("%E2%82%AC");
Truth8.assertThat(urlEncode("\u20AC")).hasValue("%E2%82%AC");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package com.google.tsunami.common.net.http;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.tsunami.common.net.http.HttpRequest.get;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import com.google.common.truth.Truth8;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void setTrustAllCertificates_whenCliOptionEnabledAndCertIsInvalid_ignores
MockWebServer mockWebServer = startMockWebServerWithSsl();

HttpResponse response = httpClient.send(get(mockWebServer.url("/")).withEmptyHeaders().build());
assertThat(response.bodyString()).hasValue("body");
Truth8.assertThat(response.bodyString()).hasValue("body");

mockWebServer.shutdown();
}
Expand All @@ -168,7 +168,7 @@ public void setTrustAllCertificates_whenCliOptionEnabledAndCertIsInvalid_ignores
MockWebServer mockWebServer = startMockWebServerWithSsl();

HttpResponse response = httpClient.send(get(mockWebServer.url("/")).withEmptyHeaders().build());
assertThat(response.bodyString()).hasValue("body");
Truth8.assertThat(response.bodyString()).hasValue("body");

mockWebServer.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package com.google.tsunami.common.net.http;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.common.collect.ImmutableListMultimap;
import com.google.common.truth.Truth8;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void get_whenRequestedHeaderExists_returnsRequestedHeader() {
.addHeader(com.google.common.net.HttpHeaders.CONTENT_TYPE, "text/html; charset=UTF-8")
.build();

assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.ACCEPT)).hasValue("*/*");
Truth8.assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.ACCEPT)).hasValue("*/*");
}

@Test
Expand All @@ -128,7 +128,7 @@ public void get_whenMultipleValuesExist_returnsFirstValue() {
.addHeader(com.google.common.net.HttpHeaders.ACCEPT, "text/html")
.build();

assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.ACCEPT)).hasValue("*/*");
Truth8.assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.ACCEPT)).hasValue("*/*");
}

@Test
Expand All @@ -140,7 +140,7 @@ public void get_whenRequestedHeaderDoesNotExist_returnsEmpty() {
.addHeader(com.google.common.net.HttpHeaders.ACCEPT, "text/html")
.build();

assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.COOKIE)).isEmpty();
Truth8.assertThat(httpHeaders.get(com.google.common.net.HttpHeaders.COOKIE)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package com.google.tsunami.common.net.http;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import com.google.common.truth.Truth8;
import com.google.protobuf.ByteString;
import okhttp3.HttpUrl;
import org.junit.Test;
Expand All @@ -43,7 +43,7 @@ public void bodyJson_whenValidResponseBody_returnsParsedJson() {
.setResponseUrl(TEST_URL)
.build();

assertThat(httpResponse.bodyJson()).isPresent();
Truth8.assertThat(httpResponse.bodyJson()).isPresent();
assertThat(httpResponse.bodyJson().get().isJsonObject()).isTrue();
assertThat(
httpResponse
Expand All @@ -64,7 +64,7 @@ public void bodyJson_whenEmptyResponseBody_returnsEmptyOptional() {
.setResponseUrl(TEST_URL)
.build();

assertThat(httpResponse.bodyJson()).isEmpty();
Truth8.assertThat(httpResponse.bodyJson()).isEmpty();
}

@Test
Expand All @@ -77,7 +77,7 @@ public void bodyJson_whenNonJsonResponseBody_returnsEmptyOptional() {
.setResponseUrl(TEST_URL)
.build();

assertThat(httpResponse.bodyJson()).isEmpty();
Truth8.assertThat(httpResponse.bodyJson()).isEmpty();
}

@Test
Expand Down Expand Up @@ -117,7 +117,7 @@ public void jsonFieldEqualsToValue_whenNonJsonResponseBody_returnsEmptyOptional(
.setResponseUrl(TEST_URL)
.build();

assertThat(httpResponse.bodyJson()).isEmpty();
Truth8.assertThat(httpResponse.bodyJson()).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import static com.google.common.net.HttpHeaders.LOCATION;
import static com.google.common.net.HttpHeaders.USER_AGENT;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.tsunami.common.net.http.HttpRequest.get;
import static com.google.tsunami.common.net.http.HttpRequest.head;
import static com.google.tsunami.common.net.http.HttpRequest.post;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertThrows;

import com.google.common.net.MediaType;
import com.google.common.truth.Truth8;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
Expand Down Expand Up @@ -511,7 +511,7 @@ public void send_whenNotFollowRedirect_returnsFinalHttpResponse() throws IOExcep
.addHeader(CONTENT_LENGTH, "0")
.addHeader(LOCATION, RedirectDispatcher.REDIRECT_DESTINATION_PATH)
.build());
assertThat(response.bodyString()).hasValue("");
Truth8.assertThat(response.bodyString()).hasValue("");
assertThat(response)
.isEqualTo(
HttpResponse.builder()
Expand Down Expand Up @@ -550,7 +550,7 @@ public void sendAsync_whenNotFollowRedirect_returnsFinalHttpResponse()
.addHeader(CONTENT_LENGTH, "0")
.addHeader(LOCATION, RedirectDispatcher.REDIRECT_DESTINATION_PATH)
.build());
assertThat(response.bodyString()).hasValue("");
Truth8.assertThat(response.bodyString()).hasValue("");
assertThat(response)
.isEqualTo(
HttpResponse.builder()
Expand Down Expand Up @@ -667,7 +667,7 @@ protected void configure() {
httpClient.send(
get(String.format("https://%s:%d", host, port)).withEmptyHeaders().build(),
networkService);
assertThat(response.bodyString()).hasValue("body");
Truth8.assertThat(response.bodyString()).hasValue("body");

mockWebServer.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package com.google.tsunami.plugin;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;

import com.google.common.base.Stopwatch;
import com.google.common.testing.FakeTicker;
import com.google.common.truth.Truth8;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.tsunami.plugin.PluginExecutor.PluginExecutorConfig;
Expand Down Expand Up @@ -61,10 +61,10 @@ public void executeAsync_whenSucceeded_returnsSucceededResult()
.executeAsync(executorConfig)
.get();

assertThat(executionResult.exception()).isEmpty();
Truth8.assertThat(executionResult.exception()).isEmpty();
assertThat(executionResult.isSucceeded()).isTrue();
assertThat(executionResult.executionStopwatch().elapsed()).isEqualTo(TICK_DURATION);
assertThat(executionResult.resultData()).hasValue("result data");
Truth8.assertThat(executionResult.resultData()).hasValue("result data");
}

@Test
Expand All @@ -84,12 +84,12 @@ public void executeAsync_whenFailedWithPluginExecutionException_returnsFailedRes
.executeAsync(executorConfig)
.get();

assertThat(executionResult.exception()).isPresent();
Truth8.assertThat(executionResult.exception()).isPresent();
assertThat(executionResult.exception().get()).hasCauseThat().isNull();
assertThat(executionResult.exception().get()).hasMessageThat().contains("test exception");
assertThat(executionResult.isSucceeded()).isFalse();
assertThat(executionResult.executionStopwatch().elapsed()).isEqualTo(TICK_DURATION);
assertThat(executionResult.resultData()).isEmpty();
Truth8.assertThat(executionResult.resultData()).isEmpty();
}

@Test
Expand All @@ -109,7 +109,7 @@ public void executeAsync_whenFailedWithUnknownException_returnsFailedResult()
.executeAsync(executorConfig)
.get();

assertThat(executionResult.exception()).isPresent();
Truth8.assertThat(executionResult.exception()).isPresent();
assertThat(executionResult.exception().get())
.hasCauseThat()
.isInstanceOf(RuntimeException.class);
Expand All @@ -119,6 +119,6 @@ public void executeAsync_whenFailedWithUnknownException_returnsFailedResult()
String.format("Plugin execution error on '%s'.", FAKE_MATCHING_RESULT.pluginId()));
assertThat(executionResult.isSucceeded()).isFalse();
assertThat(executionResult.executionStopwatch().elapsed()).isEqualTo(TICK_DURATION);
assertThat(executionResult.resultData()).isEmpty();
Truth8.assertThat(executionResult.resultData()).isEmpty();
}
}
Loading

0 comments on commit d2cd068

Please sign in to comment.