This is an automated email from the ASF dual-hosted git repository.

ycai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 40c3fac  CASSANDRASC-57: Remove RESTEasy
40c3fac is described below

commit 40c3fac3891013457035fcfc4944b27535d5d701
Author: Francisco Guerrero <francisco.guerr...@apple.com>
AuthorDate: Wed Jun 21 11:08:37 2023 -0700

    CASSANDRASC-57: Remove RESTEasy
    
    This commit removes RESTEasy and associated dependencies from the project. 
Vertx's handler
    has been now preferred and there are no more endpoints on RESTEasy in this 
project.
    
    patch byFrancisco Guerrero; reviewed by Dinesh Joshi, Yifan Cai for 
CASSANDRASC-57
---
 CHANGES.txt                                        |   1 +
 build.gradle                                       |  36 +++----
 client/build.gradle                                |   9 ++
 .../org/apache/cassandra/sidecar/MainModule.java   |  27 +-----
 .../sidecar/routes/CassandraHealthService.java     | 104 ---------------------
 .../sidecar/routes/SwaggerOpenApiResource.java     |  75 ---------------
 .../{SidecarVersionProvider.java => IOUtils.java}  |  42 +++++----
 .../sidecar/utils/SidecarVersionProvider.java      |  15 +--
 .../sidecar/routes/SchemaHandlerTest.java          |  20 ++--
 .../routes/cassandra/NodeSettingsHandlerTest.java  |   8 +-
 .../cassandra/sidecar/snapshots/SnapshotUtils.java |  21 +++--
 11 files changed, 78 insertions(+), 280 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 1bf9841..86f8bf0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 1.0.0
 -----
+ * Remove RESTEasy (CASSANDRASC-57)
  * Use in-jvm dtest framework for integration tests (CASSANDRASC-51)
  * Sidecar returns own version in node settings (CASSANDRASC-52)
  * Deprecate the sidecar cassandra health endpoint containing instance segment 
