IoUtilTest.groovy revision 103f7abd5ad538f55215292e1460d8ef3bc46a4e
1/* 2 * Copyright 2008 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.mockftpserver.core.util 17 18import java.io.ByteArrayInputStream 19import java.io.InputStream 20 21import org.apache.log4j.Logger 22import org.mockftpserver.test.AbstractGroovyTest 23 24/** 25 * Tests for the IoUtil class 26 * 27 * @version $Revision: $ - $Date: $ 28 * 29 * @author Chris Mair 30 */ 31public class IoUtilTest extends AbstractGroovyTest { 32 33 private static final LOG = Logger.getLogger(IoUtilTest) 34 35 /** 36 * Test the readBytes() method 37 */ 38 void testReadBytes() { 39 final byte[] BYTES = "abc 123 %^&".getBytes() 40 InputStream input = new ByteArrayInputStream(BYTES) 41 assert IoUtil.readBytes(input) == BYTES 42 } 43 44 /** 45 * Test the readBytes() method, passing in a null 46 */ 47 void testReadBytes_Null() { 48 shouldFailWithMessageContaining("input") { IoUtil.readBytes(null) } 49 } 50 51} 52