Simplify, testing server is not used
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.curator;
import com.yahoo.cloud.config.CuratorConfig;
import com.yahoo.net.HostName;
-import org.apache.curator.test.TestingServer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import java.io.IOException;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
/**
- * Sets up actual ZooKeeper servers and verifies we can talk to them.
+ * Very simple testing of setting up curator
*
* @author Ulf Lilleengen
*/
public class CuratorTest {
- private static String localhost = HostName.getLocalhost();
+ private static final String localhost = HostName.getLocalhost();
- private String spec1;
- private String spec2;
- private TestingServer test1;
- private TestingServer test2;
- private int port1;
- private int port2;
-
- @Before
- public void setupServers() throws Exception {
- port1 = allocatePort();
- port2 = allocatePort();
- test1 = new TestingServer(port1);
- test2 = new TestingServer(port2);
- spec1 = localhost + ":" + port1;
- spec2 = localhost + ":" + port2;
- }
-
- private int allocatePort() {
- return PortAllocator.findAvailablePort();
- }
-
- @After
- public void teardownServers() throws IOException {
- test1.stop();
- test1.close();
- test2.close();
- test2.stop();
- }
+ private static final int port1 = 1;
+ private static final int port2 = 2;
+ private static final String spec1 = localhost + ":" + port1;
+ private static final String spec2 = localhost + ":" + port2;
@Test
public void require_curator_is_created_from_config() {
@@ -90,28 +62,4 @@ public class CuratorTest {
Optional.empty());
}
- private static class PortAllocator {
-
- private static class PortRange {
- private int first = 18621;
- private int last = 18630; // see: factory/doc/port-ranges
- private int value = first;
-
- synchronized int next() {
- if (value > last) {
- throw new RuntimeException("no port ports in range");
- }
- return value++;
- }
- }
-
- private final static PortRange portRange = new PortRange();
-
- // Get the next port from a pre-allocated range
- static int findAvailablePort() {
- return portRange.next();
- }
-
- }
-
}
