1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.io.function; 19 20 import java.io.IOException; 21 import java.io.UncheckedIOException; 22 import java.nio.file.Path; 23 import java.nio.file.Paths; 24 import java.util.function.Predicate; 25 26 /** 27 * Test fixtures for this package. 28 */ 29 class TestConstants { 30 31 static final Path ABS_PATH_A = Paths.get("LICENSE.txt").toAbsolutePath(); 32 33 static final Path ABS_PATH_B = Paths.get("NOTICE.txt").toAbsolutePath(); 34 35 static IOBiConsumer<Object, Object> THROWING_IO_BI_CONSUMER = (t, u) -> throwIOException(); 36 37 static IOBiFunction<Object, Object, Object> THROWING_IO_BI_FUNCTION = (t, u) -> throwIOException(); 38 39 static IOBinaryOperator<?> THROWING_IO_BINARY_OPERATOR = (t, u) -> throwIOException(); 40 41 static IOComparator<Object> THROWING_IO_COMPARATOR = (t, u) -> throwIOException(); 42 43 static IOConsumer<Object> THROWING_IO_CONSUMER = t -> throwIOException(); 44 45 static IOFunction<Object, Object> THROWING_IO_FUNCTION = t -> throwIOException(); 46 47 static IOIntSupplier THROWING_IO_INT_SUPPLIER = TestConstants::throwIOException; 48 49 static IOLongSupplier THROWING_IO_LONG_SUPPLIER = TestConstants::throwIOException; 50 51 static IOPredicate<Object> THROWING_IO_PREDICATE = t -> throwIOException(); 52 53 static IOQuadFunction<Object, Object, Object, Object, Object> THROWING_IO_QUAD_FUNCTION = (t, u, v, w) -> throwIOException(); 54 55 static IORunnable THROWING_IO_RUNNABLE = TestConstants::throwIOException; 56 57 static IOSupplier<Object> THROWING_IO_SUPPLIER = TestConstants::throwIOException; 58 59 static IOTriConsumer<Object, Object, Object> THROWING_IO_TRI_CONSUMER = (t, u, v) -> throwIOException(); 60 61 static IOTriFunction<Object, Object, Object, Object> THROWING_IO_TRI_FUNCTION = (t, u, v) -> throwIOException(); 62 63 static IOUnaryOperator<?> THROWING_IO_UNARY_OPERATOR = t -> throwIOException(); 64 65 static Predicate<Object> THROWING_PREDICATE = t -> { 66 throw new UncheckedIOException(new IOException("Failure")); 67 }; 68 throwIOException()69 static <T> T throwIOException() throws IOException { 70 return throwIOException("Failure"); 71 } 72 throwIOException(final String message)73 static <T> T throwIOException(final String message) throws IOException { 74 throw new IOException(message); 75 } 76 throwRuntimeException(final String message)77 static <T> T throwRuntimeException(final String message) { 78 throw new RuntimeException(message); 79 } 80 81 } 82