summaryrefslogtreecommitdiff
path: root/zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java')
-rw-r--r--zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java43
1 files changed, 21 insertions, 22 deletions
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java
index 79502cb79..c5656a0de 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/BufferSizeTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -20,10 +20,8 @@ package org.apache.zookeeper.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
-
import org.apache.jute.BinaryInputArchive;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
@@ -33,11 +31,10 @@ import org.junit.Before;
import org.junit.Test;
public class BufferSizeTest extends ClientBase {
+
public static final int TEST_MAXBUFFER = 100;
- private static final File TEST_DATA = new File(
- System.getProperty("test.data.dir", "src/test/resources/data"),
- "buffersize");
-
+ private static final File TEST_DATA = new File(System.getProperty("test.data.dir", "src/test/resources/data"), "buffersize");
+
private ZooKeeper zk;
@Before
@@ -46,7 +43,7 @@ public class BufferSizeTest extends ClientBase {
assertEquals("Can't set jute.maxbuffer!", TEST_MAXBUFFER, BinaryInputArchive.maxBuffer);
zk = createClient();
}
-
+
@Test
public void testCreatesReqs() throws Exception {
testRequests(new ClientOp() {
@@ -56,7 +53,7 @@ public class BufferSizeTest extends ClientBase {
}
});
}
-
+
@Test
public void testSetReqs() throws Exception {
final String path = "/set_test";
@@ -68,7 +65,7 @@ public class BufferSizeTest extends ClientBase {
}
});
}
-
+
/** Issues requests containing data smaller, equal, and greater than TEST_MAXBUFFER. */
private void testRequests(ClientOp clientOp) throws Exception {
clientOp.execute(new byte[TEST_MAXBUFFER - 60]);
@@ -76,15 +73,19 @@ public class BufferSizeTest extends ClientBase {
// This should fail since the buffer size > the data size due to extra fields
clientOp.execute(new byte[TEST_MAXBUFFER]);
fail("Request exceeding jute.maxbuffer succeeded!");
- } catch (KeeperException.ConnectionLossException e) {}
+ } catch (KeeperException.ConnectionLossException e) {
+ }
try {
clientOp.execute(new byte[TEST_MAXBUFFER + 10]);
fail("Request exceeding jute.maxbuffer succeeded!");
- } catch (KeeperException.ConnectionLossException e) {}
+ } catch (KeeperException.ConnectionLossException e) {
+ }
}
private interface ClientOp {
+
void execute(byte[] data) throws Exception;
+
}
@Test
@@ -96,28 +97,25 @@ public class BufferSizeTest extends ClientBase {
stopServer();
startServer();
}
-
+
@Test
public void testStartupFailureCreate() throws Exception {
// Empty snapshot and logfile containing a 5000-byte create
- testStartupFailure(new File(TEST_DATA, "create"),
- "Server started despite create exceeding jute.maxbuffer!");
+ testStartupFailure(new File(TEST_DATA, "create"), "Server started despite create exceeding jute.maxbuffer!");
}
-
+
@Test
public void testStartupFailureSet() throws Exception {
// Empty snapshot and logfile containing a 1-byte create and 5000-byte set
- testStartupFailure(new File(TEST_DATA, "set"),
- "Server started despite set exceeding jute.maxbuffer!");
+ testStartupFailure(new File(TEST_DATA, "set"), "Server started despite set exceeding jute.maxbuffer!");
}
-
+
@Test
public void testStartupFailureSnapshot() throws Exception {
// Snapshot containing 5000-byte znode and logfile containing create txn
- testStartupFailure(new File(TEST_DATA, "snapshot"),
- "Server started despite znode exceeding jute.maxbuffer!");
+ testStartupFailure(new File(TEST_DATA, "snapshot"), "Server started despite znode exceeding jute.maxbuffer!");
}
-
+
private void testStartupFailure(File testDir, String failureMsg) throws Exception {
stopServer();
// Point server at testDir
@@ -132,4 +130,5 @@ public class BufferSizeTest extends ClientBase {
tmpDir = oldTmpDir;
}
}
+
}