Skip to content

Commit

Permalink
deps: Bump testing libraries to their latest possible versions (Googl…
Browse files Browse the repository at this point in the history
…eCloudPlatform#449)

* Dependency version bumps:
  - Bump commons-io from 2.4 to 2.11.0
  - Bump junit from 4.12 to 4.13
  - Bump hamcrest-library from 1.3 to 2.2
  - Bump mockito-core from 2.11.0 to 4.11.0
  - Bump jacoco from 0.8.6 to 0.8.8
  - Bump checkstyle from 8.18 to 8.37
* Have `verifyGoogleFormat` task run before checkstyle tasks (to suggest fixing via `./gradlew googleJavaFormat`)
  • Loading branch information
TWiStErRob committed Feb 1, 2023
1 parent 2a3f5eb commit 33babd4
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 29 deletions.
19 changes: 12 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ dependencies {
implementation(gradleApi())
api("com.google.cloud.tools:appengine-plugins-core:0.9.9")

testImplementation("commons-io:commons-io:2.4")
testImplementation("junit:junit:4.12")
testImplementation("org.hamcrest:hamcrest-library:1.3")
testImplementation("org.mockito:mockito-core:2.23.4")
testImplementation("commons-io:commons-io:2.11.0")
testImplementation("junit:junit:4.13.2")
testImplementation("org.hamcrest:hamcrest-library:2.2")
testImplementation("org.mockito:mockito-core:4.11.0")
}


Expand Down Expand Up @@ -192,11 +192,16 @@ googleJavaFormat {
tasks.check.configure {
dependsOn(tasks.verifyGoogleJavaFormat)
}
tasks.withType<Checkstyle>().configureEach {
// Set up a soft dependency so that verifyGoogleFormat suggests running googleJavaFormat,
// before devs start fixing individual checkstyle violations manually.
shouldRunAfter(tasks.verifyGoogleJavaFormat)
}
// to auto-format run ./gradlew googleJavaFormat

checkstyle {
toolVersion = "8.18"
// get the google_checks.xml file from the actual tool we"re invoking)
toolVersion = "8.37"
// Get the google_checks.xml file from the actual tool we're invoking.
config = resources.text.fromArchiveEntry(configurations.checkstyle.get().files.first(), "google_checks.xml")
maxErrors = 0
maxWarnings = 0
Expand All @@ -208,7 +213,7 @@ checkstyle {

/* TEST COVERAGE */
jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.8"
}

tasks.jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.hamcrest.MatcherAssert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testDeploy()
.withArguments("appengineDeploy")
.build();

Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Deployed service [appyaml-project]"));

deleteProject();
Expand All @@ -81,18 +81,18 @@ public void testDeployAll()
.withArguments("appengineDeployAll")
.build();

Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Deployed service [appyaml-project]"));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Custom routings have been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("DoS protection has been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(),
CoreMatchers.containsString("Indexes are being rebuilt. This may take a moment."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Cron jobs have been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Task queues have been updated."));

deleteProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import com.google.cloud.tools.managedcloudsdk.UnsupportedOsException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.Arrays;
import org.apache.commons.io.FileUtils;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -131,7 +133,8 @@ public void testDevAppServer_async() throws InterruptedException, IOException {

Assert.assertEquals(1, expectedLogFileDir.listFiles().length);
File devAppserverLogFile = new File(expectedLogFileDir, "dev_appserver.out");
String devAppServerOutput = FileUtils.readFileToString(devAppserverLogFile);
String devAppServerOutput =
FileUtils.readFileToString(devAppserverLogFile, Charset.defaultCharset());
Assert.assertTrue(devAppServerOutput.contains(devAppServerStartedString));

AssertConnection.assertResponse(
Expand All @@ -157,7 +160,7 @@ public void testDeploy()
.withArguments("appengineDeploy", "--stacktrace")
.build();

Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(),
CoreMatchers.containsString("Deployed service [standard-project]"));

Expand All @@ -175,19 +178,19 @@ public void testDeployAll()
.withArguments("appengineDeployAll")
.build();

Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(),
CoreMatchers.containsString("Deployed service [standard-project]"));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Custom routings have been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("DoS protection has been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(),
CoreMatchers.containsString("Indexes are being rebuilt. This may take a moment."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Cron jobs have been updated."));
Assert.assertThat(
MatcherAssert.assertThat(
buildResult.getOutput(), CoreMatchers.containsString("Task queues have been updated."));

deleteProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.HttpURLConnection;
import java.net.URL;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;

/** Assertions for checking connections web apps. */
Expand All @@ -36,7 +37,7 @@ public static void assertResponse(String url, int expectedCode, String expectedT
int responseCode = urlConnection.getResponseCode();
Assert.assertEquals(expectedCode, responseCode);
String response = CharStreams.toString(new InputStreamReader(urlConnection.getInputStream()));
Assert.assertThat(response, CoreMatchers.equalTo(expectedText));
MatcherAssert.assertThat(response, CoreMatchers.equalTo(expectedText));
} catch (IOException e) {
Assert.fail("IOException while running test");
}
Expand Down Expand Up @@ -73,7 +74,7 @@ public static void assertResponseWithRetries(

// Will only reach this point when a response is reached
Assert.assertEquals(expectedCode, responseCode);
Assert.assertThat(response, CoreMatchers.equalTo(expectedText));
MatcherAssert.assertThat(response, CoreMatchers.equalTo(expectedText));
return;

} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package com.google.cloud.tools.gradle.appengine.appyaml;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.util.List;
import org.gradle.api.Project;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Rule;
Expand All @@ -44,7 +45,7 @@ public void testCreateDownloadSdkTask_configureAppEngineComponent() throws IOExc
.getTasks()
.getByPath(AppEngineCorePluginConfiguration.DOWNLOAD_CLOUD_SDK_TASK_NAME);
List<SdkComponent> components = task.getComponents();
Assert.assertThat(components, Matchers.hasItem(SdkComponent.APP_ENGINE_JAVA));
MatcherAssert.assertThat(components, Matchers.hasItem(SdkComponent.APP_ENGINE_JAVA));
Assert.assertEquals(1, components.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package com.google.cloud.tools.gradle.appengine.standard;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeTrue;

import com.google.cloud.tools.gradle.appengine.BuildResultFilter;
Expand Down

0 comments on commit 33babd4

Please sign in to comment.