Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less use of deprecated APIs in Java code #2413

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
package akka.stream.alpakka.amqp.javadsl;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Why hamcrest's assertThat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JUnit variant is deprecated nowadays.

import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import akka.stream.alpakka.amqp.*;
import akka.stream.alpakka.testkit.javadsl.LogCapturingJunit4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry;
import software.amazon.awssdk.services.eventbridge.model.PutEventsResponse;

import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.*;

import java.util.Collections;
Expand Down
63 changes: 18 additions & 45 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ lazy val csvBench = internalProject("csv-bench")

lazy val dynamodb = alpakkaProject("dynamodb", "aws.dynamodb", Dependencies.DynamoDB)

lazy val elasticsearch = alpakkaProject(
"elasticsearch",
"elasticsearch",
Dependencies.Elasticsearch
)
lazy val elasticsearch = alpakkaProject("elasticsearch", "elasticsearch", Dependencies.Elasticsearch)

// The name 'file' is taken by `sbt.file`, hence 'files'
lazy val files = alpakkaProject("file", "file", Dependencies.File)
Expand Down Expand Up @@ -194,7 +190,8 @@ lazy val googleCloudPubSubGrpc = alpakkaProject(
"-P:silencer:pathFilters=akka-grpc/main",
"-P:silencer:pathFilters=akka-grpc/test"
),
crossScalaVersions --= Seq(Dependencies.Scala211) // 2.11 is not supported since Akka gRPC 0.6
compile / javacOptions := (compile / javacOptions).value.filterNot(_ == "-Xlint:deprecation"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] This effectively just sets -Xlint:unchecked. We could set this setting to that instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we might want to add more linting in Common.

crossScalaVersions --= Seq(Dependencies.Scala211)
).enablePlugins(AkkaGrpcPlugin)

lazy val googleCloudStorage =
Expand All @@ -203,12 +200,7 @@ lazy val googleCloudStorage =
Dependencies.GoogleStorage,
crossScalaVersions -= Dependencies.Scala211)

lazy val googleFcm = alpakkaProject(
"google-fcm",
"google.firebase.fcm",
Dependencies.GoogleFcm,
Test / fork := true
)
lazy val googleFcm = alpakkaProject("google-fcm", "google.firebase.fcm", Dependencies.GoogleFcm, Test / fork := true)

lazy val hbase = alpakkaProject("hbase", "hbase", Dependencies.HBase, Test / fork := true)

Expand All @@ -228,21 +220,15 @@ lazy val ironmq = alpakkaProject(
crossScalaVersions -= Dependencies.Scala211 // hseeberger/akka-http-json does not support Scala 2.11 anymore
)

lazy val jms =
alpakkaProject("jms", "jms", Dependencies.Jms, fatalWarnings := false)
lazy val jms = alpakkaProject("jms", "jms", Dependencies.Jms)

lazy val jsonStreaming = alpakkaProject("json-streaming", "json.streaming", Dependencies.JsonStreaming)

lazy val kinesis = alpakkaProject(
"kinesis",
"aws.kinesis",
Dependencies.Kinesis
)
lazy val kinesis = alpakkaProject("kinesis", "aws.kinesis", Dependencies.Kinesis)

lazy val kudu = alpakkaProject("kudu", "kudu", Dependencies.Kudu, fork in Test := false)

lazy val mongodb =
alpakkaProject("mongodb", "mongodb", Dependencies.MongoDb)
lazy val mongodb = alpakkaProject("mongodb", "mongodb", Dependencies.MongoDb)

lazy val mqtt = alpakkaProject("mqtt", "mqtt", Dependencies.Mqtt)

Expand All @@ -262,48 +248,35 @@ lazy val reference = internalProject("reference", Dependencies.Reference)

lazy val s3 = alpakkaProject("s3", "aws.s3", Dependencies.S3)

lazy val pravega =
alpakkaProject("pravega",
"pravega",
Dependencies.Pravega,
Test / fork := true,
crossScalaVersions -= Dependencies.Scala211 // 2.11 SAM issue for java API.
)
lazy val pravega = alpakkaProject(
"pravega",
"pravega",
Dependencies.Pravega,
Test / fork := true,
crossScalaVersions -= Dependencies.Scala211 // 2.11 SAM issue for java API.
)

lazy val springWeb = alpakkaProject("spring-web", "spring.web", Dependencies.SpringWeb)

lazy val simpleCodecs = alpakkaProject("simple-codecs", "simplecodecs")

lazy val slick = alpakkaProject("slick", "slick", Dependencies.Slick)

lazy val eventbridge =
alpakkaProject("aws-event-bridge", "aws.eventbridge", Dependencies.Eventbridge)
lazy val eventbridge = alpakkaProject("aws-event-bridge", "aws.eventbridge", Dependencies.Eventbridge)

lazy val sns = alpakkaProject(
"sns",
"aws.sns",
Dependencies.Sns
)
lazy val sns = alpakkaProject("sns", "aws.sns", Dependencies.Sns)

lazy val solr = alpakkaProject("solr", "solr", Dependencies.Solr)

lazy val sqs = alpakkaProject(
"sqs",
"aws.sqs",
Dependencies.Sqs
)
lazy val sqs = alpakkaProject("sqs", "aws.sqs", Dependencies.Sqs)

lazy val sse = alpakkaProject("sse", "sse", Dependencies.Sse)

