Skip to content
Merged
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 @@ -26,6 +26,7 @@
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Bytes;
import io.druid.jackson.DefaultObjectMapper;
import io.druid.java.util.common.StringUtils;
import io.druid.server.lookup.namespace.cache.CacheHandler;
Expand All @@ -47,11 +48,12 @@
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -129,18 +131,15 @@ public void testCacheKeyScramblesOnNewData()
TOPIC,
DEFAULT_PROPERTIES
);
factory.getMapRef().set(ImmutableMap.<String, String>of());
factory.getMapRef().set(ImmutableMap.of());
final AtomicLong events = factory.getDoubleEventCount();

final LookupExtractor extractor = factory.get();

final List<byte[]> byteArrays = new ArrayList<>(n);
final Set<List<Byte>> byteArrays = new HashSet<>(n);
for (int i = 0; i < n; ++i) {
final byte[] myKey = extractor.getCacheKey();
// Not terribly efficient.. but who cares
for (byte[] byteArray : byteArrays) {
Assert.assertFalse(Arrays.equals(byteArray, myKey));
}
final List<Byte> myKey = Bytes.asList(extractor.getCacheKey());
Assert.assertFalse(byteArrays.contains(myKey));
byteArrays.add(myKey);
events.incrementAndGet();
}
Expand All @@ -156,17 +155,14 @@ public void testCacheKeyScramblesDifferentStarts()
TOPIC,
DEFAULT_PROPERTIES
);
factory.getMapRef().set(ImmutableMap.<String, String>of());
factory.getMapRef().set(ImmutableMap.of());
final AtomicLong events = factory.getDoubleEventCount();

final List<byte[]> byteArrays = new ArrayList<>(n);
final Set<List<Byte>> byteArrays = new HashSet<>(n);
for (int i = 0; i < n; ++i) {
final LookupExtractor extractor = factory.get();
final byte[] myKey = extractor.getCacheKey();
// Not terribly efficient.. but who cares
for (byte[] byteArray : byteArrays) {
Assert.assertFalse(Arrays.equals(byteArray, myKey));
}
final List<Byte> myKey = Bytes.asList(extractor.getCacheKey());
Assert.assertFalse(byteArrays.contains(myKey));
byteArrays.add(myKey);
events.incrementAndGet();
}
Expand Down