From 60f08c5d9fa9414bf27f2f7327420b9c7fea3eb9 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 25 Aug 2008 05:26:54 +0000 Subject: [PATCH] Added SwitchableInputStreamTest --- pom.xml | 287 ++++++++---------- .../netty/util/SwitchableInputStreamTest.java | 64 ++++ 2 files changed, 183 insertions(+), 168 deletions(-) create mode 100644 src/test/java/org/jboss/netty/util/SwitchableInputStreamTest.java diff --git a/pom.xml b/pom.xml index 16f0e7d062..9e7fb02716 100644 --- a/pom.xml +++ b/pom.xml @@ -1,167 +1,30 @@ - - - + 4.0.0 org.jboss.netty netty - 3.0.0.CR3-SNAPSHOT bundle - The Netty Project - - The Netty project is an effort to provide an asynchronous / event-driven network application framework for rapid development of high-performance / high-scalability protocol servers and clients, including its related out-of-the-box protocol extensions and tool suite. - - + 3.0.0.CR3-SNAPSHOT + The Netty project is an effort to provide an asynchronous / event-driven network application framework for rapid development of high-performance / high-scalability protocol servers and clients, including its related out-of-the-box protocol extensions and tool suite. http://www.jboss.org/netty/ - - JBoss - a division of Red Hat - http://www.jboss.org/ - - 2008 - GNU Lesser General Public License http://www.gnu.org/licenses/lgpl.html - scm:svn:http://anonsvn.jboss.org/repos/netty/trunk scm:svn:https://svn.jboss.org/repos/netty/trunk - - - - - apiviz.release - APIviz releases - http://apiviz.googlecode.com/svn/site/repo/mvn/release - - true - - - false - - - - - - jboss.release - JBoss releases - http://repository.jboss.org/maven2 - - true - - - false - - - - - - - repository.jboss.org - JBoss.org Release Distribution Repository - https://svn.jboss.org/repos/repository.jboss.org/maven2 - - - snapshots.jboss.org - JBoss.org Development Snapshot Repository - https://snapshots.jboss.org/maven2 - - - - - - - org.slf4j - slf4j-api - 1.5.2 - compile - true - - - commons-logging - commons-logging - 1.1.1 - compile - true - - - org.jboss.logging - jboss-logging-spi - 2.0.5.GA - compile - true - - - log4j - log4j - 1.2.15 - compile - true - - - javax.mail - mail - - - javax.jms - jms - - - com.sun.jdmk - jmxtools - - - com.sun.jmx - jmxri - - - - - - - junit - junit - 4.4 - test - - - org.easymock - easymock - 2.4 - test - - - + + JBoss - a division of Red Hat + http://www.jboss.org/ + - org.apache.maven.plugins maven-compiler-plugin UTF-8 @@ -195,7 +58,6 @@ - org.apache.maven.plugins maven-source-plugin @@ -208,7 +70,6 @@ - org.apache.maven.plugins maven-javadoc-plugin @@ -227,8 +88,7 @@ 1.1.3 true - - -charset UTF-8 + -charset UTF-8 -docencoding UTF-8 -version -author @@ -241,35 +101,36 @@ -group "Central interface for all I/O operations" ${project.groupId}.channel* -group "Client & Server bootstrapping utilities" ${project.groupId}.bootstrap* -group "Reusable I/O event interceptors" ${project.groupId}.handler* - -group "Miscellaneous" ${project.groupId}.logging* - + -group "Miscellaneous" ${project.groupId}.logging* UTF-8 en_US ${project.groupId}.example*:${project.groupId}.util* - org.apache.maven.plugins maven-jxr-plugin UTF-8 UTF-8 false - + maven-antrun-plugin add-license package + + run + - - + + @@ -278,7 +139,7 @@ - + @@ -289,7 +150,7 @@ - + @@ -300,16 +161,13 @@ - + - - run - @@ -342,15 +200,108 @@ maven-release-plugin - - https://svn.jboss.org/repos/netty/tags - + https://svn.jboss.org/repos/netty/tags - - - - - + + + + + false + + apiviz.release + APIviz releases + http://apiviz.googlecode.com/svn/site/repo/mvn/release + + + + + false + + jboss.release + JBoss releases + http://repository.jboss.org/maven2 + + + + + org.slf4j + slf4j-api + 1.5.2 + compile + true + + + commons-logging + commons-logging + 1.1.1 + compile + true + + + org.jboss.logging + jboss-logging-spi + 2.0.5.GA + compile + true + + + log4j + log4j + 1.2.15 + compile + + + mail + javax.mail + + + jms + javax.jms + + + jmxtools + com.sun.jdmk + + + jmxri + com.sun.jmx + + + true + + + junit + junit + 4.4 + test + + + org.easymock + easymock + 2.4 + test + + + org.easymock + easymockclassextension + 2.3 + test + + + + + + repository.jboss.org + JBoss.org Release Distribution Repository + https://svn.jboss.org/repos/repository.jboss.org/maven2 + + + snapshots.jboss.org + JBoss.org Development Snapshot Repository + https://snapshots.jboss.org/maven2 + + + \ No newline at end of file diff --git a/src/test/java/org/jboss/netty/util/SwitchableInputStreamTest.java b/src/test/java/org/jboss/netty/util/SwitchableInputStreamTest.java new file mode 100644 index 0000000000..d93754d39e --- /dev/null +++ b/src/test/java/org/jboss/netty/util/SwitchableInputStreamTest.java @@ -0,0 +1,64 @@ +/* + * JBoss, Home of Professional Open Source + * + * Copyright 2008, Red Hat Middleware LLC, and individual contributors + * by the @author tags. See the COPYRIGHT.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.netty.util; + +import static org.easymock.EasyMock.*; +import static org.easymock.classextension.EasyMock.*; +import static org.junit.Assert.*; + +import java.io.InputStream; + +import org.junit.Test; + + +/** + * @author The Netty Project (netty-dev@lists.jboss.org) + * @author Trustin Lee (tlee@redhat.com) + * + * @version $Rev$, $Date$ + * + */ +public class SwitchableInputStreamTest { + + @Test + public void testSwitchStream() throws Exception { + SwitchableInputStream sin = new SwitchableInputStream(); + + InputStream in1 = createStrictMock(InputStream.class); + InputStream in2 = createStrictMock(InputStream.class); + expect(in1.read()).andReturn(1); + replay(in1, in2); + + sin.switchStream(in1); + assertEquals(1, sin.read()); + verify(in1, in2); + reset(in1, in2); + + expect(in2.read()).andReturn(2); + replay(in1, in2); + + sin.switchStream(in2); + assertEquals(2, sin.read()); + verify(in1, in2); + } +}