directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r349928 - in /directory/network/branches/chain_refactor/src: java/org/apache/mina/common/DefaultIoFilterChainBuilder.java test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
Date Wed, 30 Nov 2005 11:56:26 GMT
Author: trustin
Date: Wed Nov 30 03:56:15 2005
New Revision: 349928

URL: http://svn.apache.org/viewcvs?rev=349928&view=rev
Log:
* Added a test case for DefaultIoFilterChainBuilder
* Added a missing license statement

Added:
    directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
Modified:
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java?rev=349928&r1=349927&r2=349928&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
Wed Nov 30 03:56:15 2005
@@ -1,3 +1,21 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 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.mina.common;
 
 import java.util.ArrayList;
@@ -12,6 +30,12 @@
 import org.apache.mina.common.IoFilter.NextFilter;
 import org.apache.mina.common.IoFilterChain.Entry;
 
+/**
+ * TODO Document me
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
 public class DefaultIoFilterChainBuilder implements IoFilterChainBuilder
 {
     private List entries = new ArrayList();

Added: directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java?rev=349928&view=auto
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
(added)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
Wed Nov 30 03:56:15 2005
@@ -0,0 +1,105 @@
+/*
+ *   @(#) $Id: ExceptionMonitor.java 326586 2005-10-19 15:50:29Z trustin $
+ *
+ *   Copyright 2004 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.mina.common;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.mina.common.IoFilterChain.Entry;
+
+/**
+ * Tests {@link DefaultIoFilterChainBuilder}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class DefaultIoFilterChainBuilderTest extends TestCase
+{
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( DefaultIoFilterChainBuilderTest.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+    }
+
+    protected void tearDown() throws Exception
+    {
+    }
+    
+    public void testAdd() throws Exception
+    {
+        DefaultIoFilterChainBuilder builder = new DefaultIoFilterChainBuilder();
+        
+        builder.addFirst( "A", new IoFilterAdapter() );
+        builder.addLast( "B", new IoFilterAdapter() );
+        builder.addFirst( "C", new IoFilterAdapter() );
+        builder.addLast( "D", new IoFilterAdapter() );
+        builder.addBefore( "B", "E", new IoFilterAdapter() );
+        builder.addBefore( "C", "F", new IoFilterAdapter() );
+        builder.addAfter( "B", "G", new IoFilterAdapter() );
+        builder.addAfter( "D", "H", new IoFilterAdapter() );
+        
+        String actual = "";
+        for( Iterator i = builder.getAll().iterator(); i.hasNext(); ) 
+        {
+            Entry e = ( Entry ) i.next();
+            actual += e.getName();
+        }
+        
+        Assert.assertEquals( "FCAEBGDH", actual );
+    }
+    
+    public void testRemove() throws Exception
+    {
+        DefaultIoFilterChainBuilder builder = new DefaultIoFilterChainBuilder();
+        
+        builder.addLast( "A", new IoFilterAdapter() );
+        builder.addLast( "B", new IoFilterAdapter() );
+        builder.addLast( "C", new IoFilterAdapter() );
+        builder.addLast( "D", new IoFilterAdapter() );
+        builder.addLast( "E", new IoFilterAdapter() );
+        
+        builder.remove( "A" );
+        builder.remove( "E" );
+        builder.remove( "C" );
+        builder.remove( "B" );
+        builder.remove( "D" );
+        
+        Assert.assertEquals( 0, builder.getAll().size() );
+    }
+    
+    public void testClear() throws Exception
+    {
+        DefaultIoFilterChainBuilder builder = new DefaultIoFilterChainBuilder();
+        
+        builder.addLast( "A", new IoFilterAdapter() );
+        builder.addLast( "B", new IoFilterAdapter() );
+        builder.addLast( "C", new IoFilterAdapter() );
+        builder.addLast( "D", new IoFilterAdapter() );
+        builder.addLast( "E", new IoFilterAdapter() );
+        
+        builder.clear();
+        
+        Assert.assertEquals( 0, builder.getAll().size() );
+    }
+}



Mime
View raw message