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 @@ -25,8 +25,8 @@
import org.apache.druid.collections.bitmap.WrappedBitSetBitmap;
import org.apache.druid.collections.bitmap.WrappedConciseBitmap;
import org.apache.druid.collections.bitmap.WrappedRoaringBitmap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Set;

Expand All @@ -48,7 +48,7 @@ public void testSimpleSet()
IntSetTestUtility.addAllToMutable(wrappedBitSetBitmapBitSet, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitSetBitmapBitSet);

Assert.assertTrue(Sets.difference(integerSet, IntSetTestUtility.getSetBits()).isEmpty());
Assertions.assertTrue(Sets.difference(integerSet, IntSetTestUtility.getSetBits()).isEmpty());
}

@Test
Expand All @@ -63,10 +63,10 @@ public void testSimpleAdd() throws IllegalAccessException, InstantiationExceptio
set.add(999);
integerSet.add(999);

Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
Assertions.assertTrue(Sets.difference(integerSet, set).isEmpty());

integerSet.add(58577);
Assert.assertFalse(Sets.difference(integerSet, set).isEmpty());
Assertions.assertFalse(Sets.difference(integerSet, set).isEmpty());
}
}

Expand All @@ -79,10 +79,10 @@ public void testContainsAll() throws IllegalAccessException, InstantiationExcept
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);

Set<Integer> set = IntSetTestUtility.getSetBits();
Assert.assertTrue(integerSet.containsAll(set));
Assertions.assertTrue(integerSet.containsAll(set));

set.add(999);
Assert.assertFalse(integerSet.containsAll(set));
Assertions.assertFalse(integerSet.containsAll(set));
}
}

Expand All @@ -98,7 +98,7 @@ public void testRemoveEverything() throws IllegalAccessException, InstantiationE

integerSet.removeAll(set);
boolean isEmpty = integerSet.isEmpty();
Assert.assertTrue(isEmpty);
Assertions.assertTrue(isEmpty);
}
}

Expand All @@ -115,7 +115,7 @@ public void testRemoveOneThing() throws IllegalAccessException, InstantiationExc
integerSet.remove(1);
set.remove(1);

Assert.assertTrue(Sets.difference(set, integerSet).isEmpty());
Assertions.assertTrue(Sets.difference(set, integerSet).isEmpty());
}
}

Expand All @@ -128,14 +128,14 @@ public void testIsEmpty() throws IllegalAccessException, InstantiationException
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);

Assert.assertFalse(integerSet.isEmpty());
Assertions.assertFalse(integerSet.isEmpty());

integerSet.clear();

Assert.assertTrue(integerSet.isEmpty());
Assertions.assertTrue(integerSet.isEmpty());

integerSet.add(1);
Assert.assertFalse(integerSet.isEmpty());
Assertions.assertFalse(integerSet.isEmpty());
}
}

Expand All @@ -149,7 +149,7 @@ public void testSize() throws IllegalAccessException, InstantiationException

Set<Integer> set = IntSetTestUtility.getSetBits();

Assert.assertEquals(set.size(), integerSet.size());
Assertions.assertEquals(set.size(), integerSet.size());
}
}

Expand All @@ -174,7 +174,7 @@ public void testRetainAll() throws IllegalAccessException, InstantiationExceptio
catch (UnsupportedOperationException ex) {
threwError = true;
}
Assert.assertTrue(threwError);
Assertions.assertTrue(threwError);
}
}

Expand All @@ -192,7 +192,7 @@ public void testIntOverflow() throws IllegalAccessException, InstantiationExcept
catch (IllegalArgumentException ex) {
e = ex;
}
Assert.assertNotNull(e);
Assertions.assertNotNull(e);
}
}

Expand All @@ -204,7 +204,7 @@ public void testToArray() throws IllegalAccessException, InstantiationException
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = Sets.newHashSet((Integer[]) integerSet.toArray());
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
Assertions.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}

Expand All @@ -217,7 +217,7 @@ public void testToSmallArray() throws IllegalAccessException, InstantiationExcep
IntSetTestUtility.addAllToMutable(wrappedBitmap, IntSetTestUtility.getSetBits());
IntegerSet integerSet = IntegerSet.wrap(wrappedBitmap);
Set<Integer> set = Sets.newHashSet((Integer[]) integerSet.toArray(new Integer[0]));
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
Assertions.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}

