Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A81A8C032 for ; Thu, 9 Aug 2012 08:53:55 +0000 (UTC) Received: (qmail 60979 invoked by uid 500); 9 Aug 2012 08:53:55 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 60888 invoked by uid 500); 9 Aug 2012 08:53:53 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 60851 invoked by uid 99); 9 Aug 2012 08:53:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2012 08:53:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2012 08:53:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 302E623888E3 for ; Thu, 9 Aug 2012 08:53:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1371095 - /httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java Date: Thu, 09 Aug 2012 08:53:04 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120809085304.302E623888E3@eris.apache.org> Author: olegk Date: Thu Aug 9 08:53:03 2012 New Revision: 1371095 URL: http://svn.apache.org/viewvc?rev=1371095&view=rev Log: Added unit tests for Args utils Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java (with props) Added: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java?rev=1371095&view=auto ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java (added) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java Thu Aug 9 08:53:03 2012 @@ -0,0 +1,161 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.util; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +/** + * Unit tests for {@link Args}. + */ +public class TestArgs { + + @Test + public void testArgCheckPass() { + Args.check(true, "All is well"); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgCheckFail() { + Args.check(false, "Oopsie"); + } + + @Test + public void testArgNotNullPass() { + String stuff = "stuff"; + Assert.assertSame(stuff, Args.notNull(stuff, "Stuff")); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgNotNullFail() { + Args.notNull(null, "Stuff"); + } + + @Test + public void testArgNotEmptyPass() { + String stuff = "stuff"; + Assert.assertSame(stuff, Args.notEmpty(stuff, "Stuff")); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgNotEmptyFail1() { + Args.notEmpty((String) null, "Stuff"); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgNotEmptyFail2() { + Args.notEmpty("", "Stuff"); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgNotEmptyFail3() { + Args.notEmpty(" \t \n\r", "Stuff"); + } + + @Test + public void testArgCollectionNotEmptyPass() { + List list = Arrays.asList("stuff"); + Assert.assertSame(list, Args.notEmpty(list, "List")); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgCollectionNotEmptyFail1() { + Args.notEmpty((List) null, "List"); + } + + @Test(expected=IllegalArgumentException.class) + public void testArgCollectionNotEmptyFail2() { + Args.notEmpty(Collections.emptyList(), "List"); + } + + @Test + public void testPositiveIntPass() { + Assert.assertEquals(1, Args.positive(1, "Number")); + } + + @Test(expected=IllegalArgumentException.class) + public void testPositiveIntFail1() { + Args.positive(-1, "Number"); + } + + @Test(expected=IllegalArgumentException.class) + public void testPositiveIntFail2() { + Args.positive(0, "Number"); + } + + @Test + public void testPositiveLongPass() { + Assert.assertEquals(1L, Args.positive(1L, "Number")); + } + + @Test(expected=IllegalArgumentException.class) + public void testPositiveLongFail1() { + Args.positive(-1L, "Number"); + } + + @Test(expected=IllegalArgumentException.class) + public void testPositiveLongFail2() { + Args.positive(0L, "Number"); + } + + @Test + public void testNotNegativeIntPass1() { + Assert.assertEquals(1, Args.notNegative(1, "Number")); + } + + @Test + public void testNotNegativeIntPass2() { + Assert.assertEquals(0, Args.notNegative(0, "Number")); + } + + @Test(expected=IllegalArgumentException.class) + public void testNotNegativeIntFail1() { + Args.notNegative(-1, "Number"); + } + + @Test + public void testNotNegativeLongPass1() { + Assert.assertEquals(1L, Args.notNegative(1L, "Number")); + } + + @Test + public void testNotNegativeLongPass2() { + Assert.assertEquals(0L, Args.notNegative(0L, "Number")); + } + + @Test(expected=IllegalArgumentException.class) + public void testNotNegativeLongFail1() { + Args.notNegative(-1L, "Number"); + } + +} Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestArgs.java ------------------------------------------------------------------------------ svn:mime-type = text/plain