Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 54281 invoked from network); 9 Apr 2004 21:40:32 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 9 Apr 2004 21:40:32 -0000 Received: (qmail 1226 invoked by uid 500); 9 Apr 2004 21:40:14 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 1197 invoked by uid 500); 9 Apr 2004 21:40:14 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 1184 invoked by uid 500); 9 Apr 2004 21:40:14 -0000 Received: (qmail 1181 invoked from network); 9 Apr 2004 21:40:14 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 9 Apr 2004 21:40:14 -0000 Received: (qmail 54257 invoked by uid 1643); 9 Apr 2004 21:40:26 -0000 Date: 9 Apr 2004 21:40:26 -0000 Message-ID: <20040409214026.54256.qmail@minotaur.apache.org> From: ggregory@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/codec/src/test/org/apache/commons/codec/net RFC1522CodecTest.java QCodecTest.java BCodecTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ggregory 2004/04/09 14:40:26 Modified: codec/src/test/org/apache/commons/codec/net QCodecTest.java BCodecTest.java Added: codec/src/test/org/apache/commons/codec/net RFC1522CodecTest.java Log: PR: [Codec][Patch] RFC 1522 codecs: Q-codec & B-codec http://issues.apache.org/bugzilla/show_bug.cgi?id=28002 Submitted by: Oleg Kalnichevski Reviewed by: Gary Gregory Revision Changes Path 1.2 +16 -34 jakarta-commons/codec/src/test/org/apache/commons/codec/net/QCodecTest.java Index: QCodecTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/codec/src/test/org/apache/commons/codec/net/QCodecTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- QCodecTest.java 29 Mar 2004 23:04:09 -0000 1.1 +++ QCodecTest.java 9 Apr 2004 21:40:26 -0000 1.2 @@ -52,6 +52,12 @@ return buffer.toString(); } + public void testNullInput() throws Exception { + QCodec qcodec = new QCodec(); + assertNull(qcodec.doDecoding(null)); + assertNull(qcodec.doEncoding(null)); + } + public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -98,40 +104,6 @@ qcodec.decode((String)null)); } - public void testDecodeInvalid() throws Exception { - QCodec qcodec = new QCodec(); - try { - qcodec.decode("whatever"); - fail("DecoderException should have been thrown"); - } catch(DecoderException e) { - // Expected. Move on - } - try { - qcodec.decode("=?UTF-8?Q?stuff"); - fail("DecoderException should have been thrown"); - } catch(DecoderException e) { - // Expected. Move on - } - try { - qcodec.decode("=??Q?stuff?="); - fail("DecoderException should have been thrown"); - } catch(DecoderException e) { - // Expected. Move on - } - try { - qcodec.decode("=?UTF-8??stuff?="); - fail("DecoderException should have been thrown"); - } catch(DecoderException e) { - // Expected. Move on - } - try { - qcodec.decode("=?UTF-8?W?stuff?="); - fail("DecoderException should have been thrown"); - } catch(DecoderException e) { - // Expected. Move on - } - } - public void testEncodeStringWithNull() throws Exception { QCodec qcodec = new QCodec(); String test = null; @@ -219,4 +191,14 @@ s = qcodec.decode(encoded2); assertEquals("Blanks decoding with the Q codec test", plain, s); } + + + public void testLetUsMakeCloverHappy() throws Exception { + QCodec qcodec = new QCodec(); + qcodec.setEncodeBlanks(true); + assertTrue(qcodec.isEncodeBlanks()); + qcodec.setEncodeBlanks(false); + assertFalse(qcodec.isEncodeBlanks()); + } + } 1.2 +7 -35 jakarta-commons/codec/src/test/org/apache/commons/codec/net/BCodecTest.java Index: BCodecTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/codec/src/test/org/apache/commons/codec/net/BCodecTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- BCodecTest.java 29 Mar 2004 23:04:09 -0000 1.1 +++ BCodecTest.java 9 Apr 2004 21:40:26 -0000 1.2 @@ -48,6 +48,12 @@ return buffer.toString(); } + public void testNullInput() throws Exception { + BCodec bcodec = new BCodec(); + assertNull(bcodec.doDecoding(null)); + assertNull(bcodec.doEncoding(null)); + } + public void testUTF8RoundTrip() throws Exception { String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); @@ -76,40 +82,6 @@ assertNull("Null string B decoding test", bcodec.decode((String) null)); } - public void testDecodeInvalid() throws Exception { - BCodec bcodec = new BCodec(); - try { - bcodec.decode("whatever"); - fail("DecoderException should have been thrown"); - } catch (DecoderException e) { - // Expected. Move on - } - try { - bcodec.decode("=?UTF-8?B?stuff"); - fail("DecoderException should have been thrown"); - } catch (DecoderException e) { - // Expected. Move on - } - try { - bcodec.decode("=??B?stuff?="); - fail("DecoderException should have been thrown"); - } catch (DecoderException e) { - // Expected. Move on - } - try { - bcodec.decode("=?UTF-8??stuff?="); - fail("DecoderException should have been thrown"); - } catch (DecoderException e) { - // Expected. Move on - } - try { - bcodec.decode("=?UTF-8?W?stuff?="); - fail("DecoderException should have been thrown"); - } catch (DecoderException e) { - // Expected. Move on - } - } - public void testEncodeStringWithNull() throws Exception { BCodec bcodec = new BCodec(); String test = null; @@ -152,7 +124,7 @@ // Exception expected, test segment passes. } try { - bcodec.decode("=?NONSENSE?Q?Hello there!?="); + bcodec.decode("=?NONSENSE?B?Hello there!?="); fail("We set the encoding to a bogus NONSENSE value, this shouldn't have worked."); } catch (DecoderException ee) { // Exception expected, test segment passes. 1.1 jakarta-commons/codec/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java Index: RFC1522CodecTest.java =================================================================== /* * Copyright 2001-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.commons.codec.net; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import junit.framework.TestCase; /** * RFC 1522 compliant codec test cases * * @author Oleg Kalnichevski */ public class RFC1522CodecTest extends TestCase { public RFC1522CodecTest(String name) { super(name); } class RFC1522TestCodec extends RFC1522Codec { protected byte[] doDecoding(byte[] bytes) throws DecoderException { return bytes; } protected byte[] doEncoding(byte[] bytes) throws EncoderException { return bytes; } protected String getEncoding() { return "T"; } } public void testNullInput() throws Exception { RFC1522TestCodec testcodec = new RFC1522TestCodec(); assertNull(testcodec.decodeText(null)); assertNull(testcodec.encodeText(null, "UTF-8")); } public void testDecodeInvalid() throws Exception { RFC1522TestCodec testcodec = new RFC1522TestCodec(); try { testcodec.decodeText("whatever"); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=?stuff?="); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=?UTF-8?stuff?="); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=?UTF-8?T?stuff"); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=??T?stuff?="); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=?UTF-8??stuff?="); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } try { testcodec.decodeText("=?UTF-8?W?stuff?="); fail("DecoderException should have been thrown"); } catch(DecoderException e) { // Expected. Move on } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org