Expand All @@ -233,7 +233,7 @@ public void testToBigArray() throws IllegalAccessException, InstantiationExcepti
Integer[] bigArray = new Integer[1024];
integerSet.toArray(bigArray);
Set<Integer> set = Sets.newHashSet(bigArray);
Assert.assertTrue(Sets.difference(integerSet, set).isEmpty());
Assertions.assertTrue(Sets.difference(integerSet, set).isEmpty());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.apache.druid.metadata.MetadataStorageTablesConfig;
import org.apache.druid.metadata.TestMetadataStorageConnector;
import org.apache.druid.metadata.TestMetadataStorageTablesConfig;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -84,19 +84,19 @@ public void testSetNewObjectIsNull()
{
setup();
ConfigManager.SetResult setResult = configManager.set(CONFIG_KEY, configConfigSerdeFromClass, null);
Assert.assertFalse(setResult.isOk());
Assert.assertFalse(setResult.isRetryable());
Assert.assertTrue(setResult.getException() instanceof IllegalAccessException);
Assertions.assertFalse(setResult.isOk());
Assertions.assertFalse(setResult.isRetryable());
Assertions.assertInstanceOf(IllegalAccessException.class, setResult.getException());
}

@Test
public void testSetConfigManagerNotStarted()
{
setup();
ConfigManager.SetResult setResult = configManager.set(CONFIG_KEY, configConfigSerdeFromClass, NEW_CONFIG);
Assert.assertFalse(setResult.isOk());
Assert.assertFalse(setResult.isRetryable());
Assert.assertTrue(setResult.getException() instanceof IllegalStateException);
Assertions.assertFalse(setResult.isOk());
Assertions.assertFalse(setResult.isRetryable());
Assertions.assertInstanceOf(IllegalStateException.class, setResult.getException());
}

@Test
Expand All @@ -109,18 +109,18 @@ public void testSetOldObjectNullShouldInsertWithoutSwap()
@Override
public Void insertOrUpdate(String tableName, String keyColumn, String valueColumn, String key, byte[] value)
{
Assert.assertFalse(called.getAndSet(true));
Assert.assertEquals(TABLE_NAME, tableName);
Assert.assertEquals(CONFIG_KEY, key);
Assertions.assertFalse(called.getAndSet(true));
Assertions.assertEquals(TABLE_NAME, tableName);
Assertions.assertEquals(CONFIG_KEY, key);
return null;
}
});

