summaryrefslogtreecommitdiffstats
path: root/nio
diff options
context:
space:
mode:
Diffstat (limited to 'nio')
-rw-r--r--nio/src/main/java/java/nio/Buffer.java12
-rw-r--r--nio/src/main/java/java/nio/IntToByteBufferAdapter.java8
-rw-r--r--nio/src/main/java/java/nio/ShortToByteBufferAdapter.java8
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java296
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java3
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java69
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java458
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java71
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java1301
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java38
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java817
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java103
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java495
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java3
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java3
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java485
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java69
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java23
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java22
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java22
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java22
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java22
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java22
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java450
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java52
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java451
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java47
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java69
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java218
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java49
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java183
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java184
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java91
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java9
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java184
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java184
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java183
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java92
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java6
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java6
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java6
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java456
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java4
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java68
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java84
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java19
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java3
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java50
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java50
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java650
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java42
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java42
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java42
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java50
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java4036
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java254
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java2614
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java141
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java33
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSecurityManager.java69
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java60
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java30
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java292
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java277
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java597
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java376
-rwxr-xr-xnio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java2606
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java321
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java46
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java50
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java85
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java217
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java47
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java241
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java2
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java53
-rw-r--r--nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java103
-rw-r--r--nio/src/test/java/tests/nio/AllTests.java2
109 files changed, 11669 insertions, 10403 deletions
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java
index 9e870e4..844d2ce 100644
--- a/nio/src/main/java/java/nio/Buffer.java
+++ b/nio/src/main/java/java/nio/Buffer.java
@@ -150,11 +150,21 @@ public abstract class Buffer {
* @since Android 1.0
*/
public final Buffer clear() {
+ // BEGIN android-changed
+ internalClear();
+ // END android-changed
+ return this;
+ }
+
+ // BEGIN android-added
+ // We need a possibility to change the behavior of clear in some optimized
+ // DirectByteBuffer adapters.
+ void internalClear() {
position = 0;
mark = UNSET_MARK;
limit = capacity;
- return this;
}
+ // END android-added
/**
* Flips this buffer.
diff --git a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
index b5e1118..e52f6b6 100644
--- a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
@@ -203,6 +203,14 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return super.put(i, off, len);
}
}
+
+ @Override
+ void internalClear() {
+ if (byteBuffer instanceof ReadWriteDirectByteBuffer) {
+ byteBuffer.clear();
+ }
+ super.internalClear();
+ }
// END android-added
public IntBuffer slice() {
diff --git a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
index a3c3e38..fe4fff4 100644
--- a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
@@ -203,6 +203,14 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return super.put(s, off, len);
}
}
+
+ @Override
+ void internalClear() {
+ if (byteBuffer instanceof ReadWriteDirectByteBuffer) {
+ byteBuffer.clear();
+ }
+ super.internalClear();
+ }
// END android-added
public ShortBuffer slice() {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
index f58bf7d..901a2a6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AbstractBufferTest.java
@@ -16,9 +16,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.Buffer;
@@ -26,45 +25,44 @@ import java.nio.ByteBuffer;
import java.nio.InvalidMarkException;
import junit.framework.TestCase;
-@TestTargetClass(java.nio.Buffer.class)
+
/**
* Tests a java.nio.Buffer instance.
*/
+@TestTargetClass(java.nio.Buffer.class)
public class AbstractBufferTest extends TestCase {
protected Buffer baseBuf;
+ protected int capacity;
protected void setUp() throws Exception{
super.setUp();
+ capacity = 10;
baseBuf = ByteBuffer.allocate(10);
}
protected void tearDown() throws Exception{
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check capacity with which the buffer is created.",
- targets = {
- @TestTarget(
- methodName = "capacity",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "capacity",
+ args = {}
+ )
public void testCapacity() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
+ assertEquals(capacity, baseBuf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- // level = TestLevel.PARTIAL
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "clear",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "clear",
+ args = {}
+ )
public void testClear() {
// save state
int oldPosition = baseBuf.position();
@@ -72,7 +70,7 @@ public class AbstractBufferTest extends TestCase {
Buffer ret = baseBuf.clear();
assertSame(ret, baseBuf);
- assertEquals(baseBuf.position(), 0);
+ assertEquals(0, baseBuf.position());
assertEquals(baseBuf.limit(), baseBuf.capacity());
try {
baseBuf.reset();
@@ -85,24 +83,24 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check that mark is discarted.",
- targets = {
- @TestTarget(
- methodName = "flip",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "flip",
+ args = {}
+ )
public void testFlip() {
// save state
int oldPosition = baseBuf.position();
int oldLimit = baseBuf.limit();
+ baseBuf.mark();
+
Buffer ret = baseBuf.flip();
assertSame(ret, baseBuf);
- assertEquals(baseBuf.position(), 0);
- assertEquals(baseBuf.limit(), oldPosition);
+ assertEquals(0, baseBuf.position());
+ assertEquals(oldPosition, baseBuf.limit());
try {
baseBuf.reset();
fail("Should throw Exception"); //$NON-NLS-1$
@@ -114,15 +112,13 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hasRemaining",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasRemaining",
+ args = {}
+ )
public void testHasRemaining() {
// save state
int oldPosition = baseBuf.position();
@@ -136,15 +132,13 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Abstract method.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
baseBuf.isReadOnly();
}
@@ -152,32 +146,27 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for int limit()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "limit",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "limit",
+ args = {}
+ )
public void testLimit() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
+ assertEquals(capacity, baseBuf.limit());
}
/*
* Class under test for Buffer limit(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "limit",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "limit",
+ args = {int.class}
+ )
public void testLimitint() {
// save state
int oldPosition = baseBuf.position();
@@ -190,24 +179,23 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(baseBuf.capacity());
assertEquals(baseBuf.limit(), baseBuf.capacity());
// position should not change
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
// mark should be valid
baseBuf.reset();
- if (baseBuf.capacity() > 0) {
- baseBuf.limit(baseBuf.capacity());
- baseBuf.position(baseBuf.capacity());
- baseBuf.mark();
- baseBuf.limit(baseBuf.capacity() - 1);
- // position should be the new limit
- assertEquals(baseBuf.position(), baseBuf.limit());
- // mark should be invalid
- try {
- baseBuf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
+ assertTrue("The buffer capacity was 0", baseBuf.capacity() > 0);
+ baseBuf.limit(baseBuf.capacity());
+ baseBuf.position(baseBuf.capacity());
+ baseBuf.mark();
+ baseBuf.limit(baseBuf.capacity() - 1);
+ // position should be the new limit
+ assertEquals(baseBuf.limit(), baseBuf.position());
+ // mark should be invalid
+ try {
+ baseBuf.reset();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (InvalidMarkException e) {
+ // expected
}
try {
@@ -227,15 +215,13 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "mark",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "mark",
+ args = {}
+ )
public void testMark() {
// save state
int oldPosition = baseBuf.position();
@@ -247,12 +233,12 @@ public class AbstractBufferTest extends TestCase {
baseBuf.mark();
baseBuf.position(baseBuf.limit());
baseBuf.reset();
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
baseBuf.mark();
baseBuf.position(baseBuf.limit());
baseBuf.reset();
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
// restore state
baseBuf.limit(oldLimit);
@@ -262,32 +248,27 @@ public class AbstractBufferTest extends TestCase {
/*
* Class under test for int position()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void testPosition() {
assertTrue(0 <= baseBuf.position() && baseBuf.position() <= baseBuf.limit()
&& baseBuf.limit() <= baseBuf.capacity());
+ assertEquals(0, baseBuf.position());
}
/*
* Class under test for Buffer position(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {int.class}
+ )
public void testPositionint() {
// save state
int oldPosition = baseBuf.position();
@@ -309,26 +290,25 @@ public class AbstractBufferTest extends TestCase {
baseBuf.mark();
baseBuf.position(baseBuf.position());
baseBuf.reset();
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
baseBuf.position(0);
- assertEquals(baseBuf.position(), 0);
+ assertEquals(0, baseBuf.position());
+ baseBuf.position(baseBuf.limit());
+ assertEquals(baseBuf.limit(), baseBuf.position());
+
+ assertTrue("The buffer capacity was 0.", baseBuf.capacity() > 0);
+ baseBuf.limit(baseBuf.capacity());
baseBuf.position(baseBuf.limit());
- assertEquals(baseBuf.position(), baseBuf.limit());
-
- if (baseBuf.capacity() > 0) {
- baseBuf.limit(baseBuf.capacity());
- baseBuf.position(baseBuf.limit());
- baseBuf.mark();
- baseBuf.position(baseBuf.limit() - 1);
- assertEquals(baseBuf.position(), baseBuf.limit() - 1);
- // mark should be invalid
- try {
- baseBuf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
+ baseBuf.mark();
+ baseBuf.position(baseBuf.limit() - 1);
+ assertEquals(baseBuf.limit() - 1, baseBuf.position());
+ // mark should be invalid
+ try {
+ baseBuf.reset();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (InvalidMarkException e) {
+ // expected
}
Buffer ret = baseBuf.position(0);
@@ -338,27 +318,23 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "remaining",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "remaining",
+ args = {}
+ )
public void testRemaining() {
assertEquals(baseBuf.remaining(), baseBuf.limit() - baseBuf.position());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "reset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "reset",
+ args = {}
+ )
public void testReset() {
// save state
int oldPosition = baseBuf.position();
@@ -367,12 +343,12 @@ public class AbstractBufferTest extends TestCase {
baseBuf.mark();
baseBuf.position(baseBuf.limit());
baseBuf.reset();
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
baseBuf.mark();
baseBuf.position(baseBuf.limit());
baseBuf.reset();
- assertEquals(baseBuf.position(), oldPosition);
+ assertEquals(oldPosition, baseBuf.position());
Buffer ret = baseBuf.reset();
assertSame(ret, baseBuf);
@@ -389,22 +365,20 @@ public class AbstractBufferTest extends TestCase {
baseBuf.limit(oldLimit);
baseBuf.position(oldPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "rewind",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "rewind",
+ args = {}
+ )
public void testRewind() {
// save state
int oldPosition = baseBuf.position();
int oldLimit = baseBuf.limit();
Buffer ret = baseBuf.rewind();
- assertEquals(baseBuf.position(), 0);
+ assertEquals(0, baseBuf.position());
assertSame(ret, baseBuf);
try {
baseBuf.reset();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
index 5b4cbc5..6528c22 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/AllTests.java
@@ -31,7 +31,7 @@ public class AllTests {
}
public static Test suite() {
- TestSuite suite = new TestSuite("Tests for java.nio");
+ TestSuite suite = tests.TestSuiteFactory.createTestSuite("Tests for java.nio");
//$JUnit-BEGIN$
suite.addTestSuite(ReadOnlyHeapShortBufferTest.class);
suite.addTestSuite(ReadOnlyLongBufferTest.class);
@@ -70,7 +70,6 @@ public class AllTests {
suite.addTestSuite(DoubleBufferTest.class);
suite.addTestSuite(ReadOnlyWrappedFloatBufferTest.class);
suite.addTestSuite(ShortBufferTest.class);
- suite.addTestSuite(BufferTest.class);
suite.addTestSuite(DirectFloatBufferTest.class);
suite.addTestSuite(SliceWrappedByteBufferTest.class);
suite.addTestSuite(DirectCharBufferTest.class);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
index 7d8c763..d7dd36e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java
@@ -16,9 +16,9 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -33,15 +33,20 @@ public class BufferOverflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility. And tests default constructor",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferOverflowException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new BufferOverflowException());
@@ -50,17 +55,41 @@ public class BufferOverflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferOverflowException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new BufferOverflowException());
}
+
+ // BEGIN android-added
+ // copied from newer version of harmony
+ /**
+ *@tests {@link java.nio.BufferOverflowException#BufferOverflowException()}
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferOverflowException",
+ args = {}
+ )
+ public void test_Constructor() {
+ BufferOverflowException exception = new BufferOverflowException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getLocalizedMessage());
+ assertNull(exception.getCause());
+ }
+ // END android-added
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java
deleted file mode 100644
index a2ee5fd..0000000
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferTest.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * 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 regarding copyright ownership.
- * The ASF licenses this file 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
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.nio.tests.java.nio;
-
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestTargetClass;
-
-import java.nio.Buffer;
-import java.nio.InvalidMarkException;
-
-import junit.framework.TestCase;
-/**
- * Test a java.nio.Buffer instance.
- */
-@TestTargetClass(Buffer.class)
-public class BufferTest extends TestCase {
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that buffer's state doesn't change after testing.",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "limit",
- methodArgs = {}
- )
- })
- public static void testBufferInstance(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- testCapacity(buf);
- testClear(buf);
- testFlip(buf);
- testHasRemaining(buf);
- testIsReadOnly(buf);
- testLimit(buf);
- testLimitint(buf);
- testMark(buf);
- testPosition(buf);
- testPositionint(buf);
- testRemaining(buf);
- testReset(buf);
- testRewind(buf);
-
- // check state, should not change
- assertEquals(buf.position(), oldPosition);
- assertEquals(buf.limit(), oldLimit);
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check capacity with which the buffer is created.",
- targets = {
- @TestTarget(
- methodName = "capacity",
- methodArgs = {}
- )
- })
- public static void testCapacity(Buffer buf) {
- assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
- && buf.limit() <= buf.capacity());
- }
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "clear",
- methodArgs = {}
- )
- })
- public static void testClear(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- Buffer ret = buf.clear();
- assertSame(ret, buf);
- assertEquals(buf.position(), 0);
- assertEquals(buf.limit(), buf.capacity());
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check that mark is discarded after a call of flip " +
- "method. ",
- targets = {
- @TestTarget(
- methodName = "flip",
- methodArgs = {}
- )
- })
- public static void testFlip(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- Buffer ret = buf.flip();
- assertSame(ret, buf);
- assertEquals(buf.position(), 0);
- assertEquals(buf.limit(), oldPosition);
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hasRemaining",
- methodArgs = {}
- )
- })
- public static void testHasRemaining(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- assertEquals(buf.hasRemaining(), buf.position() < buf.limit());
- buf.position(buf.limit());
- assertFalse(buf.hasRemaining());
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
- public static void testIsReadOnly(Buffer buf) {
- buf.isReadOnly();
- }
-
- /*
- * Class under test for int limit()
- */
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "limit",
- methodArgs = {}
- )
- })
- public static void testLimit(Buffer buf) {
- assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
- && buf.limit() <= buf.capacity());
- }
-
- /*
- * Class under test for Buffer limit(int)
- */
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "limit",
- methodArgs = {int.class}
- )
- })
- public static void testLimitint(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- Buffer ret = buf.limit(buf.limit());
- assertSame(ret, buf);
-
- buf.mark();
- buf.limit(buf.capacity());
- assertEquals(buf.limit(), buf.capacity());
- // position should not change
- assertEquals(buf.position(), oldPosition);
- // mark should be valid
- buf.reset();
-
- if (buf.capacity() > 0) {
- buf.limit(buf.capacity());
- buf.position(buf.capacity());
- buf.mark();
- buf.limit(buf.capacity() - 1);
- // position should be the new limit
- assertEquals(buf.position(), buf.limit());
- // mark should be invalid
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
- }
-
- try {
- buf.limit(-1);
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // expected
- }
- try {
- buf.limit(buf.capacity() + 1);
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "mark",
- methodArgs = {}
- )
- })
- public static void testMark(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- Buffer ret = buf.mark();
- assertSame(ret, buf);
-
- buf.mark();
- buf.position(buf.limit());
- buf.reset();
- assertEquals(buf.position(), oldPosition);
-
- buf.mark();
- buf.position(buf.limit());
- buf.reset();
- assertEquals(buf.position(), oldPosition);
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
-
- /*
- * Class under test for int position()
- */
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
- public static void testPosition(Buffer buf) {
- assertTrue(0 <= buf.position() && buf.position() <= buf.limit()
- && buf.limit() <= buf.capacity());
- }
-
- /*
- * Class under test for Buffer position(int)
- */
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {int.class}
- )
- })
- public static void testPositionint(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- try {
- buf.position(-1);
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // expected
- }
- try {
- buf.position(buf.limit() + 1);
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // expected
- }
-
- buf.mark();
- buf.position(buf.position());
- buf.reset();
- assertEquals(buf.position(), oldPosition);
-
- buf.position(0);
- assertEquals(buf.position(), 0);
- buf.position(buf.limit());
- assertEquals(buf.position(), buf.limit());
-
- if (buf.capacity() > 0) {
- buf.limit(buf.capacity());
- buf.position(buf.limit());
- buf.mark();
- buf.position(buf.limit() - 1);
- assertEquals(buf.position(), buf.limit() - 1);
- // mark should be invalid
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
- }
-
- Buffer ret = buf.position(0);
- assertSame(ret, buf);
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "remaining",
- methodArgs = {}
- )
- })
- public static void testRemaining(Buffer buf) {
- assertEquals(buf.remaining(), buf.limit() - buf.position());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "reset",
- methodArgs = {}
- )
- })
- public static void testReset(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- buf.mark();
- buf.position(buf.limit());
- buf.reset();
- assertEquals(buf.position(), oldPosition);
-
- buf.mark();
- buf.position(buf.limit());
- buf.reset();
- assertEquals(buf.position(), oldPosition);
-
- Buffer ret = buf.reset();
- assertSame(ret, buf);
-
- buf.clear();
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "rewind",
- methodArgs = {}
- )
- })
- public static void testRewind(Buffer buf) {
- // save state
- int oldPosition = buf.position();
- int oldLimit = buf.limit();
-
- Buffer ret = buf.rewind();
- assertEquals(buf.position(), 0);
- assertSame(ret, buf);
- try {
- buf.reset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (InvalidMarkException e) {
- // expected
- }
-
- // restore state
- buf.limit(oldLimit);
- buf.position(oldPosition);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Doesn't test anything. Just to remove JUnit warning.",
- targets = {
- @TestTarget(
- methodName = "",
- methodArgs = {}
- )
- })
- public void testNothing() {
- // to remove JUnit warning
- }
-
-} \ No newline at end of file
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
index 5180f52..2c8d09e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java
@@ -16,9 +16,9 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferUnderflowException;
@@ -27,24 +27,29 @@ import junit.framework.TestCase;
import org.apache.harmony.testframework.serialization.SerializationTest;
-@TestTargetClass(BufferUnderflowException.class)
/**
* Tests for BufferUnderflowException
*/
+@TestTargetClass(BufferUnderflowException.class)
public class BufferUnderflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferUnderflowException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new BufferUnderflowException());
@@ -53,17 +58,41 @@ public class BufferUnderflowExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferUnderflowException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new BufferUnderflowException());
}
+
+ // BEGIN android-added
+ // copied from newer version of harmony
+ /**
+ *@tests {@link java.nio.BufferUnderflowException#BufferUnderflowException()}
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "BufferUnderflowException",
+ args = {}
+ )
+ public void test_Constructor() {
+ BufferUnderflowException exception = new BufferUnderflowException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getLocalizedMessage());
+ assertNull(exception.getCause());
+ }
+ // END android-added
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
index f97ad5f..8bf0208 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteBufferTest.java
@@ -17,9 +17,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -48,6 +47,7 @@ public class ByteBufferTest extends AbstractBufferTest {
protected ByteBuffer buf;
protected void setUp() throws Exception {
+ capacity = 10;
buf = ByteBuffer.allocate(10);
baseBuf = buf;
}
@@ -62,24 +62,30 @@ public class ByteBufferTest extends AbstractBufferTest {
* 1. case for check ByteBuffer testBuf properties
* 2. case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check backing array. Doesn't check boundary value " +
- "of capacity.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
- // case: ByteBuffer testBuf properties is satisfy the conditions specification
+ // case: ByteBuffer testBuf properties is satisfy the conditions
+ // specification
ByteBuffer testBuf = ByteBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
- // case: expected IllegalArgumentException
+ testBuf = ByteBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
+
+ // case: expected IllegalArgumentException
try {
testBuf = ByteBuffer.allocate(-20);
fail("allocate method does not throws expected exception");
@@ -91,23 +97,40 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* test for method static ByteBuffer allocateDirect(int capacity)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check check backing array. Doesn't check boundary " +
- "value of capacity.",
- targets = {
- @TestTarget(
- methodName = "allocateDirect",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocateDirect",
+ args = {int.class}
+ )
public void test_AllocateDirectI() {
- // case: ByteBuffer testBuf properties is satisfy the conditions specification
+ // case: ByteBuffer testBuf properties is satisfy the conditions
+ // specification
ByteBuffer testBuf = ByteBuffer.allocateDirect(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
+ assertEquals(0, testBuf.position());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = ByteBuffer.allocateDirect(0);
+ assertEquals(0, testBuf.position());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
+
+ try {
+ testBuf.array();
+ fail("Didn't throw expected UnsupportedOperationException.");
+ } catch (UnsupportedOperationException e) {
+ //expected
+ }
- // case: expected IllegalArgumentException
+ try {
+ testBuf.arrayOffset();
+ fail("Didn't throw expected UnsupportedOperationException.");
+ } catch (UnsupportedOperationException e) {
+ //expected
+ }
+
+ // case: expected IllegalArgumentException
try {
testBuf = ByteBuffer.allocate(-20);
fail("allocate method does not throws expected exception");
@@ -115,107 +138,59 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The second if/else verifies the same case.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
- if (buf.hasArray()) {
- byte array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ byte array[] = buf.array();
+ assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData1(array, buf.arrayOffset(), buf.capacity());
+ assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, buf.arrayOffset(), buf.capacity());
+ assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData1(buf);
+ assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- } else {
- if (buf.isReadOnly()) {
- try {
- buf.array();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- // Note:can not tell when to throw
- // UnsupportedOperationException
- // or ReadOnlyBufferException, so catch all.
- }
- } else {
- try {
- buf.array();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
- }
+ loadTestData2(buf);
+ assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The second if/else verifies the same case.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
- public void testArrayOffset() {
- if (buf.hasArray()) {
- byte array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
+ public void testArrayOffset() {
+ byte array[] = buf.array();
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = (byte) i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ ByteBuffer wrapped = ByteBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
- } else {
- if (buf.isReadOnly()) {
- try {
- buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- // Note:can not tell when to throw
- // UnsupportedOperationException
- // or ReadOnlyBufferException, so catch all.
- }
- } else {
- try {
- buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- }
- }
- }
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -233,21 +208,19 @@ public class ByteBufferTest extends AbstractBufferTest {
// readonly's position, mark, and limit should be independent to buf
readonly.reset();
- assertEquals(readonly.position(), 0);
+ assertEquals(0, readonly.position());
readonly.clear();
assertEquals(buf.position(), buf.limit());
buf.reset();
- assertEquals(buf.position(), 0);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+ assertEquals(0, buf.position());
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
if (buf.isReadOnly()) {
try {
@@ -265,8 +238,8 @@ public class ByteBufferTest extends AbstractBufferTest {
loadTestData1(buf);
ByteBuffer ret = buf.compact();
assertSame(ret, buf);
- assertEquals(buf.position(), buf.capacity());
- assertEquals(buf.limit(), buf.capacity());
+ assertEquals(buf.capacity(), buf.position());
+ assertEquals(buf.capacity(), buf.limit());
assertContentLikeTestData1(buf, 0, (byte) 0, buf.capacity());
try {
buf.reset();
@@ -281,7 +254,7 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.mark();
ret = buf.compact();
assertSame(ret, buf);
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
assertEquals(buf.limit(), buf.capacity());
assertContentLikeTestData1(buf, 0, (byte) 0, buf.capacity());
try {
@@ -298,7 +271,7 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.mark();
ret = buf.compact();
assertSame(ret, buf);
- assertEquals(buf.position(), 4);
+ assertEquals(4, buf.position());
assertEquals(buf.limit(), buf.capacity());
assertContentLikeTestData1(buf, 0, (byte) 1, 4);
try {
@@ -308,15 +281,13 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -344,15 +315,13 @@ public class ByteBufferTest extends AbstractBufferTest {
assertTrue(ByteBuffer.wrap(new byte[21]).compareTo(ByteBuffer.allocateDirect(21)) == 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -370,11 +339,11 @@ public class ByteBufferTest extends AbstractBufferTest {
// duplicate's position, mark, and limit should be independent to buf
duplicate.reset();
- assertEquals(duplicate.position(), 0);
+ assertEquals(0, duplicate.position());
duplicate.clear();
assertEquals(buf.position(), buf.limit());
buf.reset();
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
// duplicate share the same content with buf
if (!duplicate.isReadOnly()) {
@@ -384,15 +353,13 @@ public class ByteBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -418,19 +385,16 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for byte get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), i);
+ assertEquals(i, buf.position());
assertEquals(buf.get(), buf.get(i));
}
try {
@@ -444,30 +408,31 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer get(byte[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {byte[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {byte[].class}
+ )
public void testGetbyteArray() {
byte array[] = new byte[1];
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), i);
+ assertEquals(i, buf.position());
ByteBuffer ret = buf.get(array);
assertEquals(array[0], buf.get(i));
assertSame(ret, buf);
}
+
+ buf.get(new byte[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
try {
buf.get((byte[])null);
fail("Should throw Exception"); //$NON-NLS-1$
@@ -479,15 +444,12 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer get(byte[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {byte[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {byte[].class, int.class, int.class}
+ )
public void testGetbyteArrayintint() {
buf.clear();
byte array[] = new byte[buf.capacity()];
@@ -498,7 +460,7 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (BufferUnderflowException e) {
// expected
}
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
try {
buf.get(array, -1, array.length);
fail("Should throw Exception"); //$NON-NLS-1$
@@ -512,7 +474,7 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (IndexOutOfBoundsException e) {
// expected
}
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
try {
buf.get(array, 2, -1);
fail("Should throw Exception"); //$NON-NLS-1$
@@ -543,7 +505,7 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (IndexOutOfBoundsException e) {
// expected
}
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
buf.clear();
ByteBuffer ret = buf.get(array, 0, array.length);
@@ -555,19 +517,16 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for byte get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), i);
+ assertEquals(i, buf.position());
assertEquals(buf.get(), buf.get(i));
}
try {
@@ -583,48 +542,35 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same verification in if/else block.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
if (buf.hasArray()) {
assertNotNull(buf.array());
} else {
- if (buf.isReadOnly()) {
- try {
- buf.array();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- // Note:can not tell when to throw
- // UnsupportedOperationException
- // or ReadOnlyBufferException, so catch all.
- }
- } else {
- try {
- buf.array();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
- // expected
- }
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
}
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
loadTestData1(buf);
@@ -637,9 +583,14 @@ public class ByteBufferTest extends AbstractBufferTest {
}
//for the testHashCode() method of readonly subclasses
- protected void readOnlyHashCode() {
- //create a new buffer initiated with some data
- ByteBuffer buf = ByteBuffer.allocate(BUFFER_LENGTH);
+ protected void readOnlyHashCode(boolean direct) {
+ //create a new buffer initiated with some data
+ ByteBuffer buf;
+ if (direct) {
+ buf = ByteBuffer.allocateDirect(BUFFER_LENGTH);
+ } else {
+ buf = ByteBuffer.allocate(BUFFER_LENGTH);
+ }
loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
buf.clear();
@@ -649,27 +600,23 @@ public class ByteBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity()/2);
assertTrue(buf.hashCode()!= duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Abstract method.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
buf.isDirect();
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
// BIG_ENDIAN is the default byte order
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
@@ -692,15 +639,12 @@ public class ByteBufferTest extends AbstractBufferTest {
* test covers following usecases:
* 1. case for check
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {java.nio.ByteOrder.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {java.nio.ByteOrder.class}
+ )
public void test_OrderLjava_lang_ByteOrder() {
// BIG_ENDIAN is the default byte order
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
@@ -721,15 +665,12 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(byte)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {byte.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "put",
+ args = {byte.class}
+ )
public void testPutbyte() {
if (buf.isReadOnly()) {
try {
@@ -744,9 +685,9 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), i);
+ assertEquals(i, buf.position());
ByteBuffer ret = buf.put((byte) i);
- assertEquals(buf.get(i), (byte) i);
+ assertEquals((byte) i, buf.get(i));
assertSame(ret, buf);
}
try {
@@ -755,20 +696,24 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (BufferOverflowException e) {
// expected
}
+
+ buf.rewind();
+ buf.put(Byte.MAX_VALUE);
+ assertEquals(Byte.MAX_VALUE, buf.get(0));
+ buf.rewind();
+ buf.put(Byte.MIN_VALUE);
+ assertEquals(Byte.MIN_VALUE, buf.get(0));
}
/*
* Class under test for java.nio.ByteBuffer put(byte[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {byte[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "put",
+ args = {byte[].class}
+ )
public void testPutbyteArray() {
byte array[] = new byte[1];
if (buf.isReadOnly()) {
@@ -783,10 +728,10 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), i);
+ assertEquals(i, buf.position());
array[0] = (byte) i;
ByteBuffer ret = buf.put(array);
- assertEquals(buf.get(i), (byte) i);
+ assertEquals((byte) i, buf.get(i));
assertSame(ret, buf);
}
try {
@@ -806,15 +751,12 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(byte[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {byte[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "put",
+ args = {byte[].class, int.class, int.class}
+ )
public void testPutbyteArrayintint() {
buf.clear();
byte array[] = new byte[buf.capacity()];
@@ -834,7 +776,7 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (BufferOverflowException e) {
// expected
}
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
try {
buf.put(array, -1, array.length);
fail("Should throw Exception"); //$NON-NLS-1$
@@ -848,7 +790,7 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
buf.put(array, array.length, 0);
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
try {
buf.put(array, 0, -1);
fail("Should throw Exception"); //$NON-NLS-1$
@@ -881,7 +823,7 @@ public class ByteBufferTest extends AbstractBufferTest {
// expected
}
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
loadTestData2(array, 0, array.length);
ByteBuffer ret = buf.put(array, 0, array.length);
@@ -893,15 +835,12 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(java.nio.ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "put",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testPutByteBuffer() {
ByteBuffer other = ByteBuffer.allocate(buf.capacity());
if (buf.isReadOnly()) {
@@ -954,15 +893,12 @@ public class ByteBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ByteBuffer put(int, byte)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, byte.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "put",
+ args = {int.class, byte.class}
+ )
public void testPutintbyte() {
if (buf.isReadOnly()) {
try {
@@ -976,9 +912,9 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
- assertEquals(buf.position(), 0);
+ assertEquals(0, buf.position());
ByteBuffer ret = buf.put(i, (byte) i);
- assertEquals(buf.get(i), (byte) i);
+ assertEquals((byte) i, buf.get(i));
assertSame(ret, buf);
}
try {
@@ -993,16 +929,19 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (IndexOutOfBoundsException e) {
// expected
}
+
+ buf.put(0, Byte.MAX_VALUE);
+ assertEquals(Byte.MAX_VALUE, buf.get(0));
+ buf.put(0, Byte.MIN_VALUE);
+ assertEquals(Byte.MIN_VALUE, buf.get(0));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > SMALL_TEST_LENGTH);
buf.position(1);
@@ -1012,9 +951,9 @@ public class ByteBufferTest extends AbstractBufferTest {
assertEquals(buf.isReadOnly(), slice.isReadOnly());
assertEquals(buf.isDirect(), slice.isDirect());
assertEquals(buf.order(), slice.order());
- assertEquals(slice.position(), 0);
- assertEquals(slice.limit(), buf.remaining());
- assertEquals(slice.capacity(), buf.remaining());
+ assertEquals(0, slice.position());
+ assertEquals(buf.remaining(), slice.limit());
+ assertEquals(buf.remaining(), slice.capacity());
try {
slice.reset();
fail("Should throw Exception"); //$NON-NLS-1$
@@ -1027,18 +966,16 @@ public class ByteBufferTest extends AbstractBufferTest {
loadTestData1(slice);
assertContentLikeTestData1(buf, 1, (byte) 0, slice.capacity());
buf.put(2, (byte) 100);
- assertEquals(slice.get(1), 100);
- }
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+ assertEquals(100, slice.get(1));
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Byte") >= 0 || str.indexOf("byte") >= 0);
@@ -1046,15 +983,13 @@ public class ByteBufferTest extends AbstractBufferTest {
assertTrue(str.indexOf("" + buf.limit()) >= 0);
assertTrue(str.indexOf("" + buf.capacity()) >= 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asCharBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asCharBuffer",
+ args = {}
+ )
public void testAsCharBuffer() {
CharBuffer charBuffer;
byte bytes[] = new byte[2];
@@ -1110,15 +1045,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asDoubleBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asDoubleBuffer",
+ args = {}
+ )
public void testAsDoubleBuffer() {
DoubleBuffer doubleBuffer;
byte bytes[] = new byte[8];
@@ -1181,15 +1114,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asFloatBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asFloatBuffer",
+ args = {}
+ )
public void testAsFloatBuffer() {
FloatBuffer floatBuffer;
byte bytes[] = new byte[4];
@@ -1252,15 +1183,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asIntBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asIntBuffer",
+ args = {}
+ )
public void testAsIntBuffer() {
IntBuffer intBuffer;
byte bytes[] = new byte[4];
@@ -1317,15 +1246,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asLongBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asLongBuffer",
+ args = {}
+ )
public void testAsLongBuffer() {
LongBuffer longBuffer;
byte bytes[] = new byte[8];
@@ -1382,15 +1309,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asShortBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asShortBuffer",
+ args = {}
+ )
public void testAsShortBuffer() {
ShortBuffer shortBuffer;
byte bytes[] = new byte[2];
@@ -1447,15 +1372,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.clear();
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getChar",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getChar",
+ args = {}
+ )
public void testGetChar() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1481,15 +1404,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getChar",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getChar",
+ args = {int.class}
+ )
public void testGetCharint() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -1520,15 +1441,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "putChar",
- methodArgs = {char.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putChar",
+ args = {char.class}
+ )
public void testPutChar() {
if (buf.isReadOnly()) {
try {
@@ -1565,16 +1484,21 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.rewind();
+ buf.putChar(0, Character.MAX_VALUE);
+ assertEquals(Character.MAX_VALUE, buf.getChar(0));
+ buf.rewind();
+ buf.putChar(0, Character.MIN_VALUE);
+ assertEquals(Character.MIN_VALUE, buf.getChar(0));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "putChar",
- methodArgs = {int.class, char.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putChar",
+ args = {int.class, char.class}
+ )
public void testPutCharint() {
if (buf.isReadOnly()) {
try {
@@ -1621,16 +1545,19 @@ public class ByteBufferTest extends AbstractBufferTest {
} catch (IndexOutOfBoundsException e) {
//expected
}
+
+ buf.putChar(0, Character.MAX_VALUE);
+ assertEquals(Character.MAX_VALUE, buf.getChar(0));
+ buf.putChar(0, Character.MIN_VALUE);
+ assertEquals(Character.MIN_VALUE, buf.getChar(0));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getDouble",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getDouble",
+ args = {}
+ )
public void testGetDouble() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1659,15 +1586,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getDouble",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getDouble",
+ args = {int.class}
+ )
public void testGetDoubleint() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -1707,15 +1632,13 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putDouble",
- methodArgs = {double.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putDouble",
+ args = {double.class}
+ )
public void testPutDouble() {
if (buf.isReadOnly()) {
try {
@@ -1752,16 +1675,30 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putDouble",
- methodArgs = {int.class, double.class}
- )
- })
+
+ buf.rewind();
+ buf.putDouble(Double.MAX_VALUE);
+ assertEquals(Double.MAX_VALUE, buf.getDouble(0));
+ buf.rewind();
+ buf.putDouble(Double.MIN_VALUE);
+ assertEquals(Double.MIN_VALUE, buf.getDouble(0));
+ buf.rewind();
+ buf.putDouble(Double.NaN);
+ assertEquals(Double.NaN, buf.getDouble(0));
+ buf.rewind();
+ buf.putDouble(Double.NEGATIVE_INFINITY);
+ assertEquals(Double.NEGATIVE_INFINITY, buf.getDouble(0));
+ buf.rewind();
+ buf.putDouble(Double.POSITIVE_INFINITY);
+ assertEquals(Double.POSITIVE_INFINITY, buf.getDouble(0));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putDouble",
+ args = {int.class, double.class}
+ )
public void testPutDoubleint() {
if (buf.isReadOnly()) {
try {
@@ -1802,16 +1739,25 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getFloat",
- methodArgs = {}
- )
- })
+
+ buf.putDouble(0, Double.MAX_VALUE);
+ assertEquals(Double.MAX_VALUE, buf.getDouble(0));
+ buf.putDouble(0, Double.MIN_VALUE);
+ assertEquals(Double.MIN_VALUE, buf.getDouble(0));
+ buf.putDouble(0, Double.NaN);
+ assertEquals(Double.NaN, buf.getDouble(0));
+ buf.putDouble(0, Double.NEGATIVE_INFINITY);
+ assertEquals(Double.NEGATIVE_INFINITY, buf.getDouble(0));
+ buf.putDouble(0, Double.POSITIVE_INFINITY);
+ assertEquals(Double.POSITIVE_INFINITY, buf.getDouble(0));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getFloat",
+ args = {}
+ )
public void testGetFloat() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1840,15 +1786,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getFloat",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getFloat",
+ args = {int.class}
+ )
public void testGetFloatint() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -1882,15 +1826,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putFloat",
- methodArgs = {float.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putFloat",
+ args = {float.class}
+ )
public void testPutFloat() {
if (buf.isReadOnly()) {
try {
@@ -1927,16 +1869,30 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putFloat",
- methodArgs = {int.class, float.class}
- )
- })
+
+ buf.rewind();
+ buf.putFloat(Float.MAX_VALUE);
+ assertEquals(Float.MAX_VALUE, buf.getFloat(0));
+ buf.rewind();
+ buf.putFloat(Float.MIN_VALUE);
+ assertEquals(Float.MIN_VALUE, buf.getFloat(0));
+ buf.rewind();
+ buf.putFloat(Float.NaN);
+ assertEquals(Float.NaN, buf.getFloat(0));
+ buf.rewind();
+ buf.putFloat(Float.NEGATIVE_INFINITY);
+ assertEquals(Float.NEGATIVE_INFINITY, buf.getFloat(0));
+ buf.rewind();
+ buf.putFloat(Float.POSITIVE_INFINITY);
+ assertEquals(Float.POSITIVE_INFINITY, buf.getFloat(0));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putFloat",
+ args = {int.class, float.class}
+ )
public void testPutFloatint() {
if (buf.isReadOnly()) {
try {
@@ -1977,16 +1933,25 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getInt",
- methodArgs = {}
- )
- })
+
+ buf.putFloat(0, Float.MAX_VALUE);
+ assertEquals(Float.MAX_VALUE, buf.getFloat(0));
+ buf.putFloat(0, Float.MIN_VALUE);
+ assertEquals(Float.MIN_VALUE, buf.getFloat(0));
+ buf.putFloat(0, Float.NaN);
+ assertEquals(Float.NaN, buf.getFloat(0));
+ buf.putFloat(0, Float.NEGATIVE_INFINITY);
+ assertEquals(Float.NEGATIVE_INFINITY, buf.getFloat(0));
+ buf.putFloat(0, Float.POSITIVE_INFINITY);
+ assertEquals(Float.POSITIVE_INFINITY, buf.getFloat(0));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getInt",
+ args = {}
+ )
public void testGetInt() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -2012,15 +1977,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getInt",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getInt",
+ args = {int.class}
+ )
public void testGetIntint() {
int nbytes = 4;
byte bytes[] = new byte[nbytes];
@@ -2056,15 +2019,13 @@ public class ByteBufferTest extends AbstractBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putInt",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putInt",
+ args = {int.class}
+ )
public void testPutInt() {
if (buf.isReadOnly()) {
try {
@@ -2101,16 +2062,21 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.rewind();
+ buf.putInt(Integer.MAX_VALUE);
+ assertEquals(Integer.MAX_VALUE, buf.getInt(0));
+ buf.rewind();
+ buf.putInt(Integer.MIN_VALUE);
+ assertEquals(Integer.MIN_VALUE, buf.getInt(0));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putInt",
- methodArgs = {int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putInt",
+ args = {int.class, int.class}
+ )
public void testPutIntint() {
if (buf.isReadOnly()) {
try {
@@ -2151,16 +2117,19 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.putInt(0, Integer.MAX_VALUE);
+ assertEquals(Integer.MAX_VALUE, buf.getInt(0));
+ buf.putInt(0, Integer.MIN_VALUE);
+ assertEquals(Integer.MIN_VALUE, buf.getInt(0));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getLong",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getLong",
+ args = {}
+ )
public void testGetLong() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -2186,15 +2155,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getLong",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getLong",
+ args = {int.class}
+ )
public void testGetLongint() {
int nbytes = 8;
byte bytes[] = new byte[nbytes];
@@ -2225,15 +2192,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putLong",
- methodArgs = {long.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putLong",
+ args = {long.class}
+ )
public void testPutLong() {
if (buf.isReadOnly()) {
try {
@@ -2270,16 +2235,21 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.rewind();
+ buf.putLong(Long.MAX_VALUE);
+ assertEquals(Long.MAX_VALUE, buf.getLong(0));
+ buf.rewind();
+ buf.putLong(Long.MIN_VALUE);
+ assertEquals(Long.MIN_VALUE, buf.getLong(0));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putLong",
- methodArgs = {int.class, long.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putLong",
+ args = {int.class, long.class}
+ )
public void testPutLongint() {
if (buf.isReadOnly()) {
try {
@@ -2320,16 +2290,19 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.putLong(0, Long.MAX_VALUE);
+ assertEquals(Long.MAX_VALUE, buf.getLong(0));
+ buf.putLong(0, Long.MIN_VALUE);
+ assertEquals(Long.MIN_VALUE, buf.getLong(0));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getShort",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getShort",
+ args = {}
+ )
public void testGetShort() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -2355,15 +2328,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "getShort",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "getShort",
+ args = {int.class}
+ )
public void testGetShortint() {
int nbytes = 2;
byte bytes[] = new byte[nbytes];
@@ -2394,15 +2365,13 @@ public class ByteBufferTest extends AbstractBufferTest {
buf.order(ByteOrder.BIG_ENDIAN);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putShort",
- methodArgs = {short.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putShort",
+ args = {short.class}
+ )
public void testPutShort() {
if (buf.isReadOnly()) {
try {
@@ -2439,16 +2408,21 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.rewind();
+ buf.putShort(Short.MAX_VALUE);
+ assertEquals(Short.MAX_VALUE, buf.getShort(0));
+ buf.rewind();
+ buf.putShort(Short.MIN_VALUE);
+ assertEquals(Short.MIN_VALUE, buf.getShort(0));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check boundary values.",
- targets = {
- @TestTarget(
- methodName = "putShort",
- methodArgs = {int.class, short.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "putShort",
+ args = {int.class, short.class}
+ )
public void testPutShortint() {
if (buf.isReadOnly()) {
try {
@@ -2489,21 +2463,22 @@ public class ByteBufferTest extends AbstractBufferTest {
}
buf.order(ByteOrder.BIG_ENDIAN);
+
+ buf.putShort(0, Short.MAX_VALUE);
+ assertEquals(Short.MAX_VALUE, buf.getShort(0));
+ buf.putShort(0, Short.MIN_VALUE);
+ assertEquals(Short.MIN_VALUE, buf.getShort(0));
}
/**
* @tests java.nio.ByteBuffer.wrap(byte[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Verifies NullPointerException, " +
- "IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {byte[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies NullPointerException, IndexOutOfBoundsException.",
+ method = "wrap",
+ args = {byte[].class, int.class, int.class}
+ )
public void testWrappedByteBuffer_null_array() {
// Regression for HARMONY-264
byte array[] = null;
@@ -2526,29 +2501,26 @@ public class ByteBufferTest extends AbstractBufferTest {
* 2. case for check equal between buf2 and byte array[]
* 3. case for check a buf2 dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {byte[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {byte[].class}
+ )
public void test_Wrap$B() {
byte array[] = new byte[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
ByteBuffer buf2 = ByteBuffer.wrap(array);
- // case: ByteBuffer buf2 properties is satisfy the conditions specification
- assertEquals(buf2.capacity(), array.length);
- assertEquals(buf2.limit(), array.length);
- assertEquals(buf2.position(), 0);
+ // case: ByteBuffer buf2 properties is satisfy the conditions specification
+ assertEquals(array.length, buf2.capacity());
+ assertEquals(array.length, buf2.limit());
+ assertEquals(0, buf2.position());
// case: ByteBuffer buf2 is equal to byte array[]
assertContentEquals(buf2, array, 0, array.length);
- // case: ByteBuffer buf2 is depended to byte array[]
+ // case: ByteBuffer buf2 is depended to byte array[]
loadTestData2(array, 0, buf.capacity());
assertContentEquals(buf2, array, 0, array.length);
}
@@ -2561,15 +2533,12 @@ public class ByteBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[]
* 4. case expected IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {byte[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {byte[].class, int.class, int.class}
+ )
public void test_Wrap$BII() {
byte array[] = new byte[BUFFER_LENGTH];
int offset = 5;
@@ -2577,16 +2546,16 @@ public class ByteBufferTest extends AbstractBufferTest {
loadTestData1(array, 0, BUFFER_LENGTH);
ByteBuffer buf2 = ByteBuffer.wrap(array, offset, length);
- // case: ByteBuffer buf2 properties is satisfy the conditions specification
- assertEquals(buf2.capacity(), array.length);
- assertEquals(buf2.position(), offset);
- assertEquals(buf2.limit(), offset + length);
- assertEquals(buf2.arrayOffset(), 0);
+ // case: ByteBuffer buf2 properties is satisfy the conditions specification
+ assertEquals(array.length, buf2.capacity());
+ assertEquals(offset, buf2.position());
+ assertEquals(offset + length, buf2.limit());
+ assertEquals(0, buf2.arrayOffset());
// case: ByteBuffer buf2 is equal to byte array[]
assertContentEquals(buf2, array, 0, array.length);
- // case: ByteBuffer buf2 is depended to byte array[]
+ // case: ByteBuffer buf2 is depended to byte array[]
loadTestData2(array, 0, buf.capacity());
assertContentEquals(buf2, array, 0, array.length);
@@ -2629,7 +2598,7 @@ public class ByteBufferTest extends AbstractBufferTest {
private void assertContentEquals(ByteBuffer buf, byte array[],
int offset, int length) {
for (int i = 0; i < length; i++) {
- assertEquals(buf.get(i), array[offset + i]);
+ assertEquals(array[offset + i], buf.get(i));
}
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
index 1fc82ab..069b056 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ByteOrderTest.java
@@ -17,46 +17,42 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteOrder;
import junit.framework.TestCase;
-@TestTargetClass(ByteOrder.class)
+
/**
* Test java.nio.ByteOrder
*
*/
+@TestTargetClass(ByteOrder.class)
public class ByteOrderTest extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(ByteOrderTest.class);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
assertEquals(ByteOrder.BIG_ENDIAN.toString(), "BIG_ENDIAN");
assertEquals(ByteOrder.LITTLE_ENDIAN.toString(), "LITTLE_ENDIAN");
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "nativeOrder",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "nativeOrder",
+ args = {}
+ )
public void testNativeOrder() {
ByteOrder o = ByteOrder.nativeOrder();
assertTrue(o == ByteOrder.BIG_ENDIAN || o == ByteOrder.LITTLE_ENDIAN);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
index ce394a5..21d96a5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java
@@ -17,9 +17,9 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.io.IOException;
@@ -45,6 +45,7 @@ public class CharBufferTest extends AbstractBufferTest {
private static char[] chars = "123456789a".toCharArray();
protected void setUp() throws Exception{
+ capacity = chars.length;
char[] charscopy = new char[chars.length];
System.arraycopy(chars, 0, charscopy, 0, chars.length);
buf = CharBuffer.wrap(charscopy);
@@ -61,22 +62,28 @@ public class CharBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check CharBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify boundary values.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: CharBuffer testBuf properties is satisfy the conditions
// specification
CharBuffer testBuf = CharBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = CharBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -87,15 +94,13 @@ public class CharBufferTest extends AbstractBufferTest {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test code as in testArrayOffset method.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
char array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -112,40 +117,36 @@ public class CharBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test code as in testArrayOffset method.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
char array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = (char) i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ CharBuffer wrapped = CharBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -195,15 +196,13 @@ public class CharBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), originalPosition);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -254,15 +253,13 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.CharBuffer.class}
+ )
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -288,15 +285,13 @@ public class CharBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
// mark the position 0
buf.clear();
@@ -358,15 +353,13 @@ public class CharBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -392,15 +385,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for char get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -418,15 +408,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer get(char[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify different arrays: empty, null and etc.",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {char[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {char[].class}
+ )
public void testGetcharArray() {
char array[] = new char[1];
buf.clear();
@@ -436,26 +423,33 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i));
assertSame(ret, buf);
}
+
+ buf.get(new char[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
+ try {
+ buf.get((char[])null);
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (NullPointerException e) {
+ // expected
+ }
}
/*
* Class under test for java.nio.CharBuffer get(char[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {char[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {char[].class, int.class, int.class}
+ )
public void testGetcharArrayintint() {
buf.clear();
char array[] = new char[buf.capacity()];
@@ -523,15 +517,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for char get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -551,15 +542,13 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
loadTestData1(buf);
@@ -574,15 +563,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {char.class}
+ )
public void testPutchar() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -602,15 +588,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {char[].class}
+ )
public void testPutcharArray() {
char array[] = new char[1];
@@ -639,15 +622,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(char[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {char[].class, int.class, int.class}
+ )
public void testPutcharArrayintint() {
buf.clear();
char array[] = new char[buf.capacity()];
@@ -720,15 +700,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(java.nio.CharBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.CharBuffer.class}
+ )
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(buf.capacity());
@@ -771,15 +748,12 @@ public class CharBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.CharBuffer put(int, char)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, char.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, char.class}
+ )
public void testPutintchar() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -801,15 +775,13 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -819,9 +791,9 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(buf.isReadOnly(), slice.isReadOnly());
assertEquals(buf.isDirect(), slice.isDirect());
assertEquals(buf.order(), slice.order());
- assertEquals(slice.position(), 0);
- assertEquals(slice.limit(), buf.remaining());
- assertEquals(slice.capacity(), buf.remaining());
+ assertEquals(0, slice.position());
+ assertEquals(buf.remaining(), slice.limit());
+ assertEquals(buf.remaining(), slice.capacity());
try {
slice.reset();
fail("Should throw Exception"); //$NON-NLS-1$
@@ -837,15 +809,13 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String expected = "";
for (int i = buf.position(); i < buf.limit(); i++) {
@@ -854,15 +824,13 @@ public class CharBufferTest extends AbstractBufferTest {
String str = buf.toString();
assertEquals(expected, str);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "charAt",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "charAt",
+ args = {int.class}
+ )
public void testCharAt() {
for (int i = 0; i < buf.remaining(); i++) {
assertEquals(buf.get(buf.position() + i), buf.charAt(i));
@@ -880,27 +848,23 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "length",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "length",
+ args = {}
+ )
public void testLength() {
assertEquals(buf.length(), buf.remaining());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "subSequence",
- methodArgs = {int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "subSequence",
+ args = {int.class, int.class}
+ )
public void testSubSequence() {
try {
buf.subSequence(-1, buf.length());
@@ -936,15 +900,13 @@ public class CharBufferTest extends AbstractBufferTest {
.toString().substring(1, buf.length() - 1));
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.lang.String.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.lang.String.class}
+ )
public void testPutString() {
String str = " ";
@@ -969,15 +931,13 @@ public class CharBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.lang.String.class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.lang.String.class, int.class, int.class}
+ )
public void testPutStringintint() {
buf.clear();
String str = String.valueOf(new char[buf.capacity()]);
@@ -1092,16 +1052,13 @@ public class CharBufferTest extends AbstractBufferTest {
value = (char) (value + 1);
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies append method with the same CharSequence object " +
- "for which it's called.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies append method with the same CharSequence object for which it's called.",
+ method = "append",
+ args = {java.lang.CharSequence.class}
+ )
public void testAppendSelf() throws Exception {
CharBuffer cb = CharBuffer.allocate(10);
CharBuffer cb2 = cb.duplicate();
@@ -1127,21 +1084,25 @@ public class CharBufferTest extends AbstractBufferTest {
cb2.clear();
assertEquals(cb, cb2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies BufferOverflowException.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {char.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies BufferOverflowException.",
+ method = "append",
+ args = {char.class}
),
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies BufferOverflowException.",
+ method = "append",
+ args = {java.lang.CharSequence.class}
),
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies BufferOverflowException.",
+ method = "append",
+ args = {java.lang.CharSequence.class, int.class, int.class}
)
})
public void testAppendOverFlow() throws IOException {
@@ -1167,21 +1128,25 @@ public class CharBufferTest extends AbstractBufferTest {
// expected;
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {char.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "append",
+ args = {char.class}
),
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "append",
+ args = {java.lang.CharSequence.class}
),
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "append",
+ args = {java.lang.CharSequence.class, int.class, int.class}
)
})
public void testReadOnlyMap() throws IOException {
@@ -1207,30 +1172,26 @@ public class CharBufferTest extends AbstractBufferTest {
}
cb.append(cs, 1, 1);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {char.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exceptions.",
+ method = "append",
+ args = {char.class}
+ )
public void testAppendCNormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(2);
cb.put('A');
assertSame(cb, cb.append('B'));
assertEquals('B', cb.get(1));
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exceptions.",
+ method = "append",
+ args = {java.lang.CharSequence.class}
+ )
public void testAppendCharSequenceNormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.put('A');
@@ -1239,16 +1200,13 @@ public class CharBufferTest extends AbstractBufferTest {
cb.append(null);
assertEquals("null", cb.flip().toString());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies positive case, and null as CharSequence " +
- "parameter.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies positive case, and null as CharSequence parameter.",
+ method = "append",
+ args = {java.lang.CharSequence.class, int.class, int.class}
+ )
public void testAppendCharSequenceIINormal() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.put('A');
@@ -1258,15 +1216,13 @@ public class CharBufferTest extends AbstractBufferTest {
cb.append(null, 0, 1);
assertEquals("n", cb.flip().toString());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "append",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException.",
+ method = "append",
+ args = {java.lang.CharSequence.class, int.class, int.class}
+ )
public void testAppendCharSequenceII_IllegalArgument() throws IOException {
CharBuffer cb = CharBuffer.allocate(10);
cb.append("String", 0, 0);
@@ -1302,15 +1258,13 @@ public class CharBufferTest extends AbstractBufferTest {
// expected;
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "read",
+ args = {java.nio.CharBuffer.class}
+ )
public void testReadCharBuffer() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(10);
@@ -1327,15 +1281,13 @@ public class CharBufferTest extends AbstractBufferTest {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "read",
+ args = {java.nio.CharBuffer.class}
+ )
public void testReadReadOnly() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(10).asReadOnlyBuffer();
@@ -1349,16 +1301,13 @@ public class CharBufferTest extends AbstractBufferTest {
target.flip();
assertEquals(0, source.read(target));
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies read method with CharBuffer parameter which length " +
- "is less than read CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies read method with CharBuffer parameter which length is less than read CharBuffer.",
+ method = "read",
+ args = {java.nio.CharBuffer.class}
+ )
public void testReadOverflow() throws IOException {
CharBuffer source = CharBuffer.wrap("String");
CharBuffer target = CharBuffer.allocate(1);
@@ -1366,15 +1315,13 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals("S", target.flip().toString());
assertEquals(1, source.position());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "read",
+ args = {java.nio.CharBuffer.class}
+ )
public void testReadSelf() throws Exception {
CharBuffer source = CharBuffer.wrap("abuffer");
try {
@@ -1384,51 +1331,55 @@ public class CharBufferTest extends AbstractBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Abstract method.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify false returned value.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertTrue(buf.hasArray());
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Abstract method.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
@@ -1439,15 +1390,12 @@ public class CharBufferTest extends AbstractBufferTest {
* for check equal between buf2 and char array[] 3. case for check a buf2
* dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {char[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {char[].class}
+ )
public void test_Wrap$C() {
char array[] = new char[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -1475,15 +1423,12 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[]
* 4. case expected IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {char[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {char[].class, int.class, int.class}
+ )
public void test_Wrap$CII() {
char array[] = new char[BUFFER_LENGTH];
int offset = 5;
@@ -1491,20 +1436,20 @@ public class CharBufferTest extends AbstractBufferTest {
loadTestData1(array, 0, BUFFER_LENGTH);
CharBuffer buf2 = CharBuffer.wrap(array, offset, length);
- // case: CharBuffer buf2 properties is satisfy the conditions specification
+ // case: CharBuffer buf2 properties is satisfy the conditions specification
assertEquals(buf2.capacity(), array.length);
assertEquals(buf2.position(), offset);
assertEquals(buf2.limit(), offset + length);
assertEquals(buf2.arrayOffset(), 0);
- // case: CharBuffer buf2 is equal to char array[]
+ // case: CharBuffer buf2 is equal to char array[]
assertContentEquals(buf2, array, 0, array.length);
- // case: CharBuffer buf2 is depended to char array[]
+ // case: CharBuffer buf2 is depended to char array[]
loadTestData2(array, 0, buf.capacity());
assertContentEquals(buf2, array, 0, array.length);
- // case: expected IndexOutOfBoundsException
+ // case: expected IndexOutOfBoundsException
try {
offset = 7;
buf2 = CharBuffer.wrap(array, offset, length);
@@ -1522,19 +1467,16 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check String
* 4. case for check CharBuffer
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {java.lang.CharSequence.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {java.lang.CharSequence.class}
+ )
public void test_WrapLjava_lang_CharSequence() {
// added this if clause to prevent Tests failing under special conditions.
// If the test extending this test is made for a read only buffer it fails
- // when it trys to call loadTestData1.
+ // when it tries to call loadTestData1.
if(buf.isReadOnly()) {
char[] charscopy = new char[chars.length];
System.arraycopy(chars, 0, charscopy, 0, chars.length);
@@ -1554,7 +1496,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStrBf.position(), 0);
assertContentEquals(bufStrBf, buf);
- // case: StringBuilder
+ // case: StringBuilder
CharBuffer bufStrBl = CharBuffer.wrap(testStrBuilder);
assertTrue(bufStrBl.isReadOnly());
assertEquals(bufStrBl.capacity(), testStrBuilder.length());
@@ -1562,7 +1504,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStrBl.position(), 0);
assertContentEquals(bufStrBl, buf);
- // case: String
+ // case: String
CharBuffer bufStr = CharBuffer.wrap(testStr);
assertTrue(bufStr.isReadOnly());
assertEquals(bufStr.capacity(), testStr.length());
@@ -1570,7 +1512,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStr.position(), 0);
assertContentEquals(bufStr, buf);
- // case: CharBuffer
+ // case: CharBuffer
CharBuffer bufChBf = CharBuffer.wrap(buf);
assertTrue(bufChBf.isReadOnly());
assertEquals(bufChBf.capacity(), buf.length());
@@ -1587,21 +1529,18 @@ public class CharBufferTest extends AbstractBufferTest {
* 3. case for check String
* 4. case for check CharBuffer
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify exception.",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exception.",
+ method = "wrap",
+ args = {java.lang.CharSequence.class, int.class, int.class}
+ )
public void test_WrapLjava_lang_CharSequenceII() {
int start = buf.position();
int end = buf.limit();
CharBuffer buf2 = CharBuffer.wrap(buf.toString() + buf.toString()); //buf.toString() + buf.toString() //"123456789a123456789a"
- //case: StringBuffer
+ // case: StringBuffer
StringBuffer testStrBuffer = new StringBuffer(buf2);
CharBuffer bufStrBf = CharBuffer.wrap(testStrBuffer, start, end);
assertTrue(bufStrBf.isReadOnly());
@@ -1610,7 +1549,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStrBf.position(), start);
assertEquals(bufStrBf.toString(), buf.toString());
- // case: StringBuilder
+ // case: StringBuilder
StringBuilder testStrBuilder = new StringBuilder(buf2);
CharBuffer bufStrBl = CharBuffer.wrap(testStrBuilder, start, end);
assertTrue(bufStrBl.isReadOnly());
@@ -1619,7 +1558,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStrBl.position(), start);
assertEquals(bufStrBl.toString(), buf.toString());
- // case: String
+ // case: String
String testStr = new String(buf2.toString());
CharBuffer bufStr = CharBuffer.wrap(testStr, start, end);
assertTrue(bufStr.isReadOnly());
@@ -1628,7 +1567,7 @@ public class CharBufferTest extends AbstractBufferTest {
assertEquals(bufStr.position(), start);
assertEquals(bufStr.toString(), buf.toString());
- // case: CharBuffer
+ // case: CharBuffer
CharBuffer bufChBf = CharBuffer.wrap(buf2, start, end);
assertTrue(bufChBf.isReadOnly());
assertEquals(bufChBf.capacity(), buf2.length());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
index 20f3f8f..08e4813 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectByteBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -27,6 +26,7 @@ public class DirectByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH);
baseBuf = buf;
}
@@ -41,15 +41,12 @@ public class DirectByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocateDirect(int)
*
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocateDirect",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocateDirect",
+ args = {int.class}
+ )
public void testAllocatedByteBuffer_IllegalArg() {
try {
ByteBuffer.allocateDirect(-1);
@@ -58,39 +55,69 @@ public class DirectByteBufferTest extends ByteBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isDirect method for direct ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
+ public void testArray() {
+ try {
+ buf.array();
+ fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
+ public void testArrayOffset() {
+ try {
+ buf.arrayOffset();
+ fail("Should throw UnsupportedOperationException"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct ByteBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for direct ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct ByteBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for direct ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for direct ByteBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
index 0a7c91d..fb55e1d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectCharBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -27,6 +26,7 @@ import java.nio.ByteOrder;
public class DirectCharBufferTest extends CharBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*2).asCharBuffer();
super.loadTestData1(buf);
baseBuf = buf;
@@ -36,27 +36,23 @@ public class DirectCharBufferTest extends CharBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies hasArray method for direct CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct CharBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct CharBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -64,15 +60,13 @@ public class DirectCharBufferTest extends CharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct CharBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -80,27 +74,23 @@ public class DirectCharBufferTest extends CharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isDirect method for direct CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct CharBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
index f157fb1..afc9b03 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectDoubleBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -26,6 +25,7 @@ import java.nio.ByteOrder;
@TestTargetClass(java.nio.DoubleBuffer.class)
public class DirectDoubleBufferTest extends DoubleBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*8).asDoubleBuffer();
loadTestData1(buf);
baseBuf = buf;
@@ -35,27 +35,23 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies hasArray method for direct DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct DoubleBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct DoubleBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -63,15 +59,13 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct DoubleBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -79,27 +73,23 @@ public class DirectDoubleBufferTest extends DoubleBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for direct DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct DoubleBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies order method for direct DoubleBuffer.",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
index 3a48c70..2c614c1 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectFloatBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -26,6 +25,7 @@ import java.nio.ByteOrder;
@TestTargetClass(java.nio.FloatBuffer.class)
public class DirectFloatBufferTest extends FloatBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asFloatBuffer();
loadTestData1(buf);
baseBuf = buf;
@@ -35,27 +35,23 @@ public class DirectFloatBufferTest extends FloatBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for direct FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct FloatBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct FloatBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -63,15 +59,13 @@ public class DirectFloatBufferTest extends FloatBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct FloatBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -80,27 +74,23 @@ public class DirectFloatBufferTest extends FloatBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for direct FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct FloatBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies order method for direct FloatBuffer.",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
index b28cab0..4e72a43 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectIntBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -26,6 +25,7 @@ import java.nio.ByteOrder;
@TestTargetClass(java.nio.IntBuffer.class)
public class DirectIntBufferTest extends IntBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*4).asIntBuffer();
loadTestData1(buf);
baseBuf = buf;
@@ -35,27 +35,23 @@ public class DirectIntBufferTest extends IntBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for direct IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct IntBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct IntBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -63,15 +59,13 @@ public class DirectIntBufferTest extends IntBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct IntBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -80,27 +74,23 @@ public class DirectIntBufferTest extends IntBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for direct IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct IntBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies order method for direct IntBuffer.",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
index c148aba..9653960 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectLongBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -26,6 +25,7 @@ import java.nio.ByteOrder;
@TestTargetClass(java.nio.LongBuffer.class)
public class DirectLongBufferTest extends LongBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*8).asLongBuffer();
loadTestData1(buf);
baseBuf = buf;
@@ -35,27 +35,23 @@ public class DirectLongBufferTest extends LongBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for direct LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct LongBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct LongBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -63,15 +59,13 @@ public class DirectLongBufferTest extends LongBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct LongBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -80,27 +74,23 @@ public class DirectLongBufferTest extends LongBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for direct LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct LongBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies order method for direct LongBuffer.",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
index 184adb9..a76701f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DirectShortBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -26,6 +25,7 @@ import java.nio.ByteOrder;
@TestTargetClass(java.nio.ShortBuffer.class)
public class DirectShortBufferTest extends ShortBufferTest {
public void setUp(){
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocateDirect(BUFFER_LENGTH*2).asShortBuffer();
loadTestData1(buf);
baseBuf = buf;
@@ -35,27 +35,23 @@ public class DirectShortBufferTest extends ShortBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for direct ShortBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies array method for direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies array method for direct ShortBuffer.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -63,15 +59,13 @@ public class DirectShortBufferTest extends ShortBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies arrayOffset method for direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies arrayOffset method for direct ShortBuffer.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
@@ -80,27 +74,23 @@ public class DirectShortBufferTest extends ShortBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for direct ShortBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertTrue(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies order method for direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies order method for direct ShortBuffer.",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.BIG_ENDIAN, buf.order());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
index 64b0c97..44f0ae7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DoubleBufferTest.java
@@ -17,9 +17,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -42,6 +41,7 @@ public class DoubleBufferTest extends AbstractBufferTest {
protected DoubleBuffer buf;
protected void setUp() throws Exception {
+ capacity = BUFFER_LENGTH;
buf = DoubleBuffer.allocate(BUFFER_LENGTH);
loadTestData1(buf);
baseBuf = buf;
@@ -57,22 +57,28 @@ public class DoubleBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check DoubleBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verifies boundary value.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: DoubleBuffer testBuf properties is satisfy the conditions
// specification
DoubleBuffer testBuf = DoubleBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = DoubleBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -87,15 +93,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
* Test with bit sequences that represent the IEEE754 doubles Positive
* infinity, negative infinity, and NaN.
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies boundary values.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies boundary values.",
+ method = "put",
+ args = {double.class}
+ )
public void testNaNs() {
long[] nans = new long[] { 0x7ff0000000000000L, 0xfff0000000000000L,
0x7ff8000000000000L };
@@ -116,15 +119,13 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertTrue(longBitsIn == bufLongOut);
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArrayOffset.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
double array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -141,40 +142,36 @@ public class DoubleBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArray.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
double array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ DoubleBuffer wrapped = DoubleBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -197,16 +194,28 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertEquals(buf.position(), buf.limit());
buf.reset();
assertEquals(buf.position(), 0);
+
+ // BEGIN android-added
+ // copied from a newer version of Harmony
+ DoubleBuffer dbuffer1 = DoubleBuffer.wrap(new double[] { Double.NaN });
+ DoubleBuffer dbuffer2 = DoubleBuffer.wrap(new double[] { Double.NaN });
+ DoubleBuffer dbuffer3 = DoubleBuffer.wrap(new double[] { 42d });
+
+ assertEquals("Failed equal comparison with NaN entry", 0, dbuffer1
+ .compareTo(dbuffer2));
+ assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer3
+ .compareTo(dbuffer1));
+ assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer1
+ .compareTo(dbuffer3));
+ // END android-added
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -257,15 +266,13 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.DoubleBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.DoubleBuffer.class}
+ )
public void testCompareTo() {
DoubleBuffer other = DoubleBuffer.allocate(buf.capacity());
loadTestData1(other);
@@ -281,27 +288,14 @@ public class DoubleBufferTest extends AbstractBufferTest {
other.limit(5);
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
-
- DoubleBuffer dbuffer1 = DoubleBuffer.wrap(new double[] { Double.NaN });
- DoubleBuffer dbuffer2 = DoubleBuffer.wrap(new double[] { Double.NaN });
- DoubleBuffer dbuffer3 = DoubleBuffer.wrap(new double[] { 42d });
-
- assertEquals("Failed equal comparison with NaN entry", 0, dbuffer1
- .compareTo(dbuffer2));
- assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer3
- .compareTo(dbuffer1));
- assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer1
- .compareTo(dbuffer3));
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -334,15 +328,13 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -368,15 +360,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for double get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -394,15 +383,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer get(double[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {double[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {double[].class}
+ )
public void testGetdoubleArray() {
double array[] = new double[1];
buf.clear();
@@ -412,26 +398,33 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i), 0.01);
assertSame(ret, buf);
}
+
+ buf.get(new double[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
+ try {
+ buf.get((double[])null);
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (NullPointerException e) {
+ // expected
+ }
}
/*
* Class under test for java.nio.DoubleBuffer get(double[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {double[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {double[].class, int.class, int.class}
+ )
public void testGetdoubleArrayintint() {
buf.clear();
double array[] = new double[buf.capacity()];
@@ -499,15 +492,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for double get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -527,27 +517,35 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify false returned value.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertTrue(buf.hasArray());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
DoubleBuffer readonly = buf.asReadOnlyBuffer();
@@ -558,27 +556,23 @@ public class DoubleBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify direct buffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify direct buffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
@@ -586,15 +580,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify boundary values, and ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify boundary values, and ReadOnlyBufferException.",
+ method = "put",
+ args = {double.class}
+ )
public void testPutdouble() {
buf.clear();
@@ -615,15 +606,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {double[].class}
+ )
public void testPutdoubleArray() {
double array[] = new double[1];
@@ -646,15 +634,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(double[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {double[].class, int.class, int.class}
+ )
public void testPutdoubleArrayintint() {
buf.clear();
double array[] = new double[buf.capacity()];
@@ -722,15 +707,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(java.nio.DoubleBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.DoubleBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.DoubleBuffer.class}
+ )
public void testPutDoubleBuffer() {
DoubleBuffer other = DoubleBuffer.allocate(buf.capacity());
@@ -760,15 +742,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.DoubleBuffer put(int, double)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, double.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, double.class}
+ )
public void testPutintdouble() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -790,15 +769,13 @@ public class DoubleBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -827,15 +804,13 @@ public class DoubleBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500, 0.0);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Double") >= 0 || str.indexOf("double") >= 0);
@@ -850,15 +825,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
* case for check equal between buf2 and double array[] 3. case for check a
* buf2 dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {double[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {double[].class}
+ )
public void test_Wrap$D() {
double array[] = new double[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -885,15 +857,12 @@ public class DoubleBufferTest extends AbstractBufferTest {
* 3. case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {double[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {double[].class, int.class, int.class}
+ )
public void test_Wrap$DII() {
double array[] = new double[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
index 29af679..1335bb8 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateHeapByteBufferTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
index 7b38bac..d967387 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/DuplicateWrappedByteBufferTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
index 67f2c2d..f140dd2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java
@@ -17,15 +17,14 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.InvalidMarkException;
@@ -43,6 +42,7 @@ public class FloatBufferTest extends AbstractBufferTest {
protected FloatBuffer buf;
protected void setUp() throws Exception {
+ capacity = BUFFER_LENGTH;
buf = FloatBuffer.allocate(BUFFER_LENGTH);
loadTestData1(buf);
baseBuf = buf;
@@ -58,22 +58,28 @@ public class FloatBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check FloatBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify boundary case.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: FloatBuffer testBuf properties is satisfy the conditions
// specification
FloatBuffer testBuf = FloatBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = FloatBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -83,15 +89,39 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArrayOffset.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies boundary values.",
+ method = "put",
+ args = {float.class}
+ )
+ public void testNaNs() {
+ int[] nans = new int[] { 0x7f800000, 0xff800000, 0x7fc00000 };
+ for (int i = 0; i < nans.length; i++) {
+ int intBitsIn = nans[i];
+ float flt = Float.intBitsToFloat(intBitsIn);
+ int intBitsOut = Float.floatToRawIntBits(flt);
+ // Sanity check
+ assertTrue(intBitsIn == intBitsOut);
+
+ // Store the float and retrieve it
+ ByteBuffer buffer = ByteBuffer.allocate(8);
+ buffer.putFloat(flt);
+ float bufFloatOut = buffer.getFloat(0);
+
+ // Check the bits sequence was not normalized
+ int bufIntOut = Float.floatToRawIntBits(bufFloatOut);
+ assertTrue(intBitsIn == bufIntOut);
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
float array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -108,40 +138,36 @@ public class FloatBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArray.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
float array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ FloatBuffer wrapped = FloatBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -165,15 +191,13 @@ public class FloatBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
@@ -225,15 +249,13 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.FloatBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.FloatBuffer.class}
+ )
public void testCompareTo() {
try {
buf.compareTo(null);
@@ -262,7 +284,9 @@ public class FloatBufferTest extends AbstractBufferTest {
other.limit(5);
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
-
+
+ // BEGIN android-added
+ // copied from a newer version of Harmony
FloatBuffer fbuffer1 = FloatBuffer.wrap(new float[] { Float.NaN });
FloatBuffer fbuffer2 = FloatBuffer.wrap(new float[] { Float.NaN });
FloatBuffer fbuffer3 = FloatBuffer.wrap(new float[] { 42f });
@@ -273,17 +297,15 @@ public class FloatBufferTest extends AbstractBufferTest {
.compareTo(fbuffer1));
assertEquals("Failed greater than comparison with NaN entry", 1, fbuffer1
.compareTo(fbuffer3));
-
+ // END android-added
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -315,15 +337,13 @@ public class FloatBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -349,15 +369,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for float get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -375,15 +392,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer get(float[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {float[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {float[].class}
+ )
public void testGetfloatArray() {
float array[] = new float[1];
buf.clear();
@@ -393,34 +407,33 @@ public class FloatBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i), 0.01);
assertSame(ret, buf);
}
+
+ buf.get(new float[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
try {
- buf.position(buf.limit());
buf.get((float[])null);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (NullPointerException e) {
// expected
}
- buf.get(new float[0]);
}
/*
* Class under test for java.nio.FloatBuffer get(float[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {float[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {float[].class, int.class, int.class}
+ )
public void testGetfloatArrayintint() {
buf.clear();
float array[] = new float[buf.capacity()];
@@ -488,15 +501,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for float get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -516,27 +526,35 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that array method doesn't return null.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertNotNull(buf.array());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
FloatBuffer readonly = buf.asReadOnlyBuffer();
@@ -547,27 +565,23 @@ public class FloatBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify direct buffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify direct buffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
buf.order();
if (buf.hasArray()) {
@@ -578,15 +592,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {float.class}
+ )
public void testPutfloat() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -606,15 +617,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {float[].class}
+ )
public void testPutfloatArray() {
float array[] = new float[1];
buf.clear();
@@ -643,15 +651,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(float[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {float[].class, int.class, int.class}
+ )
public void testPutfloatArrayintint() {
buf.clear();
float array[] = new float[buf.capacity()];
@@ -718,15 +723,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(java.nio.FloatBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.FloatBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.FloatBuffer.class}
+ )
public void testPutFloatBuffer() {
FloatBuffer other = FloatBuffer.allocate(buf.capacity());
try {
@@ -762,15 +764,12 @@ public class FloatBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.FloatBuffer put(int, float)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, float.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, float.class}
+ )
public void testPutintfloat() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -792,15 +791,13 @@ public class FloatBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -828,15 +825,13 @@ public class FloatBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500, 0.0);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Float") >= 0 || str.indexOf("float") >= 0);
@@ -851,15 +846,12 @@ public class FloatBufferTest extends AbstractBufferTest {
* for check equal between buf2 and float array[] 3. case for check a buf2
* dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {float[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {float[].class}
+ )
public void test_Wrap$S() {
float array[] = new float[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -886,15 +878,12 @@ public class FloatBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {float[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {float[].class, int.class, int.class}
+ )
public void test_Wrap$SII() {
float array[] = new float[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
index 13949e6..046350f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapByteBufferTest.java
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -28,6 +26,7 @@ public class HeapByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.allocate(BUFFER_LENGTH);
baseBuf = buf;
}
@@ -42,15 +41,12 @@ public class HeapByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocate(int)
*
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedByteBuffer_IllegalArg() {
try {
ByteBuffer.allocate(-1);
@@ -59,39 +55,34 @@ public class HeapByteBufferTest extends ByteBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isDirect method with not direct buffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method with not direct buffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that hasArray returns true value.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that hasArray returns true value.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertTrue(buf.hasArray());
+ assertNotNull(buf.array());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method with non read only buffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method with non read only buffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
index ba9e681..5c370a2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapCharBufferTest.java
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.CharBuffer;
@@ -27,9 +25,6 @@ import java.nio.CharBuffer;
public class HeapCharBufferTest extends CharBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = CharBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -37,15 +32,13 @@ public class HeapCharBufferTest extends CharBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedCharBuffer_IllegalArg() {
try {
CharBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
index e5f8c3e..ddef05f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapDoubleBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.DoubleBuffer;
@@ -26,9 +25,6 @@ import java.nio.DoubleBuffer;
public class HeapDoubleBufferTest extends DoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = DoubleBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -36,15 +32,13 @@ public class HeapDoubleBufferTest extends DoubleBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedDoubleBuffer_IllegalArg() {
try {
DoubleBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
index 2d1f7fd..2a323c5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapFloatBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.FloatBuffer;
@@ -26,9 +25,6 @@ import java.nio.FloatBuffer;
public class HeapFloatBufferTest extends FloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = FloatBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -36,15 +32,13 @@ public class HeapFloatBufferTest extends FloatBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedFloatBuffer_IllegalArg() {
try {
FloatBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
index 946f75c..b92f7c6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapIntBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.IntBuffer;
@@ -26,9 +25,6 @@ import java.nio.IntBuffer;
public class HeapIntBufferTest extends IntBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = IntBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -36,15 +32,13 @@ public class HeapIntBufferTest extends IntBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedIntBuffer_IllegalArg() {
try {
IntBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
index a08d93e..7beedbb 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapLongBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.LongBuffer;
@@ -26,9 +25,6 @@ import java.nio.LongBuffer;
public class HeapLongBufferTest extends LongBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = LongBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -36,15 +32,13 @@ public class HeapLongBufferTest extends LongBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedLongBuffer_IllegalArg() {
try {
LongBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
index 15d7f0a..4de5229 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/HeapShortBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ShortBuffer;
@@ -26,9 +25,6 @@ import java.nio.ShortBuffer;
public class HeapShortBufferTest extends ShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = ShortBuffer.allocate(BUFFER_LENGTH);
- loadTestData1(buf);
- baseBuf = buf;
}
protected void tearDown() throws Exception {
@@ -36,15 +32,13 @@ public class HeapShortBufferTest extends ShortBufferTest {
buf = null;
baseBuf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "allocate",
+ args = {int.class}
+ )
public void testAllocatedShortBuffer_IllegalArg() {
try {
ShortBuffer.allocate(-1);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
index 308bfd6..1f26d5e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/IntBufferTest.java
@@ -17,9 +17,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -43,6 +42,7 @@ public class IntBufferTest extends AbstractBufferTest {
protected IntBuffer buf;
protected void setUp() throws Exception {
+ capacity = BUFFER_LENGTH;
buf = IntBuffer.allocate(BUFFER_LENGTH);
loadTestData1(buf);
baseBuf = buf;
@@ -58,22 +58,28 @@ public class IntBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check IntBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't veify boundary values.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: IntBuffer testBuf properties is satisfy the conditions
// specification
IntBuffer testBuf = IntBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = IntBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -83,15 +89,13 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArrayOffset.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
int array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -108,40 +112,36 @@ public class IntBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArray.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
int array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ IntBuffer wrapped = IntBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -165,15 +165,13 @@ public class IntBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -224,15 +222,13 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.IntBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.IntBuffer.class}
+ )
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -255,15 +251,13 @@ public class IntBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -295,15 +289,13 @@ public class IntBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -329,15 +321,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for int get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -355,15 +344,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer get(int[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int[].class}
+ )
public void testGetintArray() {
int array[] = new int[1];
buf.clear();
@@ -373,12 +359,16 @@ public class IntBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i));
assertSame(ret, buf);
}
+
+ buf.get(new int[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
try {
buf.get((int[])null);
fail("Should throw NPE"); //$NON-NLS-1$
@@ -390,15 +380,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer get(int[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int[].class, int.class, int.class}
+ )
public void testGetintArrayintint() {
buf.clear();
int array[] = new int[buf.capacity()];
@@ -466,15 +453,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for int get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -494,27 +478,35 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that array method doesn't return null.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertNotNull(buf.array());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
IntBuffer readonly = buf.asReadOnlyBuffer();
@@ -525,44 +517,36 @@ public class IntBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for non direct buffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for non direct buffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
- buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
/*
* Class under test for java.nio.IntBuffer put(int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class}
+ )
public void testPutint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -582,15 +566,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int[].class}
+ )
public void testPutintArray() {
int array[] = new int[1];
buf.clear();
@@ -619,15 +600,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int[].class, int.class, int.class}
+ )
public void testPutintArrayintint() {
buf.clear();
int array[] = new int[buf.capacity()];
@@ -694,15 +672,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(java.nio.IntBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.IntBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.IntBuffer.class}
+ )
public void testPutIntBuffer() {
IntBuffer other = IntBuffer.allocate(buf.capacity());
try {
@@ -738,15 +713,12 @@ public class IntBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.IntBuffer put(int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, int.class}
+ )
public void testPutintint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -768,15 +740,13 @@ public class IntBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -804,15 +774,13 @@ public class IntBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Int") >= 0 || str.indexOf("int") >= 0);
@@ -827,15 +795,12 @@ public class IntBufferTest extends AbstractBufferTest {
* equal between buf2 and int array[] 3. case for check a buf2 dependens to
* array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {int[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {int[].class}
+ )
public void test_Wrap$I() {
int array[] = new int[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -862,15 +827,12 @@ public class IntBufferTest extends AbstractBufferTest {
* for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {int[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {int[].class, int.class, int.class}
+ )
public void test_Wrap$III() {
int array[] = new int[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
index b18d3da..3fd32f5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.InvalidMarkException;
@@ -32,15 +31,12 @@ public class InvalidMarkExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ )
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new InvalidMarkException());
@@ -49,17 +45,33 @@ public class InvalidMarkExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ )
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new InvalidMarkException());
}
+
+ // BEGIN android-added
+ // copied from newer version of harmony
+ /**
+ *@tests {@link java.nio.InvalidMarkException#InvalidMarkException()}
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "InvalidMarkException",
+ args = {}
+ )
+ public void test_Constructor() {
+ InvalidMarkException exception = new InvalidMarkException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getLocalizedMessage());
+ assertNull(exception.getCause());
+ }
+ // END android-added
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
index 1529df7..c608f70 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/LongBufferTest.java
@@ -17,9 +17,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -43,6 +42,7 @@ public class LongBufferTest extends AbstractBufferTest {
protected LongBuffer buf;
protected void setUp() throws Exception {
+ capacity = BUFFER_LENGTH;
buf = LongBuffer.allocate(BUFFER_LENGTH);
loadTestData1(buf);
baseBuf = buf;
@@ -58,22 +58,28 @@ public class LongBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check LongBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify boundary value.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: LongBuffer testBuf properties is satisfy the conditions
// specification
LongBuffer testBuf = LongBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = LongBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -83,15 +89,13 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArrayOffset.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
long array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -108,40 +112,36 @@ public class LongBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArray.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
long array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ LongBuffer wrapped = LongBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -165,15 +165,13 @@ public class LongBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -224,15 +222,13 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.LongBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.LongBuffer.class}
+ )
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -255,15 +251,13 @@ public class LongBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -295,15 +289,13 @@ public class LongBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -329,15 +321,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for long get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -355,15 +344,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer get(long[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {long[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {long[].class}
+ )
public void testGetlongArray() {
long array[] = new long[1];
buf.clear();
@@ -373,14 +359,17 @@ public class LongBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i));
assertSame(ret, buf);
}
+
+ buf.get(new long[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
try {
- buf.position(buf.limit());
buf.get((long[])null);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (NullPointerException e) {
@@ -391,15 +380,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer get(long[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {long[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {long[].class, int.class, int.class}
+ )
public void testGetlongArrayintint() {
buf.clear();
long array[] = new long[buf.capacity()];
@@ -467,15 +453,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for long get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -495,27 +478,35 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that array method doesn't return null.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertNotNull(buf.array());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
LongBuffer readonly = buf.asReadOnlyBuffer();
@@ -526,44 +517,36 @@ public class LongBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for non direct buffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for non direct buffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
- buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
/*
* Class under test for java.nio.LongBuffer put(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {long.class}
+ )
public void testPutlong() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -583,15 +566,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(long[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {long[].class}
+ )
public void testPutlongArray() {
long array[] = new long[1];
buf.clear();
@@ -620,15 +600,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(long[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {long[].class, int.class, int.class}
+ )
public void testPutlongArrayintint() {
buf.clear();
long array[] = new long[buf.capacity()];
@@ -701,15 +678,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(java.nio.LongBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.LongBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.LongBuffer.class}
+ )
public void testPutLongBuffer() {
LongBuffer other = LongBuffer.allocate(buf.capacity());
try {
@@ -745,15 +719,12 @@ public class LongBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.LongBuffer put(int, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, long.class}
+ )
public void testPutintlong() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -775,15 +746,13 @@ public class LongBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -811,15 +780,13 @@ public class LongBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Long") >= 0 || str.indexOf("long") >= 0);
@@ -834,15 +801,12 @@ public class LongBufferTest extends AbstractBufferTest {
* for check equal between buf2 and ling array[] 3. case for check a buf2
* dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {long[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {long[].class}
+ )
public void test_Wrap$L() {
long array[] = new long[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -869,15 +833,12 @@ public class LongBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {long[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {long[].class, int.class, int.class}
+ )
public void test_Wrap$LII() {
long array[] = new long[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java
index 60c50ae..d9eefaf 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java
@@ -15,8 +15,16 @@
* limitations under the License.
*/
+// BEGIN android-note
+// This test was copied from a newer version of Harmony
+// END android-note
+
package org.apache.harmony.nio.tests.java.nio;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargetClass;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -30,6 +38,16 @@ import java.nio.channels.FileChannel.MapMode;
import junit.framework.TestCase;
+@TestTargetClass(
+ value = MappedByteBuffer.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_FEASIBLE,
+ method = "isLoaded",
+ args = {}
+ )
+ }
+)
public class MappedByteBufferTest extends TestCase {
File tmpFile;
@@ -38,7 +56,13 @@ public class MappedByteBufferTest extends TestCase {
* A regression test for failing to correctly set capacity of underlying
* wrapped buffer from a mapped byte buffer.
*/
- public void testasIntBuffer() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "A regression test for failing to correctly set capacity",
+ method = "asIntBuffer",
+ args = {}
+ )
+ public void test_asIntBuffer() throws IOException {
// Map file
FileInputStream fis = new FileInputStream(tmpFile);
FileChannel fc = fis.getChannel();
@@ -65,6 +89,12 @@ public class MappedByteBufferTest extends TestCase {
/**
* @tests {@link java.nio.MappedByteBuffer#force()}
*/
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "force",
+ args = {}
+ )
public void test_force() throws IOException {
// buffer was not mapped in read/write mode
FileInputStream fileInputStream = new FileInputStream(tmpFile);
@@ -110,12 +140,18 @@ public class MappedByteBufferTest extends TestCase {
/**
* @tests {@link java.nio.MappedByteBuffer#load()}
*/
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "load",
+ args = {}
+ )
public void test_load() throws IOException {
FileInputStream fileInputStream = new FileInputStream(tmpFile);
FileChannel fileChannelRead = fileInputStream.getChannel();
MappedByteBuffer mmbRead = fileChannelRead.map(MapMode.READ_ONLY, 0,
fileChannelRead.size());
-
+
assertEquals(mmbRead, mmbRead.load());
RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
@@ -124,14 +160,15 @@ public class MappedByteBufferTest extends TestCase {
FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
assertEquals(mmbReadWrite, mmbReadWrite.load());
-
+
fileChannelRead.close();
fileChannelReadWrite.close();
}
protected void setUp() throws IOException {
// Create temp file with 26 bytes and 5 ints
- tmpFile = File.createTempFile("harmony", "test"); //$NON-NLS-1$//$NON-NLS-2$
+ tmpFile = new File(System.getProperty("ctsdir"), "MappedByteBufferTest"); //$NON-NLS-1$//$NON-NLS-2$
+ tmpFile.createNewFile();
tmpFile.deleteOnExit();
FileOutputStream fileOutputStream = new FileOutputStream(tmpFile);
FileChannel fileChannel = fileOutputStream.getChannel();
@@ -147,4 +184,4 @@ public class MappedByteBufferTest extends TestCase {
fileChannel.close();
fileOutputStream.close();
}
-}
+} \ No newline at end of file
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
index 7a8dc4c..8c97ae0 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java
@@ -15,9 +15,9 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ReadOnlyBufferException;
@@ -32,15 +32,20 @@ public class ReadOnlyBufferExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "ReadOnlyBufferException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ReadOnlyBufferException());
@@ -49,17 +54,41 @@ public class ReadOnlyBufferExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "ReadOnlyBufferException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ReadOnlyBufferException());
}
+
+ // BEGIN android-added
+ // copied from newer version of harmony
+ /**
+ *@tests {@link java.nio.ReadOnlyBufferException#ReadOnlyBufferException()}
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "ReadOnlyBufferException",
+ args = {}
+ )
+ public void test_Constructor() {
+ ReadOnlyBufferException exception = new ReadOnlyBufferException();
+ assertNull(exception.getMessage());
+ assertNull(exception.getLocalizedMessage());
+ assertNull(exception.getCause());
+ }
+ // END android-added
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
index 69ae84c..e5d3573 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyCharBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.CharBuffer;
@@ -28,7 +27,6 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
protected void setUp() throws Exception {
super.setUp();
- loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
baseBuf = buf;
}
@@ -38,41 +36,33 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
baseBuf = null;
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that isReadOnly returns true for read only " +
- "CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that isReadOnly returns true for read only CharBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that hasArray returns false for read only " +
- "CharBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that hasArray returns false for read only CharBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -80,44 +70,38 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
} catch (ReadOnlyBufferException e) {
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
CharBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -126,15 +110,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {char.class}
+ )
public void testPutchar() {
try {
buf.put((char) 0);
@@ -143,15 +125,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException and NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException and NullPointerException.",
+ method = "put",
+ args = {char[].class}
+ )
public void testPutcharArray() {
char array[] = new char[1];
try {
@@ -167,15 +147,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {char[].class, int.class, int.class}
+ )
public void testPutcharArrayintint() {
char array[] = new char[1];
try {
@@ -203,15 +181,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.CharBuffer.class}
+ )
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(1);
try {
@@ -233,15 +209,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, char.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, char.class}
+ )
public void testPutintchar() {
try {
buf.put(0, (char) 0);
@@ -256,15 +230,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.lang.String.class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.lang.String.class, int.class, int.class}
+ )
public void testPutStringintint() {
buf.clear();
String str = String.valueOf(new char[buf.capacity()]);
@@ -294,15 +266,13 @@ public class ReadOnlyCharBufferTest extends CharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.lang.String.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.lang.String.class}
+ )
public void testPutString() {
String str = " ";
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
index d1a5265..e51f013 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDirectByteBufferTest.java
@@ -16,9 +16,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -33,41 +32,25 @@ public class ReadOnlyDirectByteBufferTest extends DirectByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only ByteBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that hasArray method returns false.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
- public void testHasArray() {
- assertFalse(buf.hasArray());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
- super.readOnlyHashCode();
+ super.readOnlyHashCode(true);
}
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
index 46522c2..056c2e2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyDoubleBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.DoubleBuffer;
@@ -35,39 +34,33 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only DoubleBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only DoubleBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that hasArray returns false value.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that hasArray returns false value.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -75,44 +68,38 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
} catch (ReadOnlyBufferException e) {
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
DoubleBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -121,15 +108,13 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {double.class}
+ )
public void testPutdouble() {
try {
buf.put(0);
@@ -138,15 +123,13 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {double[].class}
+ )
public void testPutdoubleArray() {
double array[] = new double[1];
try {
@@ -162,15 +145,13 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {double[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {double[].class, int.class, int.class}
+ )
public void testPutdoubleArrayintint() {
double array[] = new double[1];
try {
@@ -198,15 +179,13 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.DoubleBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.DoubleBuffer.class}
+ )
public void testPutDoubleBuffer() {
DoubleBuffer other = DoubleBuffer.allocate(1);
try {
@@ -228,15 +207,13 @@ public class ReadOnlyDoubleBufferTest extends DoubleBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, double.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, double.class}
+ )
public void testPutintdouble() {
try {
buf.put(0, (double) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
index 1edcecb..6bb572d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyFloatBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.FloatBuffer;
@@ -34,40 +33,33 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only FloatBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that hasArray returns false for Read Only " +
- "FloatBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that hasArray returns false for Read Only FloatBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -76,45 +68,39 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
FloatBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -123,15 +109,13 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {float.class}
+ )
public void testPutfloat() {
try {
buf.put(0);
@@ -140,15 +124,13 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {float[].class}
+ )
public void testPutfloatArray() {
float array[] = new float[1];
try {
@@ -164,15 +146,13 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {float[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {float[].class, int.class, int.class}
+ )
public void testPutfloatArrayintint() {
float array[] = new float[1];
try {
@@ -200,15 +180,13 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.FloatBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.FloatBuffer.class}
+ )
public void testPutFloatBuffer() {
FloatBuffer other = FloatBuffer.allocate(1);
try {
@@ -230,15 +208,13 @@ public class ReadOnlyFloatBufferTest extends FloatBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, float.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, float.class}
+ )
public void testPutintfloat() {
try {
buf.put(0, (float) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
index 7c0f093..a0a04ff 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapByteBufferTest.java
@@ -16,9 +16,10 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import java.nio.ReadOnlyBufferException;
+
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -33,40 +34,70 @@ public class ReadOnlyHeapByteBufferTest extends HeapByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
+ public void testArray() {
+ try {
+ buf.array();
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
+ public void testArrayOffset() {
+ try {
+ buf.arrayOffset();
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only ByteBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies false returned value.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies false returned value.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
- super.readOnlyHashCode();
+ super.readOnlyHashCode(false);
}
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
index e5a437d..610e498 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapCharBufferTest.java
@@ -16,22 +16,13 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import java.nio.CharBuffer;
-
@TestTargetClass(java.nio.CharBuffer.class)
public class ReadOnlyHeapCharBufferTest extends ReadOnlyCharBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = CharBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
index 8848e21..ea3b647 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapDoubleBufferTest.java
@@ -15,22 +15,13 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import java.nio.DoubleBuffer;
-
@TestTargetClass(java.nio.DoubleBuffer.class)
public class ReadOnlyHeapDoubleBufferTest extends ReadOnlyDoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = DoubleBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
index 6cda42c..8439b88 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapFloatBufferTest.java
@@ -15,22 +15,13 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestLevel;
-
-import java.nio.FloatBuffer;
@TestTargetClass(java.nio.FloatBuffer.class)
public class ReadOnlyHeapFloatBufferTest extends ReadOnlyFloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = FloatBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
index 098b9ab..7ce3057 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapIntBufferTest.java
@@ -15,22 +15,13 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import java.nio.IntBuffer;
-
@TestTargetClass(java.nio.IntBuffer.class)
public class ReadOnlyHeapIntBufferTest extends ReadOnlyIntBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = IntBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
index 6e14615..e3cbbbc 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapLongBufferTest.java
@@ -15,22 +15,13 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import java.nio.LongBuffer;
-
@TestTargetClass(java.nio.LongBuffer.class)
public class ReadOnlyHeapLongBufferTest extends ReadOnlyLongBufferTest{
protected void setUp() throws Exception {
super.setUp();
- buf = LongBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
index 4d38aa7..77d0d0b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyHeapShortBufferTest.java
@@ -15,22 +15,13 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestLevel;
-
-import java.nio.ShortBuffer;
@TestTargetClass(java.nio.ShortBuffer.class)
public class ReadOnlyHeapShortBufferTest extends ReadOnlyShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
- buf = ShortBuffer.allocate(BUFFER_LENGTH);
- super.loadTestData1(buf);
- buf = buf.asReadOnlyBuffer();
- baseBuf = buf;
}
protected void tearDown() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
index 6c97ae2..3da8d2f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyIntBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.IntBuffer;
@@ -34,40 +33,33 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only IntBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method returns false for read only " +
- "IntBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method returns false for read only IntBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -76,45 +68,39 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
IntBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -123,15 +109,13 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class}
+ )
public void testPutint() {
try {
buf.put(0);
@@ -140,15 +124,13 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int[].class}
+ )
public void testPutintArray() {
int array[] = new int[1];
try {
@@ -164,15 +146,13 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int[].class, int.class, int.class}
+ )
public void testPutintArrayintint() {
int array[] = new int[1];
try {
@@ -200,15 +180,13 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.IntBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.IntBuffer.class}
+ )
public void testPutIntBuffer() {
IntBuffer other = IntBuffer.allocate(1);
try {
@@ -230,15 +208,13 @@ public class ReadOnlyIntBufferTest extends IntBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, int.class}
+ )
public void testPutintint() {
try {
buf.put(0, (int) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
index b299d06..5337b3c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyLongBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.LongBuffer;
@@ -34,40 +33,33 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only LongBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that hasArray method returns false for read only " +
- "LongBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that hasArray method returns false for read only LongBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -76,45 +68,39 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
LongBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -123,15 +109,13 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {long.class}
+ )
public void testPutlong() {
try {
buf.put(0);
@@ -140,15 +124,13 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {long[].class}
+ )
public void testPutlongArray() {
long array[] = new long[1];
try {
@@ -164,15 +146,13 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {long[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {long[].class, int.class, int.class}
+ )
public void testPutlongArrayintint() {
long array[] = new long[1];
try {
@@ -200,15 +180,13 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.LongBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.LongBuffer.class}
+ )
public void testPutLongBuffer() {
LongBuffer other = LongBuffer.allocate(1);
try {
@@ -230,15 +208,13 @@ public class ReadOnlyLongBufferTest extends LongBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, long.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, long.class}
+ )
public void testPutintlong() {
try {
buf.put(0, (long) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
index 13c2558..a5aaa90 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyShortBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ReadOnlyBufferException;
@@ -34,39 +33,33 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only ShortBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for read only ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for read only ShortBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -75,45 +68,39 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
//expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
ShortBuffer duplicate = buf.duplicate();
assertEquals(buf.hashCode(), duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
try {
buf.arrayOffset();
- fail("Should throw Exception"); //$NON-NLS-1$
- } catch (UnsupportedOperationException e) {
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
//expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
try {
buf.compact();
@@ -122,15 +109,13 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {short.class}
+ )
public void testPutshort() {
try {
buf.put((short)0);
@@ -139,15 +124,13 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short[].class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {short[].class}
+ )
public void testPutshortArray() {
short array[] = new short[1];
try {
@@ -163,15 +146,13 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {short[].class, int.class, int.class}
+ )
public void testPutshortArrayintint() {
short array[] = new short[1];
try {
@@ -199,15 +180,13 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.ShortBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.ShortBuffer.class}
+ )
public void testPutShortBuffer() {
ShortBuffer other = ShortBuffer.allocate(1);
try {
@@ -229,15 +208,13 @@ public class ReadOnlyShortBufferTest extends ShortBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, short.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, short.class}
+ )
public void testPutintshort() {
try {
buf.put(0, (short) 0);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
index b5e1ae0..5986d96 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedByteBufferTest.java
@@ -16,9 +16,10 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
+import java.nio.ReadOnlyBufferException;
+
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -33,42 +34,71 @@ public class ReadOnlyWrappedByteBufferTest extends WrappedByteBufferTest {
protected void tearDown() throws Exception {
super.tearDown();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isReadOnly method for read only wrapped " +
- "ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
+ public void testArray() {
+ try {
+ buf.array();
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
+ public void testArrayOffset() {
+ try {
+ buf.arrayOffset();
+ fail("Should throw ReadOnlyBufferException"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isReadOnly method for read only wrapped ByteBuffer.",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertTrue(buf.isReadOnly());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for read only wrapped ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for read only wrapped ByteBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertFalse(buf.hasArray());
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (ReadOnlyBufferException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
- super.readOnlyHashCode();
+ super.readOnlyHashCode(false);
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
index 481dd9c..259e3d9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedCharBufferTest1.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.CharBuffer;
@@ -28,6 +25,7 @@ public class ReadOnlyWrappedCharBufferTest1 extends ReadOnlyCharBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = CharBuffer.wrap(new char[BUFFER_LENGTH]);
super.loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
index bdd6066..21951cf 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedDoubleBufferTest.java
@@ -15,9 +15,6 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.DoubleBuffer;
@@ -27,6 +24,7 @@ public class ReadOnlyWrappedDoubleBufferTest extends ReadOnlyDoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = DoubleBuffer.wrap(new double[BUFFER_LENGTH]);
super.loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
index 7e4d28b..cfbca11 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedFloatBufferTest.java
@@ -15,9 +15,6 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.FloatBuffer;
@@ -27,6 +24,7 @@ public class ReadOnlyWrappedFloatBufferTest extends ReadOnlyFloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = FloatBuffer.wrap(new float[BUFFER_LENGTH]);
super.loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
index 3c560bb..a9210d2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedIntBufferTest.java
@@ -15,9 +15,6 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.IntBuffer;
@@ -27,8 +24,9 @@ public class ReadOnlyWrappedIntBufferTest extends ReadOnlyIntBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = IntBuffer.wrap(new int[BUFFER_LENGTH]);
- super.loadTestData1(buf);
+ loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
baseBuf = buf;
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
index b23001a..392d9c5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedLongBufferTest.java
@@ -15,9 +15,6 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.LongBuffer;
@@ -27,8 +24,9 @@ public class ReadOnlyWrappedLongBufferTest extends ReadOnlyLongBufferTest{
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = LongBuffer.wrap(new long[BUFFER_LENGTH]);
- super.loadTestData1(buf);
+ loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
baseBuf = buf;
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
index 97f1703..32e5c29 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyWrappedShortBufferTest.java
@@ -15,9 +15,6 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
import java.nio.ShortBuffer;
@@ -27,8 +24,9 @@ public class ReadOnlyWrappedShortBufferTest extends ReadOnlyShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = ShortBuffer.wrap(new short[BUFFER_LENGTH]);
- super.loadTestData1(buf);
+ loadTestData1(buf);
buf = buf.asReadOnlyBuffer();
baseBuf = buf;
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
index 997865a..13af578 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ShortBufferTest.java
@@ -17,9 +17,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -42,6 +41,7 @@ public class ShortBufferTest extends AbstractBufferTest {
protected ShortBuffer buf;
protected void setUp() throws Exception {
+ capacity = BUFFER_LENGTH;
buf = ShortBuffer.allocate(BUFFER_LENGTH);
loadTestData1(buf);
baseBuf = buf;
@@ -57,22 +57,28 @@ public class ShortBufferTest extends AbstractBufferTest {
* following usecases: 1. case for check ShortBuffer testBuf properties 2.
* case expected IllegalArgumentException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify boundary value.",
- targets = {
- @TestTarget(
- methodName = "allocate",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "allocate",
+ args = {int.class}
+ )
public void test_AllocateI() {
// case: ShortBuffer testBuf properties is satisfy the conditions
// specification
ShortBuffer testBuf = ShortBuffer.allocate(20);
- assertEquals(testBuf.position(), 0);
- assertEquals(testBuf.limit(), testBuf.capacity());
- assertEquals(testBuf.arrayOffset(), 0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(20, testBuf.limit());
+ assertEquals(20, testBuf.capacity());
+
+ testBuf = ShortBuffer.allocate(0);
+ assertEquals(0, testBuf.position());
+ assertNotNull(testBuf.array());
+ assertEquals(0, testBuf.arrayOffset());
+ assertEquals(0, testBuf.limit());
+ assertEquals(0, testBuf.capacity());
// case: expected IllegalArgumentException
try {
@@ -82,15 +88,13 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArrayOffset.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "array",
+ args = {}
+ )
public void testArray() {
short array[] = buf.array();
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
@@ -107,40 +111,36 @@ public class ShortBufferTest extends AbstractBufferTest {
loadTestData2(buf);
assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "The same test as testArray.",
- targets = {
- @TestTarget(
- methodName = "arrayOffset",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "arrayOffset",
+ args = {}
+ )
public void testArrayOffset() {
short array[] = buf.array();
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData1(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
-
- loadTestData2(array, buf.arrayOffset(), buf.capacity());
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ for(int i = 0; i < buf.capacity(); i++) {
+ array[i] = (short) i;
+ }
+ int offset = buf.arrayOffset();
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData1(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ ShortBuffer wrapped = ShortBuffer.wrap(array, 3, array.length - 3);
+
+ loadTestData1(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
- loadTestData2(buf);
- assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity());
+ loadTestData2(array, wrapped.arrayOffset(), wrapped.capacity());
+ assertContentEquals(buf, array, offset, buf.capacity());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "asReadOnlyBuffer",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "asReadOnlyBuffer",
+ args = {}
+ )
public void testAsReadOnlyBuffer() {
buf.clear();
buf.mark();
@@ -164,15 +164,13 @@ public class ShortBufferTest extends AbstractBufferTest {
buf.reset();
assertEquals(buf.position(), 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compact",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compact",
+ args = {}
+ )
public void testCompact() {
// case: buffer is full
buf.clear();
@@ -223,15 +221,13 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "compareTo",
- methodArgs = {java.nio.ShortBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "compareTo",
+ args = {java.nio.ShortBuffer.class}
+ )
public void testCompareTo() {
// compare to self
assertEquals(0, buf.compareTo(buf));
@@ -254,15 +250,13 @@ public class ShortBufferTest extends AbstractBufferTest {
assertTrue(buf.compareTo(other) > 0);
assertTrue(other.compareTo(buf) < 0);
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "duplicate",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "duplicate",
+ args = {}
+ )
public void testDuplicate() {
buf.clear();
buf.mark();
@@ -294,15 +288,13 @@ public class ShortBufferTest extends AbstractBufferTest {
assertContentEquals(buf, duplicate);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "equals",
- methodArgs = {java.lang.Object.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "equals",
+ args = {java.lang.Object.class}
+ )
public void testEquals() {
// equal to self
assertTrue(buf.equals(buf));
@@ -328,15 +320,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for short get()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {}
+ )
public void testGet() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -354,15 +343,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer get(short[])
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {short[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {short[].class}
+ )
public void testGetshortArray() {
short array[] = new short[1];
buf.clear();
@@ -372,26 +358,33 @@ public class ShortBufferTest extends AbstractBufferTest {
assertEquals(array[0], buf.get(i));
assertSame(ret, buf);
}
+
+ buf.get(new short[0]);
+
try {
buf.get(array);
fail("Should throw Exception"); //$NON-NLS-1$
} catch (BufferUnderflowException e) {
// expected
}
+
+ try {
+ buf.get((short[])null);
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (NullPointerException e) {
+ // expected
+ }
}
/*
* Class under test for java.nio.ShortBuffer get(short[], int, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {short[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {short[].class, int.class, int.class}
+ )
public void testGetshortArrayintint() {
buf.clear();
short array[] = new short[buf.capacity()];
@@ -453,15 +446,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for short get(int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "get",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "get",
+ args = {int.class}
+ )
public void testGetint() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -481,27 +471,35 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that array method doesn't return null.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
- assertNotNull(buf.array());
- }
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "hashCode",
- methodArgs = {}
- )
- })
+ if (buf.hasArray()) {
+ assertNotNull(buf.array());
+ } else {
+ try {
+ buf.array();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ // expected
+ // Note:can not tell when to catch
+ // UnsupportedOperationException or
+ // ReadOnlyBufferException, so catch all.
+ }
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "hashCode",
+ args = {}
+ )
public void testHashCode() {
buf.clear();
ShortBuffer readonly = buf.asReadOnlyBuffer();
@@ -512,44 +510,36 @@ public class ShortBufferTest extends AbstractBufferTest {
duplicate.position(buf.capacity() / 2);
assertTrue(buf.hashCode() != duplicate.hashCode());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies isDirect method for non direct ShortBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for non direct ShortBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "order",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "order",
+ args = {}
+ )
public void testOrder() {
- buf.order();
assertEquals(ByteOrder.nativeOrder(), buf.order());
}
/*
* Class under test for java.nio.ShortBuffer put(short)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {short.class}
+ )
public void testPutshort() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -569,15 +559,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(short[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {short[].class}
+ )
public void testPutshortArray() {
short array[] = new short[1];
buf.clear();
@@ -606,15 +593,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(short[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {short[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {short[].class, int.class, int.class}
+ )
public void testPutshortArrayintint() {
buf.clear();
short array[] = new short[buf.capacity()];
@@ -681,15 +665,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(java.nio.ShortBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {java.nio.ShortBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {java.nio.ShortBuffer.class}
+ )
public void testPutShortBuffer() {
ShortBuffer other = ShortBuffer.allocate(buf.capacity());
try {
@@ -725,15 +706,12 @@ public class ShortBufferTest extends AbstractBufferTest {
/*
* Class under test for java.nio.ShortBuffer put(int, short)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify ReadOnlyBufferException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {int.class, short.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify ReadOnlyBufferException.",
+ method = "put",
+ args = {int.class, short.class}
+ )
public void testPutintshort() {
buf.clear();
for (int i = 0; i < buf.capacity(); i++) {
@@ -755,15 +733,13 @@ public class ShortBufferTest extends AbstractBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "slice",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "slice",
+ args = {}
+ )
public void testSlice() {
assertTrue(buf.capacity() > 5);
buf.position(1);
@@ -791,15 +767,13 @@ public class ShortBufferTest extends AbstractBufferTest {
assertEquals(slice.get(1), 500);
}
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void testToString() {
String str = buf.toString();
assertTrue(str.indexOf("Short") >= 0 || str.indexOf("short") >= 0);
@@ -814,15 +788,12 @@ public class ShortBufferTest extends AbstractBufferTest {
* for check equal between buf2 and short array[] 3. case for check a buf2
* dependens to array[]
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {short[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {short[].class}
+ )
public void test_Wrap$S() {
short array[] = new short[BUFFER_LENGTH];
loadTestData1(array, 0, BUFFER_LENGTH);
@@ -849,15 +820,12 @@ public class ShortBufferTest extends AbstractBufferTest {
* case for check a buf2 dependens to array[] 4. case expected
* IndexOutOfBoundsException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {short[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {short[].class, int.class, int.class}
+ )
public void test_Wrap$SII() {
short array[] = new short[BUFFER_LENGTH];
int offset = 5;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
index f6d611e..8b94e3e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceDirectByteBufferTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -26,6 +23,7 @@ public class SliceDirectByteBufferTest extends DirectByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH - 2;
buf.position(1).limit(BUFFER_LENGTH-1);
buf = buf.slice();
baseBuf = buf;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
index 2b4a7f5..aafe47f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceHeapByteBufferTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -26,6 +23,7 @@ public class SliceHeapByteBufferTest extends HeapByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH - 2;
buf.position(1).limit(BUFFER_LENGTH-1);
buf = buf.slice();
baseBuf = buf;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
index 84f37e7..d348916 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/SliceWrappedByteBufferTest.java
@@ -16,9 +16,6 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
import dalvik.annotation.TestTargetClass;
@TestTargetClass(java.nio.ByteBuffer.class)
@@ -26,6 +23,7 @@ public class SliceWrappedByteBufferTest extends WrappedByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH - 2;
buf.position(1).limit(BUFFER_LENGTH-1);
buf = buf.slice();
baseBuf = buf;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
index 78b96fc..94c8418 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedByteBufferTest.java
@@ -16,9 +16,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ByteBuffer;
@@ -28,6 +27,7 @@ public class WrappedByteBufferTest extends ByteBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = ByteBuffer.wrap(new byte[BUFFER_LENGTH]);
baseBuf = buf;
}
@@ -42,15 +42,12 @@ public class WrappedByteBufferTest extends ByteBufferTest {
* @tests java.nio.ByteBuffer#allocate(byte[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IndexOutOfBoundsException, NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {byte[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException, NullPointerException.",
+ method = "wrap",
+ args = {byte[].class, int.class, int.class}
+ )
public void testWrappedByteBuffer_IllegalArg() {
byte array[] = new byte[BUFFER_LENGTH];
try {
@@ -96,39 +93,34 @@ public class WrappedByteBufferTest extends ByteBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies isDirect method for non direct ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "isDirect",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies isDirect method for non direct ByteBuffer.",
+ method = "isDirect",
+ args = {}
+ )
public void testIsDirect() {
assertFalse(buf.isDirect());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies hasArray method for wrapped ByteBuffer.",
- targets = {
- @TestTarget(
- methodName = "hasArray",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies hasArray method for wrapped ByteBuffer.",
+ method = "hasArray",
+ args = {}
+ )
public void testHasArray() {
assertTrue(buf.hasArray());
+ assertNotNull(buf.array());
}
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isReadOnly",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isReadOnly",
+ args = {}
+ )
public void testIsReadOnly() {
assertFalse(buf.isReadOnly());
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
index 3187746..ff48762 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest1.java
@@ -16,9 +16,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.CharBuffer;
@@ -28,6 +27,7 @@ public class WrappedCharBufferTest1 extends CharBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = CharBuffer.wrap(new char[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -43,15 +43,12 @@ public class WrappedCharBufferTest1 extends CharBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IndexOutOfBoundsException, NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException, NullPointerException.",
+ method = "wrap",
+ args = {java.lang.CharSequence.class, int.class, int.class}
+ )
public void testWrappedCharBuffer_IllegalArg() {
char array[] = new char[BUFFER_LENGTH];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
index a009a41..e3a51c8 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedCharBufferTest2.java
@@ -16,9 +16,8 @@
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.BufferOverflowException;
@@ -31,6 +30,7 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = TEST_STRING.length();
buf = CharBuffer.wrap(TEST_STRING);
baseBuf = buf;
}
@@ -40,15 +40,13 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
baseBuf = null;
buf = null;
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NullPointerException, IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {java.lang.CharSequence.class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, IndexOutOfBoundsException.",
+ method = "wrap",
+ args = {java.lang.CharSequence.class, int.class, int.class}
+ )
public void testWrappedCharSequence_IllegalArg() {
String str = TEST_STRING;
try {
@@ -82,15 +80,13 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedOperationException.",
- targets = {
- @TestTarget(
- methodName = "array",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedOperationException for CharSequenceAdapter.",
+ method = "array",
+ args = {}
+ )
public void testArray() {
try {
buf.array();
@@ -98,16 +94,27 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
} catch (UnsupportedOperationException e) {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException, NullPointerException, " +
- "BufferOverflowException, IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "put",
- methodArgs = {char[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedOperationException.",
+ method = "arrayOffset",
+ args = {}
+ )
+ public void testArrayOffset() {
+ try {
+ buf.arrayOffset();
+ fail("Should throw Exception"); //$NON-NLS-1$
+ } catch (UnsupportedOperationException e) {
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException, NullPointerException, BufferOverflowException, IndexOutOfBoundsException.",
+ method = "put",
+ args = {char[].class, int.class, int.class}
+ )
public void testPutcharArrayintint() {
char array[] = new char[1];
try {
@@ -135,16 +142,13 @@ public class WrappedCharBufferTest2 extends ReadOnlyCharBufferTest {
// expected
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ReadOnlyBufferException, NullPointerException, " +
- "IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.CharBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ReadOnlyBufferException, NullPointerException, IllegalArgumentException.",
+ method = "read",
+ args = {java.nio.CharBuffer.class}
+ )
public void testPutCharBuffer() {
CharBuffer other = CharBuffer.allocate(1);
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
index 4fff361..4ea5c84 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedDoubleBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.DoubleBuffer;
@@ -26,6 +25,7 @@ import java.nio.DoubleBuffer;
public class WrappedDoubleBufferTest extends DoubleBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = DoubleBuffer.wrap(new double[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -41,15 +41,12 @@ public class WrappedDoubleBufferTest extends DoubleBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {double[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {double[].class, int.class, int.class}
+ )
public void testWrappedDoubleuffer_IllegalArg() {
double array[] = new double[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
index a309868..71f84a9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedFloatBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.FloatBuffer;
@@ -26,6 +25,7 @@ import java.nio.FloatBuffer;
public class WrappedFloatBufferTest extends FloatBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = FloatBuffer.wrap(new float[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -41,15 +41,12 @@ public class WrappedFloatBufferTest extends FloatBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {float[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {float[].class, int.class, int.class}
+ )
public void testWrappedFloatBuffer_IllegalArg() {
float array[] = new float[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
index cccb633..3041de7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedIntBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.IntBuffer;
@@ -26,6 +25,7 @@ import java.nio.IntBuffer;
public class WrappedIntBufferTest extends IntBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = IntBuffer.wrap(new int[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -41,15 +41,12 @@ public class WrappedIntBufferTest extends IntBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {int[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {int[].class, int.class, int.class}
+ )
public void testWrappedIntBuffer_IllegalArg() {
int array[] = new int[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
index 52e8eae..552a1e3 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedLongBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.LongBuffer;
@@ -26,6 +25,7 @@ import java.nio.LongBuffer;
public class WrappedLongBufferTest extends LongBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = LongBuffer.wrap(new long[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -41,15 +41,12 @@ public class WrappedLongBufferTest extends LongBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {long[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {long[].class, int.class, int.class}
+ )
public void testWrappedLongBuffer_IllegalArg() {
long array[] = new long[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
index 36794b5..9917ae0 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/WrappedShortBufferTest.java
@@ -15,9 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio;
-import dalvik.annotation.TestInfo;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.ShortBuffer;
@@ -26,6 +25,7 @@ import java.nio.ShortBuffer;
public class WrappedShortBufferTest extends ShortBufferTest {
protected void setUp() throws Exception {
super.setUp();
+ capacity = BUFFER_LENGTH;
buf = ShortBuffer.wrap(new short[BUFFER_LENGTH]);
loadTestData1(buf);
baseBuf = buf;
@@ -41,15 +41,12 @@ public class WrappedShortBufferTest extends ShortBufferTest {
* @tests java.nio.CharBuffer#allocate(char[],int,int)
*
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wrap",
- methodArgs = {short[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "wrap",
+ args = {short[].class, int.class, int.class}
+ )
public void testWrappedShortBuffer_IllegalArg() {
short array[] = new short[20];
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java
index 0ecd41c..8031c5f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AllTests.java
@@ -26,7 +26,7 @@ public class AllTests {
}
public static Test suite() {
- TestSuite suite = new TestSuite(AllTests.class.getName());
+ TestSuite suite = tests.TestSuiteFactory.createTestSuite(AllTests.class.getName());
//$JUnit-BEGIN$
suite.addTestSuite(AlreadyConnectedExceptionTest.class);
suite.addTestSuite(AsynchronousCloseExceptionTest.class);
@@ -37,7 +37,6 @@ public class AllTests {
suite.addTestSuite(ClosedSelectorExceptionTest.class);
suite.addTestSuite(ConnectionPendingExceptionTest.class);
suite.addTestSuite(DatagramChannelTest.class);
- suite.addTestSuite(FileChannelLockingTest.class);
suite.addTestSuite(FileChannelTest.class);
suite.addTestSuite(FileLockInterruptionExceptionTest.class);
suite.addTestSuite(FileLockTest.class);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
index c236659..6767713 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AlreadyConnectedExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class AlreadyConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "AlreadyConnectedException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new AlreadyConnectedException());
@@ -52,15 +57,20 @@ public class AlreadyConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "AlreadyConnectedException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new AlreadyConnectedException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
index 7a8c426..b9f392d 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/AsynchronousCloseExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class AsynchronousCloseExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "AsynchronousCloseException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new AsynchronousCloseException());
@@ -52,15 +57,20 @@ public class AsynchronousCloseExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "AsynchronousCloseException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new AsynchronousCloseException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
index 8e398a9..a8edce4 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/CancelledKeyExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class CancelledKeyExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "CancelledKeyException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new CancelledKeyException());
@@ -52,15 +57,20 @@ public class CancelledKeyExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "CancelledKeyException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new CancelledKeyException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
index a791c20..46e9f4c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ChannelsTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -117,15 +117,12 @@ public class ChannelsTest extends TestCase {
}
// test if new Channel to input is null
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.InputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.InputStream.class}
+ )
public void testNewChannelInputStream_InputNull() throws IOException {
ByteBuffer byteBuf = ByteBuffer.allocate(this.testNum);
this.fins = null;
@@ -142,15 +139,12 @@ public class ChannelsTest extends TestCase {
}
// test if buffer to read is null
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.InputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.InputStream.class}
+ )
public void testNewChannelInputStream_BufferNull() throws IOException {
ByteBuffer byteBuf = ByteBuffer.allocate(this.testNum);
int readres = this.testNum;
@@ -176,15 +170,12 @@ public class ChannelsTest extends TestCase {
/*
* Test method for 'java.nio.channels.Channels.NewChannel'
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.InputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.InputStream.class}
+ )
public void testNewChannelInputStream() throws IOException {
int bufSize = 10;
int readres = 0;
@@ -213,15 +204,12 @@ public class ChannelsTest extends TestCase {
}
// test if fout to change is null
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.OutputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.OutputStream.class}
+ )
public void testNewChannelOutputStream_inputNull() throws IOException {
int writeres = this.testNum;
ByteBuffer writebuf = ByteBuffer.allocate(this.writebufSize);
@@ -242,15 +230,12 @@ public class ChannelsTest extends TestCase {
}
// test if write buf is null
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.OutputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.OutputStream.class}
+ )
public void testNewChannelOutputStream_BufNull() throws IOException {
int writeres = this.testNum;
ByteBuffer writebuf = null;
@@ -273,15 +258,12 @@ public class ChannelsTest extends TestCase {
/*
* Test method for 'java.nio.channels.Channels.NewChannel(OutputStream)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newChannel",
- methodArgs = {java.io.OutputStream.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newChannel",
+ args = {java.io.OutputStream.class}
+ )
public void testNewChannelOutputStream() throws IOException {
int writeNum = 0;
ByteBuffer writebuf = ByteBuffer.allocateDirect(this.writebufSize);
@@ -326,15 +308,13 @@ public class ChannelsTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newInputStream",
- methodArgs = {java.nio.channels.ReadableByteChannel.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newInputStream",
+ args = {java.nio.channels.ReadableByteChannel.class}
+ )
public void testNewInputStreamReadableByteChannel_InputNull()
throws Exception {
byte[] readbuf = new byte[this.testNum];
@@ -360,16 +340,13 @@ public class ChannelsTest extends TestCase {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify IllegalBlockingModeException for read methods " +
- "according to the specification.",
- targets = {
- @TestTarget(
- methodName = "newInputStream",
- methodArgs = {java.nio.channels.ReadableByteChannel.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newInputStream",
+ args = {java.nio.channels.ReadableByteChannel.class}
+ )
public void testNewInputStreamReadableByteChannel() throws Exception {
ByteBuffer readbcbuf = ByteBuffer.allocateDirect(this.testNum);
byte[] readbuf = new byte[this.testNum];
@@ -386,6 +363,20 @@ public class ChannelsTest extends TestCase {
assertEquals(this.fins.available(), this.fileSize - this.testNum * 2);
testins.read(readbuf);
assertEquals(this.fins.available(), this.fileSize - this.testNum * 3);
+
+ assertFalse(testins.markSupported());
+ try {
+ testins.mark(10);
+ } catch (UnsupportedOperationException e) {
+ // expected;
+ }
+
+ try {
+ testins.reset();
+ } catch (IOException e) {
+ // expected;
+ }
+
// readbc.close() affect testins
readbc.close();
assertFalse(readbc.isOpen());
@@ -395,16 +386,35 @@ public class ChannelsTest extends TestCase {
} catch (ClosedChannelException e) {
// correct
}
+
+ // Read methods throw IllegalBlockingModeException if underlying channel
+ // is in non-blocking mode.
+ SocketChannel chan = SocketChannel.open();
+ chan.configureBlocking(false);
+ testins = Channels.newInputStream(chan);
+ try {
+ testins.read();
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ testins.read(new byte[1]);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ testins.read(new byte[1], 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newOutputStream",
- methodArgs = {java.nio.channels.WritableByteChannel.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newOutputStream",
+ args = {java.nio.channels.WritableByteChannel.class}
+ )
public void testNewOutputStreamWritableByteChannel_InputNull()
throws Exception {
byte[] writebuf = new byte[this.testNum];
@@ -433,16 +443,13 @@ public class ChannelsTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify IllegalBlockingModeException for write methods " +
- "according to the specification.",
- targets = {
- @TestTarget(
- methodName = "newOutputStream",
- methodArgs = {java.nio.channels.WritableByteChannel.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newOutputStream",
+ args = {java.nio.channels.WritableByteChannel.class}
+ )
public void testNewOutputStreamWritableByteChannel() throws Exception {
byte[] writebuf = new byte[this.testNum];
ByteBuffer writebcbuf = ByteBuffer.allocateDirect(this.testNum);
@@ -468,17 +475,35 @@ public class ChannelsTest extends TestCase {
} catch (ClosedChannelException e) {
// correct
}
+
+ // Write methods throw IllegalBlockingModeException if underlying
+ // channel is in non-blocking mode.
+ SocketChannel chan = SocketChannel.open();
+ chan.configureBlocking(false);
+ testouts = Channels.newOutputStream(chan);
+ try {
+ testouts.write(10);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ testouts.write(new byte[1]);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ testouts.write(new byte[1], 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedCharsetException.",
- targets = {
- @TestTarget(
- methodName = "newReader",
- methodArgs = {java.nio.channels.ReadableByteChannel.class,
- java.nio.charset.CharsetDecoder.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedCharsetException.",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.nio.charset.CharsetDecoder.class, int.class}
+ )
public void testnewReaderCharsetError() throws Exception {
this.fins = new FileInputStream(tmpFile);
@@ -492,17 +517,31 @@ public class ChannelsTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify IllegalBlockingModeException for " +
- "non-blocking mode.",
- targets = {
- @TestTarget(
- methodName = "newWriter",
- methodArgs = {java.nio.channels.WritableByteChannel.class,
- java.nio.charset.CharsetEncoder.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedCharsetException.",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.lang.String.class}
+ )
+ public void testnewReaderCharsetError2() throws Exception {
+ this.fins = new FileInputStream(tmpFile);
+
+ ReadableByteChannel rbChannel = Channels.newChannel(this.fins);
+ try {
+ Channels.newReader(rbChannel, BAD_CODE_SET);
+ fail();
+ } catch (UnsupportedCharsetException e) {
+ // correct
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedCharsetException.",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
+ )
public void testnewWriterCharsetError() throws Exception {
this.fouts = new FileOutputStream(tmpFile);
WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
@@ -515,21 +554,34 @@ public class ChannelsTest extends TestCase {
}
}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedCharsetException.",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.lang.String.class}
+ )
+ public void testnewWriterCharsetError2() throws Exception {
+ this.fouts = new FileOutputStream(tmpFile);
+ WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
+ try {
+ Channels.newWriter(wbChannel, BAD_CODE_SET);
+ fail();
+ } catch (UnsupportedCharsetException e) {
+ // correct
+ }
+ }
+
/*
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newReader",
- methodArgs = {java.nio.channels.ReadableByteChannel.class,
- java.nio.charset.CharsetDecoder.class, int.class}
- )
- })
- public void testNewReaderReadableByteChannelString_InputNull()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.nio.charset.CharsetDecoder.class, int.class}
+ )
+ public void testNewReaderReadableByteChannelCharsetDecoderI_InputNull()
throws IOException {
int bufSize = this.testNum;
int readres = 0;
@@ -574,18 +626,61 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't check IllegalBlockingModeException exception while " +
- "read method.",
- targets = {
- @TestTarget(
- methodName = "newReader",
- methodArgs = {java.nio.channels.ReadableByteChannel.class,
- java.nio.charset.CharsetDecoder.class, int.class}
- )
- })
- public void testNewReaderReadableByteChannelString_internalBufferZero()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.lang.String.class}
+ )
+ public void testNewReaderReadableByteChannelString_InputNull()
+ throws IOException {
+ int bufSize = this.testNum;
+ int readres = 0;
+ CharBuffer charBuf = CharBuffer.allocate(bufSize);
+ this.fins = new FileInputStream(tmpFile);
+ // channel null
+ Reader testReader = Channels.newReader(null, CODE_SET);
+ assertNotNull(testReader);
+ assertFalse(testReader.ready());
+ try {
+ readres = testReader.read((CharBuffer) null);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ assertEquals(0, readres);
+ try {
+ readres = testReader.read(charBuf);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+
+ this.fins = null;
+ ReadableByteChannel rbChannel = Channels.newChannel(this.fins);
+ // channel with null inputs
+ testReader = Channels.newReader(rbChannel, CODE_SET);
+ assertNotNull(testReader);
+ assertFalse(testReader.ready());
+ try {
+ readres = testReader.read(charBuf);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ }
+
+ /*
+ * Test method for
+ * 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.nio.charset.CharsetDecoder.class, int.class}
+ )
+ public void testNewReaderReadableByteChannelCharsetDecoderI_internalBufferZero()
throws IOException {
int bufSize = this.testNum;
int readres = 0;
@@ -630,17 +725,68 @@ public class ChannelsTest extends TestCase {
* Test method for
* 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify UnsupportedCharsetException.",
- targets = {
- @TestTarget(
- methodName = "newReader",
- methodArgs = {java.nio.channels.ReadableByteChannel.class,
- java.lang.String.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.lang.String.class}
+ )
+ public void testNewReaderReadableByteChannelString_internalBufferZero()
+ throws IOException {
+ int bufSize = this.testNum;
+ int readres = 0;
+ CharBuffer charBuf = CharBuffer.allocate(bufSize);
+ this.fins = new FileInputStream(tmpFile);
+ // channel null
+ Reader testReader = Channels.newReader(null, CODE_SET);
+ assertNotNull(testReader);
+ assertFalse(testReader.ready());
+ try {
+ readres = testReader.read((CharBuffer) null);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ assertEquals(0, readres);
+ try {
+ readres = testReader.read(charBuf);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ this.fins = null;
+ ReadableByteChannel rbChannel = Channels.newChannel(this.fins);
+ // channel with null inputs
+ testReader = Channels.newReader(rbChannel, CODE_SET);
+ assertNotNull(testReader);
+ assertFalse(testReader.ready());
+ try {
+ readres = testReader.read(charBuf);
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ }
+
+ /*
+ * Test method for
+ * 'java.nio.channels.Channels.newReader(ReadableByteChannel, String)'
+ */
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.lang.String.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newReader",
+ args = {java.nio.channels.ReadableByteChannel.class, java.nio.charset.CharsetDecoder.class, int.class}
)
})
- public void testNewReaderReadableByteChannelString() throws IOException {
+ public void testNewReaderReadableByteChannel() throws IOException {
int bufSize = this.testNum;
int readres = 0;
CharBuffer charBuf = CharBuffer.allocate(bufSize);
@@ -676,16 +822,13 @@ public class ChannelsTest extends TestCase {
/*
* Zero-Buffer
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "newWriter",
- methodArgs = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
- )
- })
- public void testNewWriterWritableByteChannelString_internalBufZero()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
+ )
+ public void testNewWriterWritableByteChannelCharsetEncoderI_internalBufZero()
throws IOException {
String writebuf = ""; //$NON-NLS-1$
@@ -734,19 +877,68 @@ public class ChannelsTest extends TestCase {
}
/*
+ * Zero-Buffer
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.lang.String.class}
+ )
+ public void testNewWriterWritableByteChannelString_internalBufZero()
+ throws IOException {
+
+ String writebuf = ""; //$NON-NLS-1$
+ for (int val = 0; val < this.writebufSize / 2; val++) {
+ writebuf = writebuf + ((char) (val + 64));
+ }
+ // null channel
+ Writer testWriter = Channels.newWriter(null, CODE_SET);
+ // can write to buffer
+ testWriter.write(writebuf);
+ try {
+ testWriter.flush();
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ try {
+ testWriter.close();
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+
+ // channel with null input
+ this.fouts = null;
+ WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
+ testWriter = Channels.newWriter(wbChannel, CODE_SET);
+ // can write to buffer
+ testWriter.write(writebuf);
+ try {
+ testWriter.flush();
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ try {
+ testWriter.close();
+ fail();
+ } catch (NullPointerException e) {
+ // correct
+ }
+ }
+
+ /*
* this test cannot be passed when buffer set to 0!
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify IllegalBlockingModeException for write methods.",
- targets = {
- @TestTarget(
- methodName = "newWriter",
- methodArgs = {java.nio.channels.WritableByteChannel.class,
- java.nio.charset.CharsetEncoder.class, int.class}
- )
- })
- public void testNewWriterWritableByteChannelString_InputNull()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
+ )
+ public void testNewWriterWritableByteChannelCharsetEncoderI_InputNull()
throws IOException {
this.fouts = new FileOutputStream(tmpFile);
WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
@@ -766,17 +958,47 @@ public class ChannelsTest extends TestCase {
}
/*
+ * this test cannot be passed when buffer set to 0!
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.lang.String.class}
+ )
+ public void testNewWriterWritableByteChannelString_InputNull()
+ throws IOException {
+ this.fouts = new FileOutputStream(tmpFile);
+ WritableByteChannel wbChannel = Channels.newChannel(this.fouts);
+ Writer testWriter = Channels.newWriter(wbChannel, CODE_SET);
+
+ String writebuf = ""; //$NON-NLS-1$
+ for (int val = 0; val < this.writebufSize / 2; val++) {
+ writebuf = writebuf + ((char) (val + 64));
+ }
+ // can write to buffer
+ testWriter.write(writebuf);
+ testWriter.flush();
+ testWriter.close();
+
+ }
+
+ /*
* Test method for
* 'java.nio.channels.Channels.newWriter(WritableByteChannel, String)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify UnsupportedCharsetException.",
- targets = {
- @TestTarget(
- methodName = "newWriter",
- methodArgs = {java.nio.channels.WritableByteChannel.class,
- java.lang.String.class}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.nio.charset.CharsetEncoder.class, int.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "newWriter",
+ args = {java.nio.channels.WritableByteChannel.class, java.lang.String.class}
)
})
public void testNewWriterWritableByteChannelString() throws IOException {
@@ -817,23 +1039,77 @@ public class ChannelsTest extends TestCase {
testWriter_s.write(writebuf);
testWriter.flush();
this.assertFileSizeSame(tmpFile, this.writebufSize / 2 + 1);
+
+ SocketChannel chan = SocketChannel.open();
+ chan.configureBlocking(false);
+ Writer writer = Channels.newWriter(chan, CODE_SET);
+ try {
+ writer.write(10);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write(new char[10]);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write("test");
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write(new char[10], 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write("test", 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+
+ writer = Channels.newWriter(chan, Charset.forName(
+ CODE_SET).newEncoder(), //$NON-NLS-1$
+ -1);
+ try {
+ writer.write(10);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write(new char[10]);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write("test");
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write(new char[10], 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+ try {
+ writer.write("test", 0, 1);
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
}
/**
* @tests java.nio.channels.Channels#newReader(ReadableByteChannel channel,
* String charsetName)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalBlockingModeException.",
- targets = {
- @TestTarget(
- methodName = "newReader",
- methodArgs = {java.nio.channels.ReadableByteChannel.class,
- java.lang.String.class}
- )
- })
- public void test_newReader_LReadableByteChannel_LString()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalBlockingModeException.",
+ method = "newInputStream",
+ args = {java.nio.channels.ReadableByteChannel.class}
+ )
+ public void test_newInputStream_LReadableByteChannel()
throws IOException {
InetSocketAddress localAddr = new InetSocketAddress("127.0.0.1",
Support_PortManager.getNextPort());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
index 4e48945..8b5dcc7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedByInterruptExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,14 +35,19 @@ public class ClosedByInterruptExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedByInterruptException",
+ args = {}
+ )
})
public void testSerializationSelf() throws Exception {
@@ -52,14 +57,19 @@ public class ClosedByInterruptExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedByInterruptException",
+ args = {}
+ )
})
public void testSerializationCompatibility() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
index 277ec34..088b7b5 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedChannelExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,14 +35,19 @@ public class ClosedChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedChannelException",
+ args = {}
+ )
})
public void testSerializationSelf() throws Exception {
@@ -52,14 +57,19 @@ public class ClosedChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedChannelException",
+ args = {}
+ )
})
public void testSerializationCompatibility() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
index 2f00113..145dd22 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ClosedSelectorExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,14 +35,19 @@ public class ClosedSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedSelectorException",
+ args = {}
+ )
})
public void testSerializationSelf() throws Exception {
@@ -52,14 +57,19 @@ public class ClosedSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ClosedSelectorException",
+ args = {}
+ )
})
public void testSerializationCompatibility() throws Exception {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
index 47496f7..e0d6489 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ConnectionPendingExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestLevel;
@@ -35,15 +35,20 @@ public class ConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ConnectionPendingException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new ConnectionPendingException());
@@ -52,15 +57,20 @@ public class ConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "ConnectionPendingException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new ConnectionPendingException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
index ca6d052..36e0082 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java
@@ -17,8 +17,8 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -31,23 +31,112 @@ import java.net.SocketAddress;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.SelectionKey;
import java.nio.channels.UnresolvedAddressException;
import java.nio.channels.UnsupportedAddressTypeException;
import java.nio.channels.spi.SelectorProvider;
-import java.security.Permission;
import junit.framework.TestCase;
import tests.support.Support_PortManager;
/**
* Test for DatagramChannel
- *
+ *
*/
-@TestTargetClass(DatagramChannel.class)
+@TestTargetClass(
+ value = DatagramChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ }
+)
public class DatagramChannelTest extends TestCase {
private static final int CAPACITY_NORMAL = 200;
@@ -127,17 +216,33 @@ public class DatagramChannelTest extends TestCase {
// Test for methods in abstract class.
// -------------------------------------------------------------------
/*
+ * Test method for 'java.nio.channels.DatagramChannel()'
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "DatagramChannel",
+ args = {java.nio.channels.spi.SelectorProvider.class}
+ )
+ public void testConstructor() throws IOException {
+ DatagramChannel channel =
+ SelectorProvider.provider().openDatagramChannel();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ channel = DatagramChannel.open();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(), channel.provider());
+ }
+
+ /*
* Test method for 'java.nio.channels.DatagramChannel.validOps()'
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "validOps",
+ args = {}
+ )
public void testValidOps() {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -151,15 +256,12 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.DatagramChannel.open()'
*/
- @TestInfo(
- level = TestLevel.TODO,
- purpose = "Doesn't call open method.",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies the result of the setUp method.",
+ method = "open",
+ args = {}
+ )
public void testOpen() {
MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
.provider());
@@ -171,166 +273,379 @@ public class DatagramChannelTest extends TestCase {
}
/*
- * Test method for 'java.nio.channels.DatagramChannel.read(ByteBuffer)'
+ * Test method for 'java.nio.channels.DatagramChannel.open()'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException, IOException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
+ public void testIsOpen() throws Exception {
+ assertTrue(this.channel1.isOpen());
+ this.channel1.close();
+ assertFalse(this.channel1.isOpen());
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of DatagramChannel.",
+ method = "validOps",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of DatagramChannel.",
+ method = "provider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of DatagramChannel.",
+ method = "isRegistered",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of DatagramChannel.",
+ method = "isBlocking",
+ args = {}
)
})
+ public void testChannelBasicStatus() {
+ DatagramSocket gotSocket = this.channel1.socket();
+ assertFalse(gotSocket.isClosed());
+ assertTrue(this.channel1.isBlocking());
+ assertFalse(this.channel1.isRegistered());
+ assertEquals((SelectionKey.OP_READ | SelectionKey.OP_WRITE),
+ this.channel1.validOps());
+ assertEquals(SelectorProvider.provider(), this.channel1.provider());
+ }
+
+ /*
+ * Test method for 'java.nio.channels.DatagramChannel.read(ByteBuffer)'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void testReadByteBufferArray() throws IOException {
- final int testNum = 0;
- long readres = testNum;
- MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
- .provider());
- MockDatagramChannel testMocknull = new MockDatagramChannel(null);
- int bufSize = 10;
- ByteBuffer[] readBuf = null;
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(readBuf);
- fail("Should throw NPE");
+ fail("should throw NotYetConnectedException");
+ } catch (NotYetConnectedException e) {
+ // correct
+ }
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.configureBlocking(false);
+ // note : blocking-mode will make the read process endless!
+ assertEquals(0, this.channel1.read(readBuf));
+ this.channel1.close();
+ assertFalse(this.channel1.isOpen());
+ try {
+ assertEquals(0, this.channel1.read(readBuf));
+ } catch (ClosedChannelException e) {
+ // correct
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testReadByteBufferArray_ConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.configureBlocking(false);
+ // note : blocking-mode will make the read process endless!
+ try {
+ this.channel1.read((ByteBuffer[])null);
+ fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
try {
- readres = testMock.read(readBuf);
- fail("Should throw NPE");
+ this.channel1.read(readBuf);
+ fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
- readBuf = new ByteBuffer[bufSize];
+ datagramSocket1.close();
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testReadByteBufferArray_NotConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
try {
- readres = this.channel1.read(readBuf);
- fail("Should throw NotYetConnectedException");
+ this.channel1.read((ByteBuffer[])null);
+ fail("should throw NPE");
+ } catch (NullPointerException e) {
+ // correct
+ }
+ try {
+ this.channel1.read(readBuf);
+ fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- readres = testMock.read(readBuf);
- assertEquals(testNum, readres);
- readres = testMocknull.read(readBuf);
- assertEquals(testNum, readres);
}
/*
- * Test method for 'java.nio.channels.DatagramChannel.read(ByteBuffer)'
+ * Test method for 'DatagramChannelImpl.write(ByteBuffer[])'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
- public void testReadByteBufferArray_BufNull() throws IOException {
- MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
- .provider());
- MockDatagramChannel testMocknull = new MockDatagramChannel(null);
-
- ByteBuffer[] readBuf = null;
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify all exceptions according to specification.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_Block() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
try {
- this.channel1.read(readBuf);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
+ this.channel1.write(writeBuf);
+ fail("Should throw NotYetConnectedException.");
+ } catch (NotYetConnectedException e) {
// correct
}
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf));
+ // cannot be buffered again!
+ assertEquals(0, this.channel1.write(writeBuf));
+ }
+
+ public void disabled_testWriteByteBufferArray_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.write(targetBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ public void disabled_testWriteByteBufferArray_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+ channel1.write(targetBuf);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
try {
- testMock.read(readBuf);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
+ /*
+ * Test method for 'DatagramChannelImpl.write(ByteBuffer[])'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_NonBlock() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ // non-block mode
+ this.channel1.configureBlocking(false);
+ try {
+ this.channel1.write(writeBuf);
+ fail("Should throw NotYetConnectedException.");
+ } catch (NotYetConnectedException e) {
// correct
}
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf));
+ // cannot be buffered again!
+ assertEquals(0, this.channel1.write(writeBuf));
+ this.channel1.close();
try {
- testMocknull.read(readBuf);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
+ this.channel1.write(writeBuf, 0, 1);
+ fail("Should throw ClosedChannelEception.");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_BlockClosed() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ // non-block mode
+ this.channel1.configureBlocking(false);
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.close();
+ try {
+ channel1.write(writeBuf);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
// correct
}
}
- /*
- * Test method for 'java.nio.channels.DatagramChannel.write(ByteBuffer)'
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testWriteByteBuffer() throws IOException {
- MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
- .provider());
- MockDatagramChannel testMocknull = new MockDatagramChannel(null);
- int bufSize = 10;
- ByteBuffer[] readBuf = null;
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_NonBlockClosed() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.close();
try {
- this.channel1.write(readBuf);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
+ channel1.write(writeBuf);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
// correct
}
+ }
+
+ /*
+ * Test method for 'DatagramChannelImpl.write(ByteBuffer[])'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_NotConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
- testMock.write(readBuf);
- fail("Should throw NPE");
+ this.channel1.write((ByteBuffer[])null);
+ fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
- readBuf = new ByteBuffer[bufSize];
try {
- this.channel1.write(readBuf);
- fail("Should throw NotYetConnectedException");
+ this.channel1.write(writeBuf);
+ fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- long writeres = 0;
- writeres = testMock.write(readBuf);
-
- assertEquals(0, writeres);
- writeres = testMocknull.write(readBuf);
- assertEquals(0, writeres);
}
/*
- * Test method for 'java.nio.channels.DatagramChannel.write(ByteBuffer)'
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
- public void testWriteByteBuffer_Bufnull() throws IOException {
- MockDatagramChannel testMock = new MockDatagramChannel(SelectorProvider
- .provider());
- MockDatagramChannel testMocknull = new MockDatagramChannel(null);
- ByteBuffer[] readBuf = null;
+ * Test method for 'DatagramChannelImpl.write(ByteBuffer[])'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testWriteByteBufferArray_ConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
try {
- this.channel1.write(readBuf);
- fail("Should throw NPE");
+ this.channel1.write((ByteBuffer[])null);
+ fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
try {
- testMock.write(readBuf);
- fail("Should throw NPE");
+ this.channel1.write(writeBuf);
+ fail("should throw NullPointerException");
} catch (NullPointerException e) {
// correct
}
+ datagramSocket1.close();
try {
- testMocknull.write(readBuf);
- fail("Should throw NPE");
+ this.channel1.write((ByteBuffer[])null);
+ fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
@@ -342,18 +657,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws SocketException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_BasicStatusBeforeConnect() throws SocketException {
assertFalse(this.channel1.isConnected());// not connected
DatagramSocket s1 = this.channel1.socket();
@@ -365,18 +677,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_Block_BasicStatusAfterConnect() throws IOException {
this.channel1.connect(localAddr1);
DatagramSocket s1 = this.channel1.socket();
@@ -385,17 +694,15 @@ public class DatagramChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_NonBlock_BasicStatusAfterConnect()
- throws IOException {
+ throws IOException {
this.channel1.connect(localAddr1);
this.channel1.configureBlocking(false);
DatagramSocket s1 = this.channel1.socket();
@@ -407,18 +714,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_ActionsBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
DatagramSocket s = this.channel1.socket();
@@ -427,33 +731,28 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.socket()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_Block_ActionsAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
this.channel1.connect(localAddr1);
DatagramSocket s = this.channel1.socket();
assertSocketActionAfterConnect(s);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_NonBlock_ActionsAfterConnect() throws IOException {
this.channel1.connect(localAddr1);
this.channel1.configureBlocking(false);
@@ -494,8 +793,8 @@ public class DatagramChannelTest extends TestCase {
assertEquals(s.getPort(), localAddr1.getPort());
assertTrue(s.getReceiveBufferSize() >= 8192);
// not same , but equals
- assertNotSame(s.getRemoteSocketAddress(), (SocketAddress) localAddr1);
- assertEquals(s.getRemoteSocketAddress(), (SocketAddress) localAddr1);
+ assertNotSame(s.getRemoteSocketAddress(), localAddr1);
+ assertEquals(s.getRemoteSocketAddress(), localAddr1);
assertFalse(s.getReuseAddress());
assertTrue(s.getSendBufferSize() >= 8192);
assertEquals(s.getSoTimeout(), 0);
@@ -538,15 +837,12 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test for configureBlocking()
// -------------------------------------------------------------------
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {ByteBuffer.class}
+ )
public void testConfigureBlocking_Read() throws Exception {
assertTrue(this.channel1.isBlocking());
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_1KB);
@@ -572,20 +868,18 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.isConnected()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isConnected",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isConnected",
+ args = {}
+ )
public void testIsConnected_WithServer() throws IOException {
connectLocalServer();
+ assertTrue(this.channel1.isConnected());
disconnectAfterConnected();
this.datagramSocket1.close();
this.channel1.close();
@@ -599,15 +893,12 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_BlockWithServer() throws IOException {
// blocking mode
assertTrue(this.channel1.isBlocking());
@@ -615,20 +906,16 @@ public class DatagramChannelTest extends TestCase {
datagramSocket1.close();
disconnectAfterConnected();
}
-
+
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException, SecurityException, IOException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_BlockNoServer() throws IOException {
connectWithoutServer();
disconnectAfterConnected();
@@ -636,18 +923,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_NonBlockWithServer() throws IOException {
// Non blocking mode
this.channel1.configureBlocking(false);
@@ -658,18 +942,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_Null() throws IOException {
assertFalse(this.channel1.isConnected());
try {
@@ -682,18 +963,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnsupportedAddressTypeException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnsupportedAddressTypeException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_UnsupportedType() throws IOException {
assertFalse(this.channel1.isConnected());
class SubSocketAddress extends SocketAddress {
@@ -712,20 +990,65 @@ public class DatagramChannelTest extends TestCase {
}
}
+ public void disabled_testConnect_Block_close() throws Exception {
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.connect(localAddr1);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ public void disabled_testConnect_Block_interrupt() throws Exception {
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ channel1.connect(localAddr1);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies UnresolvedAddressException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies UnresolvedAddressException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_Unresolved() throws IOException {
assertFalse(this.channel1.isConnected());
InetSocketAddress unresolved = new InetSocketAddress(
@@ -737,15 +1060,13 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_EmptyHost() throws Exception {
assertFalse(this.channel1.isConnected());
@@ -756,19 +1077,16 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ *
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_ClosedChannelException() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -783,19 +1101,16 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalStateException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ *
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalStateException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_IllegalStateException() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.connect(localAddr1);
@@ -811,19 +1126,16 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
- *
+ *
* @throws IOException
- *
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ *
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testConnect_CheckOpenBeforeStatus() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.connect(localAddr1);
@@ -874,18 +1186,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify IOException.",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify IOException.",
+ method = "disconnect",
+ args = {}
+ )
public void testDisconnect_BeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());
assertEquals(this.channel1, this.channel1.disconnect());
@@ -894,18 +1203,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "disconnect",
+ args = {}
+ )
public void testDisconnect_UnconnectedClosed() throws IOException {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -916,18 +1222,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "disconnect",
+ args = {}
+ )
public void testDisconnect_BlockWithServerChannelClosed()
throws IOException {
assertTrue(this.channel1.isBlocking());
@@ -939,18 +1242,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "disconnect",
+ args = {}
+ )
public void testDisconnect_NonBlockWithServerChannelClosed()
throws IOException {
this.channel1.configureBlocking(false);
@@ -962,19 +1262,17 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
- public void testDisconnect_BlockWithServerServerClosed() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "disconnect",
+ args = {}
+ )
+ public void testDisconnect_BlockWithServerServerClosed()
+ throws IOException {
assertTrue(this.channel1.isBlocking());
connectLocalServer();
// disconnect after server close
@@ -986,18 +1284,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.disconnect()'
- *
+ *
* @throws IOException
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "disconnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "disconnect",
+ args = {}
+ )
public void testDisconnect_NonBlockWithServerServerClosed()
throws IOException {
this.channel1.configureBlocking(false);
@@ -1016,18 +1311,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedNull() throws Exception {
assertFalse(this.channel1.isConnected());
try {
@@ -1040,18 +1332,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedReadonly() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL)
@@ -1067,18 +1356,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedBufEmpty() throws Exception {
this.channel1.configureBlocking(false);
assertFalse(this.channel1.isConnected());
@@ -1088,18 +1374,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedBufZero() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_ZERO);
@@ -1108,18 +1391,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedBufNotEmpty() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1131,18 +1411,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedBufFull() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_ONE);
@@ -1154,18 +1431,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedClose() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -1181,18 +1455,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedCloseNull() throws Exception {
assertFalse(this.channel1.isConnected());
this.channel1.close();
@@ -1208,18 +1479,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_UnconnectedCloseReadonly() throws Exception {
assertFalse(this.channel1.isConnected());
ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL)
@@ -1237,18 +1505,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerBufEmpty() throws Exception {
this.channel1.configureBlocking(false);
receiveNonBlockNoServer(CAPACITY_NORMAL);
@@ -1256,18 +1521,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_BlockNoServerNull() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerNull();
@@ -1275,18 +1537,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerNull() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerNull();
@@ -1294,18 +1553,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_BlockNoServerReadonly() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerReadonly();
@@ -1313,18 +1569,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerReadonly() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerReadonly();
@@ -1332,18 +1585,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerBufZero() throws Exception {
this.channel1.configureBlocking(false);
receiveNonBlockNoServer(CAPACITY_ZERO);
@@ -1351,18 +1601,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerBufNotEmpty() throws Exception {
this.channel1.configureBlocking(false);
connectWithoutServer();
@@ -1373,18 +1620,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerBufFull() throws Exception {
this.channel1.configureBlocking(false);
connectWithoutServer();
@@ -1394,18 +1638,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_BlockNoServerChannelClose() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelClose();
@@ -1413,18 +1654,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerChannelClose() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelClose();
@@ -1432,18 +1670,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_BlockNoServerCloseNull() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelCloseNull();
@@ -1451,18 +1686,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerCloseNull() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelCloseNull();
@@ -1470,18 +1702,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_NonBlockNoServerCloseReadonly() throws Exception {
this.channel1.configureBlocking(false);
receiveNoServerChannelCloseReadonly();
@@ -1489,18 +1718,15 @@ public class DatagramChannelTest extends TestCase {
/**
* Test method for 'DatagramChannelImpl.receive(ByteBuffer)'
- *
+ *
* @throws Exception
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceive_BlockNoServerCloseReadonly() throws Exception {
assertTrue(this.channel1.isBlocking());
receiveNoServerChannelCloseReadonly();
@@ -1598,63 +1824,56 @@ public class DatagramChannelTest extends TestCase {
private void sendDataBlocking(InetSocketAddress addr, ByteBuffer writeBuf)
throws IOException {
- InetSocketAddress ipAddr = addr;
+ InetSocketAddress ipAddr = addr;
assertEquals(CAPACITY_NORMAL, this.channel1.send(writeBuf, ipAddr));
assertTrue(this.channel1.isOpen());
assertTrue(this.channel1.isBlocking());
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
}
private void sendDataNonBlocking(InetSocketAddress addr, ByteBuffer writeBuf)
throws IOException {
- InetSocketAddress ipAddr = addr;
+ InetSocketAddress ipAddr = addr;
this.channel1.configureBlocking(false);
assertEquals(CAPACITY_NORMAL, this.channel1.send(writeBuf, ipAddr));
assertTrue(this.channel1.isOpen());
assertFalse(this.channel1.isBlocking());
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
}
/*
* Test method for 'DatagramChannelImpl.send(ByteBuffer, SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerBlockingCommon() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataBlocking(localAddr1, writeBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerNonblockingCommon() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataNonBlocking(localAddr1, writeBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataBlocking(localAddr1, writeBuf);
@@ -1667,15 +1886,13 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerNonBlockingTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
sendDataNonBlocking(localAddr1, writeBuf);
@@ -1688,15 +1905,13 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerBufNull() throws IOException {
try {
sendDataBlocking(localAddr1, null);
@@ -1705,15 +1920,13 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerBufNullTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1730,15 +1943,13 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "DOesn't verify all exceptions according to spec.",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "DOesn't verify all exceptions according to spec.",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerAddrNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -1748,20 +1959,18 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_NoServerAddrNullTwice() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
sendDataBlocking(null, writeBuf);
- fail("Should throw a NPE here.");
+ fail("Should throw NPE");
} catch (NullPointerException e) {
// correct
}
@@ -1777,19 +1986,20 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test for receive()and send(): Send and Receive with Real Data
// -------------------------------------------------------------------
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("some normal string in testReceiveSend_Normal",
@@ -1797,19 +2007,21 @@ public class DatagramChannelTest extends TestCase {
receiveByChannel(CAPACITY_NORMAL, localAddr2,
"some normal string in testReceiveSend_Normal");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_NotBound() throws Exception {
// not bound
sendByChannel("some normal string in testReceiveSend_Normal",
@@ -1818,19 +2030,21 @@ public class DatagramChannelTest extends TestCase {
assertNull(channel1.receive(buf));
assertFalse(channel1.socket().isBound());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_NotBound() throws Exception {
// not bound
this.channel1.configureBlocking(false);
@@ -1838,21 +2052,23 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("some normal string in testReceiveSend_Normal",
localAddr2);
ByteBuffer buf = ByteBuffer.wrap(new byte[CAPACITY_NORMAL]);
- assertNull((InetSocketAddress) this.channel1.receive(buf));
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+ assertNull(this.channel1.receive(buf));
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket(
@@ -1860,38 +2076,42 @@ public class DatagramChannelTest extends TestCase {
receiveByChannel(CAPACITY_NORMAL, localAddr2,
"some normal string in testReceiveSend_Normal_S2C");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Normal_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
String str1 = "some normal string in testReceiveSend_Normal_C2S";
sendByChannel(str1, localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, str1);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Normal_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1900,19 +2120,21 @@ public class DatagramChannelTest extends TestCase {
sendByChannel(str1, localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, str1);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Normal_S2S() throws Exception {
String msg = "normal string in testReceiveSend_Normal_S2S";
this.datagramSocket1 = new DatagramSocket(testPort);
@@ -1926,33 +2148,41 @@ public class DatagramChannelTest extends TestCase {
this.datagramSocket2.receive(rdp);
assertEquals(new String(buf, 0, CAPACITY_NORMAL).trim(), msg);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1960,37 +2190,41 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty_S2C() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -1998,37 +2232,41 @@ public class DatagramChannelTest extends TestCase {
sendByDatagramSocket("", localAddr2);
receiveByChannel(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Empty_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
sendByChannel("", localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Empty_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -2036,15 +2274,13 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("", localAddr2);
receiveByDatagramSocket(CAPACITY_NORMAL, localAddr2, "");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReceiveSend_Empty_S2S() throws Exception {
String msg = "";
this.datagramSocket1 = new DatagramSocket(testPort);
@@ -2058,55 +2294,61 @@ public class DatagramChannelTest extends TestCase {
this.datagramSocket2.receive(rdp);
assertEquals(new String(buf, 0, CAPACITY_NORMAL).trim(), msg);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByChannel("0123456789", localAddr2);
receiveByChannel(5, localAddr2, "01234");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize_C2S() throws Exception {
this.datagramSocket1 = new DatagramSocket(localAddr2.getPort());
sendByChannel("0123456789", localAddr2);
receiveByDatagramSocket(5, localAddr2, "01234");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_NonBlock_Oversize_C2S() throws Exception {
this.channel1.configureBlocking(false);
this.channel2.configureBlocking(false);
@@ -2114,37 +2356,41 @@ public class DatagramChannelTest extends TestCase {
sendByChannel("0123456789", localAddr2);
receiveByDatagramSocket(5, localAddr2, "01234");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_Block_Oversize_S2C() throws Exception {
this.channel1.socket().bind(localAddr2);
sendByDatagramSocket("0123456789", localAddr2);
receiveByChannel(5, localAddr2, "01234");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ })
public void testReceiveSend_8K() throws Exception {
StringBuffer str8k = new StringBuffer();
for (int i = 0; i < 8 * CAPACITY_1KB; i++) {
@@ -2155,16 +2401,13 @@ public class DatagramChannelTest extends TestCase {
sendByChannel(str, localAddr2);
receiveByChannel(8 * CAPACITY_1KB, localAddr2, str);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException.",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testReceiveSend_64K() throws Exception {
StringBuffer str64k = new StringBuffer();
for (int i = 0; i < CAPACITY_64KB; i++) {
@@ -2227,7 +2470,7 @@ public class DatagramChannelTest extends TestCase {
this.channel1.close();
}
}
-
+
/*
* Fails if the difference between current time and start time is greater
* than timeout.
@@ -2256,15 +2499,13 @@ public class DatagramChannelTest extends TestCase {
private class mockAddress extends SocketAddress {
private static final long serialVersionUID = 1L;
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
public void testSend_MockSocketAddress() throws Exception {
SocketAddress badAddr = new mockAddress();
@@ -2288,58 +2529,217 @@ public class DatagramChannelTest extends TestCase {
System.setSecurityManager(sm);
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException, IOException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testRead_Security() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify AsynchronousCloseException, ClosedByInterruptException, IOException.",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, SocketAddress.class}
+ )
+ public void testSend_Security() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
localAddr1 = new InetSocketAddress("127.0.0.1", testPort);
this.channel1.socket().bind(localAddr1);
this.channel2.socket().bind(localAddr2);
this.channel1.connect(localAddr2);
- this.channel2.send(ByteBuffer.wrap(strHello.getBytes()), localAddr1);
+
final SecurityManager sm = System.getSecurityManager();
- System.setSecurityManager(new MockSecurityManager("10.0.0.1"));
+ MockSecurityManager mockManager = new MockSecurityManager("127.0.0.1");
+ System.setSecurityManager(mockManager);
- // seems no security check
try {
+ this.channel2.send(ByteBuffer.wrap(strHello.getBytes()), localAddr1);
assertEquals(strHello.length(), this.channel1.read(buf));
} finally {
System.setSecurityManager(sm);
}
+
+ assertTrue(mockManager.checkConnectCalled);
+ }
+
+ public void disabled_testSend_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.send(targetBuf, localAddr1);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "receive",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testReceive_Peek_Security_Nonblocking() throws Exception {
+
+ public void disabled_testSend_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+ channel1.send(targetBuf, localAddr1);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReceive_Security() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
String strHello = "hello";
localAddr1 = new InetSocketAddress("127.0.0.1", testPort);
this.channel1.socket().bind(localAddr1);
sendByChannel(strHello, localAddr1);
+
final SecurityManager sm = System.getSecurityManager();
+ MockSecurityManager mockManager = new MockSecurityManager("10.0.0.1");
+ System.setSecurityManager(mockManager);
+
try {
- System.setSecurityManager(new MockSecurityManager("10.0.0.1"));
this.channel1.configureBlocking(false);
- // for accepted addr, no problem.
assertNull(this.channel1.receive(buf));
} finally {
System.setSecurityManager(sm);
}
+
+ assertTrue(mockManager.checkAcceptCalled);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReceive_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.receive(targetBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "receive",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReceive_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+ channel1.receive(targetBuf);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
+ public void testConnect_Security() throws IOException {
+ localAddr1 = new InetSocketAddress("127.0.0.1", testPort);
+ SecurityManager sm = System.getSecurityManager();
+ MockSecurityManager mockManager = new MockSecurityManager("127.0.0.1");
+ System.setSecurityManager(mockManager);
+
+ try {
+ this.channel1.connect(localAddr1);
+ } finally {
+ System.setSecurityManager(sm);
+ }
+
+ assertTrue(mockManager.checkConnectCalled);
}
// -------------------------------------------------------------------
@@ -2348,7 +2748,7 @@ public class DatagramChannelTest extends TestCase {
private void connectWriteBuf(InetSocketAddress ipAddr, ByteBuffer buf)
throws IOException {
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL, this.channel1.write(buf));
assertEquals(0, this.channel1.write(buf));
@@ -2366,47 +2766,40 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.write(ByteBuffer)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testWriteByteBuffer_Block() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
connectWriteBuf(localAddr1, writeBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testWriteByteBuffer_NonBlock() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
this.channel1.configureBlocking(false);
connectWriteBuf(localAddr1, writeBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testWriteByteBuffer_Block_closed() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testWriteByteBuffer_BlockClosed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
noconnectWrite(writeBuf);
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.close();
try {
@@ -2416,22 +2809,20 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testWriteByteBuffer_NonBlock_closed() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testWriteByteBuffer_NonBlockClosed() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non block mode
this.channel1.configureBlocking(false);
noconnectWrite(writeBuf);
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.close();
try {
@@ -2441,25 +2832,23 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testWriteByteBuffer_Block_BufNull() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testWriteByteBuffer_BlockBufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.write((ByteBuffer) null);
fail("Should throw NPE.");
} catch (NullPointerException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write((ByteBuffer) null);
@@ -2476,18 +2865,16 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testWriteByteBuffer_NonBlock_BufNull() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testWriteByteBuffer_NonBlockBufNull() throws IOException {
ByteBuffer writeBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non block mode
this.channel1.configureBlocking(false);
@@ -2498,7 +2885,7 @@ public class DatagramChannelTest extends TestCase {
} catch (NullPointerException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
this.channel1.write((ByteBuffer) null);
@@ -2519,47 +2906,114 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.write(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_Block() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify all exceptions according to specification.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_Block() throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.write(writeBuf, 0, 2);
fail("Should throw NotYetConnectedException.");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
// cannot be buffered again!
assertEquals(0, this.channel1.write(writeBuf, 0, 1));
+ this.channel1.close();
+ try {
+ this.channel1.write(writeBuf, 0, 1);
+ fail("Should throw ClosedChannelEception.");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+ }
+
+ public void disabled_testWriteByteBufferArrayII_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.write(targetBuf, 0 ,2);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ public void disabled_testWriteByteBufferArrayII_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+ channel1.write(targetBuf, 0, 2);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_NonBlock() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_NonBlock() throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
// non-block mode
this.channel1.configureBlocking(false);
try {
@@ -2568,30 +3022,80 @@ public class DatagramChannelTest extends TestCase {
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
// cannot be buffered again!
assertEquals(0, this.channel1.write(writeBuf, 0, 1));
+ this.channel1.close();
+ try {
+ this.channel1.write(writeBuf, 0, 1);
+ fail("Should throw ClosedChannelEception.");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_BlockClosed() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ // non-block mode
+ this.channel1.configureBlocking(false);
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.close();
+ try {
+ channel1.write(writeBuf, 0, 2);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // correct
+ }
+ }
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_NonBlockClosed() throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.close();
+ try {
+ channel1.write(writeBuf, 0, 2);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // correct
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_NoConnectIndexBad()
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_NotConnectedIndexBad()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
- this.channel1.write(writeBuf, -1, 2);
+ this.channel1.write(writeBuf, -1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
@@ -2602,31 +3106,48 @@ public class DatagramChannelTest extends TestCase {
} catch (IndexOutOfBoundsException e) {
// correct
}
- this.channel1.connect(ipAddr);
- assertTrue(this.channel1.isConnected());
- assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
- // cannot be buffered again!
- assertEquals(0, this.channel1.write(writeBuf, 0, 1));
+ try {
+ this.channel1.write(writeBuf, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(writeBuf, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(writeBuf, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(writeBuf, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_ConnectedIndexBad()
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_ConnectedIndexBad()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
writeBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
- this.channel1.connect(ipAddr);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
- this.channel1.write(writeBuf, -1, 2);
+ this.channel1.write(writeBuf, -1, 0);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
@@ -2637,74 +3158,94 @@ public class DatagramChannelTest extends TestCase {
} catch (IndexOutOfBoundsException e) {
// correct
}
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_BufNullNoConnect()
- throws IOException {
- ByteBuffer[] writeBuf = new ByteBuffer[2];
- writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
- this.channel1.write(null, 0, 2);
- fail("should throw NPE");
- } catch (NullPointerException e) {
+ this.channel1.write(writeBuf, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(writeBuf, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
// correct
}
try {
- this.channel1.write(null, -1, 2);
+ this.channel1.write(writeBuf, 2, 1);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
}
try {
- this.channel1.write(null, 0, 3);
+ this.channel1.write(writeBuf, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_NotConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] writeBuf = new ByteBuffer[2];
+ writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ try {
+ this.channel1.write(null, 0, 20);
fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
+ try {
+ this.channel1.write(writeBuf, 0, 2);
+ fail("should throw NotYetConnectedException");
+ } catch (NotYetConnectedException e) {
+ // correct
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testWriteByteBufferArrayIntInt_BufNullConnect()
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testWriteByteBufferArrayII_ConnectedBufNull()
throws IOException {
ByteBuffer[] writeBuf = new ByteBuffer[2];
writeBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
- this.channel1.connect(ipAddr);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
- this.channel1.write(null, 0, 2);
+ this.channel1.write(null, 0, 20);
fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
try {
- this.channel1.write(writeBuf, 0, 3);
- fail("should throw IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
+ this.channel1.write(writeBuf, 0, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
// correct
}
datagramSocket1.close();
try {
- this.channel1.write(null, 0, 2);
+ this.channel1.write(null, 0, 20);
fail("should throw NPE");
} catch (NullPointerException e) {
// correct
}
+ try {
+ this.channel1.write(writeBuf, 0, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // correct
+ }
}
// -------------------------------------------------------------------
@@ -2714,15 +3255,12 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.read(ByteBuffer)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadByteBuffer() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
try {
@@ -2731,7 +3269,7 @@ public class DatagramChannelTest extends TestCase {
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(localAddr1);
+ this.channel1.connect(localAddr1);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
@@ -2744,25 +3282,23 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void testReadByteBuffer_bufNull() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer_BufNull() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocateDirect(0);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(readBuf);
fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
try {
channel1.read((ByteBuffer) null);
@@ -2779,33 +3315,37 @@ public class DatagramChannelTest extends TestCase {
/*
* Test method for 'DatagramChannelImpl.read(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException, IOException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testReadByteBufferArrayIntInt() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify AsynchronousCloseException, ClosedByInterruptException, IOException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII() throws IOException {
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
+ InetSocketAddress ipAddr = localAddr1;
try {
this.channel1.read(readBuf, 0, 2);
fail("should throw NotYetConnectedException");
} catch (NotYetConnectedException e) {
// correct
}
- this.channel1.connect(ipAddr);
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
assertEquals(0, this.channel1.read(readBuf, 0, 1));
assertEquals(0, this.channel1.read(readBuf, 0, 2));
+ this.channel1.close();
+ assertFalse(this.channel1.isOpen());
+ try {
+ assertEquals(0, this.channel1.read(readBuf, 0, 1));
+ } catch (ClosedChannelException e) {
+ // correct
+ }
+
datagramSocket1.close();
//regression test for HARMONY-932
try {
@@ -2827,31 +3367,24 @@ public class DatagramChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void testReadByteBufferArrayIntInt_BufNull() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII_ConnectedBufNull()
+ throws IOException {
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- InetSocketAddress ipAddr = localAddr1;
- try {
- this.channel1.read(null, 0, 0);
- fail("should throw NPE");
- } catch (NullPointerException e) {
- // correct
- }
- this.channel1.connect(ipAddr);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
assertTrue(this.channel1.isConnected());
this.channel1.configureBlocking(false);
// note : blocking-mode will make the read process endless!
try {
- this.channel1.read(null, 0, 0);
+ this.channel1.read(null, 0, 2);
fail("should throw NPE");
} catch (NullPointerException e) {
// correct
@@ -2863,31 +3396,218 @@ public class DatagramChannelTest extends TestCase {
} catch (NullPointerException e) {
// correct
}
+ datagramSocket1.close();
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII_NotConnectedBufNull()
+ throws IOException {
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ try {
+ this.channel1.read(null, 0, 2);
+ fail("should throw NPE");
+ } catch (NullPointerException e) {
+ // correct
+ }
+ try {
+ this.channel1.read(readBuf, 0, 2);
+ fail("should throw NotYetConnectedException");
+ } catch (NotYetConnectedException e) {
+ // correct
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII_ConnectedIndexBad() throws IOException {
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ this.channel1.connect(ipAddr);
+ assertTrue(this.channel1.isConnected());
+ this.channel1.configureBlocking(false);
+ // note : blocking-mode will make the read process endless!
+ try {
+ this.channel1.read(readBuf, -1, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.read(readBuf, 0, -1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
try {
this.channel1.read(readBuf, 0, 3);
fail("should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
}
- datagramSocket1.close();
+ try {
+ this.channel1.read(readBuf, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.read(readBuf, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.read(readBuf, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII_NotConnectedIndexBad()
+ throws IOException {
+ ByteBuffer[] readBuf = new ByteBuffer[2];
+ readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+ InetSocketAddress ipAddr = localAddr1;
+ try {
+ this.channel1.write(readBuf, -1, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(readBuf, 0, -1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(readBuf, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(readBuf, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(readBuf, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ try {
+ this.channel1.write(readBuf, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // correct
+ }
+ }
+
+ public void disabled_testReadByteBufferArrayII_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.read(targetBuf, 0, 2);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+ channel1.read(targetBuf, 0, 2);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
}
// -------------------------------------------------------------------
// test read and write
// -------------------------------------------------------------------
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadWrite_configureBlock() throws Exception {
byte[] targetArray = new byte[2];
// bind and connect
@@ -2914,14 +3634,38 @@ public class DatagramChannelTest extends TestCase {
} catch (AsynchronousCloseException e) {
// ok
}
+ this.channel1.close();
+ try {
+ this.channel1.configureBlocking(true);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ this.channel1 = SelectorProvider.provider().openDatagramChannel();
+ this.channel1.configureBlocking(false);
+ this.channel1.register(SelectorProvider.provider().openSelector(),
+ SelectionKey.OP_READ);
+ try {
+ this.channel1.configureBlocking(true);
+ fail("should throw IllegalBlockingModeException");
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_Zero() throws Exception {
@@ -2939,23 +3683,23 @@ public class DatagramChannelTest extends TestCase {
// read
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
- int readCount = this.channel2.read(targetBuf);
-
- assertEquals(0, readCount);
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ assertEquals(0, this.channel2.read(targetBuf));
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_Normal() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -2972,13 +3716,19 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, CAPACITY_NORMAL, "testReadWrite_Block_Normal");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_Empty() throws Exception {
@@ -3002,19 +3752,21 @@ public class DatagramChannelTest extends TestCase {
// empty message let the reader blocked
closeBlockedReaderChannel2(targetBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_changeBlock_Empty() throws Exception {
// empty buf
byte[] sourceArray = "".getBytes();
@@ -3055,19 +3807,21 @@ public class DatagramChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_Block_8KB() throws Exception {
byte[] sourceArray = new byte[CAPACITY_1KB * 8];
byte[] targetArray = new byte[CAPACITY_1KB * 8];
@@ -3118,16 +3872,13 @@ public class DatagramChannelTest extends TestCase {
assertEquals(targetArray[i], (byte) i);
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify NotYetConnectedException, " +
- "ClosedChannelException, ClosedByInterruptException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadWrite_Block_64K() throws Exception {
byte[] sourceArray = new byte[CAPACITY_64KB];
for (int i = 0; i < sourceArray.length; i++) {
@@ -3149,13 +3900,19 @@ public class DatagramChannelTest extends TestCase {
// too big
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_DifferentAddr() throws Exception {
@@ -3181,13 +3938,19 @@ public class DatagramChannelTest extends TestCase {
// we close the blocked channel
closeBlockedReaderChannel2(targetBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_WriterNotBind() throws Exception {
@@ -3210,13 +3973,19 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
closeBlockedReaderChannel2(targetBuf);
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_WriterBindLater() throws Exception {
@@ -3270,13 +4039,19 @@ public class DatagramChannelTest extends TestCase {
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
)
})
public void testReadWrite_Block_ReaderNotBind() throws Exception {
@@ -3326,19 +4101,20 @@ public class DatagramChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test read and write in non-block mode.
// -------------------------------------------------------------------
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_Normal() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -3358,19 +4134,21 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, CAPACITY_NORMAL, "testReadWrite_NonBlock_Normal");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_8KB() throws Exception {
byte[] sourceArray = new byte[CAPACITY_1KB * 8];
byte[] targetArray = new byte[CAPACITY_1KB * 8];
@@ -3390,19 +4168,21 @@ public class DatagramChannelTest extends TestCase {
readWriteReadData(this.channel1, sourceArray, this.channel2,
targetArray, 8 * CAPACITY_1KB, "testReadWrite_NonBlock_8KB");
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_DifferentAddr() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -3427,19 +4207,59 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
+ public void testReadWrite_NonBlock_Empty() throws Exception {
+ // empty buf
+ byte[] sourceArray = "".getBytes();
+ byte[] targetArray = new byte[CAPACITY_NORMAL];
+
+ this.channel1.configureBlocking(false);
+ this.channel2.configureBlocking(false);
+
+ // bind and connect
+
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ // write
+ ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
+ assertEquals(0, this.channel1.write(sourceBuf));
+
+ // read
+ ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
+ assertEquals(0, this.channel2.read(targetBuf));
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_WriterNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -3463,19 +4283,57 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
+ public void testReadWrite_NonBlock_Zero() throws Exception {
+ byte[] sourceArray = new byte[0];
+ byte[] targetArray = new byte[0];
+
+ this.channel1.configureBlocking(false);
+ this.channel2.configureBlocking(false);
+
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ // write
+ ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
+ assertEquals(0, this.channel1.write(sourceBuf));
+
+ // read
+ ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
+ assertEquals(0, this.channel2.read(targetBuf));
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ })
public void testReadWrite_NonBlock_ReaderNotBind() throws Exception {
byte[] sourceArray = new byte[CAPACITY_NORMAL];
byte[] targetArray = new byte[CAPACITY_NORMAL];
@@ -3499,36 +4357,94 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer targetBuf = ByteBuffer.wrap(targetArray);
assertEquals(0, this.channel2.read(targetBuf));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_write_LBuffer_positioned() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testWriteByteBuffer_Positioned() throws Exception {
// Regression test for Harmony-683
int postion = 16;
DatagramChannel dc = DatagramChannel.open();
- byte[] sourceArray = new byte[CAPACITY_NORMAL];
+ byte[] sourceArray = new byte[CAPACITY_NORMAL];
dc.connect(localAddr1);
// write
ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
sourceBuf.position(postion);
assertEquals(CAPACITY_NORMAL - postion, dc.write(sourceBuf));
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
- public void test_send_LBuffer_LSocketAddress_PositonNotZero()
+
+ public void disabled_testWriteByteBuffer_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.send(targetBuf, localAddr1);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ public void disabled_testWriteByteBuffer_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+ channel1.send(targetBuf, localAddr1);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ public void testSend_PositonNotZero()
throws Exception {
// regression test for Harmony-701
int CAPACITY_NORMAL = 256;
@@ -3539,81 +4455,230 @@ public class DatagramChannelTest extends TestCase {
ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
sourceBuf.position(postion);
int ret = dc.send(sourceBuf, localAddr1);
- // assert send (256 - 16) bytes
+ // assert send (256 - 16) bytes
assertEquals(CAPACITY_NORMAL - postion, ret);
// assert the position of ByteBuffer has been set
assertEquals(CAPACITY_NORMAL, sourceBuf.position());
}
-
+
+ /**
+ * @tests DatagramChannel#read(ByteBuffer)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer2() throws Exception {
+ // regression test for Harmony-754
+ channel2.socket().bind(localAddr1);
+ channel1.socket().bind(localAddr2);
+ channel1.connect(localAddr1);
+ channel2.connect(localAddr2);
+ channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
+
+ ByteBuffer readBuf = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+
+ channel1.configureBlocking(true);
+ assertEquals(CAPACITY_NORMAL, channel1.read(readBuf));
+ }
+
+ public void disabled_testReadByteBuffer_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.read(targetBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer_Block_interrupt() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer targetBuf = ByteBuffer.wrap(new byte[2]);
+ channel1.read(targetBuf);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
/**
* @tests DatagramChannel#read(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
- public void test_read_$LByteBuffer() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void testReadByteBufferArray2() throws Exception {
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
channel1.socket().bind(localAddr2);
- channel1.connect(localAddr1);
+ channel1.connect(localAddr1);
channel2.connect(localAddr2);
channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
-
+
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
-
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+
channel1.configureBlocking(true);
assertEquals(CAPACITY_NORMAL, channel1.read(readBuf));
}
+ public void disabled_testReadByteBufferArray_Block_close() throws Exception {
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(TIME_UNIT);
+ channel1.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ this.channel1.read(targetBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ public void disabled_testReadByteBufferArray_Block_interrupt() throws Exception {
+ // makes emulator hang
+ // bind and connect
+ this.channel1.socket().bind(localAddr2);
+ this.channel1.connect(localAddr1);
+ this.channel2.socket().bind(localAddr1);
+ this.channel2.connect(localAddr2);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ ByteBuffer[] targetBuf = new ByteBuffer[2];
+ targetBuf[0] = ByteBuffer.wrap(new byte[2]);
+ targetBuf[1] = ByteBuffer.wrap(new byte[2]);
+ channel1.read(targetBuf);
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (IOException e) {
+ errMsg = "Unexcted Exception was thrown: " + e.getClass() +
+ ": " + e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ // ok
+ }
+ thread.join(TIME_UNIT);
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
/**
* @tests DatagramChannel#read(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void test_read_$LByteBufferII() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void testReadByteBufferArrayII2() throws Exception {
// regression test for Harmony-754
channel2.socket().bind(localAddr1);
channel1.socket().bind(localAddr2);
- channel1.connect(localAddr1);
+ channel1.connect(localAddr1);
channel2.connect(localAddr2);
channel2.write(ByteBuffer.allocate(CAPACITY_NORMAL));
-
+
ByteBuffer[] readBuf = new ByteBuffer[2];
readBuf[0] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
- readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
-
+ readBuf[1] = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
+
channel1.configureBlocking(true);
assertEquals(CAPACITY_NORMAL, channel1.read(readBuf,0,2));
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_read_LByteBuffer_closed_nullBuf() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer_closed_nullBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = null;
DatagramChannel channel = DatagramChannel.open();
@@ -3625,20 +4690,17 @@ public class DatagramChannelTest extends TestCase {
// expected
}
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_read_LByteBuffer_NotConnected_nullBuf() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer_NotConnected_nullBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = null;
DatagramChannel channel = DatagramChannel.open();
@@ -3649,20 +4711,17 @@ public class DatagramChannelTest extends TestCase {
// expected
}
}
-
+
/**
* @tests DatagramChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_read_LByteBuffer_readOnlyBuf() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void testReadByteBuffer_readOnlyBuf() throws Exception {
// regression test for Harmony-754
ByteBuffer c = ByteBuffer.allocate(1);
DatagramChannel channel = DatagramChannel.open();
@@ -3680,20 +4739,17 @@ public class DatagramChannelTest extends TestCase {
// expected
}
}
-
+
/**
* @tests DatagramChannel#send(ByteBuffer, SocketAddress)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "send",
- methodArgs = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
- )
- })
- public void test_send_LByteBuffer_LSocketAddress_closed() throws IOException{
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "send",
+ args = {java.nio.ByteBuffer.class, java.net.SocketAddress.class}
+ )
+ public void testSend_Closed() throws IOException{
// regression test for Harmony-913
channel1.close();
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -3722,20 +4778,17 @@ public class DatagramChannelTest extends TestCase {
//pass
}
}
-
+
/**
* @tests DatagramChannel#socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
- public void test_socket_IllegalBlockingModeException() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
+ public void testSocket_NonBlock_IllegalBlockingModeException() throws Exception {
// regression test for Harmony-1036
DatagramChannel channel = DatagramChannel.open();
channel.configureBlocking(false);
@@ -3753,69 +4806,4 @@ public class DatagramChannelTest extends TestCase {
// expected
}
}
-
- // -------------------------------------------------------------------
- // Mock class for security test.
- // -------------------------------------------------------------------
- private class MockSecurityManager extends SecurityManager {
-
- String validHost = null;
-
- int validPort = -1;
-
- MockSecurityManager() {
- super();
- this.validHost = null;
- }
-
- MockSecurityManager(String host) {
- super();
- this.validHost = host;
- }
-
- MockSecurityManager(int port) {
- super();
- this.validPort = port;
- }
-
- public void checkPermission(Permission perm) {
- // no-op
- }
-
- public void checkPermission(Permission perm, Object context) {
- // no-op
- }
-
- public void checkConnect(String host, int port) {
- // our local addr is OK.
- if (null != this.validHost) {
- if (!this.validHost.equals(host)) {
- throw new SecurityException();
- }
- }
- if ("127.0.0.1".equals(host)) {
- return;
- }
- super.checkConnect(host, port);
- }
-
- public void checkAccept(String host, int port) {
- // our local addr is OK.
- if (null != this.validHost) {
- if (!this.validHost.equals(host)) {
- throw new SecurityException();
- }
- }
- if (-1 != this.validPort) {
- if (this.validPort != port) {
- throw new SecurityException();
- }
- }
- if ("127.0.0.1".equals(host)) {
- return;
- }
- super.checkAccept(host, port);
- }
- }
-
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java
deleted file mode 100644
index 4d707c7..0000000
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/* 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 regarding copyright ownership.
- * The ASF licenses this file 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
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.nio.tests.java.nio.channels;
-
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.channels.NonReadableChannelException;
-import java.nio.channels.NonWritableChannelException;
-import java.nio.channels.OverlappingFileLockException;
-
-import junit.framework.TestCase;
-
-/**
- * API tests for the NIO FileChannel locking APIs
- */
-@TestTargetClass(java.nio.channels.FileChannel.class)
-public class FileChannelLockingTest extends TestCase {
-
- private FileChannel readOnlyChannel;
-
- private FileChannel writeOnlyChannel;
-
- private FileChannel readWriteChannel;
-
- private final String CONTENT = "The best things in life are nearest: Breath in your nostrils, light in your eyes, "
- + "flowers at your feet, duties at your hand, the path of right just before you. Then do not grasp at the stars, "
- + "but do life's plain, common work as it comes, certain that daily duties and daily bread are the sweetest "
- + " things in life.--Robert Louis Stevenson";
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Create a three temporary files with content.
- File[] tempFiles = new File[3];
- for (int i = 0; i < tempFiles.length; i++) {
- tempFiles[i] = File.createTempFile("testing", "tmp");
- tempFiles[i].deleteOnExit();
- FileWriter writer = new FileWriter(tempFiles[i]);
- writer.write(CONTENT);
- writer.close();
- }
-
- // Open read, write, and read/write channels on the temp files.
- FileInputStream fileInputStream = new FileInputStream(tempFiles[0]);
- readOnlyChannel = fileInputStream.getChannel();
-
- FileOutputStream fileOutputStream = new FileOutputStream(tempFiles[1]);
- writeOnlyChannel = fileOutputStream.getChannel();
-
- RandomAccessFile randomAccessFile = new RandomAccessFile(tempFiles[2],
- "rw");
- readWriteChannel = randomAccessFile.getChannel();
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
- public void test_illegalLocks() throws IOException {
- // Cannot acquire an exclusive lock on a read-only file channel
- try {
- readOnlyChannel.lock();
- fail("Acquiring a full exclusive lock on a read only channel should fail.");
- } catch (NonWritableChannelException ex) {
- // Expected.
- }
-
- // Cannot get a shared lock on a write-only file channel.
- try {
- writeOnlyChannel.lock(1, 10, true);
- fail("Acquiring a shared lock on a write-only channel should fail.");
- } catch (NonReadableChannelException ex) {
- // expected
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {}
- )
- })
- public void test_lockReadWrite() throws IOException {
- // Acquire an exclusive lock across the entire file.
- FileLock flock = readWriteChannel.lock();
- if (flock != null) {
- flock.release();
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
- public void test_illegalLockParameters() throws IOException {
- // Cannot lock negative positions
- try {
- readOnlyChannel.lock(-1, 10, true);
- fail("Passing illegal args to lock should fail.");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- writeOnlyChannel.lock(-1, 10, false);
- fail("Passing illegal args to lock should fail.");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- try {
- readWriteChannel.lock(-1, 10, false);
- fail("Passing illegal args to lock should fail.");
- } catch (IllegalArgumentException ex) {
- // expected
- }
-
- // Lock a range at the front, shared.
- FileLock flock1 = readWriteChannel.lock(22, 110, true);
-
- // Try to acquire an overlapping lock.
- try {
- readWriteChannel.lock(75, 210, true);
- } catch (OverlappingFileLockException exception) {
- // expected
- flock1.release();
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't call isShared, isValid methods after lock.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
- public void test_lockLLZ() throws IOException {
- // Lock a range at the front, non-shared.
- FileLock flock1 = readWriteChannel.lock(0, 10, false);
-
- // Lock a shared range further in the same file.
- FileLock flock2 = readWriteChannel.lock(22, 100, true);
-
- // The spec allows the impl to refuse shared locks
- flock1.release();
- flock2.release();
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {}
- )
- })
- public void test_tryLock() throws IOException {
- try {
- readOnlyChannel.tryLock();
- fail("Acquiring a full exclusive lock on a read channel should have thrown an exception.");
- } catch (NonWritableChannelException ex) {
- // Expected.
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
- public void test_tryLockLLZ() throws IOException {
- // It is illegal to request an exclusive lock on a read-only channel
- try {
- readOnlyChannel.tryLock(0, 99, false);
- fail("Acquiring exclusive lock on read-only channel should fail");
- } catch (NonWritableChannelException ex) {
- // Expected
- }
-
- // It is invalid to request a lock starting before the file start
- try {
- readOnlyChannel.tryLock(-99, 0, true);
- fail("Acquiring an illegal lock value should fail.");
- } catch (IllegalArgumentException ex) {
- // expected
- }
-
- // Acquire a valid lock
- FileLock tmpLock = readOnlyChannel.tryLock(0, 10, true);
- assertTrue(tmpLock.isValid());
- tmpLock.release();
-
- // Acquire another valid lock -- and don't release it yet
- FileLock lock = readOnlyChannel.tryLock(10, 788, true);
- assertTrue(lock.isValid());
-
- // Overlapping locks are illegal
- try {
- readOnlyChannel.tryLock(1, 23, true);
- fail("Acquiring an overlapping lock should fail.");
- } catch (OverlappingFileLockException ex) {
- // Expected
- }
-
- // Adjacent locks are legal
- FileLock adjacentLock = readOnlyChannel.tryLock(1, 3, true);
- assertTrue(adjacentLock.isValid());
- adjacentLock.release();
-
- // Release longer lived lock
- lock.release();
- }
-}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
index 68c8223..9a1a956 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java
@@ -4,9 +4,9 @@
* The ASF licenses this file 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
- *
+ *
* 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.
@@ -16,8 +16,9 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -52,13 +53,23 @@ import org.apache.harmony.luni.platform.Platform;
import junit.framework.TestCase;
-@TestTargetClass(FileChannel.class)
+@TestTargetClass(
+ value = FileChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "FileChannel",
+ args = {}
+ )
+ }
+)
public class FileChannelTest extends TestCase {
private static final int CAPACITY = 100;
private static final int LIMITED_CAPACITY = 2;
-
+
private static final int TIME_OUT = 10000;
private static final String CONTENT = "MYTESTSTRING needs to be a little long";
@@ -90,7 +101,7 @@ public class FileChannelTest extends TestCase {
private File fileOfWriteOnlyFileChannel;
private File fileOfReadWriteFileChannel;
-
+
private ReadableByteChannel readByteChannel;
private WritableByteChannel writableByteChannel;
@@ -235,16 +246,13 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify force method with false parameter.",
- targets = {
- @TestTarget(
- methodName = "force",
- methodArgs = {boolean.class}
- )
- })
- public void test_forceJ() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "force",
+ args = {boolean.class}
+ )
+ public void test_forceZ() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
writeOnlyFileChannel.write(writeBuffer);
writeOnlyFileChannel.force(true);
@@ -253,21 +261,26 @@ public class FileChannelTest extends TestCase {
fis = new FileInputStream(fileOfWriteOnlyFileChannel);
fis.read(readBuffer);
assertTrue(Arrays.equals(CONTENT_AS_BYTES, readBuffer));
+
+ writeOnlyFileChannel.write(writeBuffer);
+ writeOnlyFileChannel.force(false);
+
+ readBuffer = new byte[CONTENT_AS_BYTES_LENGTH];
+ fis = new FileInputStream(fileOfWriteOnlyFileChannel);
+ fis.read(readBuffer);
+ assertTrue(Arrays.equals(CONTENT_AS_BYTES, readBuffer));
}
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "force",
- methodArgs = {boolean.class}
- )
- })
- public void test_forceJ_closed() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "force",
+ args = {boolean.class}
+ )
+ public void test_forceZ_closed() throws Exception {
writeOnlyFileChannel.close();
try {
writeOnlyFileChannel.force(true);
@@ -287,16 +300,13 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#force(boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "force",
- methodArgs = {boolean.class}
- )
- })
- public void test_forceJ_ReadOnlyChannel() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "force",
+ args = {boolean.class}
+ )
+ public void test_forceZ_ReadOnlyChannel() throws Exception {
// force on a read only file channel has no effect.
readOnlyFileChannel.force(true);
readOnlyFileChannel.force(false);
@@ -305,15 +315,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position_Init() throws Exception {
assertEquals(0, readOnlyFileChannel.position());
assertEquals(0, writeOnlyFileChannel.position());
@@ -323,15 +330,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -343,7 +347,7 @@ public class FileChannelTest extends TestCase {
/**
* Initializes test file.
- *
+ *
* @param file
* @throws FileNotFoundException
* @throws IOException
@@ -360,14 +364,14 @@ public class FileChannelTest extends TestCase {
/**
* Initializes large test file.
- *
+ *
* @param file the file to be written
* @param size the content size to be written
* @throws FileNotFoundException
* @throws IOException
*/
- private void writeLargeDataToFile(File file, int size) throws FileNotFoundException,
- IOException {
+ private void writeLargeDataToFile(File file, int size)
+ throws FileNotFoundException, IOException {
FileOutputStream fos = new FileOutputStream(file);
byte[] buf = new byte[size];
@@ -382,15 +386,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position_WriteOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
writeOnlyFileChannel.write(writeBuffer);
@@ -400,15 +401,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position_ReadWrite() throws Exception {
writeDataToFile(fileOfReadWriteFileChannel);
@@ -425,15 +423,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "position",
+ args = {}
+ )
public void test_position_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -463,15 +458,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "position",
+ args = {long.class}
+ )
public void test_positionJ_Closed() throws Exception {
final long POSITION = 100;
@@ -503,15 +495,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "position",
+ args = {long.class}
+ )
public void test_positionJ_Negative() throws Exception {
final long NEGATIVE_POSITION = -1;
try {
@@ -539,15 +528,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {long.class}
+ )
public void test_positionJ_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -572,15 +558,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {long.class}
+ )
public void test_positionJ_WriteOnly() throws Exception {
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -615,15 +598,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies zero size.",
- targets = {
- @TestTarget(
- methodName = "size",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies zero size.",
+ method = "size",
+ args = {}
+ )
public void test_size_Init() throws Exception {
assertEquals(0, readOnlyFileChannel.size());
assertEquals(0, writeOnlyFileChannel.size());
@@ -633,15 +613,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies positive case.",
- targets = {
- @TestTarget(
- methodName = "size",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies positive case.",
+ method = "size",
+ args = {}
+ )
public void test_size() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
assertEquals(fileOfReadOnlyFileChannel.length(), readOnlyFileChannel
@@ -651,15 +628,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#size()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "size",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "size",
+ args = {}
+ )
public void test_size_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -689,15 +663,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "truncate",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "truncate",
+ args = {long.class}
+ )
public void test_truncateJ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -727,15 +698,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "truncate",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "truncate",
+ args = {long.class}
+ )
public void test_truncateJ_IllegalArgument() throws Exception {
// regression test for Harmony-941
try {
@@ -744,7 +712,7 @@ public class FileChannelTest extends TestCase {
} catch (IllegalArgumentException e) {
// expected
}
-
+
try {
writeOnlyFileChannel.truncate(-1);
fail("should throw IllegalArgumentException");
@@ -763,15 +731,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NonWritableChannelException.",
- targets = {
- @TestTarget(
- methodName = "truncate",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException.",
+ method = "truncate",
+ args = {long.class}
+ )
public void test_truncateJ_ReadOnly() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
try {
@@ -792,15 +757,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#truncate(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "truncate",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exceptions.",
+ method = "truncate",
+ args = {long.class}
+ )
public void test_truncateJ() throws Exception {
writeDataToFile(fileOfReadWriteFileChannel);
@@ -823,15 +785,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "lock",
+ args = {}
+ )
public void test_lock() throws Exception {
MockFileChannel mockFileChannel = new MockFileChannel();
// Verify that calling lock() leads to the method
@@ -845,15 +804,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -891,15 +847,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_IllegalArgument() throws Exception {
try {
writeOnlyFileChannel.lock(0, -1, false);
@@ -933,15 +886,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonWritableChannelException.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_NonWritable() throws Exception {
try {
readOnlyFileChannel.lock(0, 10, false);
@@ -962,15 +912,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonReadableChannelException.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonReadableChannelException.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_NonReadable() throws Exception {
try {
writeOnlyFileChannel.lock(0, 10, true);
@@ -991,15 +938,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies shared channel.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies shared channel.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_Shared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1016,15 +960,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that unshared channel.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that unshared channel.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_NotShared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1039,15 +980,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies lok method with Long max value as a size.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies lock method with Long max value as a size.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_Long_MAX_VALUE() throws Exception {
final long POSITION = 0;
final long SIZE = Long.MAX_VALUE;
@@ -1062,15 +1000,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies OverlappingFileLockException.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies OverlappingFileLockException.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_Overlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1088,15 +1023,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that not overlaping regions can be locked.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that not overlaping regions can be locked.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_NotOverlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1110,15 +1042,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#lock(long,long,boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies functionality after release method.",
- targets = {
- @TestTarget(
- methodName = "lock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies functionality after release method.",
+ method = "lock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_lockJJZ_After_Release() throws Exception {
fileLock = writeOnlyFileChannel.lock(0, 10, false);
fileLock.release();
@@ -1130,15 +1059,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {}
+ )
public void test_tryLock() throws Exception {
MockFileChannel mockFileChannel = new MockFileChannel();
// Verify that calling tryLock() leads to the method
@@ -1152,15 +1078,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_Closed() throws Exception {
readOnlyFileChannel.close();
try {
@@ -1198,15 +1121,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_IllegalArgument() throws Exception {
try {
writeOnlyFileChannel.tryLock(0, -1, false);
@@ -1240,15 +1160,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonWritableChannelException.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException.",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_NonWritable() throws Exception {
try {
readOnlyFileChannel.tryLock(0, 10, false);
@@ -1269,15 +1186,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonReadableChannelException.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonReadableChannelException.",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_NonReadable() throws Exception {
try {
writeOnlyFileChannel.tryLock(0, 10, true);
@@ -1298,15 +1212,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_Shared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1323,15 +1234,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_NotShared() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1346,15 +1254,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_Long_MAX_VALUE() throws Exception {
final long POSITION = 0;
final long SIZE = Long.MAX_VALUE;
@@ -1369,15 +1274,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies OverlappingFileLockException.",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies OverlappingFileLockException.",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_Overlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1395,15 +1297,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long, long, boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_NotOverlapping() throws Exception {
final long POSITION = 100;
final long SIZE = 200;
@@ -1419,15 +1318,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#tryLock(long,long,boolean)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "tryLock",
- methodArgs = {long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "tryLock",
+ args = {long.class, long.class, boolean.class}
+ )
public void test_tryLockJJZ_After_Release() throws Exception {
fileLock = writeOnlyFileChannel.tryLock(0, 10, false);
fileLock.release();
@@ -1440,15 +1336,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer_Null() throws Exception {
ByteBuffer readBuffer = null;
@@ -1470,17 +1363,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException. Doesn't verify " +
- "AsynchronousCloseException, ClosedByInterruptException, " +
- "IOException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer_Closed() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1511,6 +1399,20 @@ public class FileChannelTest extends TestCase {
// should throw ClosedChannelException first
readBuffer = null;
try {
+ readOnlyFileChannel.read(readBuffer);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ try {
+ writeOnlyFileChannel.read(readBuffer);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ try {
readWriteFileChannel.read(readBuffer);
fail("should throw ClosedChannelException");
} catch (ClosedChannelException e) {
@@ -1521,15 +1423,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonReadableChannelException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonReadableChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer_WriteOnly() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1553,15 +1452,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer_EmptyFile() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
int result = readOnlyFileChannel.read(readBuffer);
@@ -1572,15 +1468,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer_LimitedCapacity() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1597,15 +1490,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_readLByteBuffer() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -1622,15 +1512,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_Null() throws Exception {
ByteBuffer readBuffer = null;
@@ -1649,8 +1536,21 @@ public class FileChannelTest extends TestCase {
// expected
}
+ try {
+ readWriteFileChannel.read(readBuffer, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
// first throws NullPointerException
- writeOnlyFileChannel.close();
+ try {
+ readWriteFileChannel.read(readBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
try {
writeOnlyFileChannel.read(readBuffer, 0);
fail("should throw NullPointerException");
@@ -1658,8 +1558,9 @@ public class FileChannelTest extends TestCase {
// expected
}
+ // first throws NullPointerException
try {
- readWriteFileChannel.read(readBuffer, 0);
+ writeOnlyFileChannel.read(readBuffer, -1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
@@ -1673,20 +1574,54 @@ public class FileChannelTest extends TestCase {
} catch (NullPointerException e) {
// expected
}
+
+ try {
+ writeOnlyFileChannel.read(readBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ readWriteFileChannel.close();
+ try {
+ readWriteFileChannel.read(readBuffer, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ readWriteFileChannel.read(readBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.read(readBuffer, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ readOnlyFileChannel.read(readBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
}
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_Closed() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1710,15 +1645,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_IllegalArgument() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1744,6 +1676,22 @@ public class FileChannelTest extends TestCase {
}
// throws IllegalArgumentException first.
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.read(readBuffer, -1);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.read(readBuffer, -1);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
readWriteFileChannel.close();
try {
readWriteFileChannel.read(readBuffer, -1);
@@ -1756,15 +1704,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonReadableChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_WriteOnly() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1788,15 +1733,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_Emptyfile() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
int result = readOnlyFileChannel.read(readBuffer, 0);
@@ -1807,15 +1749,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_Postion_BeyondFileLimit()
throws Exception {
@@ -1831,15 +1770,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IOException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IOException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ_Postion_As_Long() throws Exception {
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
try {
@@ -1852,15 +1788,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_readLByteBufferJ() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
@@ -1879,26 +1812,23 @@ public class FileChannelTest extends TestCase {
assertEquals(CONTENT_AS_BYTES[i], readBuffer.get());
}
}
-
+
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
- public void test_read$LByteBuffer() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read$LByteBuffer_Regression() throws Exception {
// regression test for Harmony-849
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
readBuffers[1] = ByteBuffer.allocate(CAPACITY);
-
+
long readCount = readOnlyFileChannel.read(readBuffers);
assertEquals(CONTENT_AS_BYTES_LENGTH, readCount);
assertEquals(CONTENT_AS_BYTES_LENGTH, readBuffers[0].position());
@@ -1908,20 +1838,17 @@ public class FileChannelTest extends TestCase {
assertEquals(CONTENT_AS_BYTES[i], readBuffers[0].get());
}
}
-
+
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
- public void test_read$LByteBuffer_mock() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read$LByteBuffer() throws Exception {
FileChannel mockChannel = new MockFileChannel();
ByteBuffer[] buffers = new ByteBuffer[2];
mockChannel.read(buffers);
@@ -1933,50 +1860,199 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_Null() throws Exception {
- ByteBuffer[] readBuffers = null;
try {
- readOnlyFileChannel.read(readBuffers, 0, 1);
+ readOnlyFileChannel.read(null, 0, 1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
-
try {
- readOnlyFileChannel.read(readBuffers, 1, 11);
+ readOnlyFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 3, 0);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
- writeOnlyFileChannel.read(readBuffers, 0, 1);
+ writeOnlyFileChannel.read(null, 0, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 3, 0);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
try {
- readWriteFileChannel.read(readBuffers, 0, 1);
+ readWriteFileChannel.read(null, 0, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 3, 0);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
// first throws NullPointerException
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.read(null, 0, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.read(null, 3, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ readWriteFileChannel.close();
+ try {
+ readWriteFileChannel.read(null, 0, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.read(null, 3, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
writeOnlyFileChannel.close();
try {
- writeOnlyFileChannel.read(readBuffers, 0, 1);
+ writeOnlyFileChannel.read(null, 0, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 0, 3);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 2, 1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.read(null, 3, 0);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
@@ -1986,15 +2062,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_Closed() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -2022,7 +2095,7 @@ public class FileChannelTest extends TestCase {
} catch (ClosedChannelException e) {
// expected
}
-
+
// regression test for Harmony-902
readBuffers[0] = null;
try {
@@ -2048,15 +2121,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_WriteOnly() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -2078,25 +2148,75 @@ public class FileChannelTest extends TestCase {
}
}
+ private void doTestForIOOBException(FileChannel channel,
+ ByteBuffer[] buffer) throws IOException{
+ try {
+ channel.read(buffer, -1, 0);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ channel.read(buffer, 0, -1);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ channel.read(buffer, 0, 3);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ channel.read(buffer, 1, 2);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ channel.read(buffer, 2, 1);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ channel.read(buffer, 3, 0);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ }
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_IndexOutOfBound() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
readBuffers[1] = ByteBuffer.allocate(CAPACITY);
+ ByteBuffer[] readBuffersNull = new ByteBuffer[2];
+ doTestForIOOBException(readOnlyFileChannel, readBuffers);
+ doTestForIOOBException(readWriteFileChannel, readBuffers);
+ doTestForIOOBException(writeOnlyFileChannel, readBuffers);
+
+ doTestForIOOBException(readOnlyFileChannel, readBuffersNull);
+ doTestForIOOBException(readWriteFileChannel, readBuffersNull);
+ doTestForIOOBException(writeOnlyFileChannel, readBuffersNull);
+ try {
+ readOnlyFileChannel.read(null, -1, 0);
+ fail("should throw IndexOutOfBoundException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
try {
- readOnlyFileChannel.read(readBuffers, 2, 1);
+ readOnlyFileChannel.read(null, 0, -1);
fail("should throw IndexOutOfBoundException");
} catch (IndexOutOfBoundsException e) {
// expected
@@ -2104,47 +2224,52 @@ public class FileChannelTest extends TestCase {
try {
readWriteFileChannel.read(null, -1, 0);
- fail("should throw IndexOutOfBoundsException");
+ fail("should throw IndexOutOfBoundException");
} catch (IndexOutOfBoundsException e) {
// expected
}
-
try {
- writeOnlyFileChannel.read(readBuffers, 0, 3);
- fail("should throw IndexOutOfBoundsException");
+ readWriteFileChannel.read(null, 0, -1);
+ fail("should throw IndexOutOfBoundException");
} catch (IndexOutOfBoundsException e) {
// expected
}
try {
- readWriteFileChannel.read(readBuffers, -1, 0);
- fail("should throw IndexOutOfBoundsException");
+ writeOnlyFileChannel.read(null, -1, 0);
+ fail("should throw IndexOutOfBoundException");
} catch (IndexOutOfBoundsException e) {
// expected
}
-
- // throws IndexOutOfBoundsException first
- readWriteFileChannel.close();
try {
- readWriteFileChannel.read(readBuffers, 0, 3);
- fail("should throw IndexOutOfBoundsException");
+ writeOnlyFileChannel.read(null, 0, -1);
+ fail("should throw IndexOutOfBoundException");
} catch (IndexOutOfBoundsException e) {
// expected
}
+
+ readOnlyFileChannel.close();
+ doTestForIOOBException(readOnlyFileChannel, readBuffers);
+ doTestForIOOBException(readOnlyFileChannel, readBuffersNull);
+
+ readWriteFileChannel.close();
+ doTestForIOOBException(readWriteFileChannel, readBuffers);
+ doTestForIOOBException(readWriteFileChannel, readBuffersNull);
+
+ writeOnlyFileChannel.close();
+ doTestForIOOBException(writeOnlyFileChannel, readBuffers);
+ doTestForIOOBException(writeOnlyFileChannel, readBuffersNull);
}
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_EmptyFile() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
readBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -2158,17 +2283,16 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_EmptyBuffers() throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
+ readBuffers[0] = ByteBuffer.allocate(CAPACITY);
+
try {
readOnlyFileChannel.read(readBuffers, 0, 2);
} catch (NullPointerException e) {
@@ -2190,15 +2314,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_EmptyFile_EmptyBuffers()
throws Exception {
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -2210,15 +2331,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_Length_Zero() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -2231,15 +2349,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_LimitedCapacity() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -2257,19 +2372,16 @@ public class FileChannelTest extends TestCase {
assertEquals(CONTENT_AS_BYTES[i], readBuffers[1].get());
}
}
-
+
/**
* @tests java.nio.channels.FileChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII() throws Exception {
writeDataToFile(fileOfReadOnlyFileChannel);
ByteBuffer[] readBuffers = new ByteBuffer[2];
@@ -2290,14 +2402,20 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#isOpen()
+ * @tests java.nio.channels.FileChannel#close()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Doesn't verify that isOpen returns true.",
- targets = {
- @TestTarget(
- methodName = "isOpen",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
)
})
public void test_isOpen() throws Exception {
@@ -2307,6 +2425,7 @@ public class FileChannelTest extends TestCase {
FileOutputStream out = new FileOutputStream(logFile, true);
FileChannel channel = out.getChannel();
out.write(1);
+ assertTrue("Assert 0: Channel is not open", channel.isOpen());
out.close();
assertFalse("Assert 0: Channel is still open", channel.isOpen());
}
@@ -2314,15 +2433,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#position()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position_append() throws Exception {
// Regression test for Harmony-508
File tmpfile = File.createTempFile("FileOutputStream", "tmp");
@@ -2340,22 +2456,16 @@ public class FileChannelTest extends TestCase {
assertEquals(10, f.getChannel().position());
}
-
+
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NonReadableChannelException, " +
- "NonWritableChannelException , ClosedChannelException, " +
- "IllegalArgumentException, IOException. ",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonReadableChannelException, NonWritableChannelException , ClosedChannelException, IllegalArgumentException, IOException. ",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_AbnormalMode() throws IOException {
try {
writeOnlyFileChannel.map(MapMode.READ_ONLY, 0, CONTENT_LENGTH);
@@ -2443,20 +2553,16 @@ public class FileChannelTest extends TestCase {
// expected;
}
}
-
+
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_ReadOnly_CloseChannel() throws IOException {
// close channel has no effect on map if mapped
assertEquals(0, readWriteFileChannel.size());
@@ -2470,16 +2576,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_Private_CloseChannel() throws IOException {
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 0,
CONTENT_LENGTH);
@@ -2492,16 +2594,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_ReadOnly() throws IOException {
MappedByteBuffer mapped = null;
// try put something to readonly map
@@ -2533,16 +2631,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_ReadOnly_NonZeroPosition() throws IOException {
this.writeDataToFile(fileOfReadOnlyFileChannel);
MappedByteBuffer mapped = readOnlyFileChannel.map(MapMode.READ_ONLY,
@@ -2555,16 +2649,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_Private() throws IOException {
this.writeDataToFile(fileOfReadWriteFileChannel);
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 0,
@@ -2590,16 +2680,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_Private_NonZeroPosition() throws IOException {
MappedByteBuffer mapped = readWriteFileChannel.map(MapMode.PRIVATE, 10,
CONTENT_LENGTH - 10);
@@ -2611,16 +2697,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_ReadWrite() throws IOException {
MappedByteBuffer mapped = null;
writeDataToFile(fileOfReadWriteFileChannel);
@@ -2648,16 +2730,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class,
- long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
public void test_map_ReadWrite_NonZeroPosition() throws IOException {
// test position non-zero
writeDataToFile(fileOfReadWriteFileChannel);
@@ -2680,15 +2758,13 @@ public class FileChannelTest extends TestCase {
*
* @tests java.nio.channels.FileChannel#map(MapMode,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "map",
- methodArgs = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "map",
+ args = {java.nio.channels.FileChannel.MapMode.class, long.class, long.class}
+ )
+ @AndroidOnly("Platform.class is harmony specific")
public void test_map_LargePosition() throws IOException {
// Regression test for HARMONY-3085
int[] sizes = {
@@ -2705,11 +2781,12 @@ public class FileChannelTest extends TestCase {
fileOfReadOnlyFileChannel = File.createTempFile(
"File_of_readOnlyFileChannel", "tmp");
fileOfReadOnlyFileChannel.deleteOnExit();
- readOnlyFileChannel = new FileInputStream(fileOfReadOnlyFileChannel)
- .getChannel();
+ readOnlyFileChannel = new FileInputStream(
+ fileOfReadOnlyFileChannel).getChannel();
}
- writeLargeDataToFile(fileOfReadOnlyFileChannel, sizes[i] + 2 * CONTENT_LEN);
+ writeLargeDataToFile(fileOfReadOnlyFileChannel, sizes[i] +
+ 2 * CONTENT_LEN);
MappedByteBuffer mapped = readOnlyFileChannel.map(MapMode.READ_ONLY,
sizes[i], CONTENT_LEN);
assertEquals("Incorrectly mapped file channel for " + sizes[i]
@@ -2731,15 +2808,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_writeLByteBuffer_Null() throws Exception {
ByteBuffer writeBuffer = null;
@@ -2761,15 +2835,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_writeLByteBuffer_Closed() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2805,20 +2876,32 @@ public class FileChannelTest extends TestCase {
} catch (ClosedChannelException e) {
// expected
}
+
+ try {
+ readOnlyFileChannel.write(writeBuffer);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.write(writeBuffer);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonWritableChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_writeLByteBuffer_ReadOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2842,15 +2925,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_writeLByteBuffer() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
@@ -2867,20 +2947,17 @@ public class FileChannelTest extends TestCase {
fis.read(inputBuffer);
assertTrue(Arrays.equals(CONTENT_AS_BYTES, inputBuffer));
}
-
+
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_writeLByteBuffer_positioned() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void test_writeLByteBuffer_NonZeroPosition() throws Exception {
final int pos = 5;
ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
writeBuffer.position(pos);
@@ -2895,22 +2972,19 @@ public class FileChannelTest extends TestCase {
fis = new FileInputStream(fileOfWriteOnlyFileChannel);
byte[] inputBuffer = new byte[CONTENT_AS_BYTES_LENGTH - pos];
fis.read(inputBuffer);
- String test = CONTENT.substring(pos);
+ String test = CONTENT.substring(pos);
assertTrue(Arrays.equals(test.getBytes(), inputBuffer));
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_writeLByteBufferJ_Null() throws Exception {
ByteBuffer writeBuffer = null;
@@ -2921,6 +2995,14 @@ public class FileChannelTest extends TestCase {
// expected
}
+ // first throws NullPointerException
+ try {
+ readOnlyFileChannel.write(writeBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
try {
writeOnlyFileChannel.write(writeBuffer, 0);
fail("should throw NullPointerException");
@@ -2930,7 +3012,7 @@ public class FileChannelTest extends TestCase {
// first throws NullPointerException
try {
- readOnlyFileChannel.write(writeBuffer, -1);
+ writeOnlyFileChannel.write(writeBuffer, -1);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
@@ -2944,6 +3026,14 @@ public class FileChannelTest extends TestCase {
}
// first throws NullPointerException
+ try {
+ readWriteFileChannel.write(writeBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ // first throws NullPointerException
readWriteFileChannel.close();
try {
readWriteFileChannel.write(writeBuffer, 0);
@@ -2951,20 +3041,54 @@ public class FileChannelTest extends TestCase {
} catch (NullPointerException e) {
// expected
}
+
+ try {
+ readWriteFileChannel.write(writeBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.write(writeBuffer, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ writeOnlyFileChannel.write(writeBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.write(writeBuffer, 0);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ readOnlyFileChannel.write(writeBuffer, -1);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_writeLByteBufferJ_Closed() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -2988,15 +3112,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonWritableChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_writeLByteBufferJ_ReadOnly() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -3006,9 +3127,9 @@ public class FileChannelTest extends TestCase {
} catch (NonWritableChannelException e) {
// expected
}
-
+
// regression test for Harmony-903
-
+
// read-only file channel never throws ClosedChannelException even if
// the channel is closed.
readOnlyFileChannel.close();
@@ -3032,21 +3153,36 @@ public class FileChannelTest extends TestCase {
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
- }
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.FileChannel#read(ByteBuffer,long)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IOException.",
+ method = "read",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
+ public void test_writeLByteBufferJ_Postion_As_Long() throws Exception {
+ ByteBuffer writeBuffer = ByteBuffer.wrap(TEST_BYTES);
+ try {
+ writeOnlyFileChannel.write(writeBuffer, Long.MAX_VALUE);
+ } catch (IOException e) {
+ // expected
+ }
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer, long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_writeLByteBufferJ_IllegalArgument() throws Exception {
ByteBuffer writeBuffer = ByteBuffer.allocate(CAPACITY);
@@ -3072,6 +3208,22 @@ public class FileChannelTest extends TestCase {
}
// throws IllegalArgumentException first.
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.write(writeBuffer, -1);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.write(writeBuffer, -1);
+ fail("should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+
readWriteFileChannel.close();
try {
readWriteFileChannel.write(writeBuffer, -1);
@@ -3084,15 +3236,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
public void test_writeLByteBufferJ() throws Exception {
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -3117,38 +3266,165 @@ public class FileChannelTest extends TestCase {
}
/**
+ * @tests java.nio.channels.FileChannel#write(ByteBuffer)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class, long.class}
+ )
+ public void test_writeLByteBufferJ_NonZeroPosition() throws Exception {
+ final int pos = 5;
+ ByteBuffer writeBuffer = ByteBuffer.wrap(CONTENT_AS_BYTES);
+ writeBuffer.position(pos);
+ int result = writeOnlyFileChannel.write(writeBuffer, pos);
+ assertEquals(CONTENT_AS_BYTES_LENGTH - pos, result);
+ assertEquals(CONTENT_AS_BYTES_LENGTH, writeBuffer.position());
+ writeOnlyFileChannel.close();
+
+ assertEquals(CONTENT_AS_BYTES_LENGTH, fileOfWriteOnlyFileChannel
+ .length());
+
+ fis = new FileInputStream(fileOfWriteOnlyFileChannel);
+ byte[] inputBuffer = new byte[CONTENT_AS_BYTES_LENGTH - pos];
+ fis.skip(pos);
+ fis.read(inputBuffer);
+ String test = CONTENT.substring(pos);
+ assertTrue(Arrays.equals(test.getBytes(), inputBuffer));
+ }
+
+ /**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_write$LByteBuffer_Closed() throws Exception {
+ ByteBuffer[] writeBuffers = new ByteBuffer[2];
+ writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
+ writeBuffers[1] = ByteBuffer.allocate(CAPACITY);
+
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.write(writeBuffers);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.write(writeBuffers);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+
+ readWriteFileChannel.close();
+ try {
+ readWriteFileChannel.write(writeBuffers);
+ fail("should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.FileChannel#write(ByteBuffer[])
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_write$LByteBuffer_ReadOnly() throws Exception {
+ ByteBuffer[] writeBuffers = new ByteBuffer[2];
+ writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
+ writeBuffers[1] = ByteBuffer.allocate(CAPACITY);
+
+ try {
+ readOnlyFileChannel.write(writeBuffers);
+ fail("should throw NonWritableChannelException");
+ } catch (NonWritableChannelException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.FileChannel#write(ByteBuffer[])
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_write$LByteBuffer_EmptyBuffers() throws Exception {
+ ByteBuffer[] writeBuffers = new ByteBuffer[2];
+ writeBuffers[0] = ByteBuffer.allocate(this.CONTENT_LENGTH);
+ try {
+ writeOnlyFileChannel.write(writeBuffers);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ readWriteFileChannel.write(writeBuffers);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.FileChannel#write(ByteBuffer[])
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write$LByteBuffer() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
- MockFileChannel mockFileChannel = new MockFileChannel();
- mockFileChannel.write(writeBuffers);
- // verify that calling write(ByteBuffer[] srcs) leads to the method
- // write(srcs, 0, srcs.length)
- assertTrue(mockFileChannel.isWriteCalled);
+ writeBuffers[0] = ByteBuffer.wrap(CONTENT_AS_BYTES);
+ writeBuffers[1] = ByteBuffer.wrap(CONTENT_AS_BYTES);
+
+ long result = writeOnlyFileChannel.write(writeBuffers);
+ assertEquals(CONTENT_AS_BYTES_LENGTH * 2, result);
+ assertEquals(CONTENT_AS_BYTES_LENGTH, writeBuffers[0].position());
+ assertEquals(CONTENT_AS_BYTES_LENGTH, writeBuffers[1].position());
+ writeOnlyFileChannel.close();
+
+ assertEquals(CONTENT_AS_BYTES_LENGTH * 2, fileOfWriteOnlyFileChannel
+ .length());
+
+ fis = new FileInputStream(fileOfWriteOnlyFileChannel);
+ byte[] inputBuffer = new byte[CONTENT_AS_BYTES_LENGTH];
+ fis.read(inputBuffer);
+ byte[] expectedResult = new byte[CONTENT_AS_BYTES_LENGTH * 2];
+ System.arraycopy(CONTENT_AS_BYTES, 0, expectedResult, 0,
+ CONTENT_AS_BYTES_LENGTH);
+ System.arraycopy(CONTENT_AS_BYTES, 0, expectedResult,
+ CONTENT_AS_BYTES_LENGTH, CONTENT_AS_BYTES_LENGTH);
+ assertTrue(Arrays.equals(CONTENT_AS_BYTES, inputBuffer));
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write$LByteBufferII_Null() throws Exception {
ByteBuffer[] writeBuffers = null;
@@ -3174,9 +3450,25 @@ public class FileChannelTest extends TestCase {
}
// first throws NullPointerException
+ readOnlyFileChannel.close();
+ try {
+ readOnlyFileChannel.write(writeBuffers, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ writeOnlyFileChannel.close();
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 1, 2);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
readWriteFileChannel.close();
try {
- readWriteFileChannel.write(writeBuffers, 0, 0);
+ readWriteFileChannel.write(writeBuffers, 1, 2);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
@@ -3186,15 +3478,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write$LByteBufferII_Closed() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -3223,30 +3512,17 @@ public class FileChannelTest extends TestCase {
} catch (ClosedChannelException e) {
// expected
}
-
- // throws ClosedChannelException first
- writeBuffers[0] = null;
- try {
- readWriteFileChannel.write(writeBuffers, 0, 2);
- fail("should throw ClosedChannelException");
- } catch (ClosedChannelException e) {
- // expected
- }
}
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NonWritableChannelException, " +
- "IndexOutOfBoundsException, NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NonWritableChannelException, IndexOutOfBoundsException, NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write$LByteBufferII_ReadOnly() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.allocate(CAPACITY);
@@ -3268,7 +3544,7 @@ public class FileChannelTest extends TestCase {
} catch (NonWritableChannelException e) {
// expected
}
-
+
readOnlyFileChannel.close();
writeBuffers = null;
try {
@@ -3277,7 +3553,7 @@ public class FileChannelTest extends TestCase {
} catch (IndexOutOfBoundsException e) {
// expected
}
-
+
try {
readOnlyFileChannel.write(writeBuffers, 0, 1);
fail("should throw NullPointerException");
@@ -3289,17 +3565,141 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void test_write$LByteBufferII_IndexOutOfBound() throws Exception {
+ ByteBuffer[] writeBuffers = new ByteBuffer[2];
+ writeBuffers[0] = ByteBuffer.allocate(this.CONTENT_LENGTH);
+ writeBuffers[1] = ByteBuffer.allocate(this.CONTENT_LENGTH);
+
+ try {
+ writeOnlyFileChannel.write(writeBuffers, -1, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 0, -1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ writeOnlyFileChannel.write(writeBuffers, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+
+ try {
+ readWriteFileChannel.write(writeBuffers, -1, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.write(writeBuffers, 0, -1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.write(writeBuffers, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.write(writeBuffers, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.write(writeBuffers, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readWriteFileChannel.write(writeBuffers, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+
+ try {
+ readOnlyFileChannel.write(writeBuffers, -1, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.write(writeBuffers, 0, -1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.write(writeBuffers, 0, 3);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.write(writeBuffers, 1, 2);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.write(writeBuffers, 2, 1);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ try {
+ readOnlyFileChannel.write(writeBuffers, 3, 0);
+ fail("should throw IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write$LByteBufferII_EmptyBuffers() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
+ writeBuffers[0] = ByteBuffer.allocate(this.CONTENT_LENGTH);
try {
writeOnlyFileChannel.write(writeBuffers, 0, 2);
fail("should throw NullPointerException");
@@ -3318,15 +3718,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write$LByteBufferII() throws Exception {
ByteBuffer[] writeBuffers = new ByteBuffer[2];
writeBuffers[0] = ByteBuffer.wrap(CONTENT_AS_BYTES);
@@ -3351,19 +3748,16 @@ public class FileChannelTest extends TestCase {
CONTENT_AS_BYTES_LENGTH, CONTENT_AS_BYTES_LENGTH);
assertTrue(Arrays.equals(CONTENT_AS_BYTES, inputBuffer));
}
-
+
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_Closed()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -3403,15 +3797,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_SourceClosed()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -3450,15 +3841,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_IllegalArgument()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -3470,7 +3858,7 @@ public class FileChannelTest extends TestCase {
}
try {
- readWriteFileChannel.transferFrom(readByteChannel, -1, -10);
+ readWriteFileChannel.transferFrom(readByteChannel, -1, 10);
fail("should throw IllegalArgumentException.");
} catch (IllegalArgumentException e) {
// expected
@@ -3480,15 +3868,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_NonWritable()
throws Exception {
readByteChannel = DatagramChannel.open();
@@ -3503,15 +3888,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_SourceNonReadable()
throws Exception {
try {
@@ -3529,15 +3911,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_PositionBeyondSize()
throws Exception {
// init data to file.
@@ -3560,15 +3939,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_FileChannel()
throws Exception {
// init data to file.
@@ -3602,19 +3978,16 @@ public class FileChannelTest extends TestCase {
expectedContent, POSITION, LENGTH);
assertTrue(Arrays.equals(expectedContent, resultContent));
}
-
+
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_DatagramChannel()
throws Exception {
// connects two datagramChannels.
@@ -3656,15 +4029,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_SocketChannel()
throws Exception {
// connects two socketChannels.
@@ -3704,15 +4074,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferFrom(ReadableByteChannel,long,long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferFrom",
- methodArgs = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferFrom",
+ args = {java.nio.channels.ReadableByteChannel.class, long.class, long.class}
+ )
public void test_transferFromLReadableByteChannelJJ_Pipe() throws Exception {
// inits data in file.
writeDataToFile(fileOfWriteOnlyFileChannel);
@@ -3748,15 +4115,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_Null() throws Exception {
writableByteChannel = null;
try {
@@ -3793,15 +4157,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_Closed() throws Exception {
writableByteChannel = DatagramChannel.open();
readOnlyFileChannel.close();
@@ -3840,15 +4201,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_SourceClosed()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -3887,15 +4245,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_IllegalArgument()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -3907,7 +4262,7 @@ public class FileChannelTest extends TestCase {
}
try {
- readWriteFileChannel.transferTo(-1, -10, writableByteChannel);
+ readWriteFileChannel.transferTo(-1, 10, writableByteChannel);
fail("should throw IllegalArgumentException.");
} catch (IllegalArgumentException e) {
// expected
@@ -3917,15 +4272,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_NonReadable()
throws Exception {
writableByteChannel = DatagramChannel.open();
@@ -3940,15 +4292,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_TargetNonWritable()
throws Exception {
try {
@@ -3966,7 +4315,7 @@ public class FileChannelTest extends TestCase {
} catch (NonWritableChannelException e) {
// expected
}
-
+
// regression test for Harmony-941
// first throws NonWritableChannelException even arguments are illegal.
try {
@@ -3987,15 +4336,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_PositionBeyondSize()
throws Exception {
// init data to file.
@@ -4018,15 +4364,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_FileChannel()
throws Exception {
// init data to file.
@@ -4065,15 +4408,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_SocketChannel()
throws Exception {
// inits data into file.
@@ -4132,15 +4472,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_DatagramChannel()
throws Exception {
// inits data to file.
@@ -4190,15 +4527,12 @@ public class FileChannelTest extends TestCase {
/**
* @tests java.nio.channels.FileChannel#transferTo(long,long,WritableByteChannel)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "transferTo",
- methodArgs = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "transferTo",
+ args = {long.class, long.class, java.nio.channels.WritableByteChannel.class}
+ )
public void test_transferToJJLWritableByteChannel_Pipe() throws Exception {
// inits data in file.
writeDataToFile(fileOfReadOnlyFileChannel);
@@ -4226,15 +4560,15 @@ public class FileChannelTest extends TestCase {
assertEquals(CONTENT_AS_BYTES[i], readBuffer.get());
}
}
-
+
private class MockFileChannel extends FileChannel {
-
+
private boolean isLockCalled = false;
-
+
private boolean isTryLockCalled = false;
-
+
private boolean isReadCalled = false;
-
+
private boolean isWriteCalled = false;
public void force(boolean arg0) throws IOException {
@@ -4243,7 +4577,7 @@ public class FileChannelTest extends TestCase {
public FileLock lock(long position, long size, boolean shared)
throws IOException {
- // verify that calling lock() leads to the method
+ // verify that calling lock() leads to the method
// lock(0, Long.MAX_VALUE, false).
if (0 == position && Long.MAX_VALUE == size && false == shared) {
isLockCalled = true;
@@ -4302,7 +4636,7 @@ public class FileChannelTest extends TestCase {
public FileLock tryLock(long position, long size, boolean shared)
throws IOException {
- // verify that calling tryLock() leads to the method
+ // verify that calling tryLock() leads to the method
// tryLock(0, Long.MAX_VALUE, false).
if (0 == position && Long.MAX_VALUE == size && false == shared) {
isTryLockCalled = true;
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
index bc537cf..f1ccc96 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockInterruptionExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class FileLockInterruptionExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "FileLockInterruptionException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new FileLockInterruptionException());
@@ -52,15 +57,20 @@ public class FileLockInterruptionExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "FileLockInterruptionException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
index 5bee734..6dc127e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java
@@ -16,8 +16,7 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -71,15 +70,12 @@ public class FileLockTest extends TestCase {
* @tests java.nio.channels.FileLock#FileLock(FileChannel, long, long,
* boolean)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "FileLock",
- methodArgs = {java.nio.channels.FileChannel.class, long.class, long.class, boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "FileLock",
+ args = {java.nio.channels.FileChannel.class, long.class, long.class, boolean.class}
+ )
public void test_Constructor_Ljava_nio_channels_FileChannelJJZ() {
FileLock fileLock1 = new MockFileLock(null, 0, 0, false);
assertNull(fileLock1.channel());
@@ -108,15 +104,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#channel()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "channel",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "channel",
+ args = {}
+ )
public void test_channel() {
assertSame(readWriteChannel, mockLock.channel());
FileLock lock = new MockFileLock(null, 0, 10, true);
@@ -126,15 +119,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#position()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "position",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "position",
+ args = {}
+ )
public void test_position() {
FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
assertEquals(20, fileLock1.position());
@@ -148,15 +138,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#size()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "size",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "size",
+ args = {}
+ )
public void test_size() {
FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
assertEquals(100, fileLock1.size());
@@ -171,15 +158,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#isShared()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "[check with false shared parameter]",
- targets = {
- @TestTarget(
- methodName = "isShared",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "[check with false shared parameter]",
+ method = "isShared",
+ args = {}
+ )
public void test_isShared() {
assertFalse(mockLock.isShared());
FileLock lock = new MockFileLock(null, 0, 10, true);
@@ -189,15 +173,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#overlaps(long, long)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "overlaps",
- methodArgs = {long.class, long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "overlaps",
+ args = {long.class, long.class}
+ )
public void test_overlaps_JJ() {
assertTrue(mockLock.overlaps(0, 11));
assertFalse(mockLock.overlaps(0, 10));
@@ -212,15 +193,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#isValid()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid() throws IOException {
FileLock fileLock = readWriteChannel.lock();
assertTrue(fileLock.isValid());
@@ -231,15 +209,12 @@ public class FileLockTest extends TestCase {
/**
* @tests java.nio.channels.FileLock#release()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "release",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "release",
+ args = {}
+ )
public void test_release() throws Exception {
File file = File.createTempFile("test", "tmp");
file.deleteOnExit();
@@ -267,4 +242,22 @@ public class FileLockTest extends TestCase {
//expected
}
}
+
+ /**
+ * @tests java.nio.channels.FileLock#release()
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
+ public void test_toString() throws Exception {
+ File file = File.createTempFile("test", "tmp");
+ file.deleteOnExit();
+ FileOutputStream fout = new FileOutputStream(file);
+ FileChannel fileChannel = fout.getChannel();
+ FileLock fileLock = fileChannel.lock();
+ assertTrue(fileLock.toString().length() > 0);
+ }
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
index af9db67..4b1a840 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalBlockingModeExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class IllegalBlockingModeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "IllegalBlockingModeException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new IllegalBlockingModeException());
@@ -52,15 +57,20 @@ public class IllegalBlockingModeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "IllegalBlockingModeException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
index 070aeb6..e8efc31 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/IllegalSelectorExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class IllegalSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "IllegalSelectorException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new IllegalSelectorException());
@@ -52,15 +57,20 @@ public class IllegalSelectorExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "IllegalSelectorException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new IllegalSelectorException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
index 7a6699f..87835e3 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MapModeTest.java
@@ -16,8 +16,7 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -34,15 +33,12 @@ public class MapModeTest extends TestCase {
/**
* java.nio.channels.FileChannel.MapMode#PRIVATE,READONLY,READWRITE
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies fields.",
- targets = {
- @TestTarget(
- methodName = "!Constants",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies fields.",
+ method = "!Constants",
+ args = {}
+ )
public void test_PRIVATE_READONLY_READWRITE() {
assertNotNull(FileChannel.MapMode.PRIVATE);
assertNotNull(FileChannel.MapMode.READ_ONLY);
@@ -59,15 +55,12 @@ public class MapModeTest extends TestCase {
/**
* java.nio.channels.FileChannel.MapMode#toString()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "toString",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "toString",
+ args = {}
+ )
public void test_toString() {
assertNotNull(FileChannel.MapMode.PRIVATE.toString());
assertNotNull(FileChannel.MapMode.READ_ONLY.toString());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSecurityManager.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSecurityManager.java
new file mode 100644
index 0000000..916140f
--- /dev/null
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/MockSecurityManager.java
@@ -0,0 +1,69 @@
+package org.apache.harmony.nio.tests.java.nio.channels;
+
+import java.security.Permission;
+
+class MockSecurityManager extends SecurityManager {
+
+ String validHost = null;
+
+ int validPort = -1;
+
+ public boolean checkAcceptCalled = false;
+ public boolean checkConnectCalled = false;
+
+ MockSecurityManager() {
+ super();
+ this.validHost = null;
+ }
+
+ MockSecurityManager(String host) {
+ super();
+ this.validHost = host;
+ }
+
+ MockSecurityManager(int port) {
+ super();
+ this.validPort = port;
+ }
+
+ public void checkPermission(Permission perm) {
+ // no-op
+ }
+
+ public void checkPermission(Permission perm, Object context) {
+ // no-op
+ }
+
+ public void checkConnect(String host, int port) {
+ checkConnectCalled = true;
+ // our local addr is OK.
+ if (null != this.validHost) {
+ if (!this.validHost.equals(host)) {
+ throw new SecurityException();
+ }
+ }
+ if ("127.0.0.1".equals(host)) {
+ return;
+ }
+ super.checkConnect(host, port);
+ }
+
+ public void checkAccept(String host, int port) {
+ checkAcceptCalled = true;
+ // our local addr is OK.
+ if (null != this.validHost) {
+ if (!this.validHost.equals(host)) {
+ throw new SecurityException();
+ }
+ }
+ if (-1 != this.validPort) {
+ if (this.validPort != port) {
+ throw new SecurityException();
+ }
+ }
+ if ("127.0.0.1".equals(host)) {
+ return;
+ }
+ super.checkAccept(host, port);
+ }
+} \ No newline at end of file
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
index d78c466..8efe2ae 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NoConnectionPendingExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class NoConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NoConnectionPendingException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NoConnectionPendingException());
@@ -52,15 +57,20 @@ public class NoConnectionPendingExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NoConnectionPendingException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
index ac6f820..d255e4b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonReadableChannelExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class NonReadableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NonReadableChannelException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NonReadableChannelException());
@@ -52,15 +57,20 @@ public class NonReadableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NonReadableChannelException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NonReadableChannelException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
index 9f767b9..fc23223 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NonWritableChannelExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class NonWritableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NonWritableChannelException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NonWritableChannelException());
@@ -52,15 +57,20 @@ public class NonWritableChannelExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NonWritableChannelException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NonWritableChannelException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
index 95f209b..d76d84a 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetBoundExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class NotYetBoundExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NotYetBoundException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetBoundException());
@@ -52,15 +57,20 @@ public class NotYetBoundExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NotYetBoundException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetBoundException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
index be27cc7..e1a8945 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/NotYetConnectedExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class NotYetConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NotYetConnectedException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetConnectedException());
@@ -52,15 +57,20 @@ public class NotYetConnectedExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "NotYetConnectedException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetConnectedException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
index 5412b43..0c1cc8b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/OverlappingFileLockExceptionTest.java
@@ -15,8 +15,8 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -35,15 +35,20 @@ public class OverlappingFileLockExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "OverlappingFileLockException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new OverlappingFileLockException());
@@ -52,15 +57,20 @@ public class OverlappingFileLockExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "OverlappingFileLockException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
index fb02750..5eb4f8b 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
@@ -16,8 +16,7 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -27,7 +26,16 @@ import java.nio.channels.Pipe.SinkChannel;
import java.nio.channels.Pipe.SourceChannel;
import junit.framework.TestCase;
-@TestTargetClass(Pipe.class)
+@TestTargetClass(
+ value = Pipe.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ method = "Pipe",
+ args = {}
+ )
+ }
+)
/*
* Tests for Pipe and its default implementation
*/
@@ -36,15 +44,12 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#open()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "open",
+ args = {}
+ )
public void test_open() throws IOException{
Pipe pipe = Pipe.open();
assertNotNull(pipe);
@@ -53,15 +58,12 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#sink()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "sink",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "sink",
+ args = {}
+ )
public void test_sink() throws IOException {
Pipe pipe = Pipe.open();
SinkChannel sink = pipe.sink();
@@ -71,19 +73,15 @@ public class PipeTest extends TestCase {
/**
* @tests java.nio.channels.Pipe#source()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "source",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "source",
+ args = {}
+ )
public void test_source() throws IOException {
Pipe pipe = Pipe.open();
SourceChannel source = pipe.source();
assertTrue(source.isBlocking());
}
-
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
index 23478ff..085e726 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectableChannelTest.java
@@ -16,8 +16,7 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -32,21 +31,28 @@ import junit.framework.TestCase;
/*
* Tests for SelectableChannel
*/
-@TestTargetClass(SelectableChannel.class)
+@TestTargetClass(
+ value = SelectableChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "SelectableChannel",
+ args = {}
+ )
+ }
+)
public class SelectableChannelTest extends TestCase {
/**
* @tests SelectableChannel#register(Selector, int)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Abstract method.",
- targets = {
- @TestTarget(
- methodName = "register",
- methodArgs = {java.nio.channels.Selector.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Abstract method.",
+ method = "register",
+ args = {java.nio.channels.Selector.class, int.class}
+ )
public void test_register_LSelectorI() throws IOException {
MockSelectableChannel msc = new MockSelectableChannel();
// Verify that calling register(Selector, int) leads to the method
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
index 68b6532..06e1a69 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectionKeyTest.java
@@ -16,8 +16,7 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -25,10 +24,12 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.CancelledKeyException;
+import java.nio.channels.Pipe;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
import tests.support.Support_PortManager;
@@ -36,7 +37,17 @@ import tests.support.Support_PortManager;
/*
* Tests for SelectionKey and its default implementation
*/
-@TestTargetClass(SelectionKey.class)
+@TestTargetClass(
+ value = SelectionKey.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "SelectionKey",
+ args = {}
+ )
+ }
+)
public class SelectionKeyTest extends TestCase {
Selector selector;
@@ -102,15 +113,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#attach(Object)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "attach",
- methodArgs = {Object.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "attach",
+ args = {java.lang.Object.class}
+ )
public void test_attach() {
MockSelectionKey mockSelectionKey = new MockSelectionKey(SelectionKey.OP_ACCEPT);
// no previous, return null
@@ -129,15 +137,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#attachment()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "attachment",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "attachment",
+ args = {}
+ )
public void test_attachment() {
MockSelectionKey mockSelectionKey = new MockSelectionKey(SelectionKey.OP_ACCEPT);
assertNull(mockSelectionKey.attachment());
@@ -149,15 +154,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#channel()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "channel",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "channel",
+ args = {}
+ )
public void test_channel() {
assertSame(sc, selectionKey.channel());
// can be invoked even canceled
@@ -168,15 +170,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#interestOps()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "interestOps",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "interestOps",
+ args = {}
+ )
public void test_interestOps() {
assertEquals(SelectionKey.OP_CONNECT, selectionKey.interestOps());
}
@@ -184,15 +183,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#interestOps(int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify CancelledKeyException.",
- targets = {
- @TestTarget(
- methodName = "interestOps",
- methodArgs = {int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Doesn't verify CancelledKeyException.",
+ method = "interestOps",
+ args = {int.class}
+ )
public void test_interestOpsI() {
selectionKey.interestOps(SelectionKey.OP_WRITE);
assertEquals(SelectionKey.OP_WRITE, selectionKey.interestOps());
@@ -216,21 +212,25 @@ public class SelectionKeyTest extends TestCase {
} catch (IllegalArgumentException ex) {
// expected;
}
-
+
+ selectionKey.cancel();
+ try {
+ selectionKey.interestOps(-1);
+ fail("should throw IAE.");
+ } catch (CancelledKeyException ex) {
+ // expected;
+ }
}
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid() {
assertTrue(selectionKey.isValid());
}
@@ -238,15 +238,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid_KeyCancelled() {
selectionKey.cancel();
assertFalse(selectionKey.isValid());
@@ -255,15 +252,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid_ChannelColsed() throws IOException {
sc.close();
assertFalse(selectionKey.isValid());
@@ -272,15 +266,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isValid()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid_SelectorClosed() throws IOException {
selector.close();
assertFalse(selectionKey.isValid());
@@ -289,15 +280,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isAcceptable()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isAcceptable",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isAcceptable",
+ args = {}
+ )
public void test_isAcceptable() throws IOException {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_ACCEPT);
assertTrue(mockSelectionKey1.isAcceptable());
@@ -308,15 +296,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isConnectable()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isConnectable",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isConnectable",
+ args = {}
+ )
public void test_isConnectable() {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_CONNECT);
assertTrue(mockSelectionKey1.isConnectable());
@@ -327,15 +312,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isReadable()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isReadable",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isReadable",
+ args = {}
+ )
public void test_isReadable() {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_READ);
assertTrue(mockSelectionKey1.isReadable());
@@ -346,34 +328,43 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#isWritable()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify CancelledKeyException.",
- targets = {
- @TestTarget(
- methodName = "isWritable",
- methodArgs = {}
- )
- })
- public void test_isWritable() {
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isWritable",
+ args = {}
+ )
+ public void test_isWritable() throws Exception {
MockSelectionKey mockSelectionKey1 = new MockSelectionKey(SelectionKey.OP_WRITE);
assertTrue(mockSelectionKey1.isWritable());
MockSelectionKey mockSelectionKey2 = new MockSelectionKey(SelectionKey.OP_ACCEPT);
assertFalse(mockSelectionKey2.isWritable());
+
+ Selector selector = SelectorProvider.provider().openSelector();
+
+ Pipe pipe = SelectorProvider.provider().openPipe();
+ pipe.open();
+ pipe.sink().configureBlocking(false);
+ SelectionKey key = pipe.sink().register(selector, SelectionKey.OP_WRITE);
+
+ key.cancel();
+ try {
+ key.isWritable();
+ fail("should throw IAE.");
+ } catch (CancelledKeyException ex) {
+ // expected;
+ }
}
/**
* @tests java.nio.channels.SelectionKey#cancel()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "cancel",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "cancel",
+ args = {}
+ )
public void test_cancel() {
selectionKey.cancel();
try {
@@ -426,15 +417,12 @@ public class SelectionKeyTest extends TestCase {
/**
* @tests java.nio.channels.SelectionKey#readyOps()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify CancelledKeyException.",
- targets = {
- @TestTarget(
- methodName = "readyOps",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "readyOps",
+ args = {}
+ )
public void test_readyOps() throws IOException {
int port = Support_PortManager.getNextPort();
ServerSocket ss = new ServerSocket(port);
@@ -448,21 +436,25 @@ public class SelectionKeyTest extends TestCase {
ss.close();
ss = null;
}
-
+
+ selectionKey.cancel();
+ try {
+ selectionKey.readyOps();
+ fail("should throw IAE.");
+ } catch (CancelledKeyException ex) {
+ // expected;
+ }
}
/**
* @tests java.nio.channels.SelectionKey#selector()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "selector",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "selector",
+ args = {}
+ )
public void test_selector() {
assertSame(selector, selectionKey.selector());
selectionKey.cancel();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
index feb1c92..883ca28 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
@@ -16,8 +16,8 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -40,7 +40,17 @@ import tests.support.Support_PortManager;
/*
* Tests for Selector and its default implementation
*/
-@TestTargetClass(Selector.class)
+@TestTargetClass(
+ value = Selector.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "Selector",
+ args = {}
+ )
+ }
+)
public class SelectorTest extends TestCase {
private static final int WAIT_TIME = 100;
@@ -56,7 +66,7 @@ public class SelectorTest extends TestCase {
enum SelectType {
NULL, TIMEOUT, NOW
- };
+ }
protected void setUp() throws Exception {
super.setUp();
@@ -85,15 +95,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#open()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "open",
+ args = {}
+ )
public void test_open() throws IOException {
assertNotNull(selector);
}
@@ -101,15 +108,12 @@ public class SelectorTest extends TestCase {
/**
* @tests Selector#isOpen()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isOpen",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
public void test_isOpen() throws IOException {
assertTrue(selector.isOpen());
selector.close();
@@ -119,15 +123,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#provider()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ )
public void test_provider() throws IOException {
// should be system default provider
assertNotNull(selector.provider());
@@ -137,15 +138,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#keys()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "keys",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "keys",
+ args = {}
+ )
public void test_keys() throws IOException {
SelectionKey key = ssc.register(selector, SelectionKey.OP_ACCEPT);
@@ -192,15 +190,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#keys()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "selectedKeys",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "selectedKeys",
+ args = {}
+ )
public void test_selectedKeys() throws IOException {
SocketChannel sc = SocketChannel.open();
ssc.register(selector, SelectionKey.OP_ACCEPT);
@@ -246,17 +241,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#selectNow()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies selectNow() method for Selector registered with " +
- "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
- "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
- targets = {
- @TestTarget(
- methodName = "selectNow",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies selectNow() method for Selector registered with SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
+ method = "selectNow",
+ args = {}
+ )
public void test_selectNow() throws IOException {
assert_select_OP_ACCEPT(SelectType.NOW, 0);
assert_select_OP_CONNECT(SelectType.NOW, 0);
@@ -267,16 +257,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#selectNow()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that ClosedSelectorException is thrown " +
- "if selectNow() method is called for closed Selector.",
- targets = {
- @TestTarget(
- methodName = "selectNow",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that ClosedSelectorException is thrown if selectNow() method is called for closed Selector.",
+ method = "selectNow",
+ args = {}
+ )
public void test_selectNow_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.NOW, 0);
}
@@ -284,15 +270,12 @@ public class SelectorTest extends TestCase {
/**
* @test java.nio.channels.Selector#selectNow()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that selectNow() method doesn't block.",
- targets = {
- @TestTarget(
- methodName = "selectNow",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that selectNow() method doesn't block.",
+ method = "selectNow",
+ args = {}
+ )
public void test_selectNow_Timeout() throws IOException {
// make sure selectNow doesn't block
selector.selectNow();
@@ -301,17 +284,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies select() method for Selector registered with " +
- "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
- "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies select() method for Selector registered with SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys.",
+ method = "select",
+ args = {}
+ )
public void test_select() throws IOException {
assert_select_OP_ACCEPT(SelectType.NULL, 0);
assert_select_OP_CONNECT(SelectType.NULL, 0);
@@ -322,16 +300,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select()
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that ClosedSelectorException is thrown " +
- "if select() method is called for closed Selector.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that ClosedSelectorException is thrown if select() method is called for closed Selector.",
+ method = "select",
+ args = {}
+ )
public void test_select_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.NULL, 0);
}
@@ -339,18 +313,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies select(long) method for Selector registered with " +
- "SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, " +
- "SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys and different " +
- "timeout's values.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies select(long) method for Selector registered with SelectionKeys.OP_ACCEPT, SelectionKeys.OP_CONNECT, SelectionKeys.OP_READ, SelectionKeys.OP_WRITE keys and different timeout's values.",
+ method = "select",
+ args = {long.class}
+ )
public void test_selectJ() throws IOException {
assert_select_OP_ACCEPT(SelectType.TIMEOUT, 0);
assert_select_OP_CONNECT(SelectType.TIMEOUT, 0);
@@ -364,18 +332,38 @@ public class SelectorTest extends TestCase {
}
/**
+ * @test java.nio.channels.Selector#select(long)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies select(long) method for empty selection keys.",
+ method = "select",
+ args = {long.class}
+ )
+ @KnownFailure("fixed in ToT")
+ public void test_selectJ_Empty_Keys() throws IOException {
+ // regression test, see HARMONY-3888.
+ // make sure select(long) does wait for specified amount of
+ // time if keys.size() == 0 (initial state of selector).
+
+ final long SELECT_TIMEOUT = 1000;
+
+ long time1 = System.currentTimeMillis();
+ selector.select(SELECT_TIMEOUT);
+ long time2 = System.currentTimeMillis();
+ assertEquals("elapsed time", SELECT_TIMEOUT, (time2 - time1),
+ SELECT_TIMEOUT * 0.05); // 5% accuracy
+ }
+
+ /**
* @tests java.nio.channel.Selector#select(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that ClosedSelectorException is thrown " +
- "if select(long) method is called for closed Selector.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that ClosedSelectorException is thrown if select(long) method is called for closed Selector.",
+ method = "select",
+ args = {long.class}
+ )
public void test_selectJ_SelectorClosed() throws IOException {
assert_select_SelectorClosed(SelectType.TIMEOUT, 0);
selector = Selector.open();
@@ -385,15 +373,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channel.Selector#select(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalArgumentException.",
+ method = "select",
+ args = {long.class}
+ )
public void test_selectJ_Exception() throws IOException {
try {
selector.select(-1);
@@ -405,15 +390,12 @@ public class SelectorTest extends TestCase {
/**
* @test java.nio.channels.Selector#select(long)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies that select(timeout) doesn't block.",
- targets = {
- @TestTarget(
- methodName = "select",
- methodArgs = {long.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that select(timeout) doesn't block.",
+ method = "select",
+ args = {long.class}
+ )
public void test_selectJ_Timeout() throws IOException {
// make sure select(timeout) doesn't block
selector.select(WAIT_TIME);
@@ -422,15 +404,12 @@ public class SelectorTest extends TestCase {
/**
* @tests java.nio.channels.Selector#wakeup()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "wakeup",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "wakeup",
+ args = {}
+ )
public void test_wakeup() throws IOException {
/*
* make sure the test does not block on select
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
index 9c8ab91..988cef6 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java
@@ -17,8 +17,9 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
@@ -30,6 +31,7 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NotYetBoundException;
@@ -39,6 +41,7 @@ import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
+
import tests.support.Support_PortManager;
/*
@@ -90,20 +93,32 @@ public class ServerSocketChannelTest extends TestCase {
// -------------------------------------------------------------------
// Test for methods in abstract class.
// -------------------------------------------------------------------
+ /*
+ * Test method for 'java.nio.channels.ServerSocketChannel()'
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "ServerSocketChannel",
+ args = {java.nio.channels.spi.SelectorProvider.class}
+ )
+ public void testConstructor() throws IOException {
+ ServerSocketChannel channel =
+ SelectorProvider.provider().openServerSocketChannel();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ }
/*
* Test method for 'java.nio.channels.ServerSocketChannel.validOps()'
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
- )
- })
- public void testValidOps() {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "validOps",
+ args = {}
+ )
+ public void test_validOps() {
MockServerSocketChannel testMSChnlnull = new MockServerSocketChannel(
null);
MockServerSocketChannel testMSChnl = new MockServerSocketChannel(
@@ -117,44 +132,57 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.ServerSocketChannel.open()'
*/
- @TestInfo(
- level = TestLevel.TODO,
- purpose = "Doesn't call open() method.",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {}
- )
- })
- public void testOpen() {
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies in setUp method.",
+ method = "open",
+ args = {}
+ )
+ public void test_open() {
MockServerSocketChannel testMSChnl = new MockServerSocketChannel(null);
MockServerSocketChannel testMSChnlnotnull = new MockServerSocketChannel(
SelectorProvider.provider());
assertEquals(SelectionKey.OP_ACCEPT, testMSChnlnotnull.validOps());
assertNull(testMSChnl.provider());
assertNotNull(testMSChnlnotnull.provider());
- assertNotNull(this.serverChannel.provider());
assertEquals(testMSChnlnotnull.provider(), this.serverChannel
.provider());
}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
+ public void testIsOpen() throws Exception {
+ assertTrue(this.serverChannel.isOpen());
+ this.serverChannel.close();
+ assertFalse(this.serverChannel.isOpen());
+ }
+
// -------------------------------------------------------------------
// Test for socket()
// -------------------------------------------------------------------
/*
* Test method for 'com.ibm.io.nio.ServerSocketChannelImpl.socket()'
+ * Test method for 'com.ibm.io.nio.ServerSocketChannelImpl.isOpen()'
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ ),@TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
)
})
- public void testSocket_Block_BeforeClose() throws Exception {
+ public void test_socket_Block_BeforeClose() throws Exception {
assertTrue(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
ServerSocket s1 = this.serverChannel.socket();
@@ -169,16 +197,14 @@ public class ServerSocketChannelTest extends TestCase {
assertFalse(this.serverChannel.isOpen());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
- public void testSocket_NonBlock_BeforeClose() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
+ public void test_socket_NonBlock_BeforeClose() throws Exception {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
ServerSocket s1 = this.serverChannel.socket();
@@ -193,16 +219,14 @@ public class ServerSocketChannelTest extends TestCase {
assertFalse(this.serverChannel.isOpen());
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
- public void testSocket_Block_Closed() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
+ public void test_socket_Block_Closed() throws Exception {
this.serverChannel.close();
assertFalse(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
@@ -213,16 +237,14 @@ public class ServerSocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
- public void testSocket_NonBlock_Closed() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
+ public void test_socket_NonBlock_Closed() throws Exception {
this.serverChannel.configureBlocking(false);
this.serverChannel.close();
assertFalse(this.serverChannel.isBlocking());
@@ -242,25 +264,31 @@ public class ServerSocketChannelTest extends TestCase {
assertNull(s.getLocalSocketAddress());
assertEquals(0, s.getSoTimeout());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies default status of ServerSocketChannel.",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of ServerSocketChannel.",
+ method = "validOps",
+ args = {}
),
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of ServerSocketChannel.",
+ method = "provider",
+ args = {}
),
- @TestTarget(
- methodName = "isRegistered",
- methodArgs = {}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of ServerSocketChannel.",
+ method = "isRegistered",
+ args = {}
),
- @TestTarget(
- methodName = "isBlocking",
- methodArgs = {}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of ServerSocketChannel.",
+ method = "isBlocking",
+ args = {}
)
})
public void testChannelBasicStatus() {
@@ -279,16 +307,13 @@ public class ServerSocketChannelTest extends TestCase {
/*
* Test method for 'com.ibm.io.nio.ServerSocketChannelImpl.accept()'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NotYetBoundException.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void testAccept_Block_NotYetBound() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NotYetBoundException.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_Block_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
try {
@@ -298,16 +323,14 @@ public class ServerSocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NotYetBoundException.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void testAccept_NonBlock_NotYetBound() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NotYetBoundException.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_NonBlock_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
try {
@@ -317,16 +340,14 @@ public class ServerSocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void testAccept_ClosedChannel() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_ClosedChannel() throws Exception {
this.serverChannel.close();
assertFalse(this.serverChannel.isOpen());
try {
@@ -336,16 +357,14 @@ public class ServerSocketChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies AsynchronousCloseException.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void testAccept_Block_NoConnect() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies AsynchronousCloseException.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_Block_NoConnect_close() throws IOException {
assertTrue(this.serverChannel.isBlocking());
ServerSocket gotSocket = this.serverChannel.socket();
gotSocket.bind(localAddr1);
@@ -369,17 +388,52 @@ public class ServerSocketChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that accept() returns null if the channel is in " +
- "non-blocking mode and no connection is available to be accepted.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void testAccept_NonBlock_NoConnect() throws IOException {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedByInterruptException.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_Block_NoConnect_interrupt() throws IOException {
+ assertTrue(this.serverChannel.isBlocking());
+ ServerSocket gotSocket = this.serverChannel.socket();
+ gotSocket.bind(localAddr1);
+
+ class MyThread extends Thread {
+ public String errMsg = null;
+ public void run() {
+ try {
+ serverChannel.accept();
+ errMsg = "should throw ClosedByInterruptException";
+ } catch (ClosedByInterruptException e) {
+ // expected
+ } catch (Exception e) {
+ errMsg = "caught wrong Exception: " + e.getClass() + ": " +
+ e.getMessage();
+ }
+ }
+ }
+ MyThread thread = new MyThread();
+ thread.start();
+ try {
+ Thread.currentThread().sleep(TIME_UNIT);
+ thread.interrupt();
+ } catch (InterruptedException e) {
+ fail("Should not throw a InterruptedException");
+ }
+ if (thread.errMsg != null) {
+ fail(thread.errMsg);
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that accept() returns null if the channel is in non-blocking mode and no connection is available to be accepted.",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_NonBlock_NoConnect() throws IOException {
ServerSocket gotSocket = this.serverChannel.socket();
gotSocket.bind(localAddr1);
this.serverChannel.configureBlocking(false);
@@ -390,16 +444,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_read_Blocking_RealData() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_read_Block() throws IOException {
serverChannel.socket().bind(localAddr1);
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -437,16 +488,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_read_NonBlocking_RealData() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_read_NonBlock() throws Exception {
serverChannel.configureBlocking(false);
serverChannel.socket().bind(localAddr1);
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -465,16 +513,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_write_Blocking_RealData() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_write_Block() throws IOException {
assertTrue(serverChannel.isBlocking());
ServerSocket serverSocket = serverChannel.socket();
serverSocket.bind(localAddr1);
@@ -496,16 +541,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_write_NonBlocking_RealData() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_write_NonBlock() throws Exception {
serverChannel.configureBlocking(false);
ServerSocket serverSocket = serverChannel.socket();
serverSocket.bind(localAddr1);
@@ -525,17 +567,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_read_LByteBuffer_Blocking_ReadWriteRealLargeData()
- throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_read_Block_RWLargeData() throws IOException {
serverChannel.socket().bind(localAddr1);
ByteBuffer buf = ByteBuffer.allocate(CAPACITY_64KB);
for (int i = 0; i < CAPACITY_64KB; i++) {
@@ -553,16 +591,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_read_LByteBuffer_NonBlocking_ReadWriteRealLargeData()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_read_NonBlock_RWLargeData()
throws Exception {
serverChannel.configureBlocking(false);
serverChannel.socket().bind(localAddr1);
@@ -582,16 +617,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_write_LByteBuffer_NonBlocking_ReadWriteRealLargeData()
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_write_NonBlock_RWLargeData()
throws Exception {
serverChannel.configureBlocking(false);
serverChannel.socket().bind(localAddr1);
@@ -610,17 +642,13 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#accept().socket()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
- public void test_write_LByteBuffer_Blocking_ReadWriteRealLargeData()
- throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_socket_write_Block_RWLargeData() throws Exception {
serverChannel.socket().bind(localAddr1);
byte[] writeContent = new byte[CAPACITY_64KB];
for (int i = 0; i < writeContent.length; i++) {
@@ -659,48 +687,79 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocketChannel#socket().getSoTimeout()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that accept method returns null since " +
- "there are no pending connections. Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "accept",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that accept method returns null since there are no pending connections. Doesn't verify exceptions.",
+ method = "accept",
+ args = {}
+ )
public void test_accept_SOTIMEOUT() throws IOException {
// regression test for Harmony-707
final int SO_TIMEOUT = 10;
- ServerSocketChannel sc = ServerSocketChannel.open();
+ ServerSocketChannel ssc = ServerSocketChannel.open();
try {
- ServerSocket ss = sc.socket();
+ ServerSocket ss = ssc.socket();
ss.bind(localAddr1);
- sc.configureBlocking(false);
+ ssc.configureBlocking(false);
ss.setSoTimeout(SO_TIMEOUT);
- SocketChannel client = sc.accept();
+ SocketChannel client = ssc.accept();
// non blocking mode, returns null since there are no pending connections.
assertNull(client);
int soTimeout = ss.getSoTimeout();
- // Harmony fails here.
+ // Harmony failed here.
assertEquals(SO_TIMEOUT, soTimeout);
} finally {
- sc.close();
+ ssc.close();
}
}
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "accept",
+ args = {}
+ )
+ public void test_accept_Security() throws IOException {
+ this.clientChannel.configureBlocking(true);
+ this.serverChannel.configureBlocking(true);
+ SecurityManager sm = System.getSecurityManager();
+ MockSecurityManager mockManager = new MockSecurityManager("127.0.0.1");
+ System.setSecurityManager(mockManager);
+
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ clientChannel.connect(localAddr1);
+ } catch (IOException e) {
+ }
+ }
+ };
+ t.start();
+
+ try {
+ ServerSocket ss = this.serverChannel.socket();
+ ss.bind(localAddr1);
+ this.serverChannel.accept();
+ } finally {
+ System.setSecurityManager(sm);
+ }
+
+ assertTrue(mockManager.checkAcceptCalled);
+ }
/**
* @tests ServerSocket#socket().accept()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Verifies IllegalBlockingModeException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies IllegalBlockingModeException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_accept_Blocking_NotBound() throws IOException {
// regression test for Harmony-748
ServerSocket gotSocket = serverChannel.socket();
@@ -723,15 +782,12 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Verifies IllegalBlockingModeException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies IllegalBlockingModeException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_accept_Nonblocking_NotBound() throws IOException {
// regression test for Harmony-748
ServerSocket gotSocket = serverChannel.socket();
@@ -754,16 +810,12 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Verifies IllegalBlockingModeException, " +
- "ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies IllegalBlockingModeException, ClosedChannelException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_accept_Nonblocking_Bound() throws IOException {
// regression test for Harmony-748
serverChannel.configureBlocking(false);
@@ -787,15 +839,12 @@ public class ServerSocketChannelTest extends TestCase {
/**
* @tests ServerSocket#socket().accept()
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Regression test. Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies ClosedChannelException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_accept_Blocking_Bound() throws IOException {
// regression test for Harmony-748
serverChannel.configureBlocking(true);
@@ -809,4 +858,26 @@ public class ServerSocketChannelTest extends TestCase {
// expected
}
}
+
+ /**
+ * Regression test for HARMONY-4961
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Regression test. Verifies that returned socket returns correct local port.",
+ method = "socket",
+ args = {}
+ )
+ @KnownFailure("Fixed in ToT")
+ public void test_socket_getLocalPort() throws IOException {
+ // regression test for Harmony-4961
+ serverChannel.socket().bind(localAddr1);
+ clientChannel.connect(localAddr1);
+ SocketChannel myChannel = serverChannel.accept();
+ int port = myChannel.socket().getLocalPort();
+ assertEquals(localAddr1.getPort(), port);
+ myChannel.close();
+ clientChannel.close();
+ serverChannel.close();
+ }
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
index 5cf7dd0..849ef12 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SinkChannelTest.java
@@ -16,26 +16,47 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestTarget;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargets;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
+import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
+import java.nio.channels.Pipe.SinkChannel;
+import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
-@TestTargetClass(java.nio.channels.Pipe.SinkChannel.class)
+
/**
* Tests for Pipe.SinkChannel class
*/
+@TestTargetClass(
+ value = java.nio.channels.Pipe.SinkChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "ClosedByInterruptException can not easily be tested",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ }
+)
public class SinkChannelTest extends TestCase {
private static final int BUFFER_SIZE = 5;
@@ -65,15 +86,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#validOps()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "validOps",
+ args = {}
+ )
public void test_validOps() {
assertEquals(SelectionKey.OP_WRITE, sink.validOps());
}
@@ -81,15 +99,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer [])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -125,15 +140,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_LByteBuffer_mutliThread() throws IOException,
InterruptedException {
final int THREAD_NUM = 20;
@@ -178,15 +190,66 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ public void disabled_test_read_LByteBuffer_mutliThread_close() throws Exception {
+
+ ByteBuffer sourceBuf = ByteBuffer.allocate(1000);
+ sink.configureBlocking(true);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.currentThread().sleep(500);
+ sink.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ sink.write(sourceBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
+ */
+ public void disabled_test_read_LByteBuffer_mutliThread_interrupt() throws Exception {
+
+ sink.configureBlocking(true);
+
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ sink.write(ByteBuffer.allocate(10));
+ fail("should have thrown a ClosedByInterruptException.");
+ } catch (ClosedByInterruptException e) {
+ // expected
+ return;
+ } catch (IOException e) {
+ fail("should throw a ClosedByInterruptException but " +
+ "threw " + e.getClass() + ": " + e.getMessage());
+ }
+ }
+ };
+
+ thread.start();
+ Thread.currentThread().sleep(500);
+ thread.interrupt();
+
+ }
+
+ /**
+ * @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_LByteBuffer_Exception() throws IOException {
// write null ByteBuffer
ByteBuffer nullBuf = null;
@@ -201,15 +264,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_LByteBuffer_SourceClosed() throws IOException {
source.close();
int written = sink.write(buffer);
@@ -219,16 +279,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException, " +
- "NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException, NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_LByteBuffer_SinkClosed() throws IOException {
sink.close();
try {
@@ -243,23 +299,22 @@ public class SinkChannelTest extends TestCase {
try {
sink.write(nullBuf);
fail("should throw NullPointerException");
+ } catch (ClosedChannelException e) {
+ // expected on RI
} catch (NullPointerException e) {
- // expected
+ // expected on Harmony/Android
}
}
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_$LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -293,15 +348,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_$LByteBuffer_Exception() throws IOException {
// write null ByteBuffer[]
ByteBuffer[] nullBufArrayRef = null;
@@ -326,15 +378,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_$LByteBuffer_SourceClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
source.close();
@@ -345,15 +394,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException, NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException, NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_write_$LByteBuffer_SinkClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
sink.close();
@@ -386,15 +432,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write_$LByteBufferII() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -424,16 +467,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException, " +
- "IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, IndexOutOfBoundsException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write_$LByteBufferII_Exception() throws IOException {
// write null ByteBuffer[]
ByteBuffer[] nullBufArrayRef = null;
@@ -508,15 +547,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write_$LByteBufferII_SourceClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
source.close();
@@ -527,16 +563,12 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#write(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException, NullPointerException, " +
- "IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException, NullPointerException, IndexOutOfBoundsException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_write_$LByteBufferII_SinkClosed() throws IOException {
ByteBuffer[] bufArray = { buffer };
sink.close();
@@ -620,35 +652,51 @@ public class SinkChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SinkChannel#close()
+ * @tests {@link java.nio.channels.Pipe.SinkChannel#isOpen()}
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies write method after close.",
- targets = {
- @TestTarget(
- methodName = "close",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
+ ),@TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
)
})
public void test_close() throws IOException {
+ assertTrue(sink.isOpen());
sink.close();
assertFalse(sink.isOpen());
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies that NullPointerException is thrown if " +
- "write method is called for closed channel.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "close",
- methodArgs = {}
- )
- })
- public void test_socketChannel_read_close() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "SinkChannel",
+ args = {java.nio.channels.spi.SelectorProvider.class}
+ )
+ public void testConstructor() throws IOException {
+ SinkChannel channel =
+ SelectorProvider.provider().openPipe().sink();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ channel = Pipe.open().sink();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies that NullPointerException is thrown if write" +
+ "method is called for closed channel.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void test_socketChannel_closed() throws Exception {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(),49999));
SocketChannel sc = SocketChannel.open();
@@ -671,16 +719,14 @@ public class SinkChannelTest extends TestCase {
}
sock.close();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
- public void test_socketChannel_read_write() throws Exception {
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void test_socketChannel_empty() throws Exception {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(),49999));
SocketChannel sc = SocketChannel.open();
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
index f7c8822..d31cd0a 100755
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
@@ -17,16 +17,19 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestLevel;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.annotation.Target;
import java.net.BindException;
import java.net.ConnectException;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -39,6 +42,9 @@ import java.nio.channels.ConnectionPendingException;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NoConnectionPendingException;
import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.UnresolvedAddressException;
@@ -56,6 +62,8 @@ public class SocketChannelTest extends TestCase {
private static final int CAPACITY_NORMAL = 200;
+ private static final int CAPACITY_HUGE = 512 * 1024;
+
private InetSocketAddress localAddr1;
private InetSocketAddress localAddr2;
@@ -67,9 +75,9 @@ public class SocketChannelTest extends TestCase {
private ServerSocket server1;
private ServerSocket server2;
-
+
private final static int TIMEOUT = 60000;
-
+
private final static int EOF = -1;
protected void setUp() throws Exception {
@@ -89,28 +97,28 @@ public class SocketChannelTest extends TestCase {
try {
this.channel1.close();
} catch (Exception e) {
- //ignore
+ // ignore
}
}
if (null != this.channel2) {
try {
this.channel2.close();
} catch (Exception e) {
- //ignore
+ // ignore
}
}
if (null != this.server1) {
try {
this.server1.close();
} catch (Exception e) {
- //ignore
+ // ignore
}
}
if (null != this.server2) {
try {
this.server2.close();
} catch (Exception e) {
- //ignore
+ // ignore
}
}
}
@@ -119,17 +127,57 @@ public class SocketChannelTest extends TestCase {
// Test for methods in abstract class.
// -------------------------------------------------------------------
/*
- * Test method for 'java.nio.channels.SocketChannel.validOps()'
+ * Test method for 'java.nio.channels.SocketChannel()'
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "SocketChannel",
+ args = {SelectorProvider.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "open",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ clazz = SelectorProvider.class,
+ method = "openSocketChannel",
+ args = {}
)
})
+ public void testConstructor() throws IOException {
+ SocketChannel channel =
+ SelectorProvider.provider().openSocketChannel();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(), channel.provider());
+ channel = SocketChannel.open();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(), channel.provider());
+ MockSocketChannel chan = new MockSocketChannel(
+ SelectorProvider.provider());
+ assertTrue(chan.isConstructorCalled);
+ }
+
+ /*
+ * Test method for 'java.nio.channels.SocketChannel.validOps()'
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "validOps",
+ args = {}
+ )
public void testValidOps() {
MockSocketChannel testMSChannel = new MockSocketChannel(null);
assertEquals(13, this.channel1.validOps());
@@ -139,13 +187,18 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.open()'
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "open",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "SocketChannel",
+ args = {SelectorProvider.class}
)
})
public void testOpen() throws IOException {
@@ -154,9 +207,12 @@ public class SocketChannelTest extends TestCase {
MockSocketChannel testMSChannel = new MockSocketChannel(null);
MockSocketChannel testMSChannelnotnull = new MockSocketChannel(
SelectorProvider.provider());
+ SocketChannel testSChannel = MockSocketChannel.open();
+ assertTrue(testSChannel.isOpen());
assertNull(testMSChannel.provider());
+ assertNotNull(testSChannel.provider());
+ assertEquals(SelectorProvider.provider(), testSChannel.provider());
assertNotNull(testMSChannelnotnull.provider());
- assertNotNull(this.channel1);
assertEquals(this.channel1.provider(), testMSChannelnotnull.provider());
try {
this.channel1.write(buf);
@@ -166,19 +222,139 @@ public class SocketChannelTest extends TestCase {
}
}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
+ public void testIsOpen() throws Exception {
+ assertTrue(this.channel1.isOpen());
+ this.channel1.close();
+ assertFalse(this.channel1.isOpen());
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isConnected",
+ args = {}
+ )
+ public void testIsConnected() throws Exception {
+ assertFalse(this.channel1.isConnected());// not connected
+ this.channel1.configureBlocking(false);
+ assertFalse(this.channel1.connect(localAddr1));
+ assertFalse(this.channel1.isConnected());
+ assertTrue(this.channel1.isConnectionPending());
+ assertTrue(tryFinish());
+ assertTrue(this.channel1.isConnected());
+ this.channel1.close();
+ assertFalse(this.channel1.isConnected());
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isConnectionPending",
+ args = {}
+ )
+ public void testIsConnectionPending() throws Exception {
+ // ensure
+ ensureServerClosed();
+ this.channel1.configureBlocking(false);
+ assertFalse(this.channel1.isConnectionPending());
+ // finish
+ try {
+ this.channel1.finishConnect();
+ fail("Should throw NoConnectionPendingException");
+ } catch (NoConnectionPendingException e) {
+ // OK.
+ }
+ assertFalse(this.channel1.isConnectionPending());
+ // connect
+ assertFalse(this.channel1.connect(localAddr1));
+ assertTrue(this.channel1.isConnectionPending());
+ this.channel1.close();
+
+ assertFalse(this.channel1.isConnectionPending());
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of SocketChannel.",
+ method = "validOps",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of SocketChannel.",
+ method = "provider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of SocketChannel.",
+ method = "isRegistered",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies default status of SocketChannel.",
+ method = "isBlocking",
+ args = {}
+ )
+ })
+ public void testChannelBasicStatus() {
+ Socket gotSocket = this.channel1.socket();
+ assertFalse(gotSocket.isClosed());
+ assertTrue(this.channel1.isBlocking());
+ assertFalse(this.channel1.isRegistered());
+ assertEquals((SelectionKey.OP_CONNECT | SelectionKey.OP_READ |
+ SelectionKey.OP_WRITE), this.channel1.validOps());
+ assertEquals(SelectorProvider.provider(), this.channel1.provider());
+ }
+
/*
* Test method for 'java.nio.channels.SocketChannel.open(SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IllegalArgumentException.",
- targets = {
- @TestTarget(
- methodName = "open",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
- public void testOpenSocketAddress_Null() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "open",
+ args = {java.net.SocketAddress.class}
+ )
+ public void testOpenSocketAddress() throws IOException {
+ this.channel1 = SocketChannel.open(localAddr1);
+ assertTrue(this.channel1.isConnected());
+
+ SecurityManager smngr = System.getSecurityManager();
+ System.setSecurityManager(new MockSecurityManager("blargh"));
+ try {
+ this.channel1 = SocketChannel.open(localAddr2);
+ fail("Should throw SecurityException");
+ } catch (SecurityException e) {
+ // expected
+ }
+ System.setSecurityManager(smngr);
+
+ SocketAddress newTypeAddress = new SubSocketAddress();
+ try {
+ this.channel1 = SocketChannel.open(newTypeAddress);
+ fail("Should throw UnexpectedAddressTypeException");
+ } catch (UnsupportedAddressTypeException e) {
+ // expected
+ }
+
+ SocketAddress unresolvedAddress =
+ InetSocketAddress.createUnresolved("127.0.0.1", 8080);
+ try {
+ this.channel1 = SocketChannel.open(unresolvedAddress);
+ fail("Should throw UnresolvedAddressException");
+ } catch (UnresolvedAddressException e) {
+ // expected
+ }
+
SocketChannel channel1IP = null;
try {
channel1IP = SocketChannel.open(null);
@@ -192,15 +368,12 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.read(ByteBuffer[])'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void testReadByteBufferArray() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -236,15 +409,12 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.read(ByteBuffer[])'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void testReadByteBufferArray_BufNull() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -273,16 +443,13 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'java.nio.channels.SocketChannel.write(ByteBuffer[])'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException, ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify AsynchronousCloseException," +
+ "ClosedByInterruptException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void testWriteByteBufferArray() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
@@ -294,7 +461,8 @@ public class SocketChannelTest extends TestCase {
} catch (NullPointerException e) {
// correct
}
- byteBuf = new java.nio.ByteBuffer[CAPACITY_NORMAL];
+ byteBuf = new java.nio.ByteBuffer[1];
+ byteBuf[0] = java.nio.ByteBuffer.allocate(CAPACITY_NORMAL);
try {
this.channel1.write(byteBuf);
fail("Should throw NotYetConnectedException");
@@ -303,53 +471,52 @@ public class SocketChannelTest extends TestCase {
}
testMSChannel.write(byteBuf);
testMSChannelnull.write(byteBuf);
+
+ this.channel1.close();
+ try {
+ this.channel1.write(byteBuf);
+ fail("Should throw ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // correct
+ }
}
/*
* Test method for 'java.nio.channels.SocketChannel.write(ByteBuffer[])'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void testWriteByteBufferArray_BufNull() throws IOException {
java.nio.ByteBuffer[] byteBuf = null;
MockSocketChannel testMSChannelnull = new MockSocketChannel(null);
MockSocketChannel testMSChannel = new MockSocketChannel(
SelectorProvider.provider());
+ this.channel1.connect(localAddr1);
try {
this.channel1.write(byteBuf);
fail("Should throw NPE");
} catch (NullPointerException e) {
// correct
}
+ byteBuf = new java.nio.ByteBuffer[1];
try {
- testMSChannel.write(byteBuf);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
- // correct
- }
- try {
- testMSChannelnull.write(byteBuf);
+ this.channel1.write(byteBuf);
fail("Should throw NPE");
} catch (NullPointerException e) {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_BasicStatusBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
Socket s1 = this.channel1.socket();
@@ -358,15 +525,13 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_Block_BasicStatusAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
assertTrue(this.channel1.connect(localAddr1));
@@ -379,15 +544,13 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_NonBlock_BasicStatusAfterConnect() throws Exception {
assertFalse(this.channel1.isConnected());// not connected
this.channel1.configureBlocking(false);
@@ -401,38 +564,33 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
- if (tryFinish()) {
- assertTrue(this.channel1.isConnected());
- s1 = this.channel1.socket();
- assertSocketAfterConnect(s1, localAddr1);
- s2 = this.channel1.socket();
- // same
- assertSame(s1, s2);
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ assertTrue(tryFinish());
+ assertTrue(this.channel1.isConnected());
+ s1 = this.channel1.socket();
+ assertSocketAfterConnect(s1, localAddr1);
+ s2 = this.channel1.socket();
+ // same
+ assertSame(s1, s2);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_Block_ActionsBeforeConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
Socket s = this.channel1.socket();
assertSocketAction_Block_BeforeConnect(s);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_Block_ActionsAfterConnect() throws IOException {
assertFalse(this.channel1.isConnected());// not connected
assertTrue(this.channel1.connect(localAddr1));
@@ -441,15 +599,13 @@ public class SocketChannelTest extends TestCase {
assertSocketAction_Block_AfterConnect(s);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_NonBlock_ActionsAfterConnectBeforeFinish()
throws IOException {
assertFalse(this.channel1.isConnected());// not connected
@@ -464,27 +620,24 @@ public class SocketChannelTest extends TestCase {
// same
assertSame(s1, s2);
}
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void testSocket_NonBlock_ActionsAfterConnectAfterFinish()
throws Exception {
assertFalse(this.channel1.isConnected());// not connected
this.channel1.configureBlocking(false);
assertFalse(this.channel1.connect(localAddr1));
- if (tryFinish()) {
- Socket s1 = this.channel1.socket();
- assertSocketAction_NonBlock_AfterConnect(s1);
- Socket s2 = this.channel1.socket();
- // same
- assertSame(s1, s2);
- }
+ assertTrue(tryFinish());
+ Socket s1 = this.channel1.socket();
+ assertSocketAction_NonBlock_AfterConnect(s1);
+ Socket s2 = this.channel1.socket();
+ // same
+ assertSame(s1, s2);
}
private void assertSocketBeforeConnect(Socket s) throws IOException {
@@ -513,20 +666,20 @@ public class SocketChannelTest extends TestCase {
assertNull(s.getInetAddress());
assertEquals(s.getLocalAddress().getHostAddress(), "0.0.0.0");
- // RI fails here. RI returns 0 while spec says unbound socket should
- // return -1.
- assertEquals(s.getLocalPort(), -1);
assertFalse(s.getReuseAddress());
assertNull(s.getLocalSocketAddress());
// not connected
- assertEquals(s.getPort(), 0);
+ assertEquals(0, s.getPort());
assertTrue(s.getReceiveBufferSize() >= 8192);
assertNull(s.getRemoteSocketAddress());
assertTrue(s.getSendBufferSize() >= 8192);
- assertEquals(s.getSoTimeout(), 0);
- assertEquals(s.getTrafficClass(), 0);
+ assertEquals(0, s.getSoTimeout());
+ assertEquals(0, s.getTrafficClass());
+ // RI fails here. RI returns 0 while spec says unbound socket should
+ // return -1.
+ assertEquals(-1, s.getLocalPort());
}
private void assertSocketAfterConnect(Socket s, InetSocketAddress address)
@@ -548,17 +701,17 @@ public class SocketChannelTest extends TestCase {
assertSame(s.getInetAddress(), address.getAddress());
- assertEquals(s.getLocalAddress(), this.localAddr1.getAddress());
- assertEquals(s.getPort(), address.getPort());
+ assertEquals(this.localAddr1.getAddress(), s.getLocalAddress());
+ assertEquals(address.getPort(), s.getPort());
assertNotNull(s.getLocalSocketAddress());
assertTrue(s.getReceiveBufferSize() >= 8192);
// equal , not same
- assertNotSame(s.getRemoteSocketAddress(), (SocketAddress) address);
- assertEquals(s.getRemoteSocketAddress(), (SocketAddress) address);
+ assertNotSame(address, s.getRemoteSocketAddress());
+ assertEquals(address, s.getRemoteSocketAddress());
// assertFalse(s.getReuseAddress());
assertTrue(s.getSendBufferSize() >= 8192);
- assertEquals(s.getSoTimeout(), 0);
- assertEquals(s.getTrafficClass(), 0);
+ assertEquals(0, s.getSoTimeout());
+ assertEquals(0, s.getTrafficClass());
}
private void assertSocketAction_Block_BeforeConnect(Socket s)
@@ -620,7 +773,7 @@ public class SocketChannelTest extends TestCase {
private void assertSocketAction_Block_AfterConnect(Socket s)
throws IOException {
- assertEquals(s.getPort(), localAddr1.getPort());
+ assertEquals(localAddr1.getPort(), s.getPort());
assertTrue(this.channel1.isConnected());
assertTrue(s.isConnected());
try {
@@ -644,7 +797,7 @@ public class SocketChannelTest extends TestCase {
private void assertSocketAction_NonBlock_AfterConnect(Socket s)
throws IOException {
- assertEquals(s.getPort(), localAddr1.getPort());
+ assertEquals(localAddr1.getPort(), s.getPort());
assertTrue(this.channel1.isConnected());
assertTrue(s.isConnected());
@@ -683,18 +836,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_Norml_NoServer_Block() throws Exception {
// ensure
@@ -720,18 +874,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_Norml_NoServer_NonBlock() throws Exception {
connectNoServerNonBlock();
@@ -743,18 +898,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_Norml_Server_Block() throws Exception {
connectServerBlock();
@@ -767,18 +923,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_Norml_Server_NonBlock() throws Exception {
connectServerNonBlock();
@@ -790,18 +947,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->server closed-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerClosed_Block() throws Exception {
// ensure
@@ -824,18 +982,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->server closed-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerClosed_NonBlock() throws Exception {
// ensure
@@ -857,18 +1016,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->server closed-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerClosedAfterFinish_Block() throws Exception {
connectServerBlock();
@@ -883,18 +1043,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->server closed-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerClosedAfterFinish_NonBlock() throws Exception {
connectServerNonBlock();
@@ -908,18 +1069,19 @@ public class SocketChannelTest extends TestCase {
/**
* no server-->connect-->server open-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerStartLater_Block() throws Exception {
// ensure
@@ -946,18 +1108,19 @@ public class SocketChannelTest extends TestCase {
/**
* no server-->connect-->server open-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_ServerStartLater_NonBlock() throws Exception {
// ensure
@@ -975,25 +1138,26 @@ public class SocketChannelTest extends TestCase {
statusNotConnected_Pending();
this.channel1.close();
} catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
+ // OK
}
}
/**
* connect-->finish-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishTwice_NoServer_NonBlock() throws Exception {
// ensure
@@ -1005,31 +1169,37 @@ public class SocketChannelTest extends TestCase {
statusNotConnected_Pending();
try {
assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- this.channel1.close();
} catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
+ // OK
+ }
+ statusChannelClosed();
+ try {
+ assertFalse(this.channel1.finishConnect());
+ } catch (ClosedChannelException e) {
+ // OK
}
statusChannelClosed();
+
+ this.channel1.close();
+ statusChannelClosed();
}
/**
* connect-->finish-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishTwice_Server_Block() throws Exception {
connectServerBlock();
@@ -1042,18 +1212,19 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishTwice_Server_NonBlock() throws Exception {
connectServerNonBlock();
@@ -1065,24 +1236,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies case: connect-->finish-->connect-->close. " +
- "Verifies ClosedChannelException, ConnectException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->finish-->connect-->close. Verifies ClosedChannelException, ConnectException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->finish-->connect-->close. Verifies ClosedChannelException, ConnectException.",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_ConnectAfterFinish_NoServer_Block() throws Exception {
// ensure
ensureServerClosed();
@@ -1115,20 +1282,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies case: connect-->finish-->connect-->close. " +
- "Verifies ConnectionPendingException, ConnectException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->finish-->connect-->close. Verifies ConnectionPendingException, ConnectException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->finish-->connect-->close. Verifies ConnectionPendingException, ConnectException.",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_ConnectAfterFinish_NoServer_NonBlock()
throws Exception {
// ensure
@@ -1138,67 +1305,55 @@ public class SocketChannelTest extends TestCase {
// connect
assertFalse(this.channel1.connect(localAddr1));
statusNotConnected_Pending();
+
try {
- assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- } catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
+ this.channel1.connect(localAddr1);
+ fail("Should throw a ConnectionPendingException here.");
+ } catch (ConnectionPendingException e) {
+ // OK.
}
+ statusNotConnected_Pending();
- if (this.channel1.isOpen()) {
-
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw a ConnectionPendingException here.");
- } catch (ConnectionPendingException e) {
- // OK.
- }
- statusNotConnected_Pending();
+ // connect another addr
+ try {
+ this.channel1.connect(localAddr2);
+ fail("Should throw a ConnectionPendingException here.");
+ } catch (ConnectionPendingException e) {
+ // OK.
+ }
+ statusNotConnected_Pending();
- // connect another addr
- try {
- this.channel1.connect(localAddr2);
- fail("Should throw a ConnectionPendingException here.");
- } catch (ConnectionPendingException e) {
- // OK.
- }
- statusNotConnected_Pending();
+ // connect if server closed
+ ensureServerClosed();
- // connect if server closed
- ensureServerClosed();
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw a ConnectionPendingException here.");
+ } catch (ConnectionPendingException e) {
+ // OK.
+ }
+ statusNotConnected_Pending();
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw a ConnectionPendingException here.");
- } catch (ConnectionPendingException e) {
- // OK.
- }
- statusNotConnected_Pending();
+ this.channel1.close();
- this.channel1.close();
- }
statusChannelClosed();
}
/**
* connect-->finish-->connect-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies AlreadyConnectedException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies AlreadyConnectedException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_ConnectAfterFinish_Server_Block() throws Exception {
connectServerBlock();
if (!this.channel1.isConnected()) {
- System.err
- .println("Connection fail, testCFII_ConnectAfterFinish_Server_Block is not finished.");
- return;
+ fail("Connection failed," +
+ "testCFII_ConnectAfterFinish_Server_Block not finished.");
}
try {
@@ -1237,22 +1392,18 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->finish-->connect-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies AlreadyConnectedException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies AlreadyConnectedException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_ConnectAfterFinish_Server_NonBlock() throws Exception {
connectServerNonBlock();
if (!this.channel1.isConnected()) {
- System.err
- .println("Connection fail, testCFII_ConnectAfterFinish_Server_Block is not finished.");
- return;
+ fail("Connection failed," +
+ "testCFII_ConnectAfterFinish_Server_Block not finished.");
}
try {
this.channel1.connect(localAddr1);
@@ -1290,20 +1441,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies case: connect-->connect-->finish-->close. " +
- "Verifies ConnectionPendingException, ConnectException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->connect-->finish-->close. Verifies ConnectionPendingException, ConnectException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case: connect-->connect-->finish-->close. Verifies ConnectionPendingException, ConnectException.",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_ConnectTwice_NoServer_NonBlock() throws Exception {
// ensure
ensureServerClosed();
@@ -1340,14 +1491,7 @@ public class SocketChannelTest extends TestCase {
// OK.
}
statusNotConnected_Pending();
-
- try {
- assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- this.channel1.close();
- } catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
- }
+ this.channel1.close();
statusChannelClosed();
}
@@ -1355,20 +1499,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies case connect-->connect-->finish-->close. " +
- "Verifies AlreadyConnectedException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case connect-->connect-->finish-->close. Verifies AlreadyConnectedException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case connect-->connect-->finish-->close. Verifies AlreadyConnectedException.",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_ConnectTwice_Server_Block() throws Exception {
// ensure
ensureServerOpen();
@@ -1416,20 +1560,20 @@ public class SocketChannelTest extends TestCase {
/**
* connect-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies case connect-->connect-->finish-->close. " +
- "Verifies ConnectionPendingException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case connect-->connect-->finish-->close. Verifies ConnectionPendingException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies case connect-->connect-->finish-->close. Verifies ConnectionPendingException.",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_ConnectTwice_Server_NonBlock() throws Exception {
// ensure
ensureServerOpen();
@@ -1476,17 +1620,18 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
)
})
public void testCFII_FinishFirst_NoServer_Block() throws Exception {
@@ -1522,18 +1667,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishFirst_NoServer_NonBlock() throws Exception {
// ensure
@@ -1551,14 +1697,7 @@ public class SocketChannelTest extends TestCase {
// connect
assertFalse(this.channel1.connect(localAddr1));
statusNotConnected_Pending();
-
- try {
- assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- this.channel1.close();
- } catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
- }
+ this.channel1.close();
statusChannelClosed();
}
@@ -1566,18 +1705,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishFirst_Server_Block() throws Exception {
// ensure
@@ -1606,18 +1746,19 @@ public class SocketChannelTest extends TestCase {
/**
* finish-->connect-->finish-->close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_FinishFirst_Server_NonBlock() throws Exception {
// ensure
@@ -1641,15 +1782,13 @@ public class SocketChannelTest extends TestCase {
this.channel1.close();
statusChannelClosed();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_Null() throws Exception {
statusNotConnected_NotPending();
try {
@@ -1659,24 +1798,14 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
- public void testCFII_UnsupportedType() throws Exception {
- class SubSocketAddress extends SocketAddress {
- private static final long serialVersionUID = 1L;
- //empty
- public SubSocketAddress() {
- super();
- }
- }
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
+ public void testCFII_UnsupportedType() throws Exception {
statusNotConnected_NotPending();
SocketAddress newTypeAddress = new SubSocketAddress();
try {
@@ -1686,15 +1815,13 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_Unresolved() throws IOException {
statusNotConnected_NotPending();
InetSocketAddress unresolved = new InetSocketAddress(
@@ -1706,15 +1833,13 @@ public class SocketChannelTest extends TestCase {
// OK.
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_EmptyHost() throws Exception {
statusNotConnected_NotPending();
ServerSocket server = new ServerSocket(0);
@@ -1727,21 +1852,19 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException.",
+ method = "finishConnect",
+ args = {}
)
})
public void testCFII_CloseFirst() throws Exception {
@@ -1770,18 +1893,20 @@ public class SocketChannelTest extends TestCase {
}
statusChannelClosed();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
})
public void testCFII_StatusAfterFinish() throws Exception {
// 1. close server, finish must return false, check the status
@@ -1795,7 +1920,6 @@ public class SocketChannelTest extends TestCase {
} catch (ConnectException e) {
// OK.
}
- assertFalse(this.channel1.isOpen());
assertFalse(this.channel1.isOpen());
assertTrue(this.channel1.isBlocking());
@@ -1807,11 +1931,11 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.connect(localAddr1));
try {
assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
- this.channel1.close();
+ fail("Should throw IOException: Connection refused");
} catch (ConnectException e) {
- System.out.println(e.getMessage());
+ // OK
}
+ statusChannelClosed();
// 2. start server, finish usually return true, check the status
ensureServerOpen();
@@ -1861,10 +1985,10 @@ public class SocketChannelTest extends TestCase {
statusNotConnected_Pending();
try {
assertFalse(this.channel1.finishConnect());
- statusNotConnected_Pending();
} catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
+ // OK
}
+ ensureServerClosed();
}
private void connectServerNonBlock() throws Exception {
@@ -1887,6 +2011,7 @@ public class SocketChannelTest extends TestCase {
// connect
assertTrue(this.channel1.connect(localAddr1));
statusConnected_NotPending();
+
tryFinish();
}
@@ -1939,15 +2064,12 @@ public class SocketChannelTest extends TestCase {
*
* 'SocketChannelImpl.connect(SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ )
public void testCFII_Data_ConnectWithServer() throws Exception {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -1981,23 +2103,20 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'SocketChannelImpl.connect(SocketAddress)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
+ })
public void testCFII_Data_ConnectWithServer_nonBlocking() throws Exception {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2013,17 +2132,17 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isConnected());
assertTrue(this.channel1.isConnectionPending());
assertTrue(this.channel1.isOpen());
- if (tryFinish()) {
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBufArr, 0, 1));
+ assertTrue(tryFinish());
+ assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
+ assertEquals(CAPACITY_NORMAL, this.channel1
+ .write(writeBufArr, 0, 1));
- this.channel1.configureBlocking(false);
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw AlreadyConnectedException");
- } catch (AlreadyConnectedException e) {
- // correct
- }
+ this.channel1.configureBlocking(false);
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw AlreadyConnectedException");
+ } catch (AlreadyConnectedException e) {
+ // correct
}
assertFalse(this.channel1.isRegistered());
@@ -2033,19 +2152,12 @@ public class SocketChannelTest extends TestCase {
/*
* Test method for 'SocketChannelImpl.finishConnect()'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
public void testCFII_Data_FinishConnect_nonBlocking() throws IOException {
ensureServerOpen();
@@ -2067,38 +2179,43 @@ public class SocketChannelTest extends TestCase {
assertTrue(this.channel1.isConnectionPending());
assertTrue(this.channel1.isOpen());
this.server1.accept();
- if (tryFinish()) {
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBufArr, 0, 1));
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw AlreadyConnectedException");
- } catch (AlreadyConnectedException e) {
- // correct
- }
+ assertTrue(tryFinish());
+ assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
+ assertEquals(CAPACITY_NORMAL, this.channel1
+ .write(writeBufArr, 0, 1));
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw AlreadyConnectedException");
+ } catch (AlreadyConnectedException e) {
+ // correct
}
+
assertFalse(this.channel1.isRegistered());
tryFinish();
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "connect",
- methodArgs = {java.net.SocketAddress.class}
- ),
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "open",
- methodArgs = {}
- )
- })
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "connect",
+ args = {java.net.SocketAddress.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IOException",
+ method = "open",
+ args = {SocketAddress.class}
+ )
+ })
public void testCFII_Data_FinishConnect_AddrSetServerStartLater()
- throws IOException, InterruptedException {
+ throws IOException {
ensureServerClosed();
java.nio.ByteBuffer[] writeBufArr = new java.nio.ByteBuffer[1];
writeBufArr[0] = java.nio.ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -2142,39 +2259,32 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isConnected());
ensureServerOpen();
// cannot connect?
- try {
- assertFalse(this.channel1.finishConnect());
assertFalse(this.channel1.isBlocking());
- assertFalse(this.channel1.isConnected());
- assertTrue(this.channel1.isConnectionPending());
- assertTrue(this.channel1.isOpen());
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw ConnectionPendingException");
- } catch (ConnectionPendingException e) {
- // correct
- }
- this.channel1.configureBlocking(true);
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw ConnectionPendingException");
- } catch (ConnectionPendingException e) {
- // correct
- }
- tryFinish();
- } catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ assertFalse(this.channel1.isConnected());
+ assertTrue(this.channel1.isConnectionPending());
+ assertTrue(this.channel1.isOpen());
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw ConnectionPendingException");
+ } catch (ConnectionPendingException e) {
+ // correct
+ }
+ this.channel1.configureBlocking(true);
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw ConnectionPendingException");
+ } catch (ConnectionPendingException e) {
+ // correct
+ }
+ tryFinish();
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
public void testCFII_Data_FinishConnect_ServerStartLater()
throws IOException {
ensureServerClosed();
@@ -2209,43 +2319,32 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isConnected());
ensureServerOpen();
// cannot connect?
+ assertFalse(this.channel1.isBlocking());
+ assertFalse(this.channel1.isConnected());
+ assertTrue(this.channel1.isConnectionPending());
+ assertTrue(this.channel1.isOpen());
try {
- assertFalse(this.channel1.finishConnect());
- assertFalse(this.channel1.isBlocking());
- assertFalse(this.channel1.isConnected());
- assertTrue(this.channel1.isConnectionPending());
- assertTrue(this.channel1.isOpen());
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw ConnectionPendingException");
- } catch (ConnectionPendingException e) {
- // correct
- }
- this.channel1.configureBlocking(true);
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw ConnectionPendingException");
- } catch (ConnectionPendingException e) {
- // correct
- }
- tryFinish();
- } catch (ConnectException e) {
- // FIXME: assertEquals(e.getMessage(), "Connection refused");
- }
- }
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- ),
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ this.channel1.connect(localAddr1);
+ fail("Should throw ConnectionPendingException");
+ } catch (ConnectionPendingException e) {
+ // correct
+ }
+ this.channel1.configureBlocking(true);
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw ConnectionPendingException");
+ } catch (ConnectionPendingException e) {
+ // correct
+ }
+ tryFinish();
+ }
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "finishConnect",
+ args = {}
+ )
public void testCFII_Data_FinishConnect_Blocking() throws IOException {
ensureServerOpen();
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2265,17 +2364,18 @@ public class SocketChannelTest extends TestCase {
assertTrue(this.channel1.isConnected());
assertFalse(this.channel1.isConnectionPending());
assertTrue(this.channel1.isOpen());
- if (tryFinish()) {
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
- assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBufArr, 0, 1));
+ assertTrue(tryFinish());
+ assertEquals(CAPACITY_NORMAL, this.channel1.write(writeBuf));
+ assertEquals(CAPACITY_NORMAL, this.channel1
+ .write(writeBufArr, 0, 1));
- try {
- this.channel1.connect(localAddr1);
- fail("Should throw AlreadyConnectedException");
- } catch (AlreadyConnectedException e) {
- // correct
- }
+ try {
+ this.channel1.connect(localAddr1);
+ fail("Should throw AlreadyConnectedException");
+ } catch (AlreadyConnectedException e) {
+ // correct
}
+
assertFalse(this.channel1.isRegistered());
tryFinish();
}
@@ -2283,15 +2383,12 @@ public class SocketChannelTest extends TestCase {
/**
* Regression test for Harmony-1947.
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "finishConnect",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exceptions.",
+ method = "finishConnect",
+ args = {}
+ )
public void test_finishConnect() throws Exception {
SocketAddress address = new InetSocketAddress("localhost", 2046);
@@ -2315,9 +2412,14 @@ public class SocketChannelTest extends TestCase {
// finishConnect() blocks.
channel1.configureBlocking(true);
doneNonBlockingConnect = channel1.finishConnect();
+ } else {
+ fail("Non blocking connect was connected too fast." +
+ "Could not test finishConnect().");
}
if (doneNonBlockingConnect) {
tryFinish();
+ } else {
+ fail("finishConnect() did not finish the connection.");
}
channel1.close();
}
@@ -2325,7 +2427,7 @@ public class SocketChannelTest extends TestCase {
serversocket.close();
}
}
-
+
// -------------------------------------------------------------------
// End of original tests. Test method for CFII with real data.
// -------------------------------------------------------------------
@@ -2333,16 +2435,13 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
- public void test_readLjava_nio_ByteBuffer_Blocking() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_readLByteBuffer_Blocking() throws IOException {
// initialize write content
byte[] writeContent = new byte[CAPACITY_NORMAL];
for (int i = 0; i < writeContent.length; i++) {
@@ -2375,7 +2474,10 @@ public class SocketChannelTest extends TestCase {
// blocking read, it possibly returns 0 in some cases.
assertTimeout(startTime, TIMEOUT);
}
+
+ // assert read content
assertEquals(CAPACITY_NORMAL, totalCount);
+ assertEquals(CAPACITY_NORMAL, readContent.position());
readContent.flip();
for (int i = 0; i < CAPACITY_NORMAL; i++) {
assertEquals(writeContent[i], readContent.get());
@@ -2385,16 +2487,13 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
- public void test_readLjava_nio_ByteBuffer_Nonblocking() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_readLByteBuffer_Nonblocking() throws IOException {
// initialize write content
byte[] writeContent = new byte[CAPACITY_NORMAL];
for (int i = 0; i < writeContent.length; i++) {
@@ -2440,16 +2539,13 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_wrtieLjava_nio_ByteBuffer_Blocking() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void test_writeLjava_nio_ByteBuffer_Blocking() throws IOException {
// initialize write content
ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_NORMAL);
for (int i = 0; i < CAPACITY_NORMAL; i++) {
@@ -2499,16 +2595,13 @@ public class SocketChannelTest extends TestCase {
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
- public void test_wrtieLjava_nio_ByteBuffer_NonBlocking() throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ public void test_writeLjava_nio_ByteBuffer_NonBlocking() throws Exception {
// initialize write content
ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_NORMAL);
for (int i = 0; i < CAPACITY_NORMAL; i++) {
@@ -2564,6 +2657,47 @@ public class SocketChannelTest extends TestCase {
}
}
+ /**
+ * @tests java.nio.channels.SocketChannel#read(ByteBuffer)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
+ @KnownFailure("Fxed on ToT")
+ public void test_writeLjava_nio_ByteBuffer_Nonblocking_HugeData() throws IOException {
+ // initialize write content
+ ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_HUGE);
+ for (int i = 0; i < CAPACITY_HUGE; i++) {
+ writeContent.put((byte) i);
+ }
+ writeContent.flip();
+
+ // establish connection
+ channel1.connect(localAddr1);
+ Socket acceptedSocket = server1.accept();
+
+ channel1.configureBlocking(false);
+ int writtenTotalCount = 0;
+ int writtenCount = 1;
+ long startTime = System.currentTimeMillis();
+ // use SocketChannel.write(ByteBuffer) to try to write CAPACITY_HUGE bytes
+ while (writtenTotalCount < CAPACITY_HUGE && writtenCount > 0) {
+ writtenCount = channel1.write(writeContent);
+ if (writtenCount == 0 && writtenTotalCount < CAPACITY_HUGE) {
+ assertEquals(0, channel1.write(writeContent));
+ break;
+ }
+ writtenTotalCount += writtenCount;
+ // if the channel could not finish writing in TIMEOUT ms, the
+ // test fails. It is used to guarantee the test never hangs even
+ // if there are bugs of SocketChannel implementation.
+ assertTimeout(startTime, TIMEOUT);
+ }
+ }
+
/*
* Fails if the difference between current time and start time is greater
* than timeout.
@@ -2578,15 +2712,12 @@ public class SocketChannelTest extends TestCase {
// -------------------------------------------------
// Test for read/write but no real data expressed
// -------------------------------------------------
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify all exceptions according to specification.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadByteBuffer() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer
@@ -2608,9 +2739,8 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isBlocking());
assertTrue(this.channel1.isConnectionPending());
assertFalse(this.channel1.isConnected());
- if (tryFinish()) {
- assertEquals(0, this.channel1.read(readBuf));
- }
+ assertTrue(tryFinish());
+ assertEquals(0, this.channel1.read(readBuf));
this.channel1.close();
try {
@@ -2620,15 +2750,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadByteBuffer_Direct() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer
@@ -2650,9 +2778,8 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isBlocking());
assertTrue(this.channel1.isConnectionPending());
assertFalse(this.channel1.isConnected());
- if (tryFinish()) {
- assertEquals(0, this.channel1.read(readBuf));
- }
+ assertTrue(tryFinish());
+ assertEquals(0, this.channel1.read(readBuf));
this.channel1.close();
try {
@@ -2662,15 +2789,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testReadByteBuffer_BufNull() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer readBuf = java.nio.ByteBuffer.allocate(0);
@@ -2683,36 +2808,25 @@ public class SocketChannelTest extends TestCase {
// correct
}
this.channel1.connect(localAddr1);
- if (tryFinish()) {
- try {
- this.channel1.read((java.nio.ByteBuffer) null);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
- // correct
- }
- assertEquals(0, this.channel1.read(readBuf));
- }
- this.server1.close();
+ assertTrue(tryFinish());
try {
- channel1.read((java.nio.ByteBuffer) null);
+ this.channel1.read((java.nio.ByteBuffer) null);
fail("Should throw NPE");
} catch (NullPointerException e) {
// correct
}
+ assertEquals(0, this.channel1.read(readBuf));
}
/*
* SocketChannelImpl.read(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testReadByteBufferArrayIntInt() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2735,10 +2849,9 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isBlocking());
assertTrue(this.channel1.isConnectionPending());
assertFalse(this.channel1.isConnected());
- if (tryFinish()) {
- assertEquals(0, this.channel1.read(readBuf, 0, 1));
- assertEquals(0, this.channel1.read(readBuf, 0, 2));
- }
+ assertTrue(tryFinish());
+ assertEquals(0, this.channel1.read(readBuf, 0, 1));
+ assertEquals(0, this.channel1.read(readBuf, 0, 2));
this.channel1.close();
try {
@@ -2748,19 +2861,16 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
+
/*
* SocketChannelImpl.read(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testReadByteBufferArrayIntInt_Direct() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2783,10 +2893,9 @@ public class SocketChannelTest extends TestCase {
assertFalse(this.channel1.isBlocking());
assertTrue(this.channel1.isConnectionPending());
assertFalse(this.channel1.isConnected());
- if (tryFinish()) {
- assertEquals(0, this.channel1.read(readBuf, 0, 1));
- assertEquals(0, this.channel1.read(readBuf, 0, 2));
- }
+ assertTrue(tryFinish());
+ assertEquals(0, this.channel1.read(readBuf, 0, 1));
+ assertEquals(0, this.channel1.read(readBuf, 0, 2));
this.channel1.close();
try {
@@ -2796,15 +2905,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testReadByteBufferArrayIntInt_BufNull() throws Exception {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[2];
@@ -2823,23 +2930,23 @@ public class SocketChannelTest extends TestCase {
// correct
}
this.channel1.connect(localAddr1);
- if (tryFinish()) {
+ assertTrue(tryFinish());
- try {
- channel1.read(null, 0, 0);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
- // correct
- }
- try {
- channel1.read(readBuf, 0, 2);
- fail("Should throw NPE");
- } catch (NullPointerException e) {
- // correct
- }
-
- assertEquals(0, this.channel1.read(readBuf, 0, 1));
+ try {
+ channel1.read(null, 0, 0);
+ fail("Should throw NPE");
+ } catch (NullPointerException e) {
+ // correct
+ }
+ try {
+ channel1.read(readBuf, 0, 2);
+ fail("Should throw NPE");
+ } catch (NullPointerException e) {
+ // correct
}
+
+ assertEquals(0, this.channel1.read(readBuf, 0, 1));
+
this.channel1.close();
try {
channel1.read(null, 0, 1);
@@ -2848,15 +2955,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testWriteByteBuffer() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2887,16 +2992,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException.",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify AsynchronousCloseException, ClosedByInterruptException.",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testWriteByteBuffer_Direct() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer
@@ -2927,15 +3029,13 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void testWriteByteBuffer_BufNull() throws IOException {
assertTrue(this.server1.isBound());
java.nio.ByteBuffer writeBuf = java.nio.ByteBuffer.allocate(0);
@@ -2952,16 +3052,13 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.write(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify AsynchronousCloseException, " +
- "ClosedByInterruptException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify AsynchronousCloseException," +
+ "ClosedByInterruptException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testWriteByteBufferArrayIntInt() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[2];
writeBuf[0] = java.nio.ByteBuffer.allocate(CAPACITY_NORMAL);
@@ -2990,7 +3087,7 @@ public class SocketChannelTest extends TestCase {
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
this.channel1.close();
try {
- channel1.write(writeBuf);
+ channel1.write(writeBuf, 0, 1);
fail("Should throw ClosedChannelException");
} catch (ClosedChannelException e) {
// correct
@@ -3000,15 +3097,12 @@ public class SocketChannelTest extends TestCase {
/*
* SocketChannelImpl.write(ByteBuffer[], int, int)'
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testWriteByteBufferArrayIntInt_Direct() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[2];
writeBuf[0] = java.nio.ByteBuffer.allocateDirect(CAPACITY_NORMAL);
@@ -3037,21 +3131,19 @@ public class SocketChannelTest extends TestCase {
assertEquals(CAPACITY_NORMAL * 2, this.channel1.write(writeBuf, 0, 2));
this.channel1.close();
try {
- channel1.write(writeBuf);
+ channel1.write(writeBuf, 0 ,1);
fail("Should throw ClosedChannelException");
} catch (ClosedChannelException e) {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testWriteByteBufferArrayIntInt_BufNull() throws IOException {
java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[0];
@@ -3076,6 +3168,7 @@ public class SocketChannelTest extends TestCase {
} catch (NullPointerException e) {
// correct
}
+ writeBuf[0] = java.nio.ByteBuffer.allocate(CAPACITY_NORMAL);
try {
this.channel1.write(writeBuf, 0, 2);
fail("Should throw IndexOutOfBoundsException");
@@ -3090,21 +3183,20 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException.",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testWriteByteBufferArrayIntInt_SizeError() throws IOException {
- java.nio.ByteBuffer[] writeBuf = new java.nio.ByteBuffer[0];
+ java.nio.ByteBuffer[] writeBuf =
+ {java.nio.ByteBuffer.allocate(CAPACITY_NORMAL)};
this.channel1.connect(localAddr1);
try {
- this.channel1.write(null, -1, 1);
+ this.channel1.write(writeBuf, -1, 1);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
@@ -3116,36 +3208,26 @@ public class SocketChannelTest extends TestCase {
} catch (IndexOutOfBoundsException e) {
// correct
}
- writeBuf = new java.nio.ByteBuffer[1];
- try {
- this.channel1.write(writeBuf, 2, 1);
- fail("Should throw IndexOutOfBoundsException");
- } catch (IndexOutOfBoundsException e) {
- // correct
- }
try {
- this.channel1.write(writeBuf, 2, -1);
+ this.channel1.write(writeBuf, 1, 1);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
}
- this.server1.close();
try {
- channel1.read(null, -1, -1);
+ this.channel1.write(writeBuf, 0, 2);
fail("Should throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// correct
}
}
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void testReadByteBufferArrayIntInt_SizeError() throws IOException {
java.nio.ByteBuffer[] readBuf = new java.nio.ByteBuffer[0];
@@ -3184,68 +3266,121 @@ public class SocketChannelTest extends TestCase {
// correct
}
}
-
- /*
+
+ /*
* ==========================================================================
* Tests for read/write real data
* ==========================================================================
- */
-
+ */
+
+ /**
+ * @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read$LByteBuffer_blocking() throws Exception {
+ assert_read$LByteBuffer(true);
+ }
/**
- * @tests java.nio.channels.SocketChannel#read(ByteBuffer[])
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
- public void test_read$LByteBuffer() throws IOException {
- MockSocketChannel sc = new MockSocketChannel(null);
- ByteBuffer [] byteBufferArray = { ByteBuffer.allocate(1), ByteBuffer.allocate(1)};
- // Verify that calling read(ByteBuffer[]) leads to the method
- // read(ByteBuffer[], int, int) being called with a 0 for the
- // second parameter and targets.length as the third parameter.
- sc.read(byteBufferArray);
- assertTrue(sc.isReadCalled);
+ * @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read$LByteBuffer_nonblocking() throws Exception {
+ assert_read$LByteBuffer(false);
+ }
+
+ private void assert_read$LByteBuffer(boolean isBlocking) throws IOException {
+ // initialize write content
+ byte[] writeContent = new byte[CAPACITY_NORMAL * 2];
+ for (int i = 0; i < CAPACITY_NORMAL * 2; i++) {
+ writeContent[i] = (byte) i;
+ }
+ ByteBuffer[] readContents = new ByteBuffer[2];
+ readContents[0] = ByteBuffer.allocate(CAPACITY_NORMAL);
+ readContents[1] = ByteBuffer.allocate(CAPACITY_NORMAL + 1);
+ // establish connection
+ channel1.connect(localAddr1);
+ Socket acceptedSocket = server1.accept();
+ // use OutputStream.write to send CAPACITY_NORMAL * 2 bytes data
+ OutputStream out = acceptedSocket.getOutputStream();
+ out.write(writeContent);
+ // use close to guarantee all data is sent
+ acceptedSocket.close();
+ // configure block/nonblock mode
+ channel1.configureBlocking(isBlocking);
+ long startTime = System.currentTimeMillis();
+ long totalRead = 0;
+ long countRead = 0;
+
+ while (totalRead <= CAPACITY_NORMAL * 2) {
+ countRead = channel1.read(readContents);
+ if (0 == countRead && !readContents[1].hasRemaining()) {
+ // read returns 0 because readContents is full
+ break;
+ }
+ if (EOF == countRead) {
+ break;
+ }
+ totalRead += countRead;
+ // if the channel could not finish reading in TIMEOUT ms, the
+ // test fails. It is used to guarantee the test never hangs even
+ // if there are bugs of SocketChannel implementation. For
+ // blocking read, it possibly returns 0 in some cases.
+ assertTimeout(startTime, TIMEOUT);
+ }
+
+ // assert total bytes read and the position of ByteBuffers
+ assertEquals(CAPACITY_NORMAL * 2, totalRead);
+ assertEquals(CAPACITY_NORMAL, readContents[0].position());
+ assertEquals(CAPACITY_NORMAL, readContents[1].position());
+ // assert read content
+ readContents[0].flip();
+ readContents[1].flip();
+ for (int i = 0; i < CAPACITY_NORMAL; i++) {
+ assertEquals(writeContent[i], readContents[0].get());
+ }
+ for (int i = CAPACITY_NORMAL; i < CAPACITY_NORMAL * 2; i++) {
+ assertEquals(writeContent[i], readContents[1].get());
+ }
}
+
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_blocking() throws Exception {
- assert_read$LByteBuffer(true);
+ assert_read$LByteBufferII(true);
}
-
+
/**
* @tests java.nio.channels.SocketChannel#read(ByteBuffer[],int,int)
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read$LByteBufferII_nonblocking() throws Exception {
- assert_read$LByteBuffer(false);
+ assert_read$LByteBufferII(false);
}
- private void assert_read$LByteBuffer(boolean isBlocking) throws IOException {
+ private void assert_read$LByteBufferII(boolean isBlocking) throws IOException {
// initialize write content
byte[] writeContent = new byte[CAPACITY_NORMAL * 2];
for (int i = 0; i < CAPACITY_NORMAL * 2; i++) {
@@ -3284,7 +3419,7 @@ public class SocketChannelTest extends TestCase {
// blocking read, it possibly returns 0 in some cases.
assertTimeout(startTime, TIMEOUT);
}
-
+
// assert total bytes read and the position of ByteBuffers
assertEquals(CAPACITY_NORMAL * 2, totalRead);
assertEquals(CAPACITY_NORMAL, readContents[0].position());
@@ -3298,38 +3433,31 @@ public class SocketChannelTest extends TestCase {
for (int i = CAPACITY_NORMAL; i < CAPACITY_NORMAL * 2; i++) {
assertEquals(writeContent[i], readContents[1].get());
}
- }
-
+ }
+
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void test_write$LByteBufferII_blocking() throws Exception {
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_write$LByteBuffer_blocking() throws Exception {
assert_write$LByteBuffer(true);
}
-
+
/**
* @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
- public void test_write$LByteBufferII_nonblocking()
- throws Exception {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_write$LByteBuffer_nonblocking() throws Exception {
assert_write$LByteBuffer(false);
}
@@ -3353,6 +3481,88 @@ public class SocketChannelTest extends TestCase {
// set blocking/nonblocking mode
channel1.configureBlocking(isBlocking);
+ assertEquals(2 * CAPACITY_NORMAL, channel1.write(writeContents));
+
+ // assert written count and ByteBuffer position
+ assertEquals(CAPACITY_NORMAL, writeContents[0].position());
+ assertEquals(CAPACITY_NORMAL, writeContents[1].position());
+ // use close to guarantee all data is sent
+ channel1.close();
+ InputStream in = acceptedSocket.getInputStream();
+ byte[] readContent = new byte[CAPACITY_NORMAL * 2 + 1];
+ int totalCount = 0;
+ int count = 0;
+ // if the channel could not finish reading in TIMEOUT ms, the test
+ // fails. It is used to guarantee the test never hangs even if there
+ // are bugs of SocketChannel implementation.
+ acceptedSocket.setSoTimeout(TIMEOUT);
+ // use InputStream.read to read data.
+ while (totalCount <= CAPACITY_NORMAL) {
+ count = in.read(readContent, totalCount, readContent.length
+ - totalCount);
+ if (EOF == count) {
+ break;
+ }
+ totalCount += count;
+ }
+ // assert read content
+ assertEquals(CAPACITY_NORMAL * 2, totalCount);
+ writeContents[0].flip();
+ writeContents[1].flip();
+ for (int i = 0; i < CAPACITY_NORMAL; i++) {
+ assertEquals(writeContents[0].get(), readContent[i]);
+ }
+ for (int i = CAPACITY_NORMAL; i < CAPACITY_NORMAL * 2; i++) {
+ assertEquals(writeContents[1].get(), readContent[i]);
+ }
+ }
+
+ /**
+ * @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void test_write$LByteBufferII_blocking() throws Exception {
+ assert_write$LByteBufferII(true);
+ }
+
+ /**
+ * @tests java.nio.channels.SocketChannel#write(ByteBuffer[],int,int)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
+ public void test_write$LByteBufferII_nonblocking() throws Exception {
+ assert_write$LByteBufferII(false);
+ }
+
+ private void assert_write$LByteBufferII(boolean isBlocking)
+ throws IOException {
+ // initialize write contents
+ ByteBuffer writeContents[] = new ByteBuffer[2];
+ writeContents[0] = ByteBuffer.allocate(CAPACITY_NORMAL);
+ writeContents[1] = ByteBuffer.allocate(CAPACITY_NORMAL);
+ for (int i = 0; i < CAPACITY_NORMAL; i++) {
+ writeContents[0].put((byte) i);
+ }
+ for (int i = CAPACITY_NORMAL; i < CAPACITY_NORMAL * 2; i++) {
+ writeContents[1].put((byte) i);
+ }
+ writeContents[0].flip();
+ writeContents[1].flip();
+ // establish connection
+ channel1.connect(localAddr1);
+ Socket acceptedSocket = server1.accept();
+ // set blocking/nonblocking mode
+ channel1.configureBlocking(isBlocking);
+
assertEquals(CAPACITY_NORMAL, channel1.write(writeContents, 0, 1));
assertEquals(CAPACITY_NORMAL, channel1.write(writeContents, 1, 1));
@@ -3388,38 +3598,23 @@ public class SocketChannelTest extends TestCase {
for (int i = CAPACITY_NORMAL; i < CAPACITY_NORMAL * 2; i++) {
assertEquals(writeContents[1].get(), readContent[i]);
}
- }
-
- /**
- * @tests java.nio.channels.SocketChannel#write(ByteBuffer[])
- */
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class}
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ clazz = SelectableChannel.class,
+ method = "configureBlocking",
+ args = {boolean.class}
)
})
- public void test_write$LByteBuffer() throws IOException {
- MockSocketChannel sc = new MockSocketChannel(null);
- ByteBuffer [] byteBufferArray = { ByteBuffer.allocate(1), ByteBuffer.allocate(1)};
- // Verify that calling write(ByteBuffer[]) leads to the method
- // write(ByteBuffer[], int, int) being called with a 0 for the
- // second parameter and sources.length as the third parameter.
- sc.write(byteBufferArray);
- assertTrue(sc.isWriteCalled);
- }
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalBlockingModeException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
public void testSocket_configureblocking() throws IOException {
byte[] serverWBuf = new byte[CAPACITY_NORMAL];
for (int i = 0; i < serverWBuf.length; i++) {
@@ -3450,15 +3645,12 @@ public class SocketChannelTest extends TestCase {
* @tests SocketChannel#read(ByteBuffer[], int, int) when remote server
* closed
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_socketChannel_read_ByteBufferII_remoteClosed()
throws Exception {
// regression 1 for HARMONY-549
@@ -3467,7 +3659,7 @@ public class SocketChannelTest extends TestCase {
SocketChannel sc = SocketChannel.open();
sc.connect(localAddr2);
ssc.accept().close();
- ByteBuffer[] buf = { ByteBuffer.allocate(10) };
+ ByteBuffer[] buf = {ByteBuffer.allocate(10)};
assertEquals(-1, sc.read(buf, 0, 1));
ssc.close();
sc.close();
@@ -3476,15 +3668,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_socketChannel_write_ByteBufferII() throws Exception {
// regression 2 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -3492,7 +3681,7 @@ public class SocketChannelTest extends TestCase {
SocketChannel sc = SocketChannel.open();
sc.connect(localAddr2);
SocketChannel sock = ssc.accept();
- ByteBuffer[] buf = { ByteBuffer.allocate(10), null };
+ ByteBuffer[] buf = {ByteBuffer.allocate(10), null};
try {
sc.write(buf, 0, 2);
fail("should throw NPE");
@@ -3508,15 +3697,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#read(ByteBuffer[], int, int) with a null ByteBuffer
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {java.nio.ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_socketChannel_read_ByteBufferII_bufNULL() throws Exception {
// regression 3 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -3540,19 +3726,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer) after close
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- ),
- @TestTarget(
- methodName = "close",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_socketChannel_write_close() throws Exception {
// regression 4 for HARMONY-549
ServerSocketChannel ssc = ServerSocketChannel.open();
@@ -3575,15 +3754,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannel#write(ByteBuffer) if position is not zero
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "write",
- methodArgs = {java.nio.ByteBuffer.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "write",
+ args = {java.nio.ByteBuffer.class}
+ )
public void test_socketChannel_write_ByteBuffer_posNotZero()
throws Exception {
// regression 5 for HARMONY-549
@@ -3607,20 +3783,17 @@ public class SocketChannelTest extends TestCase {
assertEquals(read[i], write[i + 2]);
}
}
-
+
/**
* @tests SocketChannelImpl#read(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Doesn't verify exceptions.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
- public void test_read_$ByteBuffer_Blocking() throws IOException {
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Doesn't verify exceptions.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read$LByteBuffer_Blocking() throws IOException {
// regression test for Harmony-728
byte[] data = new byte[CAPACITY_NORMAL];
for (int i = 0; i < CAPACITY_NORMAL; i++) {
@@ -3640,6 +3813,8 @@ public class SocketChannelTest extends TestCase {
} finally {
if (null != socket) {
socket.close();
+ } else {
+ fail();
}
}
}
@@ -3647,16 +3822,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().read
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies IllegalBlockingModeException, " +
- "NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IllegalBlockingModeException, NullPointerException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_getOutputStream_nonBlocking_read_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -3711,16 +3882,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().read
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NullPointerException, ClosedChannelException, " +
- "IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, ClosedChannelException, IndexOutOfBoundsException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_getOutputStream_blocking_read_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -3774,16 +3941,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NullPointerException, " +
- "IllegalBlockingModeException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, IllegalBlockingModeException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_getOutputStream_nonBlocking_write_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -3850,16 +4013,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "Verifies NullPointerException, " +
- "IndexOutOfBoundsException, ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, IndexOutOfBoundsException, ClosedChannelException.",
+ method = "socket",
+ args = {}
+ )
public void test_socket_getOutputStream_blocking_write_Exception()
throws IOException {
channel1.connect(this.localAddr1);
@@ -3913,15 +4072,12 @@ public class SocketChannelTest extends TestCase {
/**
* @tests SocketChannelImpl#socket().getOutputStream().write(int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL_OK,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "socket",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "socket",
+ args = {}
+ )
public void test_socket_getOutputStream_write_oneByte()
throws IOException {
@@ -3940,12 +4096,12 @@ public class SocketChannelTest extends TestCase {
os.write(MAGIC);
channel1.close();
- int lastByte = in.read();
+ int lastByte = in.read();
if (lastByte == -1) {
fail("Server received nothing. Expected 1 byte.");
} else if (lastByte != MAGIC) {
- fail("Server received wrong single byte: " + lastByte +
- ", expected: " + MAGIC);
+ fail("Server received wrong single byte: " + lastByte
+ + ", expected: " + MAGIC);
}
lastByte = in.read();
@@ -3954,14 +4110,17 @@ public class SocketChannelTest extends TestCase {
}
}
- class MockSocketChannel extends SocketChannel{
-
+ class MockSocketChannel extends SocketChannel {
+
private boolean isWriteCalled = false;
-
+
private boolean isReadCalled = false;
-
- public MockSocketChannel(SelectorProvider provider){
+
+ private boolean isConstructorCalled = false;
+
+ public MockSocketChannel(SelectorProvider provider) {
super(provider);
+ isConstructorCalled = true;
}
public Socket socket() {
@@ -3988,11 +4147,12 @@ public class SocketChannelTest extends TestCase {
return 0;
}
- public long read(ByteBuffer[] targets, int offset, int length) throws IOException {
+ public long read(ByteBuffer[] targets, int offset, int length)
+ throws IOException {
// Verify that calling read(ByteBuffer[]) leads to the method
// read(ByteBuffer[], int, int) being called with a 0 for the
// second parameter and targets.length as the third parameter.
- if(0 == offset && length == targets.length){
+ if (0 == offset && length == targets.length) {
isReadCalled = true;
}
return 0;
@@ -4002,11 +4162,12 @@ public class SocketChannelTest extends TestCase {
return 0;
}
- public long write(ByteBuffer[] sources, int offset, int length) throws IOException {
+ public long write(ByteBuffer[] sources, int offset, int length)
+ throws IOException {
// Verify that calling write(ByteBuffer[]) leads to the method
// write(ByteBuffer[], int, int) being called with a 0 for the
// second parameter and sources.length as the third parameter.
- if(0 == offset && length == sources.length){
+ if (0 == offset && length == sources.length) {
isWriteCalled = true;
}
return 0;
@@ -4016,9 +4177,18 @@ public class SocketChannelTest extends TestCase {
// empty
}
- protected void implConfigureBlocking(boolean blockingMode) throws IOException {
- // empty
+ protected void implConfigureBlocking(boolean blockingMode)
+ throws IOException {
+ // empty
}
-
- }
+ }
+
+ class SubSocketAddress extends SocketAddress {
+ private static final long serialVersionUID = 1L;
+
+ // empty
+ public SubSocketAddress() {
+ super();
+ }
+ }
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
index 9225d0a..ca713c7 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SourceChannelTest.java
@@ -16,19 +16,33 @@
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestInfo;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargets;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.AsynchronousCloseException;
+import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
+import java.nio.channels.Pipe.SourceChannel;
+import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
-@TestTargetClass(java.nio.channels.Pipe.SourceChannel.class)
+@TestTargetClass(
+ value = java.nio.channels.Pipe.SourceChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.SUFFICIENT,
+ notes = "AsynchronousCloseException can not easily be tested",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ }
+)
/**
* Tests for java.nio.channels.Pipe.SourceChannel
*/
@@ -61,15 +75,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#validOps()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "validOps",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "validOps",
+ args = {}
+ )
public void test_validOps() {
assertEquals(SelectionKey.OP_READ, source.validOps());
}
@@ -77,15 +88,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_LByteBuffer_DataAvailable() throws IOException {
// if anything can read, read method will not block
sink.write(ByteBuffer.allocate(1));
@@ -96,15 +104,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_LByteBuffer_Exception() throws IOException {
ByteBuffer nullBuf = null;
try {
@@ -118,15 +123,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_LByteBuffer_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
sink.write(buffer);
@@ -145,16 +147,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException, " +
- "NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException, NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_LByteBuffer_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
source.close();
@@ -177,8 +175,10 @@ public class SourceChannelTest extends TestCase {
try {
source.read(nullBuf);
fail("should throw NullPointerException");
+ } catch (ClosedChannelException e) {
+ // expected on RI
} catch (NullPointerException e) {
- // expected
+ // expected on Harmony/Android
}
ByteBuffer[] bufArray = null;
@@ -201,15 +201,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer[])
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_$LByteBuffer() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -261,15 +258,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_$LByteBuffer_Exception() throws IOException {
ByteBuffer[] nullBufArrayRef = null;
try {
@@ -301,15 +295,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_$LByteBuffer_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -330,15 +321,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies ClosedChannelException, NullPointerException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedChannelException, NullPointerException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
public void test_read_$LByteBuffer_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -380,15 +368,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer[], int, int)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read_$LByteBufferII() throws IOException {
ByteBuffer[] bufArray = { buffer, positionedBuffer };
boolean[] sinkBlockingMode = { true, true, false, false };
@@ -440,16 +425,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies NullPointerException, " +
- "IndexOutOfBoundsException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies NullPointerException, IndexOutOfBoundsException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read_$LByteBufferII_Exception() throws IOException {
ByteBuffer[] nullBufArrayRef = null;
@@ -522,15 +503,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read_$LByteBufferII_SinkClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -550,16 +528,12 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "Verifies IndexOutOfBoundsException, " +
- "ClosedChannelException.",
- targets = {
- @TestTarget(
- methodName = "read",
- methodArgs = {ByteBuffer[].class, int.class, int.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies IndexOutOfBoundsException, ClosedChannelException.",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class, int.class, int.class}
+ )
public void test_read_$LByteBufferII_SourceClosed() throws IOException {
ByteBuffer readBuf = ByteBuffer.allocate(BUFFER_SIZE);
ByteBuffer[] readBufArray = { readBuf };
@@ -648,19 +622,100 @@ public class SourceChannelTest extends TestCase {
/**
* @tests java.nio.channels.Pipe.SourceChannel#close()
+ * @tests {@link java.nio.channels.Pipe.SourceChannel#isOpen()}
*/
- @TestInfo(
- level = TestLevel.PARTIAL,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "close",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
+ ),@TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
+ })
public void test_close() throws IOException {
+ assertTrue(sink.isOpen());
sink.close();
assertFalse(sink.isOpen());
}
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "SourceChannel",
+ args = {java.nio.channels.spi.SelectorProvider.class}
+ )
+ public void testConstructor() throws IOException {
+ SourceChannel channel =
+ SelectorProvider.provider().openPipe().source();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ channel = Pipe.open().source();
+ assertNotNull(channel);
+ assertSame(SelectorProvider.provider(),channel.provider());
+ }
+
+ /**
+ * @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies ClosedByInterruptException",
+ method = "read",
+ args = {java.nio.ByteBuffer[].class}
+ )
+ public void test_read_LByteBuffer_mutliThread_interrupt() throws Exception {
+
+ source.configureBlocking(true);
+
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ source.read(ByteBuffer.allocate(10));
+ fail("should have thrown a ClosedByInterruptException.");
+ } catch (ClosedByInterruptException e) {
+ // expected
+ return;
+ } catch (IOException e) {
+ fail("should throw a ClosedByInterruptException but " +
+ "threw " + e.getClass() + ": " + e.getMessage());
+ }
+ }
+ };
+
+ thread.start();
+ Thread.currentThread().sleep(500);
+ thread.interrupt();
+
+ }
+
+ /**
+ * @tests java.nio.channels.Pipe.SourceChannel#read(ByteBuffer)
+ */
+ public void disabled_test_read_LByteBuffer_mutliThread_close() throws Exception {
+
+ ByteBuffer sourceBuf = ByteBuffer.allocate(1000);
+ source.configureBlocking(true);
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.currentThread().sleep(500);
+ source.close();
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ }.start();
+ try {
+ source.read(sourceBuf);
+ fail("should throw AsynchronousCloseException");
+ } catch (AsynchronousCloseException e) {
+ // ok
+ }
+ }
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
index ff9227e..fe3417f 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnresolvedAddressExceptionTest.java
@@ -15,9 +15,9 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.channels.UnresolvedAddressException;
@@ -35,15 +35,20 @@ public class UnresolvedAddressExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "UnresolvedAddressException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new UnresolvedAddressException());
@@ -52,15 +57,20 @@ public class UnresolvedAddressExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
+ @TestTargets({
+ @TestTargetNew(
level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "UnresolvedAddressException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new UnresolvedAddressException());
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
index 7dd0508..442fc1e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/UnsupportedAddressTypeExceptionTest.java
@@ -15,9 +15,9 @@
*/
package org.apache.harmony.nio.tests.java.nio.channels;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.channels.UnsupportedAddressTypeException;
@@ -35,15 +35,20 @@ public class UnsupportedAddressTypeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationSelf",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationSelf",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "UnsupportedAddressTypeException",
+ args = {}
+ )
+ })
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new UnsupportedAddressTypeException());
@@ -52,15 +57,20 @@ public class UnsupportedAddressTypeExceptionTest extends TestCase {
/**
* @tests serialization/deserialization compatibility with RI.
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "Verifies serialization/deserialization compatibility.",
- targets = {
- @TestTarget(
- methodName = "!SerializationGolden",
- methodArgs = {}
- )
- })
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "!SerializationGolden",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "Verifies serialization/deserialization compatibility.",
+ method = "UnsupportedAddressTypeException",
+ args = {}
+ )
+ })
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
index a5af1fa..d81248e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractInterruptibleChannelTest.java
@@ -16,9 +16,9 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.io.IOException;
@@ -26,19 +26,34 @@ import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import junit.framework.TestCase;
-@TestTargetClass(AbstractInterruptibleChannel.class)
+@TestTargetClass(
+ value = AbstractInterruptibleChannel.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "AbstractInterruptibleChannel",
+ args = {}
+ )
+ }
+)
public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#close()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "close",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
)
})
public void test_close() throws IOException {
@@ -53,17 +68,18 @@ public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#begin/end()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "begin",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "begin",
+ args = {}
),
- @TestTarget(
- methodName = "end",
- methodArgs = {boolean.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "end",
+ args = {boolean.class}
)
})
public void test_begin_end() throws IOException {
@@ -105,21 +121,24 @@ public class AbstractInterruptibleChannelTest extends TestCase {
/**
* @tests AbstractInterruptibleChannel#close/begin/end()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "begin",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "begin",
+ args = {}
),
- @TestTarget(
- methodName = "end",
- methodArgs = {boolean.class}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "end",
+ args = {boolean.class}
),
- @TestTarget(
- methodName = "close",
- methodArgs = {}
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
)
})
public void test_close_begin_end() throws IOException {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
index cf68b8e..c81efa2 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java
@@ -16,10 +16,11 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
@@ -34,6 +35,8 @@ import java.nio.channels.spi.SelectorProvider;
import junit.framework.TestCase;
+import org.apache.harmony.nio.tests.java.nio.channels.spi.AbstractSelectorTest.MockSelectorProvider;
+
/**
* Tests for AbstractSelectableChannel
*/
@@ -52,17 +55,35 @@ public class AbstractSelectableChannelTest extends TestCase {
testChannel.close();
}
}
+
+ /**
+ * @tests AbstractSelectableChannel()
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "AbstractSelectableChannel",
+ args = {SelectorProvider.class}
+ )
+ public void test_Constructor_LSelectorProvider() throws Exception {
+ assertSame(SelectorProvider.provider(), testChannel.provider());
+ }
/**
* @tests AbstractSelectableChannel#implCloseChannel()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "implCloseChannel",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "implCloseChannel",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "implCloseSelectableChannel",
+ args = {}
)
})
public void test_implClose() throws IOException {
@@ -88,15 +109,12 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#provider()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ )
public void test_provider() {
SelectorProvider provider = testChannel.provider();
assertSame(SelectorProvider.provider(), provider);
@@ -108,15 +126,12 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#isBlocking()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isBlocking",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "isBlocking",
+ args = {}
+ )
public void test_isBlocking() throws IOException {
assertTrue(testChannel.isBlocking());
testChannel.configureBlocking(false);
@@ -129,15 +144,12 @@ public class AbstractSelectableChannelTest extends TestCase {
*
* @tests AbstractSelectableChannel#blockingLock()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "blockingLock",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "blockingLock",
+ args = {}
+ )
public void test_blockingLock() {
Object gotObj = testChannel.blockingLock();
assertNotNull(gotObj);
@@ -146,16 +158,12 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#register(Selector, int, Object)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "register",
- methodArgs = {java.nio.channels.Selector.class,
- int.class, java.lang.Object.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "register",
+ args = {java.nio.channels.Selector.class, int.class, java.lang.Object.class}
+ )
public void test_register_LSelectorILObject() throws IOException {
assertFalse(testChannel.isRegistered());
Selector acceptSelector1 = SelectorProvider.provider().openSelector();
@@ -170,23 +178,19 @@ public class AbstractSelectableChannelTest extends TestCase {
assertSame(sc, acceptKey.channel());
//test that sc.register invokes Selector.register()
- acceptKey = sc.register(acceptSelector2, SelectionKey.OP_READ, null);
- assertNull(acceptKey);
+ sc.register(acceptSelector2, SelectionKey.OP_READ, null);
+ assertTrue(((MockAbstractSelector)acceptSelector2).isRegisterCalled);
}
/**
* @tests AbstractSelectableChannel#register(Selector, int, Object)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "register",
- methodArgs = {java.nio.channels.Selector.class,
- int.class, java.lang.Object.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "register",
+ args = {java.nio.channels.Selector.class, int.class, java.lang.Object.class}
+ )
public void test_register_LSelectorILObject_IllegalArgument()
throws IOException {
Selector acceptSelector = SelectorProvider.provider().openSelector();
@@ -279,20 +283,29 @@ public class AbstractSelectableChannelTest extends TestCase {
// expected
}
+ SelectorProvider prov1 = MockSelectorProvider.provider();
+ SelectorProvider prov2 = MockSelectorProvider.provider();
+
+ Selector sel = prov2.openSelector();
+
+ sc = prov1.openSocketChannel();
+ sc.configureBlocking(false);
+ try {
+ sc.register(sel, SelectionKey.OP_READ, null);
+ } catch (IllegalSelectorException e) {
+ // expected
+ }
}
/**
* @tests AbstractSelectableChannel#keyFor(Selector)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "keyFor",
- methodArgs = {java.nio.channels.Selector.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "keyFor",
+ args = {java.nio.channels.Selector.class}
+ )
public void test_keyfor_LSelector() throws Exception {
SocketChannel sc = SocketChannel.open();
Object argObj = new Object();
@@ -315,15 +328,12 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#configureBlocking(boolean)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "configureBlocking",
+ args = {boolean.class}
+ )
public void test_configureBlocking_Z_IllegalBlockingMode() throws Exception {
SocketChannel sc = SocketChannel.open();
sc.configureBlocking(false);
@@ -344,24 +354,49 @@ public class AbstractSelectableChannelTest extends TestCase {
/**
* @tests AbstractSelectableChannel#configureBlocking(boolean)
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "configureBlocking",
- methodArgs = {boolean.class}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "configureBlocking",
+ args = {boolean.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "implConfigureBlocking",
+ args = {boolean.class}
)
- })
+ })
public void test_configureBlocking_Z() throws Exception {
- MockSelectableChannel mock = new MockSelectableChannel(SelectorProvider
+ testChannel = new MockSelectableChannel(SelectorProvider
.provider());
- //default blocking mode is true
- //the implConfigureBlocking is only invoked if the given mode is different with current one
- mock.configureBlocking(true);
- assertFalse(mock.implConfigureBlockingCalled);
- mock.configureBlocking(false);
- assertTrue(mock.implConfigureBlockingCalled);
+ // default blocking mode is true. The implConfigureBlocking is only
+ // invoked if the given mode is different with current one.
+ testChannel.configureBlocking(true);
+ assertFalse(testChannel.implConfigureBlockingCalled);
+ testChannel.configureBlocking(false);
+ assertTrue(testChannel.implConfigureBlockingCalled);
+
+ AbstractSelectableChannel channel =
+ SelectorProvider.provider().openDatagramChannel();
+ channel.configureBlocking(false);
+ channel.register(SelectorProvider.provider().openSelector(),
+ SelectionKey.OP_READ);
+ try {
+ channel.configureBlocking(true);
+ fail("Should have thrown IllegalBlockingModeException");
+ } catch (IllegalBlockingModeException e) {
+ // expected
+ }
+
+ testChannel.close();
+ try {
+ testChannel.configureBlocking(false);
+ fail("Should have thrown ClosedChannelException");
+ } catch (ClosedChannelException e) {
+ // expected
+ }
}
private class MockSelectableChannel extends AbstractSelectableChannel {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
index 9eca42e..33c3b5c 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectionKeyTest.java
@@ -16,9 +16,10 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.nio.channels.SelectableChannel;
@@ -27,21 +28,28 @@ import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectionKey;
import junit.framework.TestCase;
-@TestTargetClass(AbstractSelectionKey.class)
+@TestTargetClass(
+ value = AbstractSelectionKey.class,
+ untestedMethods = {
+ @TestTargetNew(
+ level = TestLevel.NOT_NECESSARY,
+ notes = "empty protected constructor",
+ method = "AbstractSelectionKey",
+ args = {}
+ )
+ }
+)
public class AbstractSelectionKeyTest extends TestCase {
/**
* @tests AbstractSelectionKey#isValid() without selector
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isValid",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isValid",
+ args = {}
+ )
public void test_isValid() throws Exception {
MockSelectionKey testKey = new MockSelectionKey();
assertTrue(testKey.isValid());
@@ -50,15 +58,12 @@ public class AbstractSelectionKeyTest extends TestCase {
/**
* @tests AbstractSelectionKey#cancel
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "cancel",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "cancel",
+ args = {}
+ )
public void test_cancel() throws Exception {
MockSelectionKey testKey = new MockSelectionKey();
try {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
index 8ad2432..106184e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectorTest.java
@@ -16,18 +16,23 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.io.IOException;
-import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.AbstractSelectionKey;
import java.nio.channels.spi.SelectorProvider;
import java.nio.channels.spi.AbstractSelector;
+import java.util.Set;
import junit.framework.TestCase;
@TestTargetClass(AbstractSelector.class)
@@ -39,13 +44,18 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#provider()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "AbstractSelector",
+ args = {SelectorProvider.class}
)
})
public void test_provider() throws IOException {
@@ -60,13 +70,18 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#close()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "close",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "close",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "implCloseSelector",
+ args = {}
)
})
public void test_close() throws IOException {
@@ -80,18 +95,19 @@ public class AbstractSelectorTest extends TestCase {
*
* @tests AbstractSelector#begin/end()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "begin",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "begin",
+ args = {}
),
- @TestTarget(
- methodName = "end",
- methodArgs = {}
- )
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "end",
+ args = {}
+ )
})
public void test_begin_end() throws IOException {
MockAbstractSelector mockSelector = new MockAbstractSelector(
@@ -137,15 +153,12 @@ public class AbstractSelectorTest extends TestCase {
/**
* @tests AbstractSelector#isOpen()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "isOpen",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "isOpen",
+ args = {}
+ )
public void test_isOpen() throws Exception {
Selector acceptSelector = SelectorProvider.provider().openSelector();
assertTrue(acceptSelector.isOpen());
@@ -154,73 +167,115 @@ public class AbstractSelectorTest extends TestCase {
}
/**
- * @tests AbstractSelector#register(Selector,int)
+ * @tests AbstractSelector()
*/
- @TestInfo(
- level = TestLevel.TODO,
- purpose = "Verifies register method from SelectableChannel " +
- "class.",
- targets = {
- @TestTarget(
- methodName = "register",
- methodArgs = {Selector.class, int.class}
- )
- })
- public void test_register_LSelectorI() throws Exception {
- Selector acceptSelector = SelectorProvider.provider().openSelector();
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "AbstractSelector",
+ args = {SelectorProvider.class}
+ )
+ public void test_Constructor_LSelectorProvider() throws Exception {
+ Selector acceptSelector = new MockAbstractSelector(
+ SelectorProvider.provider());
+ assertSame(SelectorProvider.provider(), acceptSelector.provider());
+ }
+
+ /**
+ * @tests AbstractSelector#register(AbstractSelectableChannel,int,Object)
+ */
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "Verifies register method from SelectableChannel class.",
+ method = "register",
+ args = {AbstractSelectableChannel.class, int.class, java.lang.Object.class}
+ )
+ public void test_register_LAbstractSelectableChannelIObject()
+ throws Exception {
+ Selector acceptSelector = new MockSelectorProvider().openSelector();
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(false);
assertFalse(ssc.isRegistered());
- SelectionKey acceptKey = ssc.register(acceptSelector,
- SelectionKey.OP_ACCEPT);
+ ssc.register(acceptSelector, SelectionKey.OP_ACCEPT);
assertTrue(ssc.isRegistered());
+ assertTrue(((MockAbstractSelector)acceptSelector).isRegisterCalled);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "cancelledKeys",
+ args = {}
+ )
+ public void test_cancelledKeys() throws Exception {
+ MockSelectorProvider prov = new MockSelectorProvider();
+ Selector acceptSelector = prov.openSelector();
+ SocketChannel sc = prov.openSocketChannel();
+ sc.configureBlocking(false);
+
+ SelectionKey acceptKey = sc.register(acceptSelector,
+ SelectionKey.OP_READ, null);
+ acceptKey.cancel();
+ Set<SelectionKey> cKeys =
+ ((MockAbstractSelector)acceptSelector).getCancelledKeys();
+ assertTrue(cKeys.contains(acceptKey));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "deregister",
+ args = {AbstractSelectionKey.class}
+ )
+ public void test_deregister() throws Exception {
+ MockSelectorProvider prov = new MockSelectorProvider();
+ AbstractSelector acceptSelector = prov.openSelector();
+ SocketChannel sc = prov.openSocketChannel();
+ sc.configureBlocking(false);
+
+ SelectionKey acceptKey = sc.register(acceptSelector,
+ SelectionKey.OP_READ, null);
+ assertTrue(sc.isRegistered());
assertNotNull(acceptKey);
- assertTrue(acceptSelector.keys().contains(acceptKey));
+ ((MockAbstractSelector)acceptSelector).mockDeregister(
+ (MockAbstractSelector.MockSelectionKey)acceptKey);
+ assertFalse(sc.isRegistered());
}
- /**
- * @tests AbstractSelector#register(Selector,int)
- */
- @TestInfo(
- level = TestLevel.TODO,
- purpose = "Verifies register method from SelectableChannel " +
- "class.",
- targets = {
- @TestTarget(
- methodName = "register",
- methodArgs = {Selector.class, int.class}
- )
- })
- public void test_register_LSelectorI_error() throws IOException {
- Selector acceptSelector = SelectorProvider.provider().openSelector();
- ServerSocketChannel ssc = ServerSocketChannel.open();
- ssc.configureBlocking(false);
- acceptSelector.close();
+ static class MockSelectorProvider extends SelectorProvider {
+
+ private MockSelectorProvider() {
+ // do nothing
+ }
- assertFalse(acceptSelector.isOpen());
- try {
- ssc.register(acceptSelector, SelectionKey.OP_ACCEPT);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
+ @Override
+ public DatagramChannel openDatagramChannel() {
+ return null;
}
- assertFalse(ssc.isRegistered());
- acceptSelector = Selector.open();
- ssc.configureBlocking(true);
- try {
- ssc.register(acceptSelector, SelectionKey.OP_ACCEPT);
- fail("should throw IllegalBlockingModeException");
- } catch (IllegalBlockingModeException e) {
- // expected
+ @Override
+ public Pipe openPipe() {
+ return null;
}
- assertFalse(ssc.isRegistered());
- ssc.configureBlocking(false);
- SelectionKey acceptKey = ssc.register(acceptSelector,
- SelectionKey.OP_ACCEPT);
- assertNotNull(acceptKey);
- assertTrue(acceptSelector.keys().contains(acceptKey));
- assertTrue(ssc.isRegistered());
- }
+
+ @Override
+ public AbstractSelector openSelector() {
+ return new MockAbstractSelector(provider());
+ }
+
+ @Override
+ public ServerSocketChannel openServerSocketChannel() {
+ return null;
+ }
+
+ @Override
+ public SocketChannel openSocketChannel() throws IOException {
+ return SocketChannel.open();
+ }
+
+ public static SelectorProvider provider() {
+ return new MockSelectorProvider();
+ }
+ }
}
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java
index 4febb4b..1b5e12e 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AllTests.java
@@ -22,7 +22,7 @@ import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
- TestSuite suite = new TestSuite(
+ TestSuite suite = tests.TestSuiteFactory.createTestSuite(
"Test for tests.api.java.nio.channels.spi");
//$JUnit-BEGIN$
suite.addTestSuite(AbstractInterruptibleChannelTest.class);
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java
index eb6e53f..a48f2a9 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/MockAbstractSelector.java
@@ -17,17 +17,58 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
import java.io.IOException;
+import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.AbstractSelectionKey;
import java.nio.channels.spi.AbstractSelector;
import java.nio.channels.spi.SelectorProvider;
+import java.util.HashSet;
import java.util.Set;
public class MockAbstractSelector extends AbstractSelector {
+
+ class MockSelectionKey extends AbstractSelectionKey {
+
+ boolean cancelled = false;
+ Selector selector;
+ SelectableChannel channel;
+
+ MockSelectionKey(Selector sel, SelectableChannel chan) {
+ selector = sel;
+ channel = chan;
+ }
+
+ @Override
+ public SelectableChannel channel() {
+ return channel;
+ }
+
+ @Override
+ public int interestOps() {
+ return 0;
+ }
+
+ @Override
+ public SelectionKey interestOps(int operations) {
+ return null;
+ }
+
+ @Override
+ public int readyOps() {
+ return 0;
+ }
+
+ @Override
+ public Selector selector() {
+ return selector;
+ }
+ }
public boolean isImplCloseSelectorCalled = false;
+ private Set<SelectionKey> keys = new HashSet<SelectionKey>();
+ public boolean isRegisterCalled = false;
public MockAbstractSelector(SelectorProvider arg0) {
super(arg0);
@@ -37,7 +78,7 @@ public class MockAbstractSelector extends AbstractSelector {
return new MockAbstractSelector(SelectorProvider.provider());
}
- public Set getCancelledKeys() {
+ public Set<SelectionKey> getCancelledKeys() {
return super.cancelledKeys();
}
@@ -47,7 +88,11 @@ public class MockAbstractSelector extends AbstractSelector {
protected SelectionKey register(AbstractSelectableChannel arg0, int arg1,
Object arg2) {
- return null;
+ isRegisterCalled = true;
+
+ SelectionKey key = new MockSelectionKey(this, arg0);
+ keys.add(key);
+ return key;
}
public void superBegin() {
@@ -58,12 +103,12 @@ public class MockAbstractSelector extends AbstractSelector {
super.end();
}
- protected void mockDeregister(AbstractSelectionKey key) {
+ public void mockDeregister(AbstractSelectionKey key) {
super.deregister(key);
}
public Set<SelectionKey> keys() {
- return null;
+ return keys;
}
public Set<SelectionKey> selectedKeys() {
diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
index 27fffdf..f18d585 100644
--- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
+++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/SelectorProviderTest.java
@@ -16,9 +16,9 @@
package org.apache.harmony.nio.tests.java.nio.channels.spi;
-import dalvik.annotation.TestInfo;
+import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTarget;
+import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargetClass;
import java.io.IOException;
@@ -35,17 +35,85 @@ import junit.framework.TestCase;
public class SelectorProviderTest extends TestCase {
/**
- * @tests SelectorProvider#provider() using security manager
+ * @tests SelectorProvider#openDatagramChannel()
+ * @tests SelectorProvider#openPipe()
+ * @tests SelectorProvider#openServerSocketChannel()
+ * @tests SelectorProvider#openSocketChannel()
+ * @tests SelectorProvider#openSelector()
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "SelectorProvider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "inheritedChannel",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "openDatagramChannel",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "openPipe",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "openServerSocketChannel",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "openSocketChannel",
+ args = {}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "openSelector",
+ args = {}
)
})
+ public void test_open_methods() throws Exception {
+ // calling #provider to see if it returns without Exception.
+ assertNotNull(SelectorProvider.provider());
+
+ // calling #inheritedChannel to see if this already throws an exception.
+ SelectorProvider.provider().inheritedChannel();
+
+ assertNotNull(SelectorProvider.provider().openDatagramChannel());
+ assertNotNull(SelectorProvider.provider().openPipe());
+ assertNotNull(SelectorProvider.provider().openServerSocketChannel());
+ assertNotNull(SelectorProvider.provider().openSocketChannel());
+ assertNotNull(SelectorProvider.provider().openSelector());
+ }
+
+ /**
+ * @tests SelectorProvider#provider() using security manager
+ */
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ )
public void test_provider_security() {
SecurityManager originalSecuirtyManager = System.getSecurityManager();
System.setSecurityManager(new MockSelectorProviderSecurityManager());
@@ -62,15 +130,12 @@ public class SelectorProviderTest extends TestCase {
/**
* @tests SelectorProvider#provider() using security manager
*/
- @TestInfo(
- level = TestLevel.COMPLETE,
- purpose = "",
- targets = {
- @TestTarget(
- methodName = "provider",
- methodArgs = {}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.PARTIAL_COMPLETE,
+ notes = "",
+ method = "provider",
+ args = {}
+ )
public void test_provider_security_twice() {
SelectorProvider.provider();
SecurityManager originalSecuirtyManager = System.getSecurityManager();
diff --git a/nio/src/test/java/tests/nio/AllTests.java b/nio/src/test/java/tests/nio/AllTests.java
index 1abe67a..ff50aa5 100644
--- a/nio/src/test/java/tests/nio/AllTests.java
+++ b/nio/src/test/java/tests/nio/AllTests.java
@@ -29,7 +29,7 @@ public class AllTests {
}
public static Test suite() {
- TestSuite suite = new TestSuite("All Math test suites");
+ TestSuite suite = tests.TestSuiteFactory.createTestSuite("All Math test suites");
// $JUnit-BEGIN$
suite.addTest(org.apache.harmony.nio.tests.java.nio.AllTests.suite());
suite.addTest(org.apache.harmony.nio.tests.java.nio.channels.AllTests.suite());