jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/http/test MessageGeneratorTestCase.java,NONE,1.1 ParserImplTestCase.java,NONE,1.1 HTTPMessageGeneratorTestCase.java,1.3,NONE HTTPParserImplTestCase.java,1.9,NONE
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/test/org/jicarilla/http/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18181/platform/components/http/impl/src/test/org/jicarilla/http/test
Added Files:
MessageGeneratorTestCase.java ParserImplTestCase.java
Removed Files:
HTTPMessageGeneratorTestCase.java HTTPParserImplTestCase.java
Log Message:
remove the HTTP prefix from nearly every class and interface. Less typing, cleaner reading :-D
--- HTTPParserImplTestCase.java DELETED ---
--- HTTPMessageGeneratorTestCase.java DELETED ---
--- NEW FILE: ParserImplTestCase.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
[...1503 lines suppressed...]
}
private final static int BUFFER_SIZE = 2^14;
protected void doParseFile( final String fileName ) throws Exception
{
final File f = new File("");
final FileInputStream stream = new FileInputStream( f.getAbsolutePath() + "/src/test/com/leosimons/http/test/request.log");
final FileChannel streamChannel = stream.getChannel();
ByteBuffer buf = ByteBuffer.allocate( BUFFER_SIZE );
int read = 0;
while( (read = streamChannel.read( buf )) != -1 )
{
buf.rewind();
parser.parse( buf, read );
buf = ByteBuffer.allocate( BUFFER_SIZE );
}
}
}
--- NEW FILE: MessageGeneratorTestCase.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.http.test;
import junit.framework.TestCase;
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.impl.SoftReferenceObjectPool;
import org.easymock.MockControl;
import org.jicarilla.http.Message;
import org.jicarilla.http.MessageFactory;
import org.jicarilla.http.MessageGenerator;
import org.jicarilla.http.MessageReceivedListener;
import org.jicarilla.lang.ExceptionListener;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: MessageGeneratorTestCase.java,v 1.1 2004/04/09 15:52:28 lsimons Exp $
*/
public class MessageGeneratorTestCase extends TestCase
{
protected ExceptionListener el;
protected MockControl elControl;
protected MessageReceivedListener mrl;
protected MockControl mrlControl;
protected Message m;
protected MockControl mControl;
protected ObjectPool messagePool;
protected MessageGenerator generator;
public void setUp() throws Exception
{
super.setUp();
elControl = MockControl.createControl( ExceptionListener.class );
el = (ExceptionListener)elControl.getMock();
mrlControl = MockControl.createControl( MessageReceivedListener.class );
mrl = (MessageReceivedListener)mrlControl.getMock();
messagePool =
new SoftReferenceObjectPool( new MessageFactory() );
generator = new MessageGenerator( el, mrl, messagePool );
m = new Message();
}
public void testConstructor()
{
elControl.replay();
mrlControl.replay();
new MessageGenerator( el, mrl, messagePool );
elControl.verify();
mrlControl.verify();
try
{
new MessageGenerator( null, mrl, messagePool );
fail( "Expected an exception!" );
}
catch( AssertionError th ) {}
try
{
new MessageGenerator( el, null, messagePool );
fail( "Expected an exception!" );
}
catch( AssertionError th ) {}
try
{
new MessageGenerator( el, mrl, null );
fail( "Expected an exception!" );
}
catch( AssertionError th ) {}
}
public void testGetSetMessage()
{
elControl.replay();
mrlControl.replay();
generator.setMessage( new Message() );
assertNotNull( generator.getMessage() );
generator.setMessage( null );
assertNull( generator.getMessage() );
final Message msg = new Message();
generator.setMessage( msg );
assertEquals( msg, generator.getMessage() );
elControl.verify();
mrlControl.verify();
}
public void testGetMessageType()
{
generator.setMessage( m );
assertEquals( m.getMessageType(), generator.getMessageType() );
generator.setMessage( null );
try
{
generator.getMessageType();
fail( "Expected an exception!" );
}
catch( AssertionError ae ) {}
}
public void testSetMessageType()
{
generator.setMessage( m );
generator.setMessageType( false );
assertEquals( false, m.getMessageType() );
generator.setMessage( null );
try
{
generator.setMessageType(false);
fail( "Expected an exception!" );
}
catch( AssertionError ae ) {}
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click