try {
configManager.start();
ConfigManager.SetResult setResult = configManager.set(CONFIG_KEY, configConfigSerdeFromClass, null, NEW_CONFIG);
Assert.assertTrue(setResult.isOk());
Assert.assertTrue(called.get());
Assertions.assertTrue(setResult.isOk());
Assertions.assertTrue(called.get());
}
finally {
configManager.stop();
Expand All @@ -136,15 +136,15 @@ public void testSetOldObjectNotNullShouldSwap()
@Override
public boolean compareAndSwap(List<MetadataCASUpdate> updates)
{
Assert.assertFalse(called.getAndSet(true));
Assert.assertEquals(1, updates.size());
Assertions.assertFalse(called.getAndSet(true));
Assertions.assertEquals(1, updates.size());
final MetadataCASUpdate singularUpdate = updates.get(0);
Assert.assertEquals(TABLE_NAME, singularUpdate.getTableName());
Assert.assertEquals(MetadataStorageConnector.CONFIG_TABLE_KEY_COLUMN, singularUpdate.getKeyColumn());
Assert.assertEquals(MetadataStorageConnector.CONFIG_TABLE_VALUE_COLUMN, singularUpdate.getValueColumn());
Assert.assertEquals(CONFIG_KEY, singularUpdate.getKey());
Assert.assertArrayEquals(OLD_CONFIG, singularUpdate.getOldValue());
Assert.assertArrayEquals(configConfigSerdeFromClass.serialize(NEW_CONFIG), singularUpdate.getNewValue());
Assertions.assertEquals(TABLE_NAME, singularUpdate.getTableName());
Assertions.assertEquals(MetadataStorageConnector.CONFIG_TABLE_KEY_COLUMN, singularUpdate.getKeyColumn());
Assertions.assertEquals(MetadataStorageConnector.CONFIG_TABLE_VALUE_COLUMN, singularUpdate.getValueColumn());
Assertions.assertEquals(CONFIG_KEY, singularUpdate.getKey());
Assertions.assertArrayEquals(OLD_CONFIG, singularUpdate.getOldValue());
Assertions.assertArrayEquals(configConfigSerdeFromClass.serialize(NEW_CONFIG), singularUpdate.getNewValue());
return true;
}
});
Expand All @@ -156,8 +156,8 @@ public boolean compareAndSwap(List<MetadataCASUpdate> updates)
OLD_CONFIG,
NEW_CONFIG
);
Assert.assertTrue(setResult.isOk());
Assert.assertTrue(called.get());
Assertions.assertTrue(setResult.isOk());
Assertions.assertTrue(called.get());
}
finally {
configManager.stop();
Expand All @@ -174,9 +174,9 @@ public void testSetOldObjectNotNullButCompareAndSwapDisabledShouldInsertWithoutS
@Override
public Void insertOrUpdate(String tableName, String keyColumn, String valueColumn, String key, byte[] value)
{
Assert.assertFalse(called.getAndSet(true));
Assert.assertEquals(TABLE_NAME, tableName);
Assert.assertEquals(CONFIG_KEY, key);
Assertions.assertFalse(called.getAndSet(true));
Assertions.assertEquals(TABLE_NAME, tableName);
Assertions.assertEquals(CONFIG_KEY, key);
return null;
}
});
Expand All @@ -190,8 +190,8 @@ public Void insertOrUpdate(String tableName, String keyColumn, String valueColum
OLD_CONFIG,
NEW_CONFIG
);
Assert.assertTrue(setResult.isOk());
Assert.assertTrue(called.get());
Assertions.assertTrue(setResult.isOk());
Assertions.assertTrue(called.get());
}
finally {
configManager.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import org.apache.druid.data.input.MaxSizeSplitHintSpec;
import org.apache.druid.data.input.impl.systemfield.SystemFields;
import org.apache.druid.java.util.common.parsers.JSONPathSpec;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.net.URI;
Expand Down Expand Up @@ -69,9 +67,6 @@ public class CloudObjectInputSourceTest
new CloudObjectLocation(URI.create("s3://bar/foo/file2.parquet"))
);

@Rule
public ExpectedException expectedException = ExpectedException.none();

@Test
public void testGetUris()
{
Expand All @@ -80,7 +75,7 @@ public void testGetUris()
.defaultAnswer(Mockito.CALLS_REAL_METHODS)
);

Assert.assertEquals(
Assertions.assertEquals(
URIS,
inputSource.getUris()
);
Expand All @@ -94,7 +89,7 @@ public void testGetPrefixes()
.defaultAnswer(Mockito.CALLS_REAL_METHODS)
);

Assert.assertEquals(
Assertions.assertEquals(
PREFIXES,
inputSource.getPrefixes()
);
Expand All @@ -108,7 +103,7 @@ public void testGetObjectGlob()
.defaultAnswer(Mockito.CALLS_REAL_METHODS)
);

Assert.assertEquals("**.parquet", inputSource.getObjectGlob());
Assertions.assertEquals("**.parquet", inputSource.getObjectGlob());
}

@Test
Expand All @@ -124,9 +119,9 @@ public void testInequality()
.defaultAnswer(Mockito.CALLS_REAL_METHODS)
);

Assert.assertEquals("**.parquet", inputSource1.getObjectGlob());
Assert.assertEquals("**.csv", inputSource2.getObjectGlob());
Assert.assertFalse(inputSource2.equals(inputSource1));
Assertions.assertEquals("**.parquet", inputSource1.getObjectGlob());
Assertions.assertEquals("**.csv", inputSource2.getObjectGlob());
Assertions.assertFalse(inputSource2.equals(inputSource1));
}

@Test
Expand All @@ -147,12 +142,12 @@ public void testWithUrisFilter()

