Repository: incubator-distributedlog Updated Branches: refs/heads/master 32a52a9f7 -> 1a30b0ceb
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestCountBasedStreamChooser.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestCountBasedStreamChooser.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestCountBasedStreamChooser.java index 4036298..d9c2ad1 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestCountBasedStreamChooser.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestCountBasedStreamChooser.java @@ -17,18 +17,24 @@ */ package com.twitter.distributedlog.service.balancer; -import com.google.common.collect.Sets; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import com.google.common.collect.Sets; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.junit.Test; -import static org.junit.Assert.*; - +/** + * Test Case for {@link CountBasedStreamChooser}. + */ public class TestCountBasedStreamChooser { @Test(timeout = 60000) @@ -52,7 +58,7 @@ public class TestCountBasedStreamChooser { } CountBasedStreamChooser chooser = new CountBasedStreamChooser(streamDistribution); - for (int k = 0; k < i+1; k++) { + for (int k = 0; k < i + 1; k++) { assertNull(chooser.choose()); } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java index 59d1d10..04656bc 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java @@ -17,27 +17,29 @@ */ package com.twitter.distributedlog.service.balancer; +import static com.google.common.base.Charsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import com.google.common.base.Optional; import com.google.common.util.concurrent.RateLimiter; -import com.twitter.distributedlog.service.DistributedLogClient; import com.twitter.distributedlog.service.DistributedLogCluster.DLServer; import com.twitter.distributedlog.service.DistributedLogServerTestCase; import com.twitter.util.Await; +import java.nio.ByteBuffer; +import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.nio.ByteBuffer; -import java.util.Set; - -import static com.google.common.base.Charsets.*; -import static org.junit.Assert.*; - +/** + * Test Case for {@link SimpleBalancer}. + */ public class TestSimpleBalancer extends DistributedLogServerTestCase { - static final Logger logger = LoggerFactory.getLogger(TestSimpleBalancer.class); + private static final Logger logger = LoggerFactory.getLogger(TestSimpleBalancer.class); DLClient targetClient; DLServer targetServer; @@ -82,7 +84,7 @@ public class TestSimpleBalancer extends DistributedLogServerTestCase { // write to multiple streams for (int i = 0; i < numStreams; i++) { String name = namePrefix + i; - Await.result(((DistributedLogClient) dlClient.dlClient).write(name, ByteBuffer.wrap(("" + i).getBytes(UTF_8)))); + Await.result(dlClient.dlClient.write(name, ByteBuffer.wrap(("" + i).getBytes(UTF_8)))); } // validation @@ -139,7 +141,7 @@ public class TestSimpleBalancer extends DistributedLogServerTestCase { // write to multiple streams for (int i = 0; i < numStreams; i++) { String name = namePrefix + i; - Await.result(((DistributedLogClient) dlClient.dlClient).write(name, ByteBuffer.wrap(("" + i).getBytes(UTF_8)))); + Await.result(dlClient.dlClient.write(name, ByteBuffer.wrap(("" + i).getBytes(UTF_8)))); } // validation http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java index 3f90f35..d666cf7 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java @@ -17,20 +17,22 @@ */ package com.twitter.distributedlog.service.balancer; +import static com.google.common.base.Charsets.UTF_8; +import static org.junit.Assert.assertTrue; + import com.google.common.base.Optional; import com.twitter.distributedlog.service.DistributedLogClient; import com.twitter.distributedlog.service.DistributedLogCluster.DLServer; import com.twitter.distributedlog.service.DistributedLogServerTestCase; import com.twitter.util.Await; +import java.nio.ByteBuffer; import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.nio.ByteBuffer; - -import static com.google.common.base.Charsets.UTF_8; -import static org.junit.Assert.*; - +/** + * Test Case for {@link StreamMover}. + */ public class TestStreamMover extends DistributedLogServerTestCase { DLClient targetClient; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestServerConfiguration.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestServerConfiguration.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestServerConfiguration.java index c76dcb6..85ceb95 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestServerConfiguration.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestServerConfiguration.java @@ -17,9 +17,15 @@ */ package com.twitter.distributedlog.service.config; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import static org.junit.Assert.*; +/** + * Test Case for {@link ServerConfiguration}. + */ public class TestServerConfiguration { @Test(timeout = 60000, expected = IllegalArgumentException.class) http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestStreamConfigProvider.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestStreamConfigProvider.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestStreamConfigProvider.java index e934879..462f4f3 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestStreamConfigProvider.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/config/TestStreamConfigProvider.java @@ -17,21 +17,25 @@ */ package com.twitter.distributedlog.service.config; +import static com.twitter.distributedlog.DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import com.google.common.base.Optional; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.twitter.distributedlog.config.DynamicDistributedLogConfiguration; import com.twitter.distributedlog.config.PropertiesWriter; import com.twitter.distributedlog.service.streamset.IdentityStreamPartitionConverter; import com.twitter.distributedlog.service.streamset.StreamPartitionConverter; -import org.junit.Test; - import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.junit.Test; -import static com.twitter.distributedlog.DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS; -import static org.junit.Assert.*; - +/** + * Test Case for {@link StreamConfigProvider}. + */ public class TestStreamConfigProvider { private static final String DEFAULT_CONFIG_DIR = "conf"; private final String defaultConfigPath; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestLeastLoadPlacementPolicy.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestLeastLoadPlacementPolicy.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestLeastLoadPlacementPolicy.java index bde33c6..a12a64e 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestLeastLoadPlacementPolicy.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestLeastLoadPlacementPolicy.java @@ -6,9 +6,9 @@ * to you 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 - * + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> * 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. @@ -17,6 +17,20 @@ */ package com.twitter.distributedlog.service.placement; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.twitter.distributedlog.client.routing.RoutingService; +import com.twitter.distributedlog.namespace.DistributedLogNamespace; +import com.twitter.util.Await; +import com.twitter.util.Duration; +import com.twitter.util.Future; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -25,139 +39,138 @@ import java.util.Random; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicInteger; - -import scala.runtime.BoxedUnit; - import org.apache.bookkeeper.stats.NullStatsLogger; -import org.apache.bookkeeper.stats.StatsLogger; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import com.twitter.distributedlog.client.routing.RoutingService; -import com.twitter.distributedlog.namespace.DistributedLogNamespace; -import com.twitter.util.Await; -import com.twitter.util.Duration; -import com.twitter.util.Function0; -import com.twitter.util.Future; -import com.twitter.util.ScheduledThreadPoolTimer; -import com.twitter.util.Time; -import com.twitter.util.Timer; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - +/** + * Test Case for {@link LeastLoadPlacementPolicy}. + */ public class TestLeastLoadPlacementPolicy { - @Test(timeout = 10000) - public void testCalculateBalances() throws Exception { - int numSevers = new Random().nextInt(20) + 1; - int numStreams = new Random().nextInt(200) + 1; - RoutingService mockRoutingService = mock(RoutingService.class); - DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); - LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( - new EqualLoadAppraiser(), mockRoutingService, mockNamespace, null, Duration.fromSeconds(600), new NullStatsLogger()); - TreeSet<ServerLoad> serverLoads = Await.result(leastLoadPlacementPolicy.calculate(generateServers(numSevers), generateStreams(numStreams))); - long lowLoadPerServer = numStreams / numSevers; - long highLoadPerServer = lowLoadPerServer + 1; - for (ServerLoad serverLoad: serverLoads) { - long load = serverLoad.getLoad(); - assertEquals(load, serverLoad.getStreamLoads().size()); - assertTrue(String.format("Load %d is not between %d and %d", load, lowLoadPerServer, highLoadPerServer), load == lowLoadPerServer || load == highLoadPerServer); + @Test(timeout = 10000) + public void testCalculateBalances() throws Exception { + int numSevers = new Random().nextInt(20) + 1; + int numStreams = new Random().nextInt(200) + 1; + RoutingService mockRoutingService = mock(RoutingService.class); + DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); + LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( + new EqualLoadAppraiser(), + mockRoutingService, + mockNamespace, + null, + Duration.fromSeconds(600), + new NullStatsLogger()); + TreeSet<ServerLoad> serverLoads = + Await.result(leastLoadPlacementPolicy.calculate(generateServers(numSevers), generateStreams(numStreams))); + long lowLoadPerServer = numStreams / numSevers; + long highLoadPerServer = lowLoadPerServer + 1; + for (ServerLoad serverLoad : serverLoads) { + long load = serverLoad.getLoad(); + assertEquals(load, serverLoad.getStreamLoads().size()); + assertTrue(String.format("Load %d is not between %d and %d", + load, lowLoadPerServer, highLoadPerServer), load == lowLoadPerServer || load == highLoadPerServer); + } } - } - @Test(timeout = 10000) - public void testRefreshAndPlaceStream() throws Exception { - int numSevers = new Random().nextInt(20) + 1; - int numStreams = new Random().nextInt(200) + 1; - RoutingService mockRoutingService = mock(RoutingService.class); - when(mockRoutingService.getHosts()).thenReturn(generateSocketAddresses(numSevers)); - DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); - try { - when(mockNamespace.getLogs()).thenReturn(generateStreams(numStreams).iterator()); - } catch (IOException e) { - fail(); - } - PlacementStateManager mockPlacementStateManager = mock(PlacementStateManager.class); - LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( - new EqualLoadAppraiser(), mockRoutingService, mockNamespace, mockPlacementStateManager, Duration.fromSeconds(600), new NullStatsLogger()); - leastLoadPlacementPolicy.refresh(); + @Test(timeout = 10000) + public void testRefreshAndPlaceStream() throws Exception { + int numSevers = new Random().nextInt(20) + 1; + int numStreams = new Random().nextInt(200) + 1; + RoutingService mockRoutingService = mock(RoutingService.class); + when(mockRoutingService.getHosts()).thenReturn(generateSocketAddresses(numSevers)); + DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); + try { + when(mockNamespace.getLogs()).thenReturn(generateStreams(numStreams).iterator()); + } catch (IOException e) { + fail(); + } + PlacementStateManager mockPlacementStateManager = mock(PlacementStateManager.class); + LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( + new EqualLoadAppraiser(), + mockRoutingService, + mockNamespace, + mockPlacementStateManager, + Duration.fromSeconds(600), + new NullStatsLogger()); + leastLoadPlacementPolicy.refresh(); - final ArgumentCaptor<TreeSet> captor = ArgumentCaptor.forClass(TreeSet.class); - verify(mockPlacementStateManager).saveOwnership(captor.capture()); - TreeSet<ServerLoad> serverLoads = (TreeSet<ServerLoad>)captor.getValue(); - ServerLoad next = serverLoads.first(); - String serverPlacement = Await.result(leastLoadPlacementPolicy.placeStream("newstream1")); - assertEquals(next.getServer(), serverPlacement); - } + final ArgumentCaptor<TreeSet> captor = ArgumentCaptor.forClass(TreeSet.class); + verify(mockPlacementStateManager).saveOwnership(captor.capture()); + TreeSet<ServerLoad> serverLoads = (TreeSet<ServerLoad>) captor.getValue(); + ServerLoad next = serverLoads.first(); + String serverPlacement = Await.result(leastLoadPlacementPolicy.placeStream("newstream1")); + assertEquals(next.getServer(), serverPlacement); + } - @Test(timeout = 10000) - public void testCalculateUnequalWeight() throws Exception { - int numSevers = new Random().nextInt(20) + 1; - int numStreams = new Random().nextInt(200) + 1; + @Test(timeout = 10000) + public void testCalculateUnequalWeight() throws Exception { + int numSevers = new Random().nextInt(20) + 1; + int numStreams = new Random().nextInt(200) + 1; /* use AtomicInteger to have a final object in answer method */ - final AtomicInteger maxLoad = new AtomicInteger(Integer.MIN_VALUE); - RoutingService mockRoutingService = mock(RoutingService.class); - DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); - LoadAppraiser mockLoadAppraiser = mock(LoadAppraiser.class); - when(mockLoadAppraiser.getStreamLoad(anyString())).then(new Answer<Future<StreamLoad>>() { - @Override - public Future<StreamLoad> answer(InvocationOnMock invocationOnMock) throws Throwable { - int load = new Random().nextInt(100000); - if (load > maxLoad.get()) { - maxLoad.set(load); + final AtomicInteger maxLoad = new AtomicInteger(Integer.MIN_VALUE); + RoutingService mockRoutingService = mock(RoutingService.class); + DistributedLogNamespace mockNamespace = mock(DistributedLogNamespace.class); + LoadAppraiser mockLoadAppraiser = mock(LoadAppraiser.class); + when(mockLoadAppraiser.getStreamLoad(anyString())).then(new Answer<Future<StreamLoad>>() { + @Override + public Future<StreamLoad> answer(InvocationOnMock invocationOnMock) throws Throwable { + int load = new Random().nextInt(100000); + if (load > maxLoad.get()) { + maxLoad.set(load); + } + return Future.value(new StreamLoad(invocationOnMock.getArguments()[0].toString(), load)); + } + }); + LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( + mockLoadAppraiser, + mockRoutingService, + mockNamespace, + null, + Duration.fromSeconds(600), + new NullStatsLogger()); + TreeSet<ServerLoad> serverLoads = + Await.result(leastLoadPlacementPolicy.calculate(generateServers(numSevers), generateStreams(numStreams))); + long highestLoadSeen = Long.MIN_VALUE; + long lowestLoadSeen = Long.MAX_VALUE; + for (ServerLoad serverLoad : serverLoads) { + long load = serverLoad.getLoad(); + if (load < lowestLoadSeen) { + lowestLoadSeen = load; + } + if (load > highestLoadSeen) { + highestLoadSeen = load; + } } - return Future.value(new StreamLoad(invocationOnMock.getArguments()[0].toString(), load)); - } - }); - LeastLoadPlacementPolicy leastLoadPlacementPolicy = new LeastLoadPlacementPolicy( - mockLoadAppraiser, mockRoutingService, mockNamespace, null, Duration.fromSeconds(600), new NullStatsLogger()); - TreeSet<ServerLoad> serverLoads = Await.result(leastLoadPlacementPolicy.calculate(generateServers(numSevers), generateStreams(numStreams))); - long highestLoadSeen = Long.MIN_VALUE; - long lowestLoadSeen = Long.MAX_VALUE; - for (ServerLoad serverLoad: serverLoads) { - long load = serverLoad.getLoad(); - if (load < lowestLoadSeen) { - lowestLoadSeen = load; - } - if (load > highestLoadSeen) { - highestLoadSeen = load; - } - } - assertTrue("Unexpected placement for " + numStreams + " streams to " - + numSevers + " servers : highest load = " + highestLoadSeen - + ", lowest load = " + lowestLoadSeen + ", max stream load = " + maxLoad.get(), + assertTrue("Unexpected placement for " + numStreams + " streams to " + + numSevers + " servers : highest load = " + highestLoadSeen + + ", lowest load = " + lowestLoadSeen + ", max stream load = " + maxLoad.get(), highestLoadSeen - lowestLoadSeen < maxLoad.get()); - } + } - private Set<SocketAddress> generateSocketAddresses(int num) { - LinkedHashSet<SocketAddress> socketAddresses = new LinkedHashSet<SocketAddress>(); - for (int i = 0; i < num; i++) { - socketAddresses.add(new InetSocketAddress(i)); + private Set<SocketAddress> generateSocketAddresses(int num) { + LinkedHashSet<SocketAddress> socketAddresses = new LinkedHashSet<SocketAddress>(); + for (int i = 0; i < num; i++) { + socketAddresses.add(new InetSocketAddress(i)); + } + return socketAddresses; } - return socketAddresses; - } - private Set<String> generateStreams(int num) { - LinkedHashSet<String> streams = new LinkedHashSet<String>(); - for (int i = 0; i < num; i++) { - streams.add("stream_" + i); + private Set<String> generateStreams(int num) { + LinkedHashSet<String> streams = new LinkedHashSet<String>(); + for (int i = 0; i < num; i++) { + streams.add("stream_" + i); + } + return streams; } - return streams; - } - private Set<String> generateServers(int num) { - LinkedHashSet<String> servers = new LinkedHashSet<String>(); - for (int i = 0; i < num; i++) { - servers.add("server_" + i); + private Set<String> generateServers(int num) { + LinkedHashSet<String> servers = new LinkedHashSet<String>(); + for (int i = 0; i < num; i++) { + servers.add("server_" + i); + } + return servers; } - return servers; - } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestServerLoad.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestServerLoad.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestServerLoad.java index d844f78..42aeddd 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestServerLoad.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestServerLoad.java @@ -6,9 +6,9 @@ * to you 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 - * + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> * 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. @@ -17,32 +17,34 @@ */ package com.twitter.distributedlog.service.placement; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import java.io.IOException; import org.junit.Test; -import static org.junit.Assert.assertEquals; - +/** + * Test Case for {@link ServerLoad}. + */ public class TestServerLoad { - @Test(timeout = 60000) - public void testSerializeDeserialize() throws IOException { - final ServerLoad serverLoad = new ServerLoad("th1s1s@s3rv3rn@m3"); - for (int i = 0; i < 20; i++) { - serverLoad.addStream(new StreamLoad("stream-"+i, i)); + @Test(timeout = 60000) + public void testSerializeDeserialize() throws IOException { + final ServerLoad serverLoad = new ServerLoad("th1s1s@s3rv3rn@m3"); + for (int i = 0; i < 20; i++) { + serverLoad.addStream(new StreamLoad("stream-" + i, i)); + } + assertEquals(serverLoad, ServerLoad.deserialize(serverLoad.serialize())); } - assertEquals(serverLoad, ServerLoad.deserialize(serverLoad.serialize())); - } - @Test(timeout = 60000) - public void testGetLoad() throws IOException { - final ServerLoad serverLoad = new ServerLoad("th1s1s@s3rv3rn@m3"); - assertEquals(0, serverLoad.getLoad()); - serverLoad.addStream(new StreamLoad("stream-"+1, 3)); - assertEquals(3, serverLoad.getLoad()); - serverLoad.addStream(new StreamLoad("stream-"+2, 7)); - assertEquals(10, serverLoad.getLoad()); - serverLoad.addStream(new StreamLoad("stream-"+3, 1)); - assertEquals(11, serverLoad.getLoad()); - } + @Test(timeout = 60000) + public void testGetLoad() throws IOException { + final ServerLoad serverLoad = new ServerLoad("th1s1s@s3rv3rn@m3"); + assertEquals(0, serverLoad.getLoad()); + serverLoad.addStream(new StreamLoad("stream-" + 1, 3)); + assertEquals(3, serverLoad.getLoad()); + serverLoad.addStream(new StreamLoad("stream-" + 2, 7)); + assertEquals(10, serverLoad.getLoad()); + serverLoad.addStream(new StreamLoad("stream-" + 3, 1)); + assertEquals(11, serverLoad.getLoad()); + } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestStreamLoad.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestStreamLoad.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestStreamLoad.java index e5091f5..aac30d4 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestStreamLoad.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestStreamLoad.java @@ -6,9 +6,9 @@ * to you 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 - * + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> * 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. @@ -17,19 +17,21 @@ */ package com.twitter.distributedlog.service.placement; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import java.io.IOException; import org.junit.Test; -import static org.junit.Assert.assertEquals; - +/** + * Test Case for {@link StreamLoad}. + */ public class TestStreamLoad { - @Test(timeout = 10000) - public void testSerializeDeserialize() throws IOException { - final String streamName = "aHellaRandomStreamName"; - final int load = 1337; - final StreamLoad streamLoad = new StreamLoad(streamName, load); - assertEquals(streamLoad, StreamLoad.deserialize(streamLoad.serialize())); - } + @Test(timeout = 10000) + public void testSerializeDeserialize() throws IOException { + final String streamName = "aHellaRandomStreamName"; + final int load = 1337; + final StreamLoad streamLoad = new StreamLoad(streamName, load); + assertEquals(streamLoad, StreamLoad.deserialize(streamLoad.serialize())); + } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestZKPlacementStateManager.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestZKPlacementStateManager.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestZKPlacementStateManager.java index c02492d..1d11219 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestZKPlacementStateManager.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/placement/TestZKPlacementStateManager.java @@ -6,9 +6,9 @@ * to you 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 - * + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> * 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. @@ -17,117 +17,120 @@ */ package com.twitter.distributedlog.service.placement; +import static com.twitter.distributedlog.LocalDLMEmulator.DLOG_NAMESPACE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import com.twitter.distributedlog.DistributedLogConfiguration; import java.io.IOException; import java.net.URI; import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.LinkedBlockingQueue; - import org.apache.bookkeeper.stats.NullStatsLogger; import org.apache.curator.test.TestingServer; import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.twitter.distributedlog.DistributedLogConfiguration; - -import static com.twitter.distributedlog.LocalDLMEmulator.DLOG_NAMESPACE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +/** + * Test Case for {@link ZKPlacementStateManager}. + */ public class TestZKPlacementStateManager { - private TestingServer zkTestServer; - private String zkServers; - private URI uri; - private ZKPlacementStateManager zkPlacementStateManager; - - @Before - public void startZookeeper() throws Exception { - zkTestServer = new TestingServer(2181); - zkServers = "127.0.0.1:2181"; - uri = new URI("distributedlog-bk://" + zkServers + DLOG_NAMESPACE + "/bknamespace"); - zkPlacementStateManager = new ZKPlacementStateManager(uri, new DistributedLogConfiguration(), NullStatsLogger.INSTANCE); - } - - @Test(timeout = 60000) - public void testSaveLoad() throws Exception { - TreeSet<ServerLoad> ownerships = new TreeSet<ServerLoad>(); - zkPlacementStateManager.saveOwnership(ownerships); - SortedSet<ServerLoad> loadedOwnerships = zkPlacementStateManager.loadOwnership(); - assertEquals(ownerships, loadedOwnerships); - - ownerships.add(new ServerLoad("emptyServer")); - zkPlacementStateManager.saveOwnership(ownerships); - loadedOwnerships = zkPlacementStateManager.loadOwnership(); - assertEquals(ownerships, loadedOwnerships); - - ServerLoad sl1 = new ServerLoad("server1"); - sl1.addStream(new StreamLoad("stream1", 3)); - sl1.addStream(new StreamLoad("stream2", 4)); - ServerLoad sl2 = new ServerLoad("server2"); - sl2.addStream(new StreamLoad("stream3", 1)); - ownerships.add(sl1); - ownerships.add(sl2); - zkPlacementStateManager.saveOwnership(ownerships); - loadedOwnerships = zkPlacementStateManager.loadOwnership(); - assertEquals(ownerships, loadedOwnerships); + private TestingServer zkTestServer; + private String zkServers; + private URI uri; + private ZKPlacementStateManager zkPlacementStateManager; + + @Before + public void startZookeeper() throws Exception { + zkTestServer = new TestingServer(2181); + zkServers = "127.0.0.1:2181"; + uri = new URI("distributedlog-bk://" + zkServers + DLOG_NAMESPACE + "/bknamespace"); + zkPlacementStateManager = + new ZKPlacementStateManager(uri, new DistributedLogConfiguration(), NullStatsLogger.INSTANCE); + } - loadedOwnerships.remove(sl1); - zkPlacementStateManager.saveOwnership(ownerships); - loadedOwnerships = zkPlacementStateManager.loadOwnership(); - assertEquals(ownerships, loadedOwnerships); - } + @Test(timeout = 60000) + public void testSaveLoad() throws Exception { + TreeSet<ServerLoad> ownerships = new TreeSet<ServerLoad>(); + zkPlacementStateManager.saveOwnership(ownerships); + SortedSet<ServerLoad> loadedOwnerships = zkPlacementStateManager.loadOwnership(); + assertEquals(ownerships, loadedOwnerships); + + ownerships.add(new ServerLoad("emptyServer")); + zkPlacementStateManager.saveOwnership(ownerships); + loadedOwnerships = zkPlacementStateManager.loadOwnership(); + assertEquals(ownerships, loadedOwnerships); + + ServerLoad sl1 = new ServerLoad("server1"); + sl1.addStream(new StreamLoad("stream1", 3)); + sl1.addStream(new StreamLoad("stream2", 4)); + ServerLoad sl2 = new ServerLoad("server2"); + sl2.addStream(new StreamLoad("stream3", 1)); + ownerships.add(sl1); + ownerships.add(sl2); + zkPlacementStateManager.saveOwnership(ownerships); + loadedOwnerships = zkPlacementStateManager.loadOwnership(); + assertEquals(ownerships, loadedOwnerships); + + loadedOwnerships.remove(sl1); + zkPlacementStateManager.saveOwnership(ownerships); + loadedOwnerships = zkPlacementStateManager.loadOwnership(); + assertEquals(ownerships, loadedOwnerships); + } - private TreeSet<ServerLoad> waitForServerLoadsNotificationAsc( - LinkedBlockingQueue<TreeSet<ServerLoad>> notificationQueue, - int expectedNumServerLoads) throws InterruptedException { - TreeSet<ServerLoad> notification = notificationQueue.take(); - assertNotNull(notification); - while (notification.size() < expectedNumServerLoads) { - notification = notificationQueue.take(); + private TreeSet<ServerLoad> waitForServerLoadsNotificationAsc( + LinkedBlockingQueue<TreeSet<ServerLoad>> notificationQueue, + int expectedNumServerLoads) throws InterruptedException { + TreeSet<ServerLoad> notification = notificationQueue.take(); + assertNotNull(notification); + while (notification.size() < expectedNumServerLoads) { + notification = notificationQueue.take(); + } + assertEquals(expectedNumServerLoads, notification.size()); + return notification; } - assertEquals(expectedNumServerLoads, notification.size()); - return notification; - } - @Test(timeout = 60000) - public void testWatchIndefinitely() throws Exception { - TreeSet<ServerLoad> ownerships = new TreeSet<ServerLoad>(); - ownerships.add(new ServerLoad("server1")); - final LinkedBlockingQueue<TreeSet<ServerLoad>> serverLoadNotifications = + @Test(timeout = 60000) + public void testWatchIndefinitely() throws Exception { + TreeSet<ServerLoad> ownerships = new TreeSet<ServerLoad>(); + ownerships.add(new ServerLoad("server1")); + final LinkedBlockingQueue<TreeSet<ServerLoad>> serverLoadNotifications = new LinkedBlockingQueue<TreeSet<ServerLoad>>(); - PlacementStateManager.PlacementCallback callback = new PlacementStateManager.PlacementCallback() { - @Override - public void callback(TreeSet<ServerLoad> serverLoads) { - serverLoadNotifications.add(serverLoads); - } - }; - zkPlacementStateManager.saveOwnership(ownerships); // need to initialize the zk path before watching - zkPlacementStateManager.watch(callback); - // cannot verify the callback here as it may call before the verify is called - - zkPlacementStateManager.saveOwnership(ownerships); - assertEquals(ownerships, waitForServerLoadsNotificationAsc(serverLoadNotifications, 1)); - - ServerLoad server2 = new ServerLoad("server2"); - server2.addStream(new StreamLoad("hella-important-stream", 415)); - ownerships.add(server2); - zkPlacementStateManager.saveOwnership(ownerships); - assertEquals(ownerships, waitForServerLoadsNotificationAsc(serverLoadNotifications, 2)); - } + PlacementStateManager.PlacementCallback callback = new PlacementStateManager.PlacementCallback() { + @Override + public void callback(TreeSet<ServerLoad> serverLoads) { + serverLoadNotifications.add(serverLoads); + } + }; + zkPlacementStateManager.saveOwnership(ownerships); // need to initialize the zk path before watching + zkPlacementStateManager.watch(callback); + // cannot verify the callback here as it may call before the verify is called + + zkPlacementStateManager.saveOwnership(ownerships); + assertEquals(ownerships, waitForServerLoadsNotificationAsc(serverLoadNotifications, 1)); + + ServerLoad server2 = new ServerLoad("server2"); + server2.addStream(new StreamLoad("hella-important-stream", 415)); + ownerships.add(server2); + zkPlacementStateManager.saveOwnership(ownerships); + assertEquals(ownerships, waitForServerLoadsNotificationAsc(serverLoadNotifications, 2)); + } - @Test(timeout = 60000) - public void testZkFormatting() throws Exception { - final String server = "host/10.0.0.0:31351"; - final String zkFormattedServer = "host--10.0.0.0:31351"; - URI uri = new URI("distributedlog-bk://" + zkServers + DLOG_NAMESPACE + "/bknamespace"); - ZKPlacementStateManager zkPlacementStateManager = new ZKPlacementStateManager(uri, new DistributedLogConfiguration(), NullStatsLogger.INSTANCE); - assertEquals(zkFormattedServer, zkPlacementStateManager.serverToZkFormat(server)); - assertEquals(server, zkPlacementStateManager.zkFormatToServer(zkFormattedServer)); - } + @Test(timeout = 60000) + public void testZkFormatting() throws Exception { + final String server = "host/10.0.0.0:31351"; + final String zkFormattedServer = "host--10.0.0.0:31351"; + URI uri = new URI("distributedlog-bk://" + zkServers + DLOG_NAMESPACE + "/bknamespace"); + ZKPlacementStateManager zkPlacementStateManager = + new ZKPlacementStateManager(uri, new DistributedLogConfiguration(), NullStatsLogger.INSTANCE); + assertEquals(zkFormattedServer, zkPlacementStateManager.serverToZkFormat(server)); + assertEquals(server, zkPlacementStateManager.zkFormatToServer(zkFormattedServer)); + } - @After - public void stopZookeeper() throws IOException { - zkTestServer.stop(); - } + @After + public void stopZookeeper() throws IOException { + zkTestServer.stop(); + } } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamManager.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamManager.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamManager.java index 71e46db..283c290 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamManager.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamManager.java @@ -17,8 +17,13 @@ */ package com.twitter.distributedlog.service.stream; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import com.twitter.distributedlog.DistributedLogConfiguration; import com.twitter.distributedlog.config.DynamicDistributedLogConfiguration; @@ -27,13 +32,12 @@ import com.twitter.distributedlog.service.config.StreamConfigProvider; import com.twitter.distributedlog.service.streamset.Partition; import com.twitter.distributedlog.service.streamset.StreamPartitionConverter; import com.twitter.util.Await; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - /** * Test Case for StreamManager. */ @@ -53,9 +57,9 @@ public class TestStreamManager { StreamPartitionConverter mockPartitionConverter = mock(StreamPartitionConverter.class); StreamConfigProvider mockStreamConfigProvider = mock(StreamConfigProvider.class); when(mockStreamFactory.create( - (String)any(), + (String) any(), (DynamicDistributedLogConfiguration) any(), - (StreamManager)any())).thenReturn(mockStream); + (StreamManager) any())).thenReturn(mockStream); StreamManager streamManager = new StreamManagerImpl( "", new DistributedLogConfiguration(), @@ -108,7 +112,11 @@ public class TestStreamManager { StreamFactory mockStreamFactory = mock(StreamFactory.class); StreamPartitionConverter mockPartitionConverter = mock(StreamPartitionConverter.class); StreamConfigProvider mockStreamConfigProvider = mock(StreamConfigProvider.class); - when(mockStreamFactory.create((String)any(), (DynamicDistributedLogConfiguration)any(), (StreamManager)any())).thenReturn(mockStream); + when(mockStreamFactory.create( + (String) any(), + (DynamicDistributedLogConfiguration) any(), + (StreamManager) any()) + ).thenReturn(mockStream); DistributedLogNamespace dlNamespace = mock(DistributedLogNamespace.class); ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1); http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamOp.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamOp.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamOp.java index 41b4c69..7e52ff2 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamOp.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/TestStreamOp.java @@ -17,6 +17,11 @@ */ package com.twitter.distributedlog.service.stream; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import com.twitter.distributedlog.AsyncLogWriter; import com.twitter.distributedlog.DLSN; import com.twitter.distributedlog.LogRecord; @@ -30,37 +35,21 @@ import com.twitter.distributedlog.thrift.service.WriteResponse; import com.twitter.distributedlog.util.Sequencer; import com.twitter.util.Await; import com.twitter.util.Future; +import java.nio.ByteBuffer; import org.apache.bookkeeper.feature.SettableFeature; import org.apache.bookkeeper.stats.NullStatsLogger; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.ByteBuffer; -import java.util.zip.CRC32; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; /** * Test Case for StreamOps. */ public class TestStreamOp { - static final Logger logger = LoggerFactory.getLogger(TestStreamOp.class); - @Rule public TestName testName = new TestName(); - private final ThreadLocal<CRC32> requestCRC = new ThreadLocal<CRC32>() { - @Override - protected CRC32 initialValue() { - return new CRC32(); - } - }; - private WriteOp getWriteOp() { SettableFeature disabledFeature = new SettableFeature("", 0); return new WriteOp("test", @@ -69,7 +58,7 @@ public class TestStreamOp { new NullStatsLogger(), new IdentityStreamPartitionConverter(), new ServerConfiguration(), - (byte)0, + (byte) 0, null, false, disabledFeature, @@ -90,7 +79,7 @@ public class TestStreamOp { @Test(timeout = 60000) public void testResponseSucceededThenFailed() throws Exception { AsyncLogWriter writer = mock(AsyncLogWriter.class); - when(writer.write((LogRecord)any())).thenReturn(Future.value(new DLSN(1,2,3))); + when(writer.write((LogRecord) any())).thenReturn(Future.value(new DLSN(1, 2, 3))); when(writer.getStreamName()).thenReturn("test"); WriteOp writeOp = getWriteOp(); writeOp.execute(writer, new Sequencer() { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/limiter/TestServiceRequestLimiter.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/limiter/TestServiceRequestLimiter.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/limiter/TestServiceRequestLimiter.java index e2fa53b..a65e51a 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/limiter/TestServiceRequestLimiter.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/stream/limiter/TestServiceRequestLimiter.java @@ -17,31 +17,33 @@ */ package com.twitter.distributedlog.service.stream.limiter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import com.twitter.distributedlog.DistributedLogConfiguration; import com.twitter.distributedlog.config.ConcurrentConstConfiguration; import com.twitter.distributedlog.config.DynamicDistributedLogConfiguration; import com.twitter.distributedlog.exceptions.OverCapacityException; +import com.twitter.distributedlog.limiter.ChainedRequestLimiter; +import com.twitter.distributedlog.limiter.ComposableRequestLimiter; import com.twitter.distributedlog.limiter.ComposableRequestLimiter.CostFunction; import com.twitter.distributedlog.limiter.ComposableRequestLimiter.OverlimitFunction; -import com.twitter.distributedlog.limiter.ComposableRequestLimiter; -import com.twitter.distributedlog.limiter.ChainedRequestLimiter; import com.twitter.distributedlog.limiter.GuavaRateLimiter; import com.twitter.distributedlog.limiter.RateLimiter; import com.twitter.distributedlog.limiter.RequestLimiter; - import java.util.concurrent.atomic.AtomicInteger; - import org.apache.bookkeeper.feature.SettableFeature; import org.apache.bookkeeper.stats.NullStatsLogger; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.*; +/** + * Test Case for {@link ServiceRequestLimiter}. + */ public class TestServiceRequestLimiter { - static final Logger LOG = LoggerFactory.getLogger(TestServiceRequestLimiter.class); + /** + * Mock Request. + */ class MockRequest { int size; MockRequest() { @@ -55,11 +57,17 @@ public class TestServiceRequestLimiter { } } + /** + * Mock request limiter. + */ class MockRequestLimiter implements RequestLimiter<MockRequest> { public void apply(MockRequest request) { } } + /** + * Counter based limiter. + */ static class CounterLimiter implements RateLimiter { final int limit; int count; @@ -78,6 +86,9 @@ public class TestServiceRequestLimiter { } } + /** + * Mock hard request limiter. + */ class MockHardRequestLimiter implements RequestLimiter<MockRequest> { RequestLimiter<MockRequest> limiter; @@ -114,6 +125,9 @@ public class TestServiceRequestLimiter { } } + /** + * Mock soft request limiter. + */ class MockSoftRequestLimiter implements RequestLimiter<MockRequest> { RequestLimiter<MockRequest> limiter; http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestDelimiterStreamPartitionConverter.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestDelimiterStreamPartitionConverter.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestDelimiterStreamPartitionConverter.java index 2275bd6..af7b7e5 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestDelimiterStreamPartitionConverter.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestDelimiterStreamPartitionConverter.java @@ -17,12 +17,12 @@ */ package com.twitter.distributedlog.service.streamset; -import org.junit.Test; +import static org.junit.Assert.assertEquals; -import static org.junit.Assert.*; +import org.junit.Test; /** - * Test Cases for {@link DelimiterStreamPartitionConverter} + * Test Cases for {@link DelimiterStreamPartitionConverter}. */ public class TestDelimiterStreamPartitionConverter { http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestIdentityStreamPartitionConverter.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestIdentityStreamPartitionConverter.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestIdentityStreamPartitionConverter.java index 327faf2..d0c6660 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestIdentityStreamPartitionConverter.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestIdentityStreamPartitionConverter.java @@ -17,10 +17,14 @@ */ package com.twitter.distributedlog.service.streamset; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import static org.junit.Assert.*; +import org.junit.Test; +/** + * Test Case for {@link IdentityStreamPartitionConverter}. + */ public class TestIdentityStreamPartitionConverter { @Test(timeout = 20000) http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1a30b0ce/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestPartitionMap.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestPartitionMap.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestPartitionMap.java index e87fdc6..529397e 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestPartitionMap.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/streamset/TestPartitionMap.java @@ -17,12 +17,13 @@ */ package com.twitter.distributedlog.service.streamset; -import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import static org.junit.Assert.*; +import org.junit.Test; /** - * Test {@link PartitionMap} + * Test {@link PartitionMap}. */ public class TestPartitionMap {