From 5b0b56677eb84e6f4eecc953828dc9cd20b7aaf2 Mon Sep 17 00:00:00 2001 From: Stefano Fornari Date: Thu, 9 Nov 2023 00:23:24 +0100 Subject: [PATCH] improved tests and fixed header --- .../nio/spi/s3/util/S3FileSystemInfoTest.java | 43 +++++++++++++++++++ .../spi/s3/util/S3XFileSystemInfoTest.java | 15 +------ 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 src/test/java/software/amazon/nio/spi/s3/util/S3FileSystemInfoTest.java diff --git a/src/test/java/software/amazon/nio/spi/s3/util/S3FileSystemInfoTest.java b/src/test/java/software/amazon/nio/spi/s3/util/S3FileSystemInfoTest.java new file mode 100644 index 00000000..b78cc70c --- /dev/null +++ b/src/test/java/software/amazon/nio/spi/s3/util/S3FileSystemInfoTest.java @@ -0,0 +1,43 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.nio.spi.s3.util; + +import java.net.URI; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.BDDAssertions.then; +import org.junit.jupiter.api.Test; + +/** + * + */ +public class S3FileSystemInfoTest { + @Test + public void construction() { + S3FileSystemInfo info = new S3FileSystemInfo(URI.create("s3://abucket/something")); + then(info.key()).isEqualTo("abucket"); + then(info.bucket()).isEqualTo("abucket"); + then(info.endpoint()).isNull(); + then(info.accessKey()).isNull(); + then(info.accessSecret()).isNull(); + + info = new S3FileSystemInfo(URI.create("s3://anotherbucket/something/else")); + then(info.key()).isEqualTo("anotherbucket"); + then(info.bucket()).isEqualTo("anotherbucket"); + then(info.endpoint()).isNull(); + then(info.accessKey()).isNull(); + then(info.accessSecret()).isNull(); + + assertThatCode(() -> new S3FileSystemInfo(URI.create("s2://Wrong$bucket;name"))) + .as("missing sanity check") + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Bucket name should not contain uppercase characters"); + + assertThatCode(() -> new S3FileSystemInfo(null)) + .as("missing sanity check") + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("uri can not be null"); + } +} diff --git a/src/test/java/software/amazon/nio/spi/s3/util/S3XFileSystemInfoTest.java b/src/test/java/software/amazon/nio/spi/s3/util/S3XFileSystemInfoTest.java index 4354afb0..a275ab43 100644 --- a/src/test/java/software/amazon/nio/spi/s3/util/S3XFileSystemInfoTest.java +++ b/src/test/java/software/amazon/nio/spi/s3/util/S3XFileSystemInfoTest.java @@ -1,17 +1,6 @@ /* - * Copyright 2023 ste. - * - * Licensed 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. + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 */ package software.amazon.nio.spi.s3.util;