Skip to content
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 @@ -134,15 +134,17 @@ public void getColumnMetadata()
// directly.
}

@Test(expectedExceptions = TrinoException.class)
@Test
public void testCreateTable()
{
metadata.createTable(
assertThatThrownBy(() -> metadata.createTable(
SESSION,
new ConnectorTableMetadata(
new SchemaTableName("example", "foo"),
ImmutableList.of(new ColumnMetadata("text", createUnboundedVarcharType()))),
false);
false))
.isInstanceOf(TrinoException.class)
.hasMessage("This connector does not support creating tables");
}

@Test(expectedExceptions = TrinoException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import static java.nio.file.Files.createTempDirectory;
import static java.nio.file.Files.createTempFile;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
Expand Down Expand Up @@ -327,7 +328,7 @@ public void testGetMetadataRetryCounter()
}

@SuppressWarnings("ResultOfMethodCallIgnored")
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = ".*Failing getObject call with " + HTTP_NOT_FOUND + ".*")
@Test
public void testReadNotFound()
throws Exception
{
Expand All @@ -337,13 +338,15 @@ public void testReadNotFound()
fs.initialize(new URI("s3n://test-bucket/"), new Configuration(false));
fs.setS3Client(s3);
try (FSDataInputStream inputStream = fs.open(new Path("s3n://test-bucket/test"))) {
inputStream.read();
assertThatThrownBy(() -> inputStream.read())
.isInstanceOf(IOException.class)
.hasMessageContaining("Failing getObject call with " + HTTP_NOT_FOUND);
}
}
}

@SuppressWarnings("ResultOfMethodCallIgnored")
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = ".*Failing getObject call with " + HTTP_FORBIDDEN + ".*")
@Test
public void testReadForbidden()
throws Exception
{
Expand All @@ -353,7 +356,9 @@ public void testReadForbidden()
fs.initialize(new URI("s3n://test-bucket/"), new Configuration(false));
fs.setS3Client(s3);
try (FSDataInputStream inputStream = fs.open(new Path("s3n://test-bucket/test"))) {
inputStream.read();
assertThatThrownBy(inputStream::read)
.isInstanceOf(IOException.class)
.hasMessageContaining("Failing getObject call with " + HTTP_FORBIDDEN);
}
}
}
Expand Down Expand Up @@ -382,7 +387,7 @@ public void testCreateWithNonexistentStagingDirectory()
}
}

@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = "Configured staging path is not a directory: .*")
@Test
public void testCreateWithStagingDirectoryFile()
throws Exception
{
Expand All @@ -395,7 +400,9 @@ public void testCreateWithStagingDirectoryFile()
conf.set(S3_STAGING_DIRECTORY, staging.toString());
fs.initialize(new URI("s3n://test-bucket/"), conf);
fs.setS3Client(s3);
fs.create(new Path("s3n://test-bucket/test"));
assertThatThrownBy(() -> fs.create(new Path("s3n://test-bucket/test")))
.isInstanceOf(IOException.class)
.hasMessageStartingWith("Configured staging path is not a directory:");
}
finally {
Files.deleteIfExists(staging);
Expand Down Expand Up @@ -451,7 +458,7 @@ public void testReadRequestRangeNotSatisfiable()
}
}

@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = ".*Failing getObjectMetadata call with " + HTTP_FORBIDDEN + ".*")
@Test
public void testGetMetadataForbidden()
throws Exception
{
Expand All @@ -460,7 +467,9 @@ public void testGetMetadataForbidden()
s3.setGetObjectMetadataHttpCode(HTTP_FORBIDDEN);
fs.initialize(new URI("s3n://test-bucket/"), new Configuration(false));
fs.setS3Client(s3);
fs.getS3ObjectMetadata(new Path("s3n://test-bucket/test"));
assertThatThrownBy(() -> fs.getS3ObjectMetadata(new Path("s3n://test-bucket/test")))
.isInstanceOf(IOException.class)
.hasMessageContaining("Failing getObjectMetadata call with " + HTTP_FORBIDDEN);
}
}

Expand Down