List<URI> returnedLocationUris = returnedLocations.stream().map(object -> object.toUri(SCHEME)).collect(Collectors.toList());

Assert.assertEquals("**.csv", inputSource.getObjectGlob());
Assert.assertEquals(URIS, returnedLocationUris);
Assertions.assertEquals("**.csv", inputSource.getObjectGlob());
Assertions.assertEquals(URIS, returnedLocationUris);

final List<InputEntity> entities =
Lists.newArrayList(inputSource.getInputEntities(new JsonInputFormat(null, null, null, null, null)));
Assert.assertEquals(URIS.size(), entities.size());
Assertions.assertEquals(URIS.size(), entities.size());
}

@Test
Expand All @@ -173,12 +168,12 @@ public void testWithUris()

List<URI> returnedLocationUris = returnedLocations.stream().map(object -> object.toUri(SCHEME)).collect(Collectors.toList());

Assert.assertEquals(null, inputSource.getObjectGlob());
Assert.assertEquals(URIS, returnedLocationUris);
Assertions.assertEquals(null, inputSource.getObjectGlob());
Assertions.assertEquals(URIS, returnedLocationUris);

final List<InputEntity> entities =
Lists.newArrayList(inputSource.getInputEntities(new JsonInputFormat(null, null, null, null, null)));
Assert.assertEquals(URIS.size(), entities.size());
Assertions.assertEquals(URIS.size(), entities.size());
}

@Test
Expand All @@ -199,12 +194,12 @@ public void testWithObjectsFilter()

List<URI> returnedLocationUris = returnedLocations.stream().map(object -> object.toUri(SCHEME)).collect(Collectors.toList());

Assert.assertEquals("**.csv", inputSource.getObjectGlob());
Assert.assertEquals(URIS, returnedLocationUris);
Assertions.assertEquals("**.csv", inputSource.getObjectGlob());
Assertions.assertEquals(URIS, returnedLocationUris);

final List<InputEntity> entities =
Lists.newArrayList(inputSource.getInputEntities(new JsonInputFormat(null, null, null, null, null)));
Assert.assertEquals(OBJECTS.size(), entities.size());
Assertions.assertEquals(OBJECTS.size(), entities.size());
}

@Test
Expand All @@ -223,24 +218,24 @@ public void testWithObjects()

List<CloudObjectLocation> returnedLocations = splits.map(InputSplit::get).collect(Collectors.toList()).get(0);

Assert.assertNull(inputSource.getObjectGlob());
Assert.assertEquals(OBJECTS, returnedLocations);
Assertions.assertNull(inputSource.getObjectGlob());
Assertions.assertEquals(OBJECTS, returnedLocations);

final List<InputEntity> entities =
Lists.newArrayList(inputSource.getInputEntities(new JsonInputFormat(null, null, null, null, null)));
Assert.assertEquals(OBJECTS.size(), entities.size());
Assertions.assertEquals(OBJECTS.size(), entities.size());
}

@Test
public void testGlobSubdirectories()
{
PathMatcher m = FileSystems.getDefault().getPathMatcher("glob:**.parquet");
Assert.assertTrue(m.matches(Paths.get("db/date=2022-08-01/001.parquet")));
Assert.assertTrue(m.matches(Paths.get("db/date=2022-08-01/002.parquet")));
Assertions.assertTrue(m.matches(Paths.get("db/date=2022-08-01/001.parquet")));
Assertions.assertTrue(m.matches(Paths.get("db/date=2022-08-01/002.parquet")));

PathMatcher m2 = FileSystems.getDefault().getPathMatcher("glob:db/date=2022-08-01/*.parquet");
Assert.assertTrue(m2.matches(Paths.get("db/date=2022-08-01/001.parquet")));
Assert.assertFalse(m2.matches(Paths.get("db/date=2022-08-01/_junk/0/001.parquet")));
Assertions.assertTrue(m2.matches(Paths.get("db/date=2022-08-01/001.parquet")));
Assertions.assertFalse(m2.matches(Paths.get("db/date=2022-08-01/_junk/0/001.parquet")));
}

private static class MockSplitWidget implements CloudObjectSplitWidget
Expand Down
Loading
Loading