lazy val text = alpakkaProject("text", "text")

lazy val udp = alpakkaProject("udp", "udp")

lazy val unixdomainsocket = alpakkaProject(
"unix-domain-socket",
"unixdomainsocket",
Dependencies.UnixDomainSocket
)
lazy val unixdomainsocket = alpakkaProject("unix-domain-socket", "unixdomainsocket", Dependencies.UnixDomainSocket)

lazy val xml = alpakkaProject("xml", "xml", Dependencies.Xml)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package docs.javadsl;

import akka.Done;
import akka.actor.ActorSystem;
import akka.stream.Materializer;
// #deleteWithResult
Expand Down Expand Up @@ -69,7 +68,11 @@
import scala.concurrent.duration.FiniteDuration;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

public class CouchbaseExamplesTest {

Expand Down
4 changes: 1 addition & 3 deletions couchbase/src/test/java/docs/javadsl/DiscoveryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class DiscoveryTest {

@Rule public final LogCapturingJunit4 logCapturing = new LogCapturingJunit4();

private static ActorSystem actorSystem;
private static Materializer materializer;
private static final String bucketName = "akka";

@BeforeClass
public static void beforeAll() {
Config config = ConfigFactory.parseResources("discovery.conf");
actorSystem = ActorSystem.create("DiscoveryTest", config);
materializer = ActorMaterializer.create(actorSystem);
}

@AfterClass
Expand Down
2 changes: 1 addition & 1 deletion csv/src/test/java/docs/javadsl/CsvFormattingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.concurrent.TimeoutException;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class CsvFormattingTest {
@Rule public final LogCapturingJunit4 logCapturing = new LogCapturingJunit4();
Expand Down
2 changes: 1 addition & 1 deletion csv/src/test/java/docs/javadsl/CsvParsingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;

public class CsvParsingTest {
Expand Down
2 changes: 1 addition & 1 deletion csv/src/test/java/docs/javadsl/CsvToMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class CsvToMapTest {
@Rule public final LogCapturingJunit4 logCapturing = new LogCapturingJunit4();
Expand Down
7 changes: 5 additions & 2 deletions file/src/test/scala/docs/scaladsl/TarArchiveSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import akka.stream.{ActorMaterializer, IOResult, Materializer}
import akka.testkit.TestKit
import akka.util.ByteString
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.concurrent.{Eventually, IntegrationPatience, ScalaFutures}
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

Expand All @@ -35,6 +35,7 @@ class TarArchiveSpec
with ScalaFutures
with BeforeAndAfterAll
with LogCapturing
with Eventually
with IntegrationPatience {

implicit val mat: Materializer = ActorMaterializer()
Expand Down Expand Up @@ -204,7 +205,9 @@ class TarArchiveSpec
// #tar-reader
tar.futureValue shouldBe Done
val file: File = target.resolve("dir/file1.txt").toFile
file.exists() shouldBe true
eventually {
file.exists() shouldBe true
}
}

"emit empty file" in {
Expand Down
3 changes: 2 additions & 1 deletion ftp/src/test/java/docs/javadsl/FtpWritingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import akka.testkit.javadsl.TestKit;
import org.junit.*;

import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;

import java.util.concurrent.TimeUnit;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class FtpWritingTest extends BaseFtpSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class GCStorageTest extends GCStorageWiremockBase {
@Rule public final LogCapturingJunit4 logCapturing = new LogCapturingJunit4();
Expand Down
2 changes: 1 addition & 1 deletion jms/src/test/java/docs/javadsl/JmsSettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import java.time.Duration;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

// #retry-settings #send-retry-settings
import com.typesafe.config.Config;
Expand Down
6 changes: 3 additions & 3 deletions jms/src/test/scala/docs/scaladsl/JmsConnectorsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class JmsConnectorsSpec extends JmsSpec {
val completionFuture: Future[Done] = Source(msgsIn).runWith(jmsSink)
completionFuture.futureValue shouldBe Done
// make sure connection was closed
connectionFactory.cachedConnection shouldBe 'closed
eventually { connectionFactory.cachedConnection shouldBe Symbol("closed") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Don't like the symbol shorthand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's deprecated in Scala 2.13.

}

"sink exceptional completion" in withConnectionFactory() { connFactory =>
Expand All @@ -557,7 +557,7 @@ class JmsConnectorsSpec extends JmsSpec {

completionFuture.failed.futureValue shouldBe a[RuntimeException]
// make sure connection was closed
eventually { connectionFactory.cachedConnection shouldBe 'closed }
eventually { connectionFactory.cachedConnection shouldBe Symbol("closed") }
}

"producer disconnect exceptional completion" in withServer() { server =>
Expand Down Expand Up @@ -591,7 +591,7 @@ class JmsConnectorsSpec extends JmsSpec {
// - not yet initialized before broker stop, or
// - closed on broker stop (if preStart came first).
if (connectionFactory.cachedConnection != null) {
connectionFactory.cachedConnection shouldBe 'closed
connectionFactory.cachedConnection shouldBe Symbol("closed")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.concurrent.TimeoutException;

import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class JsonReaderUsageTest {
@Rule public final LogCapturingJunit4 logCapturing = new LogCapturingJunit4();
Expand Down
2 changes: 1 addition & 1 deletion kudu/src/test/java/docs/javadsl/KuduTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Loading