private void verifyTransfer(boolean srcdirect, boolean dstdirect)
	{
		String txt1 = "123";
		String txt2 = "abcde";
		String srctxt = txt1+txt2;
		byte[] srcdata = srctxt.getBytes();
		org.junit.Assert.assertEquals(srctxt.length(), srcdata.length); //sanity check
		java.nio.ByteBuffer srcbuf = NIOBuffers.create(srcdata.length, srcdirect);
		java.nio.ByteBuffer dstbuf = NIOBuffers.create(srcbuf.capacity(), dstdirect);
		org.junit.Assert.assertEquals(0, srcbuf.position());
		org.junit.Assert.assertEquals(srcdata.length, srcbuf.capacity());
		org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());

		srcbuf.put(srcdata);
		org.junit.Assert.assertEquals(srcdata.length, srcbuf.position());
		org.junit.Assert.assertEquals(srcdata.length, srcbuf.capacity());
		org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());
		srcbuf.flip();
		org.junit.Assert.assertEquals(0, srcbuf.position());
		org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());
		srcbuf.position(txt1.length());
		org.junit.Assert.assertEquals(txt1.length(), srcbuf.position());
		org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());

		dstbuf.put((byte)'x');
		dstbuf.mark();
		dstbuf.put((byte)'x');
		dstbuf.reset();

		int nbytes = NIOBuffers.transfer(srcbuf, dstbuf, null);
		if (srcdirect && dstdirect) {
			org.junit.Assert.assertEquals(-txt2.length(), nbytes);
			nbytes = NIOBuffers.transfer(srcbuf, dstbuf, new byte[-nbytes]);
		}
		org.junit.Assert.assertEquals(txt2.length(), nbytes);
		org.junit.Assert.assertEquals(txt1.length()+nbytes, srcbuf.position());
		org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());
		org.junit.Assert.assertEquals(nbytes+1, dstbuf.position());
		org.junit.Assert.assertEquals(dstbuf.limit(), dstbuf.capacity());
		dstbuf.flip();
		org.junit.Assert.assertEquals((byte)'x', dstbuf.get());
		for (int idx = 0; idx != txt2.length(); idx++) {
			org.junit.Assert.assertEquals((byte)txt2.charAt(idx), dstbuf.get());
		}

		if (srcdirect && dstdirect) {
			// do an additional test of the no-transfer-buf method, with buffers that normally need a transfer-buf
			srcbuf.clear();
			srcbuf.put(srcdata);
			srcbuf.flip();
			srcbuf.position(txt1.length());
			dstbuf.clear();
			dstbuf.put((byte)'x');
			dstbuf.mark();
			dstbuf.put((byte)'x');
			dstbuf.reset();
			nbytes = NIOBuffers.transfer(srcbuf, dstbuf);
			org.junit.Assert.assertEquals(txt2.length(), nbytes);
			org.junit.Assert.assertEquals(txt1.length()+nbytes, srcbuf.position());
			org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());
			org.junit.Assert.assertEquals(nbytes+1, dstbuf.position());
			org.junit.Assert.assertEquals(dstbuf.limit(), dstbuf.capacity());
			dstbuf.flip();
			org.junit.Assert.assertEquals((byte)'x', dstbuf.get());
			for (int idx = 0; idx != txt2.length(); idx++) {
				org.junit.Assert.assertEquals((byte)txt2.charAt(idx), dstbuf.get());
			}
		} else if (!srcdirect && !dstdirect) {
			// do an additional test of the no-transfer-buf method, with buffers that don't need transfer-buf
			srcbuf.clear();
			srcbuf.put(srcdata);
			srcbuf.flip();
			srcbuf.position(txt1.length());
			dstbuf.clear();
			int dstlmt = txt2.length() - 1;
			dstbuf.limit(dstlmt);
			nbytes = NIOBuffers.transfer(srcbuf, dstbuf);
			org.junit.Assert.assertEquals(dstlmt, nbytes);
			org.junit.Assert.assertEquals(txt1.length()+nbytes, srcbuf.position());
			org.junit.Assert.assertEquals(srcbuf.limit(), srcbuf.capacity());
			org.junit.Assert.assertEquals(nbytes, dstbuf.position());
			org.junit.Assert.assertEquals(dstlmt, dstbuf.limit());
			dstbuf.flip();
			for (int idx = 0; idx != txt2.length()-1; idx++) {
				org.junit.Assert.assertEquals((byte)txt2.charAt(idx), dstbuf.get());
			}
		}
	}