You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2014/09/05 12:33:02 UTC
[1/4] git commit: Formated the code
Repository: mina
Updated Branches:
refs/heads/trunk 147f1251e -> d38458d35
Formated the code
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/760a0f8a
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/760a0f8a
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/760a0f8a
Branch: refs/heads/trunk
Commit: 760a0f8a1f8bfb74622b3430b9e5f4270bb142ba
Parents: 1e55194
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Fri Sep 5 12:24:39 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Fri Sep 5 12:24:39 2014 +0200
----------------------------------------------------------------------
.../java/org/apache/mina/codec/IoBuffer.java | 64 ++++++++++++--------
1 file changed, 38 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/760a0f8a/codec/src/main/java/org/apache/mina/codec/IoBuffer.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/IoBuffer.java b/codec/src/main/java/org/apache/mina/codec/IoBuffer.java
index 6209184..64173ff 100644
--- a/codec/src/main/java/org/apache/mina/codec/IoBuffer.java
+++ b/codec/src/main/java/org/apache/mina/codec/IoBuffer.java
@@ -28,14 +28,18 @@ import java.nio.InvalidMarkException;
import java.nio.ReadOnlyBufferException;
/**
- * A proxy class used to manage ByteBuffers as if they were just a big ByteBuffer. We can add as many buffers as needed
- * when accumulating data. From the user point of view, the methods are the very same as ByteBuffer provides.
- *
- * <p>IoBuffer instances are *not* thread safe.
- *
- * <p>The IoBuffer uses a singly linked list to handle the multiple Buffers. Thus sequential access is
- * very efficient and random access is not. It fits well with the common usage patterns of IoBuffer.
- *
+ * A proxy class used to manage ByteBuffers as if they were just a big
+ * ByteBuffer. We can add as many buffers as needed when accumulating data. From
+ * the user point of view, the methods are the very same as ByteBuffer provides.
+ *
+ * <p>
+ * IoBuffer instances are *not* thread safe.
+ *
+ * <p>
+ * The IoBuffer uses a singly linked list to handle the multiple Buffers. Thus
+ * sequential access is very efficient and random access is not. It fits well
+ * with the common usage patterns of IoBuffer.
+ *
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public final class IoBuffer {
@@ -87,7 +91,8 @@ public final class IoBuffer {
/**
* Wraps ByteBuffers into a new IoBuffer
*
- * @param buffers the ByteBuffers to wrap
+ * @param buffers
+ * the ByteBuffers to wrap
* @return the new {@link IoBuffer}
*/
public static IoBuffer wrap(ByteBuffer... buffers) {
@@ -127,7 +132,8 @@ public final class IoBuffer {
/**
* Add one or more ByteBuffer to the current IoBuffer
*
- * @param buffers the ByteBuffers to add
+ * @param buffers
+ * the ByteBuffers to add
* @return the current {@link IoBuffer}
*/
public IoBuffer add(ByteBuffer... buffers) {
@@ -167,9 +173,9 @@ public final class IoBuffer {
* Provides an input stream which is actually reading the {@link IoBuffer}
* instance.
* <p>
- * Further reads on the returned InputStream move the reading head of the {@link IoBuffer}
- * instance used for it's creation
- *
+ * Further reads on the returned InputStream move the reading head of the
+ * {@link IoBuffer} instance used for it's creation
+ *
* @return an input stream
*/
public InputStream asInputStream() {
@@ -233,7 +239,8 @@ public final class IoBuffer {
}
/**
- * Returns a copy of the current {@link IoBuffer}, with an independent copy of the position, limit and mark.
+ * Returns a copy of the current {@link IoBuffer}, with an independent copy
+ * of the position, limit and mark.
*
* @return the copied {@link IoBuffer}
*/
@@ -311,7 +318,8 @@ public final class IoBuffer {
/**
* Extends the current IoBuffer capacity.
*
- * @param size the number of bytes to extend the current IoBuffer
+ * @param size
+ * the number of bytes to extend the current IoBuffer
* @return the current {@link IoBuffer}
*/
public IoBuffer extend(int size) {
@@ -411,8 +419,8 @@ public final class IoBuffer {
}
/**
- * @see ByteBuffer#getDouble()
- */
+ * @see ByteBuffer#getDouble()
+ */
public double getDouble() {
return Double.longBitsToDouble(getLong());
}
@@ -585,12 +593,14 @@ public final class IoBuffer {
}
/**
- * Returns the byte order used by this IoBuffer when converting bytes from/to other primitive
- * types.
+ * Returns the byte order used by this IoBuffer when converting bytes
+ * from/to other primitive types.
* <p>
- * The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
+ * The default byte order of byte buffer is always
+ * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
*
- * @return the byte order used by this IoBuffer when converting bytes from/to other primitive types.
+ * @return the byte order used by this IoBuffer when converting bytes
+ * from/to other primitive types.
*
* @see ByteBuffer#order()
*/
@@ -601,8 +611,9 @@ public final class IoBuffer {
/**
* Sets the byte order of this IoBuffer.
*
- * @param bo the byte order to set. If {@code null} then the order will be {@link ByteOrder#LITTLE_ENDIAN
- * LITTLE_ENDIAN}.
+ * @param bo
+ * the byte order to set. If {@code null} then the order will be
+ * {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}.
* @return this IoBuffer.
* @see ByteBuffer#order(ByteOrder)
*/
@@ -916,12 +927,12 @@ public final class IoBuffer {
if (hasRemaining()) {
tail.getBuffer().limit(limit.getPositionInNode());
for (BufferNode node = position.getNode(); node != limit.getNode(); node = node.getNext()) {
- if (node != head) { //NOSONAR, check if instances are the same.
+ if (node != head) { // NOSONAR, check if instances are the same.
node.getBuffer().position(0);
}
out.add(node.getBuffer());
}
- if (tail != head) { //NOSONAR, check if instances are the same.
+ if (tail != head) { // NOSONAR, check if instances are the same.
tail.getBuffer().position(0);
}
out.add(tail.getBuffer().slice());
@@ -1017,9 +1028,10 @@ public final class IoBuffer {
}
public void setPosition(int newPosition) {
- if (node == null || newPosition < node.offset) {
+ if ((node == null) || (newPosition < node.offset)) {
node = head;
}
+
positionInBuffer = node == null ? 0 : newPosition - node.offset;
}
[4/4] git commit: Applied many patches
Posted by el...@apache.org.
Applied many patches
Merge branch 'trunk' of https://git-wip-us.apache.org/repos/asf/mina into trunk
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/d38458d3
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/d38458d3
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/d38458d3
Branch: refs/heads/trunk
Commit: d38458d353ee5dace8c6daed967eccde2e867fe9
Parents: f80e27d 147f125
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Fri Sep 5 12:32:20 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Fri Sep 5 12:32:20 2014 +0200
----------------------------------------------------------------------
benchmarks/common/pom.xml | 47 +++++
.../apache/mina/core/BenchmarkBinaryTest.java | 154 +++++++++++++++
.../org/apache/mina/core/BenchmarkClient.java | 36 ++++
.../org/apache/mina/core/BenchmarkServer.java | 35 ++++
...ClientVsBioServerUdpBenchmarkBinaryTest.java | 69 +++++++
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 69 +++++++
.../org/apache/mina/core/CounterFilter.java | 31 +++
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 74 +++++++
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 69 +++++++
.../core/bio/udp/BioUdpBenchmarkClient.java | 80 ++++++++
.../core/bio/udp/BioUdpBenchmarkServer.java | 167 ++++++++++++++++
.../core/nio/tcp/Mina3TcpBenchmarkClient.java | 107 ++++++++++
.../core/nio/tcp/Mina3TcpBenchmarkServer.java | 159 +++++++++++++++
.../core/nio/udp/Mina3UdpBenchmarkClient.java | 116 +++++++++++
.../core/nio/udp/Mina3UdpBenchmarkServer.java | 167 ++++++++++++++++
.../common/src/test/resources/log4j.properties | 23 +++
benchmarks/netty3/pom.xml | 49 +++++
...entVsNetty3ServerTcpBenchmarkBinaryTest.java | 66 +++++++
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 65 ++++++
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 67 +++++++
...entVsNetty3ServerTcpBenchmarkBinaryTest.java | 65 ++++++
...entVsNetty3ServerUdpBenchmarkBinaryTest.java | 67 +++++++
.../core/nio/tcp/Netty3TcpBenchmarkClient.java | 104 ++++++++++
.../core/nio/tcp/Netty3TcpBenchmarkServer.java | 194 ++++++++++++++++++
.../core/nio/udp/Netty3UdpBenchmarkClient.java | 106 ++++++++++
.../core/nio/udp/Netty3UdpBenchmarkServer.java | 197 +++++++++++++++++++
benchmarks/netty4/pom.xml | 49 +++++
.../apache/mina/core/Netty4BenchmarkServer.java | 46 +++++
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 75 +++++++
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 69 +++++++
...entVsNetty4ServerTcpBenchmarkBinaryTest.java | 75 +++++++
...entVsNetty4ServerUdpBenchmarkBinaryTest.java | 69 +++++++
.../core/nio/tcp/Netty4TcpBenchmarkClient.java | 109 ++++++++++
.../core/nio/tcp/Netty4TcpBenchmarkServer.java | 155 +++++++++++++++
.../core/nio/udp/Netty4UdpBenchmarkClient.java | 100 ++++++++++
.../core/nio/udp/Netty4UdpBenchmarkServer.java | 133 +++++++++++++
benchmarks/pom.xml | 16 +-
.../apache/mina/core/BenchmarkBinaryTest.java | 154 ---------------
.../org/apache/mina/core/BenchmarkClient.java | 36 ----
.../mina/core/BenchmarkClientFactory.java | 53 -----
.../org/apache/mina/core/BenchmarkFactory.java | 42 ----
.../org/apache/mina/core/BenchmarkServer.java | 35 ----
.../mina/core/BenchmarkServerFactory.java | 56 ------
...ClientVsBioServerUdpBenchmarkBinaryTest.java | 68 -------
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 68 -------
.../org/apache/mina/core/CounterFilter.java | 31 ---
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 73 -------
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 68 -------
...entVsNetty3ServerTcpBenchmarkBinaryTest.java | 65 ------
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 64 ------
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 66 -------
...entVsNetty3ServerTcpBenchmarkBinaryTest.java | 64 ------
...entVsNetty3ServerUdpBenchmarkBinaryTest.java | 66 -------
.../core/bio/udp/BioUdpBenchmarkClient.java | 80 --------
.../core/bio/udp/BioUdpBenchmarkServer.java | 166 ----------------
.../core/nio/tcp/Mina3TcpBenchmarkClient.java | 107 ----------
.../core/nio/tcp/Mina3TcpBenchmarkServer.java | 159 ---------------
.../core/nio/tcp/Netty3TcpBenchmarkClient.java | 104 ----------
.../core/nio/tcp/Netty3TcpBenchmarkServer.java | 194 ------------------
.../core/nio/udp/Mina3UdpBenchmarkClient.java | 116 -----------
.../core/nio/udp/Mina3UdpBenchmarkServer.java | 166 ----------------
.../core/nio/udp/Netty3UdpBenchmarkClient.java | 106 ----------
.../core/nio/udp/Netty3UdpBenchmarkServer.java | 190 ------------------
benchmarks/src/test/resources/log4j.properties | 23 ---
benchmarks2/pom.xml | 71 -------
.../apache/mina/core/BenchmarkBinaryTest.java | 124 ------------
.../org/apache/mina/core/BenchmarkClient.java | 36 ----
.../mina/core/BenchmarkClientFactory.java | 42 ----
.../org/apache/mina/core/BenchmarkFactory.java | 42 ----
.../org/apache/mina/core/BenchmarkServer.java | 35 ----
.../mina/core/BenchmarkServerFactory.java | 51 -----
...ientVsMina3ServerTcpBenchmarkBinaryTest.java | 74 -------
...ientVsMina3ServerUdpBenchmarkBinaryTest.java | 68 -------
...entVsNetty4ServerTcpBenchmarkBinaryTest.java | 74 -------
...entVsNetty4ServerUdpBenchmarkBinaryTest.java | 68 -------
.../core/nio/tcp/Mina3TcpBenchmarkServer.java | 156 ---------------
.../core/nio/tcp/Netty4TcpBenchmarkClient.java | 109 ----------
.../core/nio/tcp/Netty4TcpBenchmarkServer.java | 171 ----------------
.../core/nio/udp/Mina3UdpBenchmarkServer.java | 166 ----------------
.../core/nio/udp/Netty4UdpBenchmarkClient.java | 100 ----------
.../core/nio/udp/Netty4UdpBenchmarkServer.java | 149 --------------
benchmarks2/src/test/resources/log4j.properties | 23 ---
monitoring/pom.xml | 6 -
pom.xml | 13 +-
84 files changed, 3281 insertions(+), 3996 deletions(-)
----------------------------------------------------------------------
[3/4] git commit: Fix for DIRMINA-943
Posted by el...@apache.org.
Fix for DIRMINA-943
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/f80e27db
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/f80e27db
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/f80e27db
Branch: refs/heads/trunk
Commit: f80e27db1ec976e09787acfb271b561f2d5a199c
Parents: 53d7fa2
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Fri Sep 5 12:26:31 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Fri Sep 5 12:26:31 2014 +0200
----------------------------------------------------------------------
.../mina/codec/textline/TextLineDecoder.java | 46 ++++++++++++--------
1 file changed, 29 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/f80e27db/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
----------------------------------------------------------------------
diff --git a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
index 6616b39..0acd2b0 100644
--- a/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
+++ b/codec/src/main/java/org/apache/mina/codec/textline/TextLineDecoder.java
@@ -49,42 +49,48 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
private int bufferLength = 128;
/**
- * Creates a new instance with the current default {@link Charset} and {@link LineDelimiter#AUTO} delimiter.
+ * Creates a new instance with the current default {@link Charset} and
+ * {@link LineDelimiter#AUTO} delimiter.
*/
public TextLineDecoder() {
this(LineDelimiter.AUTO);
}
/**
- * Creates a new instance with the current default {@link Charset} and the specified <tt>delimiter</tt>.
+ * Creates a new instance with the current default {@link Charset} and the
+ * specified <tt>delimiter</tt>.
*/
public TextLineDecoder(String delimiter) {
this(new LineDelimiter(delimiter));
}
/**
- * Creates a new instance with the current default {@link Charset} and the specified <tt>delimiter</tt>.
+ * Creates a new instance with the current default {@link Charset} and the
+ * specified <tt>delimiter</tt>.
*/
public TextLineDecoder(LineDelimiter delimiter) {
this(Charset.defaultCharset(), delimiter);
}
/**
- * Creates a new instance with the spcified <tt>charset</tt> and {@link LineDelimiter#AUTO} delimiter.
+ * Creates a new instance with the spcified <tt>charset</tt> and
+ * {@link LineDelimiter#AUTO} delimiter.
*/
public TextLineDecoder(Charset charset) {
this(charset, LineDelimiter.AUTO);
}
/**
- * Creates a new instance with the spcified <tt>charset</tt> and the specified <tt>delimiter</tt>.
+ * Creates a new instance with the spcified <tt>charset</tt> and the
+ * specified <tt>delimiter</tt>.
*/
public TextLineDecoder(Charset charset, String delimiter) {
this(charset, new LineDelimiter(delimiter));
}
/**
- * Creates a new instance with the specified <tt>charset</tt> and the specified <tt>delimiter</tt>.
+ * Creates a new instance with the specified <tt>charset</tt> and the
+ * specified <tt>delimiter</tt>.
*/
public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
if (charset == null) {
@@ -107,16 +113,18 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
}
/**
- * Returns the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this
- * value, the decoder will throw a {@link BufferDataException}. The default value is <tt>1024</tt> (1KB).
+ * Returns the allowed maximum size of the line to be decoded. If the size
+ * of the line to be decoded exceeds this value, the decoder will throw a
+ * {@link BufferDataException}. The default value is <tt>1024</tt> (1KB).
*/
public int getMaxLineLength() {
return maxLineLength;
}
/**
- * Sets the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this
- * value, the decoder will throw a {@link BufferDataException}. The default value is <tt>1024</tt> (1KB).
+ * Sets the allowed maximum size of the line to be decoded. If the size of
+ * the line to be decoded exceeds this value, the decoder will throw a
+ * {@link BufferDataException}. The default value is <tt>1024</tt> (1KB).
*/
public void setMaxLineLength(int maxLineLength) {
if (maxLineLength <= 0) {
@@ -127,9 +135,11 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
}
/**
- * Sets the default buffer size. This buffer is used in the Context to store the decoded line.
+ * Sets the default buffer size. This buffer is used in the Context to store
+ * the decoded line.
*
- * @param bufferLength The default bufer size
+ * @param bufferLength
+ * The default bufer size
*/
public void setBufferLength(int bufferLength) {
if (bufferLength <= 0) {
@@ -141,7 +151,8 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
}
/**
- * Returns the allowed buffer size used to store the decoded line in the Context instance.
+ * Returns the allowed buffer size used to store the decoded line in the
+ * Context instance.
*/
public int getBufferLength() {
return bufferLength;
@@ -222,7 +233,7 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
CharsetDecoder decoder = ctx.getDecoder();
CharBuffer buffer = decoder.decode(buf);
- decoded = new String(buffer.array());
+ decoded = buffer.toString();
} else {
int overflowPosition = ctx.getOverflowLength();
throw new IllegalStateException("Line is too long: " + overflowPosition);
@@ -313,10 +324,11 @@ public class TextLineDecoder implements ProtocolDecoder<ByteBuffer, String, Text
}
/**
- * A Context used during the decoding of a lin. It stores the decoder, the temporary buffer containing the decoded
- * line, and other status flags.
+ * A Context used during the decoding of a lin. It stores the decoder, the
+ * temporary buffer containing the decoded line, and other status flags.
*
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory
+ * Project</a>
* @version $Rev$, $Date$
*/
public class Context {
[2/4] git commit: Added a test for the mark() method
Posted by el...@apache.org.
Added a test for the mark() method
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/53d7fa2a
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/53d7fa2a
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/53d7fa2a
Branch: refs/heads/trunk
Commit: 53d7fa2a7222f4c5915faea4a9ffa3c90d23eb33
Parents: 760a0f8
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Fri Sep 5 12:24:54 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Fri Sep 5 12:24:54 2014 +0200
----------------------------------------------------------------------
.../org/apache/mina/codec/IoBufferTest.java | 80 ++++++++++++--------
1 file changed, 50 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/53d7fa2a/codec/src/test/java/org/apache/mina/codec/IoBufferTest.java
----------------------------------------------------------------------
diff --git a/codec/src/test/java/org/apache/mina/codec/IoBufferTest.java b/codec/src/test/java/org/apache/mina/codec/IoBufferTest.java
index 9e2a3b2..cd0931f 100644
--- a/codec/src/test/java/org/apache/mina/codec/IoBufferTest.java
+++ b/codec/src/test/java/org/apache/mina/codec/IoBufferTest.java
@@ -152,12 +152,12 @@ public class IoBufferTest {
ioBuffer.add(bb1, bb2);
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Test the allocate(int) method
// 1) allocation with a negative value
// 2) allocation with a 0 length
// 3) allocation with a 1024 value
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Test the allocation of a new heap IoBuffer with a negative value
*/
@@ -194,12 +194,12 @@ public class IoBufferTest {
assertTrue(ioBuffer.hasRemaining());
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Test the allocateDirect(int) method. We check :
// 1) allocation with a negative value
// 2) allocation with a 0 length
// 3) allocation with a 1024 value
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Test the allocation of a new heap IoBuffer with a negative value
*/
@@ -237,7 +237,8 @@ public class IoBufferTest {
}
/**
- * Test the get() method on a IoBuffer containing one ByteBuffer with 3 bytes
+ * Test the get() method on a IoBuffer containing one ByteBuffer with 3
+ * bytes
*/
@Test
public void testGetOneBuffer3Bytes() {
@@ -267,7 +268,8 @@ public class IoBufferTest {
}
/**
- * Test the get() method on a IoBuffer containing one ByteBuffer with 0 bytes
+ * Test the get() method on a IoBuffer containing one ByteBuffer with 0
+ * bytes
*/
@Test
public void testGetOneBuffer0Bytes() {
@@ -288,7 +290,8 @@ public class IoBufferTest {
}
/**
- * Test the get() method on a IoBuffer containing two ByteBuffer with 3 bytes
+ * Test the get() method on a IoBuffer containing two ByteBuffer with 3
+ * bytes
*/
@Test
public void testGetTwoBuffer3Bytes() {
@@ -328,13 +331,13 @@ public class IoBufferTest {
}
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Test the array() method. We will check those cases :
// 1) array over an empty buffer: we should get an empty byte array
- // 2) array over a buffer with one single empty ByteBuffer
+ // 2) array over a buffer with one single empty ByteBuffer
// 3) array over a buffer with one single ByteBuffer with data
- // 4) array over a buffer containing many ByteBuffers
- //-------------------------------------------------------------------------
+ // 4) array over a buffer containing many ByteBuffers
+ // -------------------------------------------------------------------------
/**
* Test the array method for a IoBuffer containing one empty ByteBuffer
*/
@@ -349,7 +352,8 @@ public class IoBufferTest {
}
/**
- * Test the array method for a IoBuffer containing one ByteBuffer (cases 2 and 3)
+ * Test the array method for a IoBuffer containing one ByteBuffer (cases 2
+ * and 3)
*/
@Test
public void testArrayOneByteBuffer() {
@@ -374,7 +378,8 @@ public class IoBufferTest {
}
/**
- * Test the array method for a IoBuffer containing one ByteBuffer not initialized
+ * Test the array method for a IoBuffer containing one ByteBuffer not
+ * initialized
*/
@Test
public void testArrayByteBufferNotInitialized() {
@@ -403,7 +408,8 @@ public class IoBufferTest {
}
/**
- * Test the getInt() method, on a buffer containing 2 ints in two ByteBuffers
+ * Test the getInt() method, on a buffer containing 2 ints in two
+ * ByteBuffers
*/
@Test
public void testGetInt2Ints2BBs() {
@@ -422,8 +428,8 @@ public class IoBufferTest {
}
/**
- * Test the getInt() method, on a buffer containing 2 ints in two ByteBuffers
- * with LittleInidan order
+ * Test the getInt() method, on a buffer containing 2 ints in two
+ * ByteBuffers with LittleInidan order
*/
@Test
public void testGetInt2Ints2BBsLittleIndian() {
@@ -445,7 +451,8 @@ public class IoBufferTest {
}
/**
- * Test the getInt() method, on a buffer containing 1 int spread in two ByteBuffers
+ * Test the getInt() method, on a buffer containing 1 int spread in two
+ * ByteBuffers
*/
@Test
public void testGetInt1Int2BBs() {
@@ -463,7 +470,8 @@ public class IoBufferTest {
}
/**
- * Test the getInt() method, on a buffer containing 1 incomplet int spread in two ByteBuffers
+ * Test the getInt() method, on a buffer containing 1 incomplet int spread
+ * in two ByteBuffers
*/
@Test(expected = BufferUnderflowException.class)
public void testGetIntIncompletInt2BBs() {
@@ -542,14 +550,14 @@ public class IoBufferTest {
}
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// The the clear method. It will erase all the data in all the inner
// ByteBuffer, thus the buffer size might increase.
// We will check those case :
// 1) clear an empty buffer
// 2) clear a buffer with one ByteBuffer
// 3) clear a buffer with numerous ByteBuffers
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Test the clear() method
*/
@@ -601,6 +609,18 @@ public class IoBufferTest {
ioBuffer.position(3);
ioBuffer.mark();
+ // check that we are at the right position
+ byte b = ioBuffer.get();
+ assertEquals(b, '3');
+
+ b = ioBuffer.get();
+ assertEquals(b, '4');
+
+ // Now reset to the mark
+ ioBuffer.reset();
+ b = ioBuffer.get();
+ assertEquals(b, '3');
+
ioBuffer.position(6);
ioBuffer.reset();
@@ -614,7 +634,7 @@ public class IoBufferTest {
ioBuffer.reset();
fail("An InvalidMarkException should have been thrown");
} catch (InvalidMarkException ime) {
- //
+ //
}
}
@@ -645,13 +665,13 @@ public class IoBufferTest {
assertEquals(8, ioBuffer.limit());
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Test the position() method
- // We will test that the position() metho returns the correct result in
+ // We will test that the position() metho returns the correct result in
// those cases :
// 1) the buffer is empty : must return 0
// 2) must return a value between 0 and limit()
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Test the position method over an emptyIoBuffer
*/
@@ -716,19 +736,19 @@ public class IoBufferTest {
}
}
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// Test the position(int) method
// We will test many different cases
// 1) a position() in an empty buffer
// 2) a position() with a negative value
// 3) a position() with a value above the limit
// 4) a position() within the current buffer
- // 4-1) at the beginning of the current buffer
- // 4-2) at the end of the current buffer
- // 4-3) in the middle of the current buffer
+ // 4-1) at the beginning of the current buffer
+ // 4-2) at the end of the current buffer
+ // 4-3) in the middle of the current buffer
// 5) a position() before the current buffer
// 6) a position() after the current buffer
- //-------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
/**
* Test the position method over an emptyIoBuffer
*/
@@ -1043,7 +1063,7 @@ public class IoBufferTest {
ioBuffer.putChar(3, '\u00F1');
fail("Not enough place on the buffer");
} catch (BufferUnderflowException e) {
- // Should come here
+ // Should come here
}
try {