001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.chain.web.javax; 018 019import static org.junit.jupiter.api.Assertions.assertEquals; 020import static org.junit.jupiter.api.Assertions.assertNotNull; 021 022import org.junit.jupiter.api.Test; 023 024/** 025 * Test case for {@link org.apache.commons.chain.web.javax.ChainResources} 026 */ 027public class ChainResourcesTestCase { 028 029 // ----------------------------------------------------- Instance Variables 030 031 protected TestData[] data = new TestData[] { 032 new TestData("a,b,c", new String[] {"a", "b", "c"}), 033 new TestData("a , b , c ", new String[] {"a", "b", "c"}), 034 new TestData("a,\tb,\tc ", new String[] {"a", "b", "c"}), 035 new TestData("\na,\nb,\nc\n", new String[] {"a", "b", "c"}), 036 new TestData("a,,b,c ", new String[] {"a", "b", "c"}), 037 new TestData(",a,b,,c,,", new String[] {"a", "b", "c"}), 038 new TestData(null, new String[] {}), 039 new TestData("", new String[] {}), 040 new TestData(",", new String[] {}), 041 new TestData(",,", new String[] {}) 042 }; 043 044 // ----------------------------------------------------------- Constructors 045 046 /** 047 * The Default-Constructor for this class. 048 */ 049 public ChainResourcesTestCase() { 050 } 051 052 // ------------------------------------------------ Individual Test Methods 053 054 @Test 055 public void testGetPaths() throws Exception { 056 for (TestData datum : data) { 057 String[] expected = datum.getExpected(); 058 String[] actual = ChainResources.getResourcePaths(datum.getInput()); 059 060 assertNotNull(actual); 061 assertEquals(expected.length, actual.length); 062 for (int j = 0; j < actual.length; j++) { 063 assertEquals(expected[j], actual[j]); 064 } 065 } 066 } 067 068 // ---------------------------------------------------------- Inner classes 069 070 /** 071 * Container for test data for one test 072 */ 073 public static final class TestData { 074 private String input; 075 private String[] expected; 076 public TestData(String input, String[] expected) { 077 this.input = input; 078 this.expected = expected; 079 } 080 public String getInput() { 081 return input; 082 } 083 public String[] getExpected() { 084 return expected; 085 } 086 } 087}