You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by mh...@apache.org on 2007/01/26 00:43:10 UTC
svn commit: r500058 - in /mina/sandbox/mheath/aioj/trunk: ./
src/main/java/org/apache/aio/concurrent/
src/main/java/org/apache/aio/posix/ src/test/java/ src/test/java/org/
src/test/java/org/apache/ src/test/java/org/apache/aio/
src/test/java/org/apache...
Author: mheath
Date: Thu Jan 25 15:43:09 2007
New Revision: 500058
URL: http://svn.apache.org/viewvc?view=rev&rev=500058
Log:
Added first TestNG test testing asynchronous opens.
Added:
mina/sandbox/mheath/aioj/trunk/src/test/java/org/
mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/
mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/
mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/
mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/TestOpen.java
Removed:
mina/sandbox/mheath/aioj/trunk/src/test/java/Test.java
Modified:
mina/sandbox/mheath/aioj/trunk/pom.xml
mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/concurrent/ConcurrentAsynchronousFileChannel.java
mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/posix/PosixAsynchronousFileChannelProvider.java
Modified: mina/sandbox/mheath/aioj/trunk/pom.xml
URL: http://svn.apache.org/viewvc/mina/sandbox/mheath/aioj/trunk/pom.xml?view=diff&rev=500058&r1=500057&r2=500058
==============================================================================
--- mina/sandbox/mheath/aioj/trunk/pom.xml (original)
+++ mina/sandbox/mheath/aioj/trunk/pom.xml Thu Jan 25 15:43:09 2007
@@ -86,9 +86,10 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.1</version>
+ <classifier>jdk15</classifier>
</dependency>
</dependencies>
Modified: mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/concurrent/ConcurrentAsynchronousFileChannel.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/concurrent/ConcurrentAsynchronousFileChannel.java?view=diff&rev=500058&r1=500057&r2=500058
==============================================================================
--- mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/concurrent/ConcurrentAsynchronousFileChannel.java (original)
+++ mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/concurrent/ConcurrentAsynchronousFileChannel.java Thu Jan 25 15:43:09 2007
@@ -38,11 +38,17 @@
@Override
public boolean isReadable() throws AioException {
+ if (!channel.isOpen()) {
+ throw new AioException("Channel not open");
+ }
return true;
}
@Override
public boolean isWriteable() throws AioException {
+ if (!channel.isOpen()) {
+ throw new AioException("Channel not open");
+ }
return mode == Modes.READ_WRITE;
}
@@ -107,8 +113,7 @@
}
public boolean isOpen() {
- // TODO Auto-generated method stub
- return false;
+ return channel.isOpen();
}
}
Modified: mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/posix/PosixAsynchronousFileChannelProvider.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/posix/PosixAsynchronousFileChannelProvider.java?view=diff&rev=500058&r1=500057&r2=500058
==============================================================================
--- mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/posix/PosixAsynchronousFileChannelProvider.java (original)
+++ mina/sandbox/mheath/aioj/trunk/src/main/java/org/apache/aio/posix/PosixAsynchronousFileChannelProvider.java Thu Jan 25 15:43:09 2007
@@ -19,6 +19,20 @@
*/
package org.apache.aio.posix;
-public class PosixAsynchronousFileChannelProvider {
+import java.io.File;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.aio.AioFuture;
+import org.apache.aio.AsynchronousFileChannel;
+import org.apache.aio.AsynchronousFileChannelProvider;
+import org.apache.aio.Modes;
+
+public class PosixAsynchronousFileChannelProvider implements AsynchronousFileChannelProvider {
+
+ public AioFuture<AsynchronousFileChannel> open(File fileName, Modes mode, ExecutorService executorService, Properties properties) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Added: mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/TestOpen.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/TestOpen.java?view=auto&rev=500058
==============================================================================
--- mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/TestOpen.java (added)
+++ mina/sandbox/mheath/aioj/trunk/src/test/java/org/apache/aio/concurrent/TestOpen.java Thu Jan 25 15:43:09 2007
@@ -0,0 +1,50 @@
+package org.apache.aio.concurrent;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.aio.AioFuture;
+import org.apache.aio.AsynchronousFileChannel;
+import org.apache.aio.AsynchronousFileChannelFactory;
+import org.apache.aio.Modes;
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+public class TestOpen {
+
+ @Test(groups={"concurrent"})
+ public void openNonExistingFile() throws Exception {
+ AioFuture<AsynchronousFileChannel> future = AsynchronousFileChannelFactory.open(new File("Foo"), Modes.READ_ONLY);
+ try {
+ future.get();
+ AssertJUnit.fail("Should have thrown wrapped FileNotFoundException");
+ } catch (ExecutionException e) {
+ assert e.getCause() instanceof FileNotFoundException;
+ }
+ }
+
+ @Test(groups={"concurrent"})
+ public void openFileReadOnly() throws Exception {
+ File testFile = File.createTempFile("aio", "test");
+ AioFuture<AsynchronousFileChannel> future = AsynchronousFileChannelFactory.open(testFile, Modes.READ_ONLY);
+ AsynchronousFileChannel channel = future.get();
+ assert channel.isOpen();
+ assert channel.isReadable();
+ assert !channel.isWriteable();
+ channel.close();
+ assert !channel.isOpen();
+ }
+
+ @Test(groups={"concurrent"})
+ public void openFileReadWrite() throws Exception {
+ File testFile = File.createTempFile("aio", "test");
+ AioFuture<AsynchronousFileChannel> future = AsynchronousFileChannelFactory.open(testFile, Modes.READ_WRITE);
+ AsynchronousFileChannel channel = future.get();
+ assert channel.isReadable();
+ assert channel.isWriteable();
+ channel.close();
+ }
+
+}