001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014package org.gbif.utils.rs; 015 016import java.net.URL; 017 018import org.junit.jupiter.api.Test; 019 020import static org.junit.jupiter.api.Assertions.assertEquals; 021 022public class RsGbifOrgTest { 023 024 @Test 025 public void testUrl() throws Exception { 026 assertEquals( 027 new URL("http://rs.gbif.org/dictionaries/synonyms/f1.txt"), 028 RsGbifOrg.url("dictionaries", "synonyms", "f1.txt")); 029 assertEquals(new URL("http://rs.gbif.org/"), RsGbifOrg.url()); 030 assertEquals(new URL("http://rs.gbif.org/"), RsGbifOrg.url(null)); 031 assertEquals(new URL("http://rs.gbif.org/ aha "), RsGbifOrg.url(" aha ")); 032 } 033 034 @Test 035 public void testAuthorityUrl() throws Exception { 036 assertEquals( 037 new URL("http://rs.gbif.org/dictionaries/authority/f1.txt"), 038 RsGbifOrg.authorityUrl("f1.txt")); 039 assertEquals( 040 new URL("http://rs.gbif.org/dictionaries/authority"), RsGbifOrg.authorityUrl(null)); 041 assertEquals( 042 new URL("http://rs.gbif.org/dictionaries/authority/ aha "), 043 RsGbifOrg.authorityUrl(" aha ")); 044 } 045 046 @Test 047 public void testDictionaryUrl() throws Exception { 048 assertEquals( 049 new URL("http://rs.gbif.org/dictionaries/f1.txt"), RsGbifOrg.dictionaryUrl("f1.txt")); 050 assertEquals(new URL("http://rs.gbif.org/dictionaries"), RsGbifOrg.dictionaryUrl(null)); 051 assertEquals( 052 new URL("http://rs.gbif.org/dictionaries/ aha "), RsGbifOrg.dictionaryUrl(" aha ")); 053 } 054 055 @Test 056 public void testSynonymUrl() throws Exception { 057 assertEquals( 058 new URL("http://rs.gbif.org/dictionaries/synonyms/f1.txt"), RsGbifOrg.synonymUrl("f1.txt")); 059 assertEquals(new URL("http://rs.gbif.org/dictionaries/synonyms"), RsGbifOrg.synonymUrl(null)); 060 assertEquals( 061 new URL("http://rs.gbif.org/dictionaries/synonyms/ aha "), RsGbifOrg.synonymUrl(" aha ")); 062 } 063}