You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/02/17 06:24:50 UTC
[camel] 21/31: CAMEL-15964 camel-google-storage - check style
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit be9a64b96133339a950cd1a1b389ed59e0fedd51
Author: Raffaele Marcello <ma...@gmail.com>
AuthorDate: Mon Feb 15 12:46:39 2021 +0100
CAMEL-15964 camel-google-storage - check style
---
.../GoogleCloudStorageConnectionFactory.java | 8 +++++++-
.../storage/GoogleCloudStorageConstants.java | 9 +++++++--
.../google/storage/GoogleCloudStorageEndpoint.java | 2 +-
.../integration/ComplexIntegrationTest.java | 1 -
.../storage/localstorage/FakeStorageRpc.java | 18 +++++++++++++++++-
.../storage/localstorage/LocalStorageHelper.java | 22 +++++++++++++++++++---
.../google/storage/unit/ConsumerLocalTest.java | 8 ++++----
.../google/storage/unit/ProducerLocalTest.java | 14 +++++++-------
.../src/test/resources/log4j2.properties | 19 +++++++++++++++++++
9 files changed, 81 insertions(+), 20 deletions(-)
diff --git a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConnectionFactory.java b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConnectionFactory.java
index dd301de..60f8899 100644
--- a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConnectionFactory.java
+++ b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConnectionFactory.java
@@ -23,7 +23,13 @@ import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
-public class GoogleCloudStorageConnectionFactory {
+public final class GoogleCloudStorageConnectionFactory {
+
+ /**
+ * Prevent instantiation.
+ */
+ private GoogleCloudStorageConnectionFactory() {
+ }
public static Storage create(GoogleCloudStorageComponentConfiguration configuration) throws Exception {
if (!Strings.isNullOrEmpty(configuration.getServiceAccountKey())) {
diff --git a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConstants.java b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConstants.java
index b16fc9d..1a9b316 100644
--- a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConstants.java
+++ b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConstants.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.google.storage;
-public class GoogleCloudStorageConstants {
+public final class GoogleCloudStorageConstants {
public static final String OPERATION = "CamelGoogleCloudStorageOperation";
public static final String BUCKET_NAME = "CamelGoogleCloudStorageBucketName";
@@ -34,7 +34,7 @@ public class GoogleCloudStorageConstants {
public static final String METADATA_COMPONENT_COUNT = "CamelGoogleCloudStorageComponentCount";
public static final String METADATA_CONTENT_LANGUAGE = "CamelGoogleCloudStorageContentLanguage";
public static final String METADATA_CUSTOM_TIME = "CamelGoogleCloudStorageCustomTime";
- public static final String METADATA_CRC32C_hex = "CamelGoogleCloudStorageCrc32cHex";
+ public static final String METADATA_CRC32C_HEX = "CamelGoogleCloudStorageCrc32cHex";
public static final String METADATA_ETAG = "CamelGoogleCloudStorageETag";
public static final String METADATA_GENERATION = "CamelGoogleCloudStorageGeneration";
public static final String METADATA_BLOB_ID = "CamelGoogleCloudStorageBlobId";
@@ -45,4 +45,9 @@ public class GoogleCloudStorageConstants {
public static final String METADATA_CREATE_TIME = "CamelGoogleCloudStorageCreateTime";
public static final String METADATA_LAST_UPDATE = "CamelGoogleCloudStorageLastUpdate";
+ /**
+ * Prevent instantiation.
+ */
+ private GoogleCloudStorageConstants() {
+ }
}
diff --git a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java
index e4000d6..0e8043b 100644
--- a/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java
+++ b/components/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java
@@ -168,7 +168,7 @@ public class GoogleCloudStorageEndpoint extends ScheduledPollEndpoint {
message.setHeader(GoogleCloudStorageConstants.METADATA_CONTENT_LANGUAGE, blob.getContentLanguage());
message.setHeader(GoogleCloudStorageConstants.CONTENT_TYPE, blob.getContentType());
message.setHeader(GoogleCloudStorageConstants.METADATA_CUSTOM_TIME, blob.getCustomTime());
- message.setHeader(GoogleCloudStorageConstants.METADATA_CRC32C_hex, blob.getCrc32cToHexString());
+ message.setHeader(GoogleCloudStorageConstants.METADATA_CRC32C_HEX, blob.getCrc32cToHexString());
message.setHeader(GoogleCloudStorageConstants.METADATA_ETAG, blob.getEtag());
message.setHeader(GoogleCloudStorageConstants.METADATA_GENERATION, blob.getGeneration());
message.setHeader(GoogleCloudStorageConstants.METADATA_BLOB_ID, blob.getBlobId());
diff --git a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/integration/ComplexIntegrationTest.java b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/integration/ComplexIntegrationTest.java
index c28e040..30b7aa4 100644
--- a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/integration/ComplexIntegrationTest.java
+++ b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/integration/ComplexIntegrationTest.java
@@ -90,7 +90,6 @@ public class ComplexIntegrationTest extends CamelTestSupport {
+ "&operation=createDownloadLink")
.log("URL for ${header.CamelGoogleCloudStorageBucketName}/${header.CamelGoogleCloudStorageObjectName} =${body}")
.to("mock:bucket2");
- ;
//list all buckets
from("timer:timer1?repeatCount=1&fixedRate=true&period=10000")
diff --git a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
index 70153fd..712ee51 100644
--- a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
+++ b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
@@ -1,3 +1,19 @@
+/*
+ * 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.camel.component.google.storage.localstorage;
import java.io.IOException;
@@ -491,7 +507,7 @@ class FakeStorageRpc extends StorageRpcTestBase {
}
private String fullname(StorageObject so) {
- return (so.getBucket() + "/" + so.getName());
+ return so.getBucket() + "/" + so.getName();
}
private BigInteger size(StorageObject so) {
diff --git a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/LocalStorageHelper.java b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/LocalStorageHelper.java
index fb28518..2591932 100644
--- a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/LocalStorageHelper.java
+++ b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/LocalStorageHelper.java
@@ -1,3 +1,19 @@
+/*
+ * 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.camel.component.google.storage.localstorage;
import com.google.cloud.spi.ServiceRpcFactory;
@@ -44,7 +60,7 @@ import com.google.cloud.storage.spi.v1.StorageRpc;
public final class LocalStorageHelper {
// used for testing. Will throw if you pass it an option.
- private static final FakeStorageRpc instance = new FakeStorageRpc(true);
+ private static final FakeStorageRpc INSTANCE = new FakeStorageRpc(true);
private LocalStorageHelper() {
}
@@ -54,14 +70,14 @@ public final class LocalStorageHelper {
* from a clean slate. That instance will throw if you pass it any option.
*/
public static StorageOptions getOptions() {
- instance.reset();
+ INSTANCE.reset();
return StorageOptions.newBuilder()
.setProjectId("dummy-project-for-testing")
.setServiceRpcFactory(
new ServiceRpcFactory<StorageOptions>() {
@Override
public StorageRpc create(StorageOptions options) {
- return instance;
+ return INSTANCE;
}
})
.build();
diff --git a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ConsumerLocalTest.java b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ConsumerLocalTest.java
index e728081..419bbe1 100644
--- a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ConsumerLocalTest.java
+++ b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ConsumerLocalTest.java
@@ -64,12 +64,12 @@ public class ConsumerLocalTest extends GoogleCloudStorageBaseTest {
@Test
public void sendIn() throws Exception {
- final int NUMBER_OF_FILES = 3;
+ final int numberOfFiles = 3;
- result.expectedMessageCount(NUMBER_OF_FILES);
- consumedObjects.expectedMessageCount(NUMBER_OF_FILES);
+ result.expectedMessageCount(numberOfFiles);
+ consumedObjects.expectedMessageCount(numberOfFiles);
- for (int i = 0; i < NUMBER_OF_FILES; i++) {
+ for (int i = 0; i < numberOfFiles; i++) {
final String filename = String.format("file_%s.txt", i);
final String body = String.format("body_%s", i);
//upload a file
diff --git a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ProducerLocalTest.java b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ProducerLocalTest.java
index 37aebc2..41bb2fe 100644
--- a/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ProducerLocalTest.java
+++ b/components/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/unit/ProducerLocalTest.java
@@ -69,20 +69,20 @@ public class ProducerLocalTest extends GoogleCloudStorageBaseTest {
public void sendIn() throws Exception {
result.expectedMessageCount(1);
- final String FILENAME_1 = "just_a_file.txt";
+ final String fileName = "just_a_file.txt";
//upload a file
byte[] payload = "Hi, How are you ?".getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(payload);
Exchange addObjectExchange = template.request("direct:addObject", exchange -> {
- exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, FILENAME_1);
+ exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, fileName);
exchange.getIn().setHeader(GoogleCloudStorageConstants.CONTENT_ENCODING, "text/plain");
exchange.getIn().setBody(bais);
});
Blob addObject = addObjectExchange.getMessage().getBody(Blob.class);
LOG.info("addObject {}", addObject);
assertNotNull(addObject);
- assertEquals(FILENAME_1, addObject.getName());
+ assertEquals(fileName, addObject.getName());
Exchange listBucketsExchange = template.request("direct:listBucket", exchange -> {
exchange.getIn().setHeader(GoogleCloudStorageConstants.OPERATION,
@@ -99,17 +99,17 @@ public class ProducerLocalTest extends GoogleCloudStorageBaseTest {
LOG.info("listObjectsExchange.body={}", listObjectsExchange.getMessage().getBody());
List<Blob> resp = listObjectsExchange.getMessage().getBody(List.class);
assertEquals(1, resp.size());
- assertEquals(FILENAME_1, resp.get(0).getName());
+ assertEquals(fileName, resp.get(0).getName());
Exchange getObjectExchange = template.request("direct:getObject", exchange -> {
exchange.getIn().setHeader(GoogleCloudStorageConstants.OPERATION,
GoogleCloudStorageComponentOperations.getObject);
- exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, FILENAME_1);
+ exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, fileName);
});
Blob getObject = getObjectExchange.getMessage().getBody(Blob.class);
LOG.info("getObject: {}", getObject);
assertNotNull(getObject);
- assertEquals(FILENAME_1, getObject.getName());
+ assertEquals(fileName, getObject.getName());
/*
//sign url
@@ -126,7 +126,7 @@ public class ProducerLocalTest extends GoogleCloudStorageBaseTest {
Exchange deleteObjectExchange = template.send("direct:deleteObject", exchange -> {
exchange.getIn().setHeader(GoogleCloudStorageConstants.OPERATION,
GoogleCloudStorageComponentOperations.deleteObject);
- exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, FILENAME_1);
+ exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, fileName);
});
boolean deleteObject = deleteObjectExchange.getMessage().getBody(Boolean.class).booleanValue();
diff --git a/components/camel-google-storage/src/test/resources/log4j2.properties b/components/camel-google-storage/src/test/resources/log4j2.properties
index 328db35..aa9bb86 100644
--- a/components/camel-google-storage/src/test/resources/log4j2.properties
+++ b/components/camel-google-storage/src/test/resources/log4j2.properties
@@ -1,4 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# The logging properties used during tests..
+#
appender.out.type = Console
appender.out.name = out
appender.out.layout.type = PatternLayout