Skip to content
Closed
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
47 changes: 18 additions & 29 deletions hadoop-tools/hadoop-gcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,23 +425,23 @@
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<!--
We're using a specific Protobuf version to ensure compatibility with the
Google Cloud Storage (GCS) client. The GCS client often relies on
particular Long-Term Support (LTS) versions of Protobuf. When we upgrade
the GCS client, we'll likely need to update Protobuf too. To prevent
dependency conflicts, Protobuf will be shaded within the GCS connector's
fat JAR.
-->
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.5</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<!--
We're using a specific Protobuf version to ensure compatibility with the
Google Cloud Storage (GCS) client. The GCS client often relies on
particular Long-Term Support (LTS) versions of Protobuf. When we upgrade
the GCS client, we'll likely need to update Protobuf too. To prevent
dependency conflicts, Protobuf will be shaded within the GCS connector's
fat JAR.
-->
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.5</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
Expand Down Expand Up @@ -475,26 +475,16 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
Expand All @@ -511,4 +501,3 @@
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.net.URI;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

package org.apache.hadoop.fs.gs;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

Expand All @@ -42,29 +43,39 @@ public void testValidateBucketNameEndsWithSlash() {
assertEquals("another-bucket", StringPaths.validateBucketName("another-bucket/"));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateBucketNameEmpty() {
StringPaths.validateBucketName("");
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateBucketName("");
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateBucketNameNull() {
StringPaths.validateBucketName(null);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateBucketName(null);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateBucketNameInvalidChars() {
StringPaths.validateBucketName("my bucket"); // Space
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateBucketName("my bucket"); // Space
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateBucketNameInvalidChars2() {
StringPaths.validateBucketName("my@bucket"); // @ symbol
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateBucketName("my@bucket"); // @ symbol
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateBucketNameUpperCase() {
StringPaths.validateBucketName("MyBucket"); // Uppercase
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateBucketName("MyBucket"); // Uppercase
});
}

@Test
Expand All @@ -84,14 +95,18 @@ public void testValidateObjectNameLeadingSlash() {
assertEquals("object", StringPaths.validateObjectName("/object", false));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateObjectNameEmptyNotAllowed() {
StringPaths.validateObjectName("", false);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateObjectName("", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateObjectNameNullNotAllowed() {
StringPaths.validateObjectName(null, false);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateObjectName(null, false);
});
}

@Test
Expand All @@ -101,19 +116,25 @@ public void testValidateObjectNameEmptyAllowed() {
assertEquals("", StringPaths.validateObjectName("/", true)); // Single slash becomes empty
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateObjectNameConsecutiveSlashes() {
StringPaths.validateObjectName("path//to/object", false);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateObjectName("path//to/object", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateObjectNameConsecutiveSlashesAtStart() {
StringPaths.validateObjectName("//path/to/object", false);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateObjectName("//path/to/object", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testValidateObjectNameConsecutiveSlashesAtEnd() {
StringPaths.validateObjectName("path/to/object//", false);
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.validateObjectName("path/to/object//", false);
});
}

@Test
Expand All @@ -124,9 +145,11 @@ public void testFromComponentsValid() {
assertEquals("gs://my-bucket/", StringPaths.fromComponents("my-bucket", ""));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testFromComponentsNullBucketNonNullObject() {
StringPaths.fromComponents(null, "path/to/object");
assertThrows(IllegalArgumentException.class, () -> {
StringPaths.fromComponents(null, "path/to/object");
});
}

@Test
Expand Down Expand Up @@ -163,4 +186,4 @@ public void testToDirectoryPath() {
assertEquals("", StringPaths.toDirectoryPath(""));
assertNull(StringPaths.toDirectoryPath(null));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

import java.net.URI;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class TestUriPaths {
@Test
Expand Down Expand Up @@ -130,23 +131,31 @@ public void testFromStringPathComponentsValid() throws Exception {
UriPaths.fromStringPathComponents("my-bucket", "", true));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testFromStringPathComponentsNullBucketNameNotAllowed() {
UriPaths.fromStringPathComponents(null, "object", false);
assertThrows(IllegalArgumentException.class, () -> {
UriPaths.fromStringPathComponents(null, "object", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testFromStringPathComponentsEmptyObjectNameNotAllowed() {
UriPaths.fromStringPathComponents("my-bucket", "", false);
assertThrows(IllegalArgumentException.class, () -> {
UriPaths.fromStringPathComponents("my-bucket", "", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testFromStringPathComponentsConsecutiveSlashes() {
UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false);
assertThrows(IllegalArgumentException.class, () -> {
UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testFromStringPathComponentsInvalidBucketName() {
UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase
assertThrows(IllegalArgumentException.class, () -> {
UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase
});
}
}
}