(CASSANDRASC-50)
diff --git a/build.gradle b/build.gradle
index 3a3764b..055cd28 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,8 +17,6 @@ plugins {
 
     // since we're using a specific version here, we delay applying the plugin 
till the all projects
     id "com.github.spotbugs" version "3.0.0" apply false
-    id 'org.hidetake.swagger.generator' version '2.16.0'
-    id "io.swagger.core.v3.swagger-gradle-plugin" version "2.1.2"
 
     // https://github.com/nebula-plugins/gradle-ospackage-plugin/wiki
     id "nebula.ospackage" version "8.3.0"
@@ -109,9 +107,19 @@ configurations {
     jolokia
 
     integrationTestImplementation.extendsFrom testImplementation
+
+    runtime.exclude(group: "com.google.code.findbugs", module: "jsr305")
+    runtime.exclude(group: "org.codehaus.mojo", module: 
"animal-sniffer-annotations")
+    runtime.exclude(group: "com.google.guava", module: "listenablefuture")
+    runtime.exclude(group: "org.checkerframework", module: "checker-qual")
+    runtime.exclude(group: "com.google.errorprone", module: 
"error_prone_annotations")
+    runtime.exclude(group: 'com.github.jnr', module: 'jnr-ffi')
+    runtime.exclude(group: 'com.github.jnr', module: 'jnr-posix')
 }
 
 dependencies {
+    compileOnly('org.jetbrains:annotations:23.0.0')
+
     implementation("io.vertx:vertx-web:${project.vertxVersion}") {
         exclude group: 'junit', module: 'junit'
     }
@@ -120,11 +128,6 @@ dependencies {
 
     implementation('com.datastax.cassandra:cassandra-driver-core:3.11.3')
     implementation('com.google.inject:guice:4.2.2')
-    implementation('io.swagger.core.v3:swagger-jaxrs2:2.1.0')
-    implementation("org.jboss.resteasy:resteasy-vertx:4.7.4.Final")
-    implementation('org.jboss.resteasy:resteasy-jackson2-provider:4.7.4.Final')
-    implementation(group: 'org.jboss.spec.javax.servlet', name: 
'jboss-servlet-api_4.0_spec', version: '2.0.0.Final')
-    compileOnly('org.jetbrains:annotations:23.0.0')
     implementation("com.github.ben-manes.caffeine:caffeine:2.9.3")
 
     // Trying to be exactly compatible with Cassandra's deps
@@ -133,10 +136,9 @@ dependencies {
     implementation('ch.qos.logback:logback-classic:1.2.3')
 
     implementation(group: 'org.apache.commons', name: 
'commons-configuration2', version: '2.7')
-    implementation('org.webjars:swagger-ui:3.10.0')
 
-    runtime group: 'commons-beanutils', name: 'commons-beanutils', version: 
'1.9.3'
-    runtime group: 'org.yaml', name: 'snakeyaml', version: '1.26'
+    runtimeOnly group: 'commons-beanutils', name: 'commons-beanutils', 
version: '1.9.3'
+    runtimeOnly group: 'org.yaml', name: 'snakeyaml', version: '1.26'
 
     jolokia 'org.jolokia:jolokia-jvm:1.6.0:agent'
 
@@ -338,22 +340,10 @@ applicationDistribution.from("LICENSE.txt") {
     into ""
 }
 
-// This task is defined by swagger-gradle-plugin
-// Resolves project openAPI specification and saves
-// the result in JSON during the build process.
-resolve {
-    outputFileName = 'api'
-    outputFormat = 'JSON'
-    prettyPrint = 'TRUE'
-    classpath = sourceSets.main.runtimeClasspath
-    resourcePackages = ['org.apache.cassandra.sidecar']
-    outputDir = file('build/generated/swagger')
-}
-
 integrationTest.onlyIf { "true" != System.getenv("skipIntegrationTest") }
 
 // copyDist gets called on every build
 copyDist.dependsOn installDist, copyJolokia
 check.dependsOn checkstyleMain, checkstyleTest, integrationTest, 
jacocoTestReport
-build.dependsOn copyDist, generateReDoc, generateSwaggerUI, copyJolokia, 
copyDocs
+build.dependsOn copyDist, copyJolokia, copyDocs
 run.dependsOn build
diff --git a/client/build.gradle b/client/build.gradle
index edc4c16..85165a9 100644
--- a/client/build.gradle
+++ b/client/build.gradle
@@ -53,6 +53,15 @@ test {
 
 configurations {
     all*.exclude(group: 'ch.qos.logback')
+
+    runtime.exclude(group: "com.google.code.findbugs", module: "jsr305")
+    runtime.exclude(group: "org.codehaus.mojo", module: 
"animal-sniffer-annotations")
+    runtime.exclude(group: "com.google.guava", module: "listenablefuture")
+    runtime.exclude(group: "com.google.guava", module: "failureaccess")
+    runtime.exclude(group: "org.checkerframework", module: "checker-qual")
+    runtime.exclude(group: "com.google.errorprone", module: 
"error_prone_annotations")
+    runtime.exclude(group: 'com.github.jnr', module: 'jnr-ffi')
+    runtime.exclude(group: 'com.github.jnr', module: 'jnr-posix')
 }
 
 dependencies {
diff --git a/src/main/java/org/apache/cassandra/sidecar/MainModule.java 
b/src/main/java/org/apache/cassandra/sidecar/MainModule.java
index baf5837..024db71 100644
--- a/src/main/java/org/apache/cassandra/sidecar/MainModule.java
+++ b/src/main/java/org/apache/cassandra/sidecar/MainModule.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+
 import com.google.common.util.concurrent.SidecarRateLimiter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,7 +58,6 @@ import org.apache.cassandra.sidecar.routes.RingHandler;
 import org.apache.cassandra.sidecar.routes.SchemaHandler;
 import org.apache.cassandra.sidecar.routes.SnapshotsHandler;
 import org.apache.cassandra.sidecar.routes.StreamSSTableComponentHandler;
-import org.apache.cassandra.sidecar.routes.SwaggerOpenApiResource;
 import org.apache.cassandra.sidecar.routes.TimeSkewHandler;
 import org.apache.cassandra.sidecar.routes.cassandra.NodeSettingsHandler;
 import 
org.apache.cassandra.sidecar.routes.sstableuploads.SSTableCleanupHandler;
@@ -67,9 +67,6 @@ import org.apache.cassandra.sidecar.utils.ChecksumVerifier;
 import org.apache.cassandra.sidecar.utils.MD5ChecksumVerifier;
 import org.apache.cassandra.sidecar.utils.SidecarVersionProvider;
 import org.apache.cassandra.sidecar.utils.TimeProvider;
-import org.jboss.resteasy.plugins.server.vertx.VertxRegistry;
-import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler;
-import org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment;
 
 /**
  * Provides main binding for more complex Guice dependencies
@@ -93,7 +90,7 @@ public class MainModule extends AbstractModule
 
     @Provides
     @Singleton
-    public HttpServer vertxServer(Vertx vertx, Configuration conf, Router 
router, VertxRequestHandler restHandler)
+    public HttpServer vertxServer(Vertx vertx, Configuration conf, Router 
router)
     {
         HttpServerOptions options = new 
HttpServerOptions().setLogActivity(true);
         options.setIdleTimeoutUnit(TimeUnit.MILLISECONDS)
@@ -114,24 +111,10 @@ public class MainModule extends AbstractModule
             }
         }
 
-        router.route().pathRegex(".*").handler(rc -> 
restHandler.handle(rc.request()));
-
         return vertx.createHttpServer(options)
                     .requestHandler(router);
     }
 
-    @Provides
-    @Singleton
-    private VertxRequestHandler configureServices(Vertx vertx)
-    {
-        VertxResteasyDeployment deployment = new VertxResteasyDeployment();
-        deployment.start();
-        VertxRegistry registry = deployment.getRegistry();
-        registry.addPerInstanceResource(SwaggerOpenApiResource.class);
-
-        return new VertxRequestHandler(vertx, deployment);
-    }
-
     @Provides
     @Singleton
     public Router vertxRouter(Vertx vertx,
@@ -161,12 +144,6 @@ public class MainModule extends AbstractModule
               .path(ApiEndpointsV1.API + "/*")
               .failureHandler(errorHandler);
 
-        // Static web assets for Swagger
-        StaticHandler swaggerStatic = 
StaticHandler.create("META-INF/resources/webjars/swagger-ui");
-        router.route()
-              .path("/static/swagger-ui/*")
-              .handler(swaggerStatic);
-
         // Docs index.html page
         StaticHandler docs = StaticHandler.create("docs");
         router.route()
diff --git 
a/src/main/java/org/apache/cassandra/sidecar/routes/CassandraHealthService.java 
b/src/main/java/org/apache/cassandra/sidecar/routes/CassandraHealthService.java
deleted file mode 100644
index 3f51a0a..0000000
--- 
a/src/main/java/org/apache/cassandra/sidecar/routes/CassandraHealthService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cassandra.sidecar.routes;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.common.collect.ImmutableMap;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import io.netty.handler.codec.http.HttpResponseStatus;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.vertx.core.http.HttpServerRequest;
-import io.vertx.core.json.Json;
-import org.apache.cassandra.sidecar.common.CassandraAdapterDelegate;
-import org.apache.cassandra.sidecar.utils.InstanceMetadataFetcher;
-
-/**
- * Provides a simple REST endpoint to determine if a node is available
- */
-@Singleton
-@Path("/api")
-@Produces(MediaType.APPLICATION_JSON)
-public class CassandraHealthService
-{
-    private final InstanceMetadataFetcher metadataFetcher;
-
-    @Inject
-    public CassandraHealthService(InstanceMetadataFetcher metadataFetcher)
-    {
-        this.metadataFetcher = metadataFetcher;
-    }
-
-    @Operation(summary = "Health Check for Cassandra's status",
-    description = "Returns HTTP 200 if Cassandra is available, 503 otherwise",
-    responses = {
-    @ApiResponse(responseCode = "200", description = "Cassandra is available"),
-    @ApiResponse(responseCode = "503", description = "Cassandra is not 
available")
-    })
-    @GET
-    @Path("/v1/cassandra/__health")
-    public Response cassandraHealth(@Context HttpServerRequest req,
-                                    @QueryParam(AbstractHandler.INSTANCE_ID) 
Integer instanceId)
-    {
-        CassandraAdapterDelegate cassandra;
-        try
-        {
-            cassandra = instanceId == null
-                        ? metadataFetcher.delegate(req.host())
-                        : metadataFetcher.delegate(instanceId);
-        }
-        catch (IllegalArgumentException e)
-        {
-            return 
Response.status(HttpResponseStatus.BAD_REQUEST.code()).entity(e.getMessage()).build();
-        }
-        return healthResponse(cassandra);
-    }
-
-    @Operation(summary = "Health Check for a particular cassandra instance's 
status",
-    description = "Returns HTTP 200 if Cassandra instance is available, 503 
otherwise",
-    responses = {
-    @ApiResponse(responseCode = "200", description = "Cassandra is available"),
-    @ApiResponse(responseCode = "503", description = "Cassandra is not 
available")
-    })
-    @GET
-    @Path("/v1/cassandra/instance/{instanceId}/__health")
-    public Response cassandraHealthForInstance(@PathParam("instanceId") int 
instanceId)
-    {
-        final CassandraAdapterDelegate cassandra = 
metadataFetcher.delegate(instanceId);
-        return healthResponse(cassandra);
-    }
-
-    private Response healthResponse(CassandraAdapterDelegate cassandra)
-    {
-        final boolean up = cassandra.isUp();
-        int status = up ? HttpResponseStatus.OK.code() : 
HttpResponseStatus.SERVICE_UNAVAILABLE.code();
-        return 
Response.status(status).entity(Json.encode(ImmutableMap.of("status", up ?
-                                                                               
     "OK" : "NOT_OK"))).build();
-    }
-}
diff --git 
a/src/main/java/org/apache/cassandra/sidecar/routes/SwaggerOpenApiResource.java 
b/src/main/java/org/apache/cassandra/sidecar/routes/SwaggerOpenApiResource.java
deleted file mode 100644
index 71b4d13..0000000
--- 
a/src/main/java/org/apache/cassandra/sidecar/routes/SwaggerOpenApiResource.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cassandra.sidecar.routes;
-
-import java.util.Collections;
-import javax.servlet.ServletConfig;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import io.swagger.v3.core.util.Json;
-import io.swagger.v3.jaxrs2.Reader;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.integration.SwaggerConfiguration;
-import io.swagger.v3.oas.models.OpenAPI;
-
-/**
- * Exposes Swagger OpenAPI definition for all SideCar REST APIs
- */
-@Path("/api/v1/schema/openapi.{type:json}")
-public class SwaggerOpenApiResource
-{
-    static final OpenAPI OAS;
-    @Context
-    ServletConfig config;
-    @Context
-    Application app;
-
-    public SwaggerOpenApiResource()
-    {
-        super();
-    }
-
-    @GET
-    @Produces({ MediaType.APPLICATION_JSON })
-    @Operation(hidden = true)
-    public Response openApi(@Context HttpHeaders headers,
-                            @Context UriInfo uriInfo,
-                            @PathParam("type") String type)
-    {
-        return Response.status(Response.Status.OK)
-                       .entity(Json.pretty(OAS))
-                       .type(MediaType.APPLICATION_JSON_TYPE)
-                       .build();
-    }
-
-    static
-    {
-        Reader reader = new Reader(new SwaggerConfiguration());
-        OAS = reader.read(Collections.emptySet());
-    }
-}
diff --git 
a/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java 
b/src/main/java/org/apache/cassandra/sidecar/utils/IOUtils.java
similarity index 50%
copy from 
src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java
copy to src/main/java/org/apache/cassandra/sidecar/utils/IOUtils.java
index 9279895..71e246b 100644
--- 
a/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java
+++ b/src/main/java/org/apache/cassandra/sidecar/utils/IOUtils.java
@@ -19,37 +19,47 @@
 package org.apache.cassandra.sidecar.utils;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 
 /**
- * Retrieves, caches, and provides build version of this Sidecar binary
+ * Utilities for IO operations
  */
-public class SidecarVersionProvider
+public class IOUtils
 {
-    private final String sidecarVersion;
+    /**
+     * Returns the {@link StandardCharsets#UTF_8} String read from the 
provided {@code resource}.
+     *
+     * @param resource the resource to read
+     * @return the {@link StandardCharsets#UTF_8} String read from the 
provided {@code resource}
+     * @throws IOException when an error occurs during reading the resource or 
decoding the resource to {@code UTF-8}
+     */
+    public static String readFully(String resource) throws IOException
+    {
+        return readFully(IOUtils.class.getResourceAsStream(resource));
+    }
 
-    public SidecarVersionProvider(String resource)
+    /**
+     * Returns the {@link StandardCharsets#UTF_8} String read from the 
provided {@link InputStream inputStream}.
+     *
+     * @param inputStream the input stream to read from
+     * @return the {@link StandardCharsets#UTF_8} String read from the 
provided {@link InputStream inputStream}
+     * @throws IOException when an error occurs during reading the input 
stream or decoding the resource to
+     *                     {@code UTF-8}
+     */
+    public static String readFully(InputStream inputStream) throws IOException
     {
-        try (InputStream input = getClass().getResourceAsStream(resource);
+        try (InputStream input = inputStream;
              ByteArrayOutputStream output = new ByteArrayOutputStream())
         {
-            byte[] buffer = new byte[32];
             int length;
+            byte[] buffer = new byte[32];
             while ((length = input.read(buffer)) >= 0)
             {
                 output.write(buffer, 0, length);
             }
-            sidecarVersion = output.toString(StandardCharsets.UTF_8.name());
+            return output.toString(StandardCharsets.UTF_8.name());
         }
-        catch (Exception exception)
-        {
-            throw new IllegalStateException("Failed to retrieve Sidecar 
version from resource " + resource, exception);
-        }
-    }
-
-    public String sidecarVersion()
-    {
-        return sidecarVersion;
     }
 }
diff --git 
a/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java 
b/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java
index 9279895..c9c4b34 100644
--- 
a/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java
+++ 
b/src/main/java/org/apache/cassandra/sidecar/utils/SidecarVersionProvider.java
@@ -18,10 +18,6 @@
 
 package org.apache.cassandra.sidecar.utils;
 
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-
 /**
  * Retrieves, caches, and provides build version of this Sidecar binary
  */
@@ -31,16 +27,9 @@ public class SidecarVersionProvider
 
     public SidecarVersionProvider(String resource)
     {
-        try (InputStream input = getClass().getResourceAsStream(resource);
-             ByteArrayOutputStream output = new ByteArrayOutputStream())
+        try
         {
-            byte[] buffer = new byte[32];
-            int length;
-            while ((length = input.read(buffer)) >= 0)
-            {
-                output.write(buffer, 0, length);
-            }
-            sidecarVersion = output.toString(StandardCharsets.UTF_8.name());
+            sidecarVersion = IOUtils.readFully(resource);
         }
         catch (Exception exception)
         {
diff --git 
a/src/test/java/org/apache/cassandra/sidecar/routes/SchemaHandlerTest.java 
b/src/test/java/org/apache/cassandra/sidecar/routes/SchemaHandlerTest.java
index f20cdb9..3cead95 100644
--- a/src/test/java/org/apache/cassandra/sidecar/routes/SchemaHandlerTest.java
+++ b/src/test/java/org/apache/cassandra/sidecar/routes/SchemaHandlerTest.java
@@ -20,12 +20,10 @@ package org.apache.cassandra.sidecar.routes;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -55,6 +53,7 @@ import org.apache.cassandra.sidecar.TestModule;
 import org.apache.cassandra.sidecar.cluster.InstancesConfig;
 import org.apache.cassandra.sidecar.cluster.instance.InstanceMetadata;
 import org.apache.cassandra.sidecar.common.CassandraAdapterDelegate;
+import org.apache.cassandra.sidecar.utils.IOUtils;
 
 import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
 import static io.netty.handler.codec.http.HttpResponseStatus.OK;
@@ -76,13 +75,11 @@ class SchemaHandlerTest
     File dataDir0;
     String testKeyspaceSchema;
 
-    @SuppressWarnings("DataFlowIssue")
     @BeforeEach
     void before() throws InterruptedException, IOException
     {
         ClassLoader cl = getClass().getClassLoader();
-        testKeyspaceSchema = 
IOUtils.toString(cl.getResourceAsStream("schema/test_keyspace_schema.cql"),
-                                              StandardCharsets.UTF_8);
+        testKeyspaceSchema = 
IOUtils.readFully(cl.getResourceAsStream("schema/test_keyspace_schema.cql"));
 
         Injector injector;
         injector = Guice.createInjector(Modules.override(new MainModule())
@@ -115,13 +112,12 @@ class SchemaHandlerTest
         String testRoute = "/api/v1/schema/keyspaces";
         client.get(config.getPort(), config.getHost(), testRoute)
               .expect(ResponsePredicate.SC_OK)
-              .send(context.succeeding(response -> context.verify(() ->
-              {
+              .send(context.succeeding(response -> context.verify(() -> {
                   assertThat(response.statusCode()).isEqualTo(OK.code());
                   JsonObject jsonObject = response.bodyAsJsonObject();
                   assertThat(jsonObject.getString("keyspace")).isNull();
                   assertThat(jsonObject.getString("schema"))
-                      .isEqualTo("FULL SCHEMA");
+                  .isEqualTo("FULL SCHEMA");
                   context.completeNow();
               })));
     }
@@ -133,13 +129,12 @@ class SchemaHandlerTest
         String testRoute = "/api/v1/schema/keyspaces/testKeyspace";
         client.get(config.getPort(), config.getHost(), testRoute)
               .expect(ResponsePredicate.SC_OK)
-              .send(context.succeeding(response -> context.verify(() ->
-              {
+              .send(context.succeeding(response -> context.verify(() -> {
                   assertThat(response.statusCode()).isEqualTo(OK.code());
                   JsonObject jsonObject = response.bodyAsJsonObject();
                   
assertThat(jsonObject.getString("keyspace")).isEqualTo("testKeyspace");
                   assertThat(jsonObject.getString("schema"))
-                      .isEqualTo(testKeyspaceSchema);
+                  .isEqualTo(testKeyspaceSchema);
                   context.completeNow();
               })));
     }
@@ -151,8 +146,7 @@ class SchemaHandlerTest
         String testRoute = "/api/v1/schema/keyspaces/nonExistent";
         client.get(config.getPort(), config.getHost(), testRoute)
               .expect(ResponsePredicate.SC_NOT_FOUND)
-              .send(context.succeeding(response -> context.verify(() ->
-              {
+              .send(context.succeeding(response -> context.verify(() -> {
                   
assertThat(response.statusCode()).isEqualTo(NOT_FOUND.code());
                   context.completeNow();
               })));
diff --git 
a/src/test/java/org/apache/cassandra/sidecar/routes/cassandra/NodeSettingsHandlerTest.java
 
b/src/test/java/org/apache/cassandra/sidecar/routes/cassandra/NodeSettingsHandlerTest.java
index e3cdce8..4642faa 100644
--- 
a/src/test/java/org/apache/cassandra/sidecar/routes/cassandra/NodeSettingsHandlerTest.java
+++ 
b/src/test/java/org/apache/cassandra/sidecar/routes/cassandra/NodeSettingsHandlerTest.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.util.Modules;
+import io.netty.handler.codec.http.HttpResponseStatus;
 import io.vertx.core.Vertx;
 import io.vertx.core.http.HttpServer;
 import io.vertx.core.json.JsonObject;
@@ -41,7 +42,6 @@ import org.apache.cassandra.sidecar.Configuration;
 import org.apache.cassandra.sidecar.MainModule;
 import org.apache.cassandra.sidecar.TestModule;
 import org.apache.cassandra.sidecar.common.NodeSettings;
-import org.apache.http.HttpStatus;
 
 import static 
org.apache.cassandra.sidecar.common.ApiEndpointsV1.NODE_SETTINGS_ROUTE;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -89,7 +89,7 @@ class NodeSettingsHandlerTest
         client.get(config.getPort(), "localhost", NODE_SETTINGS_ROUTE)
               .as(BodyCodec.buffer())
               .send(resp -> {
-                  
assertThat(resp.result().statusCode()).isEqualTo(HttpStatus.SC_OK);
+                  
assertThat(resp.result().statusCode()).isEqualTo(HttpResponseStatus.OK.code());
                   NodeSettings status = 
resp.result().bodyAsJson(NodeSettings.class);
                   
assertThat(status.partitioner()).isEqualTo("testPartitioner");
                   assertThat(status.releaseVersion()).isEqualTo("testVersion");
@@ -105,7 +105,7 @@ class NodeSettingsHandlerTest
         client.get(config.getPort(), "localhost", 
String.format(URI_WITH_INSTANCE_ID, "1"))
               .as(BodyCodec.buffer())
               .send(resp -> {
-                  
assertThat(resp.result().statusCode()).isEqualTo(HttpStatus.SC_OK);
+                  
assertThat(resp.result().statusCode()).isEqualTo(HttpResponseStatus.OK.code());
                   NodeSettings status = 
resp.result().bodyAsJson(NodeSettings.class);
                   
assertThat(status.partitioner()).isEqualTo("testPartitioner");
                   assertThat(status.releaseVersion()).isEqualTo("testVersion");
@@ -121,7 +121,7 @@ class NodeSettingsHandlerTest
         client.get(config.getPort(), "localhost", 
String.format(URI_WITH_INSTANCE_ID, "10"))
               .as(BodyCodec.buffer())
               .send(resp -> {
-                  
assertThat(resp.result().statusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
+                  
assertThat(resp.result().statusCode()).isEqualTo(HttpResponseStatus.NOT_FOUND.code());
                   JsonObject error = resp.result().bodyAsJsonObject();
                   assertThat(error.getString("status")).isEqualTo("Not Found");
                   assertThat(error.getString("message")).isEqualTo("Instance 
id 10 not found");
diff --git 
a/src/test/java/org/apache/cassandra/sidecar/snapshots/SnapshotUtils.java 
b/src/test/java/org/apache/cassandra/sidecar/snapshots/SnapshotUtils.java
index 020b0e2..0e1d6a6 100644
--- a/src/test/java/org/apache/cassandra/sidecar/snapshots/SnapshotUtils.java
+++ b/src/test/java/org/apache/cassandra/sidecar/snapshots/SnapshotUtils.java
@@ -20,14 +20,14 @@ package org.apache.cassandra.sidecar.snapshots;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.commons.io.FileUtils;
-
 import org.apache.cassandra.sidecar.cluster.InstancesConfig;
 import org.apache.cassandra.sidecar.cluster.InstancesConfigImpl;
 import org.apache.cassandra.sidecar.cluster.instance.InstanceMetadata;
@@ -65,18 +65,25 @@ public class SnapshotUtils
         for (final String fileName : mockSnapshotFiles())
         {
             File snapshotFile = new File(temporaryFolder, fileName);
-            FileUtils.writeStringToFile(snapshotFile, "hello world", 
Charset.defaultCharset());
+            Files.write(snapshotFile.toPath(), "hello 
world".getBytes(StandardCharsets.UTF_8));
         }
         for (final String fileName : mockNonSnapshotFiles())
         {
             File nonSnapshotFile = new File(temporaryFolder, fileName);
-            FileUtils.touch(nonSnapshotFile);
+            Files.write(nonSnapshotFile.toPath(), new byte[0]);
         }
         // adding secondary index files
         assertThat(new File(temporaryFolder, 
"d1/data/keyspace1/table1-1234/snapshots/snapshot1/.index/")
                    .mkdirs()).isTrue();
-        FileUtils.touch(new File(temporaryFolder,
-                                 
"d1/data/keyspace1/table1-1234/snapshots/snapshot1/.index/secondary.db"));
+        Path path = temporaryFolder.toPath().resolve("d1")
+                                   .resolve("data")
+                                   .resolve("keyspace1")
+                                   .resolve("table1-1234")
+                                   .resolve("snapshots")
+                                   .resolve("snapshot1")
+                                   .resolve(".index")
+                                   .resolve("secondary.db");
+        Files.write(path, new byte[0]);
 
         assertThat(new File(temporaryFolder, "d1/data/keyspace1/table1-1234")
                    .setLastModified(System.currentTimeMillis() + 
2_000_000)).isTrue();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to