activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [14/30] - in /incubator/activemq/trunk: ./ activecluster/ activecluster/src/java/org/apache/activecluster/ activecluster/src/java/org/apache/activecluster/election/ activecluster/src/java/org/apache/activecluster/election/impl/ acti...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalImplTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalImplTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalImplTest.java Tue Feb 21 15:12:56 2006
@@ -1,168 +1,168 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.journal.active;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.activeio.journal.InvalidRecordLocationException;
-import org.apache.activeio.journal.Journal;
-import org.apache.activeio.journal.RecordLocation;
-import org.apache.activeio.journal.active.JournalImpl;
-import org.apache.activeio.journal.active.Location;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.Packet;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Tests the JournalImpl
- * 
- * @version $Revision: 1.1 $
- */
-public class JournalImplTest extends TestCase {
-
-    Log log = LogFactory.getLog(JournalImplTest.class);
-	
-    int size = 1024*10;
-    int logFileCount=2;
-    File logDirectory = new File("test-logfile");
-	private Journal journal;
-    
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        if( logDirectory.exists() ) {
-        	deleteDir(logDirectory);
-        }
-        assertTrue("Could not delete directory: "+logDirectory.getCanonicalPath(), !logDirectory.exists() );
-        journal = new JournalImpl(logDirectory,logFileCount, size, logDirectory);
-    }
-
-    /**
-	 */
-	private void deleteDir(File f) {
-		File[] files = f.listFiles();
-		for (int i = 0; i < files.length; i++) {
-			File file = files[i];
-			file.delete();
-		}
-		f.delete();
-	}
-
-	protected void tearDown() throws Exception {
-		journal.close();
-        if( logDirectory.exists() )
-        	deleteDir(logDirectory);
-        //assertTrue( !logDirectory.exists() );
-    }
-    
-    public void testLogFileCreation() throws IOException {
-        	RecordLocation mark = journal.getMark();
-        	assertNull(mark);
-    }
-    
-    public void testAppendAndRead() throws InvalidRecordLocationException, InterruptedException, IOException {
-    	
-        Packet data1 = createPacket("Hello World 1");
-    	RecordLocation location1 = journal.write( data1, false);
-    	Packet data2 = createPacket("Hello World 2");
-    	RecordLocation location2 = journal.write( data2, false);
-    	Packet data3  = createPacket("Hello World 3");
-    	RecordLocation location3 = journal.write( data3, false);
-    	
-    	// Now see if we can read that data.
-    	Packet data;
-    	data = journal.read(location2);
-    	assertEquals( data2, data);
-    	data = journal.read(location1);
-    	assertEquals( data1, data);
-    	data = journal.read(location3);
-    	assertEquals( data3, data);
-    	
-    	// Can we cursor the data?
-    	RecordLocation l=journal.getNextRecordLocation(null);
-    	assertEquals(0, l.compareTo(location1));
-    	data = journal.read(l);
-    	assertEquals( data1, data);
-
-    	l=journal.getNextRecordLocation(l);
-    	assertEquals(0, l.compareTo(location2));
-    	data = journal.read(l);
-    	assertEquals( data2, data);
-
-    	l=journal.getNextRecordLocation(l);
-    	assertEquals(0, l.compareTo(location3));
-    	data = journal.read(l);
-    	assertEquals( data3, data);
-    	
-    	l=journal.getNextRecordLocation(l);
-    	assertNull(l);
-    	
-    	log.info(journal);
-    }
-
-    public void testCanReadFromArchivedLogFile() throws InvalidRecordLocationException, InterruptedException, IOException {
-        
-        Packet data1 = createPacket("Hello World 1");
-        RecordLocation location1 = journal.write( data1, false);
-        
-        Location  pos;
-        do {
-            
-            Packet p = createPacket("<<<data>>>");
-            pos = (Location) journal.write( p, false);
-            journal.setMark(pos, false);
-            
-        } while( pos.getLogFileId() < 5 );
-        
-        // Now see if we can read that first packet.
-        Packet data;
-        data = journal.read(location1);
-        assertEquals( data1, data);
-        
-    }
-
-    /**
-     * @param string
-     * @return
-     */
-    private Packet createPacket(String string) {
-        return new ByteArrayPacket(string.getBytes());
-    }
-
-    public static void assertEquals(Packet arg0, Packet arg1) {
-        assertEquals(arg0.sliceAsBytes(), arg1.sliceAsBytes());
-    }
-    
-    public static void assertEquals(byte[] arg0, byte[] arg1) {
-    	if( arg0==null ^ arg1==null )
-    		fail("Not equal: "+arg0+" != "+arg1);
-    	if( arg0==null )
-    		return;
-    	if( arg0.length!=arg1.length)
-    		fail("Array lenght not equal: "+arg0.length+" != "+arg1.length);
-    	for( int i=0; i<arg0.length;i++) {
-    		if( arg0[i]!= arg1[i]) {
-        		fail("Array item not equal at index "+i+": "+arg0[i]+" != "+arg1[i]);
-    		}
-    	}
-	}
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.journal.active;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.activeio.journal.InvalidRecordLocationException;
+import org.apache.activeio.journal.Journal;
+import org.apache.activeio.journal.RecordLocation;
+import org.apache.activeio.journal.active.JournalImpl;
+import org.apache.activeio.journal.active.Location;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Tests the JournalImpl
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class JournalImplTest extends TestCase {
+
+    Log log = LogFactory.getLog(JournalImplTest.class);
+	
+    int size = 1024*10;
+    int logFileCount=2;
+    File logDirectory = new File("test-logfile");
+	private Journal journal;
+    
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        if( logDirectory.exists() ) {
+        	deleteDir(logDirectory);
+        }
+        assertTrue("Could not delete directory: "+logDirectory.getCanonicalPath(), !logDirectory.exists() );
+        journal = new JournalImpl(logDirectory,logFileCount, size, logDirectory);
+    }
+
+    /**
+	 */
+	private void deleteDir(File f) {
+		File[] files = f.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			File file = files[i];
+			file.delete();
+		}
+		f.delete();
+	}
+
+	protected void tearDown() throws Exception {
+		journal.close();
+        if( logDirectory.exists() )
+        	deleteDir(logDirectory);
+        //assertTrue( !logDirectory.exists() );
+    }
+    
+    public void testLogFileCreation() throws IOException {
+        	RecordLocation mark = journal.getMark();
+        	assertNull(mark);
+    }
+    
+    public void testAppendAndRead() throws InvalidRecordLocationException, InterruptedException, IOException {
+    	
+        Packet data1 = createPacket("Hello World 1");
+    	RecordLocation location1 = journal.write( data1, false);
+    	Packet data2 = createPacket("Hello World 2");
+    	RecordLocation location2 = journal.write( data2, false);
+    	Packet data3  = createPacket("Hello World 3");
+    	RecordLocation location3 = journal.write( data3, false);
+    	
+    	// Now see if we can read that data.
+    	Packet data;
+    	data = journal.read(location2);
+    	assertEquals( data2, data);
+    	data = journal.read(location1);
+    	assertEquals( data1, data);
+    	data = journal.read(location3);
+    	assertEquals( data3, data);
+    	
+    	// Can we cursor the data?
+    	RecordLocation l=journal.getNextRecordLocation(null);
+    	assertEquals(0, l.compareTo(location1));
+    	data = journal.read(l);
+    	assertEquals( data1, data);
+
+    	l=journal.getNextRecordLocation(l);
+    	assertEquals(0, l.compareTo(location2));
+    	data = journal.read(l);
+    	assertEquals( data2, data);
+
+    	l=journal.getNextRecordLocation(l);
+    	assertEquals(0, l.compareTo(location3));
+    	data = journal.read(l);
+    	assertEquals( data3, data);
+    	
+    	l=journal.getNextRecordLocation(l);
+    	assertNull(l);
+    	
+    	log.info(journal);
+    }
+
+    public void testCanReadFromArchivedLogFile() throws InvalidRecordLocationException, InterruptedException, IOException {
+        
+        Packet data1 = createPacket("Hello World 1");
+        RecordLocation location1 = journal.write( data1, false);
+        
+        Location  pos;
+        do {
+            
+            Packet p = createPacket("<<<data>>>");
+            pos = (Location) journal.write( p, false);
+            journal.setMark(pos, false);
+            
+        } while( pos.getLogFileId() < 5 );
+        
+        // Now see if we can read that first packet.
+        Packet data;
+        data = journal.read(location1);
+        assertEquals( data1, data);
+        
+    }
+
+    /**
+     * @param string
+     * @return
+     */
+    private Packet createPacket(String string) {
+        return new ByteArrayPacket(string.getBytes());
+    }
+
+    public static void assertEquals(Packet arg0, Packet arg1) {
+        assertEquals(arg0.sliceAsBytes(), arg1.sliceAsBytes());
+    }
+    
+    public static void assertEquals(byte[] arg0, byte[] arg1) {
+    	if( arg0==null ^ arg1==null )
+    		fail("Not equal: "+arg0+" != "+arg1);
+    	if( arg0==null )
+    		return;
+    	if( arg0.length!=arg1.length)
+    		fail("Array lenght not equal: "+arg0.length+" != "+arg1.length);
+    	for( int i=0; i<arg0.length;i++) {
+    		if( arg0[i]!= arg1[i]) {
+        		fail("Array item not equal at index "+i+": "+arg0[i]+" != "+arg1[i]);
+    		}
+    	}
+	}
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalPerfTool.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalPerfTool.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalPerfTool.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalPerfTool.java Tue Feb 21 15:12:56 2006
@@ -1,76 +1,76 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.journal.active;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.activeio.journal.Journal;
-import org.apache.activeio.journal.JournalPerfToolSupport;
-import org.apache.activeio.journal.active.JournalImpl;
-
-/**
- * A Performance statistics gathering tool for the JournalImpl based Journal.
- * 
- * @version $Revision: 1.1 $
- */
-public class JournalPerfTool extends JournalPerfToolSupport {
-	
-	private int logFileSize = 1024*1000*5;
-    private int logFileCount = 4;
-	
-	public static void main(String[] args) throws Exception {
-		JournalPerfTool tool = new JournalPerfTool();
-		if( args.length > 0 ) {
-			tool.journalDirectory = new File(args[0]);
-		}
-		if( args.length > 1 ) {
-			tool.workerIncrement = Integer.parseInt(args[1]);
-		}
-		if( args.length > 2 ) {
-			tool.incrementDelay = Long.parseLong(args[2]);
-		}
-		if( args.length > 3 ) {
-			tool.verbose = Boolean.getBoolean(args[3]);
-		}
-		if( args.length > 4 ) {
-			tool.recordSize = Integer.parseInt(args[4]);
-		}
-		if( args.length > 5 ) {
-			tool.syncFrequency = Integer.parseInt(args[5]);
-		}
-		if( args.length > 6 ) {
-			tool.workerThinkTime = Integer.parseInt(args[6]);
-		}
-		if( args.length > 7 ) {
-			tool.logFileCount = Integer.parseInt(args[7]);
-		}
-		if( args.length > 8 ) {
-			tool.logFileSize = Integer.parseInt(args[8]);
-		}
-		tool.exec();
-	}
-
-	/**
-	 * @throws IOException
-	 * @see org.apache.activeio.journal.JournalPerfToolSupport#createJournal()
-	 */
-	public Journal createJournal() throws IOException {
-		return new JournalImpl( this.journalDirectory, logFileCount, logFileSize);
-	}
-	
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.journal.active;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.activeio.journal.Journal;
+import org.apache.activeio.journal.JournalPerfToolSupport;
+import org.apache.activeio.journal.active.JournalImpl;
+
+/**
+ * A Performance statistics gathering tool for the JournalImpl based Journal.
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class JournalPerfTool extends JournalPerfToolSupport {
+	
+	private int logFileSize = 1024*1000*5;
+    private int logFileCount = 4;
+	
+	public static void main(String[] args) throws Exception {
+		JournalPerfTool tool = new JournalPerfTool();
+		if( args.length > 0 ) {
+			tool.journalDirectory = new File(args[0]);
+		}
+		if( args.length > 1 ) {
+			tool.workerIncrement = Integer.parseInt(args[1]);
+		}
+		if( args.length > 2 ) {
+			tool.incrementDelay = Long.parseLong(args[2]);
+		}
+		if( args.length > 3 ) {
+			tool.verbose = Boolean.getBoolean(args[3]);
+		}
+		if( args.length > 4 ) {
+			tool.recordSize = Integer.parseInt(args[4]);
+		}
+		if( args.length > 5 ) {
+			tool.syncFrequency = Integer.parseInt(args[5]);
+		}
+		if( args.length > 6 ) {
+			tool.workerThinkTime = Integer.parseInt(args[6]);
+		}
+		if( args.length > 7 ) {
+			tool.logFileCount = Integer.parseInt(args[7]);
+		}
+		if( args.length > 8 ) {
+			tool.logFileSize = Integer.parseInt(args[8]);
+		}
+		tool.exec();
+	}
+
+	/**
+	 * @throws IOException
+	 * @see org.apache.activeio.journal.JournalPerfToolSupport#createJournal()
+	 */
+	public Journal createJournal() throws IOException {
+		return new JournalImpl( this.journalDirectory, logFileCount, logFileSize);
+	}
+	
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/JournalPerfTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/LogFileManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/LogFileManagerTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/LogFileManagerTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/LogFileManagerTest.java Tue Feb 21 15:12:56 2006
@@ -1,134 +1,134 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.journal.active;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import junit.framework.TestCase;
-
-import org.apache.activeio.journal.InvalidRecordLocationException;
-import org.apache.activeio.journal.active.BatchedWrite;
-import org.apache.activeio.journal.active.Location;
-import org.apache.activeio.journal.active.LogFileManager;
-import org.apache.activeio.journal.active.Record;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.ByteBufferPacket;
-
-/**
- * Tests the LogFile used by JournalImpl
- * 
- * @version $Revision: 1.1 $
- */
-public class LogFileManagerTest extends TestCase {
-
-    int size = 1024 * 512;
-
-    int logFileCount = 4;
-
-    File logDirectory = new File("test-logfile");
-
-    private LogFileManager logFile;
-
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        if (logDirectory.exists()) {
-            deleteDir(logDirectory);
-        }
-        assertTrue(!logDirectory.exists());
-        logFile = new LogFileManager(logDirectory, logFileCount, size, null);
-    }
-
-    /**
-     */
-    private void deleteDir(File f) {
-        File[] files = f.listFiles();
-        for (int i = 0; i < files.length; i++) {
-            File file = files[i];
-            file.delete();
-        }
-        f.delete();
-    }
-
-    protected void tearDown() throws Exception {
-        logFile.dispose();
-        if (logDirectory.exists())
-            deleteDir(logDirectory);
-        assertTrue(!logDirectory.exists());
-    }
-
-    public void testLogFileCreation() throws IOException {
-        assertTrue(logFile.canActivateNextLogFile());
-        assertEquals(null,logFile.getFirstActiveLogLocation());
-        assertNull(logFile.getLastMarkedRecordLocation());
-        assertEquals(new Location(0, 0),logFile.getNextAppendLocation());
-    }
-
-    public void testAppendAndRead() throws IOException, InvalidRecordLocationException, InterruptedException {
-
-        System.out.println("Initial:"+logFile.getNextAppendLocation());
-        appendHelloRecord(1001);
-        Location loc2 = logFile.getNextAppendLocation();
-        appendHelloRecord(2002);
-        appendHelloRecord(3003);
-        appendHelloRecord(3004);
-
-        Location loc3 = logFile.getNextDataRecordLocation(loc2);
-        assertTrue(loc3.getLogFileOffset() > loc2.getLogFileOffset());
-        Location loc4 = logFile.getNextDataRecordLocation(loc3);
-        assertTrue(loc4.getLogFileOffset() > loc3.getLogFileOffset());
-
-    }
-
-    public void testRollOver() throws IOException, InvalidRecordLocationException, InterruptedException {
-
-        int lastId = logFile.getNextAppendLocation().getLogFileId();
-        int counter = 0;
-        for (int i = 0; i < logFileCount; i++) {
-            counter += 500;
-            appendHelloRecord(counter);
-            if (i + 1 == logFileCount) {
-                assertFalse(logFile.canActivateNextLogFile());
-            } else {
-                assertTrue(logFile.canActivateNextLogFile());
-                logFile.activateNextLogFile();
-                assertEquals(lastId + 1, logFile.getNextAppendLocation().getLogFileId());
-                lastId = logFile.getNextAppendLocation().getLogFileId();
-            }
-        }
-
-    }
-
-    /**
-     * @param i
-     * @throws IOException
-     * @throws InterruptedException
-     */
-    private void appendHelloRecord(int i) throws IOException, InterruptedException {
-        byte data[] = ("Hello World: " + i).getBytes();
-        Record batchedRecord = new Record(LogFileManager.DATA_RECORD_TYPE, new ByteArrayPacket(data), null);
-        batchedRecord.setLocation(logFile.getNextAppendLocation());
-        
-        BatchedWrite write = new BatchedWrite(new ByteBufferPacket(ByteBuffer.allocate(1024)));
-        write.append(batchedRecord,null, true);
-        write.flip();
-        logFile.append(write);
-    }
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.journal.active;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import junit.framework.TestCase;
+
+import org.apache.activeio.journal.InvalidRecordLocationException;
+import org.apache.activeio.journal.active.BatchedWrite;
+import org.apache.activeio.journal.active.Location;
+import org.apache.activeio.journal.active.LogFileManager;
+import org.apache.activeio.journal.active.Record;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.ByteBufferPacket;
+
+/**
+ * Tests the LogFile used by JournalImpl
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class LogFileManagerTest extends TestCase {
+
+    int size = 1024 * 512;
+
+    int logFileCount = 4;
+
+    File logDirectory = new File("test-logfile");
+
+    private LogFileManager logFile;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        if (logDirectory.exists()) {
+            deleteDir(logDirectory);
+        }
+        assertTrue(!logDirectory.exists());
+        logFile = new LogFileManager(logDirectory, logFileCount, size, null);
+    }
+
+    /**
+     */
+    private void deleteDir(File f) {
+        File[] files = f.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File file = files[i];
+            file.delete();
+        }
+        f.delete();
+    }
+
+    protected void tearDown() throws Exception {
+        logFile.dispose();
+        if (logDirectory.exists())
+            deleteDir(logDirectory);
+        assertTrue(!logDirectory.exists());
+    }
+
+    public void testLogFileCreation() throws IOException {
+        assertTrue(logFile.canActivateNextLogFile());
+        assertEquals(null,logFile.getFirstActiveLogLocation());
+        assertNull(logFile.getLastMarkedRecordLocation());
+        assertEquals(new Location(0, 0),logFile.getNextAppendLocation());
+    }
+
+    public void testAppendAndRead() throws IOException, InvalidRecordLocationException, InterruptedException {
+
+        System.out.println("Initial:"+logFile.getNextAppendLocation());
+        appendHelloRecord(1001);
+        Location loc2 = logFile.getNextAppendLocation();
+        appendHelloRecord(2002);
+        appendHelloRecord(3003);
+        appendHelloRecord(3004);
+
+        Location loc3 = logFile.getNextDataRecordLocation(loc2);
+        assertTrue(loc3.getLogFileOffset() > loc2.getLogFileOffset());
+        Location loc4 = logFile.getNextDataRecordLocation(loc3);
+        assertTrue(loc4.getLogFileOffset() > loc3.getLogFileOffset());
+
+    }
+
+    public void testRollOver() throws IOException, InvalidRecordLocationException, InterruptedException {
+
+        int lastId = logFile.getNextAppendLocation().getLogFileId();
+        int counter = 0;
+        for (int i = 0; i < logFileCount; i++) {
+            counter += 500;
+            appendHelloRecord(counter);
+            if (i + 1 == logFileCount) {
+                assertFalse(logFile.canActivateNextLogFile());
+            } else {
+                assertTrue(logFile.canActivateNextLogFile());
+                logFile.activateNextLogFile();
+                assertEquals(lastId + 1, logFile.getNextAppendLocation().getLogFileId());
+                lastId = logFile.getNextAppendLocation().getLogFileId();
+            }
+        }
+
+    }
+
+    /**
+     * @param i
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    private void appendHelloRecord(int i) throws IOException, InterruptedException {
+        byte data[] = ("Hello World: " + i).getBytes();
+        Record batchedRecord = new Record(LogFileManager.DATA_RECORD_TYPE, new ByteArrayPacket(data), null);
+        batchedRecord.setLocation(logFile.getNextAppendLocation());
+        
+        BatchedWrite write = new BatchedWrite(new ByteBufferPacket(ByteBuffer.allocate(1024)));
+        write.append(batchedRecord,null, true);
+        write.flip();
+        logFile.append(write);
+    }
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/LogFileManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/howl/JournalPerfTool.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/howl/JournalPerfTool.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/howl/JournalPerfTool.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/howl/JournalPerfTool.java Tue Feb 21 15:12:56 2006
@@ -1,92 +1,92 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.journal.howl;
-
-import java.io.File;
-
-import org.apache.activeio.journal.Journal;
-import org.apache.activeio.journal.JournalPerfToolSupport;
-import org.apache.activeio.journal.howl.HowlJournal;
-import org.objectweb.howl.log.Configuration;
-
-/**
- * A Performance statistics gathering tool for the HOWL based Journal.
- * 
- * @version $Revision: 1.1 $
- */
-public class JournalPerfTool extends JournalPerfToolSupport {
-	
-    private int maxLogFiles=  2;
-	private int bufferSize = 1024*4;
-	private int maxBuffers = 20;
-	private int maxBlocksPerFile = 100;
-	
-	public static void main(String[] args) throws Exception {
-		
-		try {
-			JournalPerfTool tool = new JournalPerfTool();
-			if( args.length > 0 ) {
-				tool.journalDirectory = new File(args[0]);
-			}
-			if( args.length > 1 ) {
-				tool.workerIncrement = Integer.parseInt(args[1]);
-			}
-			if( args.length > 2 ) {
-				tool.incrementDelay = Long.parseLong(args[2]);
-			}
-			if( args.length > 3 ) {
-				tool.verbose = Boolean.getBoolean(args[3]);
-			}
-			if( args.length > 4 ) {
-				tool.recordSize = Integer.parseInt(args[4]);
-			}
-			if( args.length > 5 ) {
-				tool.syncFrequency = Integer.parseInt(args[5]);
-			}
-			if( args.length > 6 ) {
-				tool.workerThinkTime = Integer.parseInt(args[6]);
-			}
-			
-			if( args.length > 7 ) {
-				tool.maxLogFiles = Integer.parseInt(args[7]);
-			}
-			if( args.length > 8 ) {
-				tool.bufferSize = Integer.parseInt(args[8]);
-			}
-			if( args.length > 9 ) {
-				tool.maxBuffers = Integer.parseInt(args[9]);
-			}
-			if( args.length > 10 ) {
-				tool.maxBlocksPerFile = Integer.parseInt(args[10]);
-			}
-			tool.exec();
-		} catch (Throwable e) {
-			e.printStackTrace();
-		}
-	}
-
-	public Journal createJournal() throws Exception {
-		Configuration c = new Configuration();
-		c.setLogFileDir(journalDirectory.getPath());
-		c.setMaxLogFiles(maxLogFiles);
-		c.setBufferSize(bufferSize);
-		c.setMaxBuffers(maxBuffers);
-		c.setMaxBlocksPerFile(maxBlocksPerFile);
-		return new HowlJournal( c );
-	}
-	
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.journal.howl;
+
+import java.io.File;
+
+import org.apache.activeio.journal.Journal;
+import org.apache.activeio.journal.JournalPerfToolSupport;
+import org.apache.activeio.journal.howl.HowlJournal;
+import org.objectweb.howl.log.Configuration;
+
+/**
+ * A Performance statistics gathering tool for the HOWL based Journal.
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class JournalPerfTool extends JournalPerfToolSupport {
+	
+    private int maxLogFiles=  2;
+	private int bufferSize = 1024*4;
+	private int maxBuffers = 20;
+	private int maxBlocksPerFile = 100;
+	
+	public static void main(String[] args) throws Exception {
+		
+		try {
+			JournalPerfTool tool = new JournalPerfTool();
+			if( args.length > 0 ) {
+				tool.journalDirectory = new File(args[0]);
+			}
+			if( args.length > 1 ) {
+				tool.workerIncrement = Integer.parseInt(args[1]);
+			}
+			if( args.length > 2 ) {
+				tool.incrementDelay = Long.parseLong(args[2]);
+			}
+			if( args.length > 3 ) {
+				tool.verbose = Boolean.getBoolean(args[3]);
+			}
+			if( args.length > 4 ) {
+				tool.recordSize = Integer.parseInt(args[4]);
+			}
+			if( args.length > 5 ) {
+				tool.syncFrequency = Integer.parseInt(args[5]);
+			}
+			if( args.length > 6 ) {
+				tool.workerThinkTime = Integer.parseInt(args[6]);
+			}
+			
+			if( args.length > 7 ) {
+				tool.maxLogFiles = Integer.parseInt(args[7]);
+			}
+			if( args.length > 8 ) {
+				tool.bufferSize = Integer.parseInt(args[8]);
+			}
+			if( args.length > 9 ) {
+				tool.maxBuffers = Integer.parseInt(args[9]);
+			}
+			if( args.length > 10 ) {
+				tool.maxBlocksPerFile = Integer.parseInt(args[10]);
+			}
+			tool.exec();
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+
+	public Journal createJournal() throws Exception {
+		Configuration c = new Configuration();
+		c.setLogFileDir(journalDirectory.getPath());
+		c.setMaxLogFiles(maxLogFiles);
+		c.setBufferSize(bufferSize);
+		c.setMaxBuffers(maxBuffers);
+		c.setMaxBlocksPerFile(maxBlocksPerFile);
+		return new HowlJournal( c );
+	}
+	
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/howl/JournalPerfTool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/oneport/OnePortAsyncChannelServerTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/oneport/OnePortAsyncChannelServerTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/oneport/OnePortAsyncChannelServerTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/oneport/OnePortAsyncChannelServerTest.java Tue Feb 21 15:12:56 2006
@@ -1,228 +1,228 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.oneport;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.apache.activeio.AcceptListener;
-import org.apache.activeio.Channel;
-import org.apache.activeio.adapter.AsyncToSyncChannel;
-import org.apache.activeio.adapter.SyncToAsyncChannelFactory;
-import org.apache.activeio.oneport.HttpRecognizer;
-import org.apache.activeio.oneport.IIOPRecognizer;
-import org.apache.activeio.oneport.OnePortAsyncChannelServer;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.packet.async.AsyncChannel;
-import org.apache.activeio.packet.async.AsyncChannelFactory;
-import org.apache.activeio.packet.async.AsyncChannelServer;
-import org.apache.activeio.packet.async.FilterAsyncChannelServer;
-import org.apache.activeio.packet.sync.FilterSyncChannel;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.socket.SocketSyncChannelFactory;
-import org.apache.activeio.stream.sync.socket.SocketMetadata;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
-
-/**
- */
-public class OnePortAsyncChannelServerTest extends TestCase {
-
-    static private Log log = LogFactory.getLog(OnePortAsyncChannelServerTest.class);
-    static public AtomicInteger serverPacketCounter = new AtomicInteger(0);
-
-    public OnePortAsyncChannelServer server;
-    public AsyncChannelServer httpServer;
-    public AsyncChannelServer iiopServer;
-    public SocketSyncChannelFactory channelFactory;
-    public BlockingQueue resultSlot = new ArrayBlockingQueue(1);
-
-    public void testIIOPAccept() throws Exception {
-        serverPacketCounter.set(0);
-        hitIIOPServer();
-        String type = (String) resultSlot.poll(10, TimeUnit.SECONDS);
-        assertEquals("IIOP", type);
-        // Verify that a request when through the one port.
-        assertTrue(serverPacketCounter.get()>0);
-    }
-
-    public void testHttpAccept() throws IOException, URISyntaxException, InterruptedException {
-        serverPacketCounter.set(0);
-        hitHttpServer();
-        String type = (String) resultSlot.poll(60, TimeUnit.SECONDS);
-        assertEquals("HTTP", type);
-        // Verify that a request when through the one port.
-        assertTrue(serverPacketCounter.get()>0);
-    }
-
-    protected void hitHttpServer() throws IOException, MalformedURLException {
-        URI connectURI = server.getConnectURI();
-        String url = "http://" + connectURI.getHost() + ":" + connectURI.getPort() + "/index.action";
-        log.info(url);
-        InputStream is = new URL(url).openStream();
-        StringBuffer b = new StringBuffer();
-        int c;
-        while ((c = is.read()) >= 0) {
-            b.append((char) c);
-        }
-
-        log.info("HTTP response: " + b);
-    }
-
-    protected void hitIIOPServer() throws Exception {
-        SyncChannel channel = channelFactory.openSyncChannel(server.getConnectURI());
-        ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
-        channel.write(new ByteArrayPacket("GIOPcrapcrap".getBytes("UTF-8")));
-        channel.flush();
-        channel.stop();
-    }
-
-    public void testUnknownAccept() throws IOException, URISyntaxException, InterruptedException {
-        SyncChannel channel = channelFactory.openSyncChannel(server.getConnectURI());
-        ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
-        channel
-                .write(new ByteArrayPacket("Licensed under the Apache License, Version 2.0 (the \"License\")"
-                        .getBytes("UTF-8")));
-        channel.flush();
-        String type = (String) resultSlot.poll(1000 * 5, TimeUnit.MILLISECONDS);
-        assertNull(type);
-        channel.dispose();
-    }
-
-    protected void setUp() throws Exception {
-        channelFactory = new SocketSyncChannelFactory();
-        ThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory(){
-            int count=0;
-            public Thread newThread(Runnable arg0) {
-                return new Thread(arg0, "activeio:"+(count++));
-            }});
-        AsyncChannelFactory factory = SyncToAsyncChannelFactory.adapt(channelFactory,executor);
-
-        AsyncChannelServer cs = factory.bindAsyncChannel(new URI("tcp://localhost:0"));
-        cs = new FilterAsyncChannelServer(cs) {
-            public void onAccept(Channel channel) {
-                SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);                
-                super.onAccept(new FilterSyncChannel(syncChannel) {
-                    public org.apache.activeio.packet.Packet read(long timeout) throws IOException {
-                        Packet packet = super.read(timeout);
-                        if( packet!=null && packet.hasRemaining() )
-                            serverPacketCounter.incrementAndGet();
-                        return packet;
-                    }
-                });
-            }
-        };
-        
-        server = new OnePortAsyncChannelServer(cs);
-        server.start();
-
-        startHTTPServer();
-        startIIOPServer();
-
-        log.info("Running on: "+server.getConnectURI());
-    }
-
-    /**
-     * @throws IOException
-     * @throws NamingException
-     */
-    protected void startIIOPServer() throws Exception {
-        iiopServer = server.bindAsyncChannel(IIOPRecognizer.IIOP_RECOGNIZER);
-        iiopServer.setAcceptListener(new AcceptListener() {
-            public void onAccept(Channel channel) {
-                try {
-                    log.info("Got a IIOP connection.");
-                    resultSlot.offer("IIOP", 1, TimeUnit.MILLISECONDS);
-                    channel.dispose();
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-
-            public void onAcceptError(IOException error) {
-            }
-        });
-        iiopServer.start();
-    }
-
-    /**
-     * @throws IOException
-     * @throws Exception
-     */
-    protected void startHTTPServer() throws Exception {
-        httpServer = server.bindAsyncChannel(HttpRecognizer.HTTP_RECOGNIZER);
-        httpServer.setAcceptListener(new AcceptListener() {
-            public void onAccept(Channel channel) {
-                try {
-                    log.info("Got a HTTP connection.");
-                    resultSlot.offer("HTTP", 1, TimeUnit.MILLISECONDS);
-
-                    byte data[] = ("HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "\r\n"
-                            + "Hello World").getBytes("UTF-8");
-
-                    ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
-                    ((AsyncChannel) channel).write(new ByteArrayPacket(data));
-
-                    channel.dispose();
-                } catch (Throwable e) {
-                    e.printStackTrace();
-                }
-            }
-
-            public void onAcceptError(IOException error) {
-            }
-        });
-        httpServer.start();
-    }
-
-    protected void tearDown() throws Exception {
-        stopIIOPServer();
-        stopHTTPServer();
-        server.dispose();
-    }
-
-    /**
-     * @throws InterruptedException
-     * 
-     */
-    protected void stopHTTPServer() throws InterruptedException {
-        httpServer.dispose();
-    }
-
-    /**
-     * @throws Exception
-     * 
-     */
-    protected void stopIIOPServer() throws Exception {
-        iiopServer.dispose();
-    }
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.oneport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.activeio.AcceptListener;
+import org.apache.activeio.Channel;
+import org.apache.activeio.adapter.AsyncToSyncChannel;
+import org.apache.activeio.adapter.SyncToAsyncChannelFactory;
+import org.apache.activeio.oneport.HttpRecognizer;
+import org.apache.activeio.oneport.IIOPRecognizer;
+import org.apache.activeio.oneport.OnePortAsyncChannelServer;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannelFactory;
+import org.apache.activeio.packet.async.AsyncChannelServer;
+import org.apache.activeio.packet.async.FilterAsyncChannelServer;
+import org.apache.activeio.packet.sync.FilterSyncChannel;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.socket.SocketSyncChannelFactory;
+import org.apache.activeio.stream.sync.socket.SocketMetadata;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ */
+public class OnePortAsyncChannelServerTest extends TestCase {
+
+    static private Log log = LogFactory.getLog(OnePortAsyncChannelServerTest.class);
+    static public AtomicInteger serverPacketCounter = new AtomicInteger(0);
+
+    public OnePortAsyncChannelServer server;
+    public AsyncChannelServer httpServer;
+    public AsyncChannelServer iiopServer;
+    public SocketSyncChannelFactory channelFactory;
+    public BlockingQueue resultSlot = new ArrayBlockingQueue(1);
+
+    public void testIIOPAccept() throws Exception {
+        serverPacketCounter.set(0);
+        hitIIOPServer();
+        String type = (String) resultSlot.poll(10, TimeUnit.SECONDS);
+        assertEquals("IIOP", type);
+        // Verify that a request when through the one port.
+        assertTrue(serverPacketCounter.get()>0);
+    }
+
+    public void testHttpAccept() throws IOException, URISyntaxException, InterruptedException {
+        serverPacketCounter.set(0);
+        hitHttpServer();
+        String type = (String) resultSlot.poll(60, TimeUnit.SECONDS);
+        assertEquals("HTTP", type);
+        // Verify that a request when through the one port.
+        assertTrue(serverPacketCounter.get()>0);
+    }
+
+    protected void hitHttpServer() throws IOException, MalformedURLException {
+        URI connectURI = server.getConnectURI();
+        String url = "http://" + connectURI.getHost() + ":" + connectURI.getPort() + "/index.action";
+        log.info(url);
+        InputStream is = new URL(url).openStream();
+        StringBuffer b = new StringBuffer();
+        int c;
+        while ((c = is.read()) >= 0) {
+            b.append((char) c);
+        }
+
+        log.info("HTTP response: " + b);
+    }
+
+    protected void hitIIOPServer() throws Exception {
+        SyncChannel channel = channelFactory.openSyncChannel(server.getConnectURI());
+        ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
+        channel.write(new ByteArrayPacket("GIOPcrapcrap".getBytes("UTF-8")));
+        channel.flush();
+        channel.stop();
+    }
+
+    public void testUnknownAccept() throws IOException, URISyntaxException, InterruptedException {
+        SyncChannel channel = channelFactory.openSyncChannel(server.getConnectURI());
+        ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
+        channel
+                .write(new ByteArrayPacket("Licensed under the Apache License, Version 2.0 (the \"License\")"
+                        .getBytes("UTF-8")));
+        channel.flush();
+        String type = (String) resultSlot.poll(1000 * 5, TimeUnit.MILLISECONDS);
+        assertNull(type);
+        channel.dispose();
+    }
+
+    protected void setUp() throws Exception {
+        channelFactory = new SocketSyncChannelFactory();
+        ThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory(){
+            int count=0;
+            public Thread newThread(Runnable arg0) {
+                return new Thread(arg0, "activeio:"+(count++));
+            }});
+        AsyncChannelFactory factory = SyncToAsyncChannelFactory.adapt(channelFactory,executor);
+
+        AsyncChannelServer cs = factory.bindAsyncChannel(new URI("tcp://localhost:0"));
+        cs = new FilterAsyncChannelServer(cs) {
+            public void onAccept(Channel channel) {
+                SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);                
+                super.onAccept(new FilterSyncChannel(syncChannel) {
+                    public org.apache.activeio.packet.Packet read(long timeout) throws IOException {
+                        Packet packet = super.read(timeout);
+                        if( packet!=null && packet.hasRemaining() )
+                            serverPacketCounter.incrementAndGet();
+                        return packet;
+                    }
+                });
+            }
+        };
+        
+        server = new OnePortAsyncChannelServer(cs);
+        server.start();
+
+        startHTTPServer();
+        startIIOPServer();
+
+        log.info("Running on: "+server.getConnectURI());
+    }
+
+    /**
+     * @throws IOException
+     * @throws NamingException
+     */
+    protected void startIIOPServer() throws Exception {
+        iiopServer = server.bindAsyncChannel(IIOPRecognizer.IIOP_RECOGNIZER);
+        iiopServer.setAcceptListener(new AcceptListener() {
+            public void onAccept(Channel channel) {
+                try {
+                    log.info("Got a IIOP connection.");
+                    resultSlot.offer("IIOP", 1, TimeUnit.MILLISECONDS);
+                    channel.dispose();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+
+            public void onAcceptError(IOException error) {
+            }
+        });
+        iiopServer.start();
+    }
+
+    /**
+     * @throws IOException
+     * @throws Exception
+     */
+    protected void startHTTPServer() throws Exception {
+        httpServer = server.bindAsyncChannel(HttpRecognizer.HTTP_RECOGNIZER);
+        httpServer.setAcceptListener(new AcceptListener() {
+            public void onAccept(Channel channel) {
+                try {
+                    log.info("Got a HTTP connection.");
+                    resultSlot.offer("HTTP", 1, TimeUnit.MILLISECONDS);
+
+                    byte data[] = ("HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "\r\n"
+                            + "Hello World").getBytes("UTF-8");
+
+                    ((SocketMetadata)channel.getAdapter(SocketMetadata.class)).setTcpNoDelay(true);
+                    ((AsyncChannel) channel).write(new ByteArrayPacket(data));
+
+                    channel.dispose();
+                } catch (Throwable e) {
+                    e.printStackTrace();
+                }
+            }
+
+            public void onAcceptError(IOException error) {
+            }
+        });
+        httpServer.start();
+    }
+
+    protected void tearDown() throws Exception {
+        stopIIOPServer();
+        stopHTTPServer();
+        server.dispose();
+    }
+
+    /**
+     * @throws InterruptedException
+     * 
+     */
+    protected void stopHTTPServer() throws InterruptedException {
+        httpServer.dispose();
+    }
+
+    /**
+     * @throws Exception
+     * 
+     */
+    protected void stopIIOPServer() throws Exception {
+        iiopServer.dispose();
+    }
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/oneport/OnePortAsyncChannelServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/AppendedPacketTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/AppendedPacketTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/AppendedPacketTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/AppendedPacketTest.java Tue Feb 21 15:12:56 2006
@@ -1,37 +1,37 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet;
-
-import org.apache.activeio.packet.AppendedPacket;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.Packet;
-
-
-/**
- */
-public class AppendedPacketTest extends PacketTestSupport {
-
-    Packet createTestPacket(int capacity) {
-        int c1 = capacity/2;
-        int c2 = capacity-c1;
-        
-        return AppendedPacket.join(
-                	new ByteArrayPacket(new byte[c1]),
-                	new ByteArrayPacket(new byte[c2]));
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet;
+
+import org.apache.activeio.packet.AppendedPacket;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.Packet;
+
+
+/**
+ */
+public class AppendedPacketTest extends PacketTestSupport {
+
+    Packet createTestPacket(int capacity) {
+        int c1 = capacity/2;
+        int c2 = capacity-c1;
+        
+        return AppendedPacket.join(
+                	new ByteArrayPacket(new byte[c1]),
+                	new ByteArrayPacket(new byte[c2]));
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/AppendedPacketTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteArrayPacketTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteArrayPacketTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteArrayPacketTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteArrayPacketTest.java Tue Feb 21 15:12:56 2006
@@ -1,31 +1,31 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet;
-
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.Packet;
-
-
-/**
- */
-public class ByteArrayPacketTest extends PacketTestSupport {
-
-    Packet createTestPacket(int capacity) {
-        return new ByteArrayPacket(new byte[capacity]);
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet;
+
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.Packet;
+
+
+/**
+ */
+public class ByteArrayPacketTest extends PacketTestSupport {
+
+    Packet createTestPacket(int capacity) {
+        return new ByteArrayPacket(new byte[capacity]);
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteArrayPacketTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteBufferPacketTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteBufferPacketTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteBufferPacketTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteBufferPacketTest.java Tue Feb 21 15:12:56 2006
@@ -1,33 +1,33 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet;
-
-import java.nio.ByteBuffer;
-
-import org.apache.activeio.packet.ByteBufferPacket;
-import org.apache.activeio.packet.Packet;
-
-
-/**
- */
-public class ByteBufferPacketTest extends PacketTestSupport {
-
-    Packet createTestPacket(int capacity) {
-        return new ByteBufferPacket(ByteBuffer.allocate(capacity));
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet;
+
+import java.nio.ByteBuffer;
+
+import org.apache.activeio.packet.ByteBufferPacket;
+import org.apache.activeio.packet.Packet;
+
+
+/**
+ */
+public class ByteBufferPacketTest extends PacketTestSupport {
+
+    Packet createTestPacket(int capacity) {
+        return new ByteBufferPacket(ByteBuffer.allocate(capacity));
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ByteBufferPacketTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/ClientLoadSimulator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java Tue Feb 21 15:12:56 2006
@@ -1,158 +1,158 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet;
-
-import java.util.Arrays;
-
-import org.apache.activeio.packet.Packet;
-
-import junit.framework.TestCase;
-
-
-/**
- */
-abstract public class PacketTestSupport extends TestCase {
-    abstract Packet createTestPacket(int capacity);
-    
-    public void testInit() {
-        Packet packet = createTestPacket(100);
-        assertEquals( 100, packet.capacity() );        
-        assertEquals( 0, packet.position());        
-        assertEquals( 100, packet.limit() );        
-        assertEquals( 100, packet.remaining() );        
-        assertTrue( packet.hasRemaining() );        
-    }
-    
-    public void testPosition() {
-        Packet packet = createTestPacket(100);
-        packet.position(10);
-        assertEquals( 10, packet.position() );        
-    }
-
-    public void testLimit() {
-        Packet packet = createTestPacket(100);
-        packet.limit(10);
-        assertEquals( 10, packet.limit() );        
-    }
-
-    public void testRemaining() {
-        Packet packet = createTestPacket(100);
-        packet.position(5);
-        packet.limit(95);
-        assertEquals(90, packet.remaining());
-        assertTrue(packet.hasRemaining());
-
-        packet.position(5);
-        packet.limit(5);
-        assertEquals(0, packet.remaining());
-        assertFalse(packet.hasRemaining());
-    }
-    
-    public void testFlip() {
-        Packet packet = createTestPacket(100);
-        packet.position(95);
-        packet.flip();        
-        assertEquals(0, packet.position());
-        assertEquals(95, packet.limit());
-    }
-    
-    public void testClear() {
-        Packet packet = createTestPacket(100);
-        packet.position(5);
-        packet.limit(95);
-        packet.clear();        
-        assertEquals(0, packet.position());
-        assertEquals(100, packet.limit());
-    }
-
-    public void testDuplicate() {
-        Packet packet = createTestPacket(100);
-        packet.position(5);
-        packet.limit(95);
-        Packet packet2 = packet.duplicate();
-        packet2.position(10);
-        packet2.limit(20);
-        
-        assertEquals(5, packet.position());
-        assertEquals(95, packet.limit());
-        assertEquals(10, packet2.position());
-        assertEquals(20, packet2.limit());
-    }
-
-    public void testRewind() {
-        Packet packet = createTestPacket(100);
-        packet.position(5);
-        packet.limit(95);
-        packet.rewind();
-        
-        assertEquals(0, packet.position());
-        assertEquals(95, packet.limit());
-    }
-    
-    public void testSlice() {
-        Packet packet = createTestPacket(100);
-        packet.position(5);
-        packet.limit(95);
-        Packet packet2 = packet.slice();
-        
-        assertEquals(0, packet2.position());
-        assertEquals(90, packet2.capacity());
-        assertEquals(90, packet2.limit());
-    }
-
-    public void testWriteAndReadByte() {
-        
-        Packet packet = createTestPacket(256);
-        for(int i=0; i < 256; i++) {
-            assertTrue(packet.write(i));
-        }
-        assertFalse(packet.write(0));
-        
-        packet.flip();
-        for(int i=0; i < 256; i++) {
-            assertEquals(i, packet.read());
-        }       
-        assertEquals(-1, packet.read());        
-    }
-    
-    public void testWriteAndReadBulkByte() {
-        
-        byte data[] = new byte[10];        
-        Packet packet = createTestPacket(data.length*10);
-        for(int i=0; i < 10; i++) {
-            Arrays.fill(data,(byte)i);
-            assertEquals(data.length, packet.write(data,0,data.length));
-        }
-        assertEquals(-1, packet.write(data,0,data.length));
-        
-        byte buffer[] = new byte[data.length];
-        packet.flip();
-        for(int i=0; i < 10; i++) {
-            assertEquals(buffer.length, packet.read(buffer,0,buffer.length));
-            Arrays.fill(data,(byte)i);
-            assertEquals(buffer, data);
-        }       
-        assertEquals(-1, packet.read(buffer,0,buffer.length));
-    }
- 
-    public void assertEquals(byte buffer[], byte data[]) {
-        assertEquals(buffer.length, data.length);
-        for (int i = 0; i < data.length; i++) {
-            assertEquals(buffer[i], data[i]);
-        }
-    }
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet;
+
+import java.util.Arrays;
+
+import org.apache.activeio.packet.Packet;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+abstract public class PacketTestSupport extends TestCase {
+    abstract Packet createTestPacket(int capacity);
+    
+    public void testInit() {
+        Packet packet = createTestPacket(100);
+        assertEquals( 100, packet.capacity() );        
+        assertEquals( 0, packet.position());        
+        assertEquals( 100, packet.limit() );        
+        assertEquals( 100, packet.remaining() );        
+        assertTrue( packet.hasRemaining() );        
+    }
+    
+    public void testPosition() {
+        Packet packet = createTestPacket(100);
+        packet.position(10);
+        assertEquals( 10, packet.position() );        
+    }
+
+    public void testLimit() {
+        Packet packet = createTestPacket(100);
+        packet.limit(10);
+        assertEquals( 10, packet.limit() );        
+    }
+
+    public void testRemaining() {
+        Packet packet = createTestPacket(100);
+        packet.position(5);
+        packet.limit(95);
+        assertEquals(90, packet.remaining());
+        assertTrue(packet.hasRemaining());
+
+        packet.position(5);
+        packet.limit(5);
+        assertEquals(0, packet.remaining());
+        assertFalse(packet.hasRemaining());
+    }
+    
+    public void testFlip() {
+        Packet packet = createTestPacket(100);
+        packet.position(95);
+        packet.flip();        
+        assertEquals(0, packet.position());
+        assertEquals(95, packet.limit());
+    }
+    
+    public void testClear() {
+        Packet packet = createTestPacket(100);
+        packet.position(5);
+        packet.limit(95);
+        packet.clear();        
+        assertEquals(0, packet.position());
+        assertEquals(100, packet.limit());
+    }
+
+    public void testDuplicate() {
+        Packet packet = createTestPacket(100);
+        packet.position(5);
+        packet.limit(95);
+        Packet packet2 = packet.duplicate();
+        packet2.position(10);
+        packet2.limit(20);
+        
+        assertEquals(5, packet.position());
+        assertEquals(95, packet.limit());
+        assertEquals(10, packet2.position());
+        assertEquals(20, packet2.limit());
+    }
+
+    public void testRewind() {
+        Packet packet = createTestPacket(100);
+        packet.position(5);
+        packet.limit(95);
+        packet.rewind();
+        
+        assertEquals(0, packet.position());
+        assertEquals(95, packet.limit());
+    }
+    
+    public void testSlice() {
+        Packet packet = createTestPacket(100);
+        packet.position(5);
+        packet.limit(95);
+        Packet packet2 = packet.slice();
+        
+        assertEquals(0, packet2.position());
+        assertEquals(90, packet2.capacity());
+        assertEquals(90, packet2.limit());
+    }
+
+    public void testWriteAndReadByte() {
+        
+        Packet packet = createTestPacket(256);
+        for(int i=0; i < 256; i++) {
+            assertTrue(packet.write(i));
+        }
+        assertFalse(packet.write(0));
+        
+        packet.flip();
+        for(int i=0; i < 256; i++) {
+            assertEquals(i, packet.read());
+        }       
+        assertEquals(-1, packet.read());        
+    }
+    
+    public void testWriteAndReadBulkByte() {
+        
+        byte data[] = new byte[10];        
+        Packet packet = createTestPacket(data.length*10);
+        for(int i=0; i < 10; i++) {
+            Arrays.fill(data,(byte)i);
+            assertEquals(data.length, packet.write(data,0,data.length));
+        }
+        assertEquals(-1, packet.write(data,0,data.length));
+        
+        byte buffer[] = new byte[data.length];
+        packet.flip();
+        for(int i=0; i < 10; i++) {
+            assertEquals(buffer.length, packet.read(buffer,0,buffer.length));
+            Arrays.fill(data,(byte)i);
+            assertEquals(buffer, data);
+        }       
+        assertEquals(-1, packet.read(buffer,0,buffer.length));
+    }
+ 
+    public void assertEquals(byte buffer[], byte data[]) {
+        assertEquals(buffer.length, data.length);
+        for (int i = 0; i < data.length; i++) {
+            assertEquals(buffer[i], data[i]);
+        }
+    }
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/nio/NIOAsyncChannelTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/nio/NIOAsyncChannelTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/nio/NIOAsyncChannelTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/nio/NIOAsyncChannelTest.java Tue Feb 21 15:12:56 2006
@@ -1,43 +1,43 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet.async.nio;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelServer;
-import org.apache.activeio.packet.async.nio.NIOAsyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelTestSupport;
-
-/**
- * @version $Revision$
- */
-public class NIOAsyncChannelTest extends SyncChannelTestSupport {
-
-    NIOAsyncChannelFactory factory = new NIOAsyncChannelFactory(true);
-    
-    protected Channel openChannel(URI connectURI) throws IOException {
-        return factory.openAsyncChannel(connectURI);
-    }
-
-    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
-        return factory.bindAsyncChannel(new URI("tcp://localhost:0"));
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet.async.nio;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelServer;
+import org.apache.activeio.packet.async.nio.NIOAsyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class NIOAsyncChannelTest extends SyncChannelTestSupport {
+
+    NIOAsyncChannelFactory factory = new NIOAsyncChannelFactory(true);
+    
+    protected Channel openChannel(URI connectURI) throws IOException {
+        return factory.openAsyncChannel(connectURI);
+    }
+
+    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
+        return factory.bindAsyncChannel(new URI("tcp://localhost:0"));
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/nio/NIOAsyncChannelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeAsyncChannelTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeAsyncChannelTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeAsyncChannelTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeAsyncChannelTest.java Tue Feb 21 15:12:56 2006
@@ -1,43 +1,43 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet.async.vmpipe;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelServer;
-import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelTestSupport;
-
-/**
- * @version $Revision$
- */
-public class VMPipeAsyncChannelTest extends SyncChannelTestSupport {
-
-    VMPipeAsyncChannelFactory factory =  new VMPipeAsyncChannelFactory();
-
-    protected Channel openChannel(URI connectURI) throws IOException {
-        return factory.openAsyncChannel(connectURI);
-    }
-
-    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
-        return factory.bindAsyncChannel(new URI("vmpipe://testpipe"));
-    }
-    
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet.async.vmpipe;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelServer;
+import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class VMPipeAsyncChannelTest extends SyncChannelTestSupport {
+
+    VMPipeAsyncChannelFactory factory =  new VMPipeAsyncChannelFactory();
+
+    protected Channel openChannel(URI connectURI) throws IOException {
+        return factory.openAsyncChannel(connectURI);
+    }
+
+    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
+        return factory.bindAsyncChannel(new URI("vmpipe://testpipe"));
+    }
+    
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeAsyncChannelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeReflectionAsyncChannelTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeReflectionAsyncChannelTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeReflectionAsyncChannelTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeReflectionAsyncChannelTest.java Tue Feb 21 15:12:56 2006
@@ -1,45 +1,45 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed 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.activeio.packet.async.vmpipe;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelServer;
-import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelTestSupport;
-
-/**
- * @version $Revision$
- */
-public class VMPipeReflectionAsyncChannelTest extends SyncChannelTestSupport {
-
-    VMPipeAsyncChannelFactory factory =  new VMPipeAsyncChannelFactory();
-
-    protected Channel openChannel(URI connectURI) throws IOException {
-        factory.setForceRefelection(true);
-        return factory.openAsyncChannel(connectURI);
-    }
-
-    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
-        factory.setForceRefelection(true);
-        return factory.bindAsyncChannel(new URI("vmpipe://testpipe"));
-    }
-    
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.activeio.packet.async.vmpipe;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelServer;
+import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class VMPipeReflectionAsyncChannelTest extends SyncChannelTestSupport {
+
+    VMPipeAsyncChannelFactory factory =  new VMPipeAsyncChannelFactory();
+
+    protected Channel openChannel(URI connectURI) throws IOException {
+        factory.setForceRefelection(true);
+        return factory.openAsyncChannel(connectURI);
+    }
+
+    protected ChannelServer bindChannel() throws IOException, URISyntaxException {
+        factory.setForceRefelection(true);
+        return factory.bindAsyncChannel(new URI("vmpipe://testpipe"));
+    }
+    
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/packet/async/vmpipe/VMPipeReflectionAsyncChannelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message