Skip to content

Commit

Permalink
ZOOKEEPER-2656: Fix ServerConfigTest#testValidArguments test case.
Browse files Browse the repository at this point in the history
ServerConfig.getDataDir returns type String in branch-3.4 but return type File in branch-3.5 and master. So we need to deal with this difference accordingly in our test.

This PR is intended to be merged in master, branch-3.5, and branch-3.4.

rakeshadr PTAL

Author: Michael Han <[email protected]>

Reviewers: Edward Ribeiro <[email protected]>, Rakesh Radhakrishnan <[email protected]>

Closes apache#140 from hanm/ZOOKEEPER-2565
  • Loading branch information
hanm authored and rakeshadr committed Jan 6, 2017
1 parent 0753f4c commit 1d38d30
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/java/test/org/apache/zookeeper/ServerConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;

Expand All @@ -47,7 +49,7 @@ public void testValidArguments() {
serverConfig.parse(args);

assertEquals(2181, serverConfig.getClientPortAddress().getPort());
assertEquals(new File("/data/dir"), serverConfig.getDataDir());
assertTrue(checkEquality("/data/dir", serverConfig.getDataDir()));
assertEquals(60000, serverConfig.getTickTime());
assertEquals(10000, serverConfig.getMaxClientCnxns());
}
Expand All @@ -57,4 +59,16 @@ public void testTooManyArguments() {
String[] args = {"2181", "/data/dir", "60000", "10000", "9999"};
serverConfig.parse(args);
}
}

boolean checkEquality(String a, String b) {
assertNotNull(a);
assertNotNull(b);
return a.equals(b);
}

boolean checkEquality(String a, File b) {
assertNotNull(a);
assertNotNull(b);
return new File(a).equals(b);
}
}

0 comments on commit 1d38d30

Please sign in to comment.