tom@9671: /* Copyright (C) 2020 by Bundesanstalt für Gewässerkunde tom@9671: * Software engineering by Intevation GmbH tom@9671: * tom@9671: * This file is Free Software under the GNU AGPL (>=v3) tom@9671: * and comes with ABSOLUTELY NO WARRANTY! Check out the tom@9671: * documentation coming with Dive4Elements River for details. tom@9671: */ tom@9671: tom@9671: import static org.junit.Assert.assertEquals; tom@9671: tom@9671: import org.junit.Test; tom@9671: tom@9671: import org.dive4elements.river.utils.MapUtils; tom@9671: tom@9671: public class MapUtilsTest { tom@9671: tom@9671: private static final String DRV_PG = "jdbc:postgresql:"; tom@9671: private static final String DRV_ORA = "jdbc:oracle:thin:"; tom@9671: tom@9671: private static final String USER = "d4euser"; tom@9671: private static final String PSWD = "d4epswd"; tom@9671: private static final String DB = "d4edb"; tom@9671: private static final String HOST = "d4ehost"; tom@9671: private static final String PORT = "2345"; tom@9671: tom@9671: private static final String PG_CON_SUFFIX = " sslmode=disable"; tom@9671: tom@9671: @Test tom@9671: public void hostPortNamedPG() { tom@9671: MapUtils mu = new MapUtils(); tom@9671: String con = MapUtils.getConnection( tom@9671: USER, PSWD, DRV_PG + "//" + HOST + ":" + PORT + "/" + DB); tom@9671: assertEquals( tom@9671: "dbname=" + DB tom@9671: + " host='" + HOST + "' user=" + USER + " port=" + PORT tom@9671: + " password='" + PSWD + "'" + PG_CON_SUFFIX, tom@9671: con); tom@9671: } tom@9671: tom@9671: @Test tom@9671: public void serviceNameORA() { tom@9671: MapUtils mu = new MapUtils(); tom@9671: String con = MapUtils.getConnection( tom@9671: USER, PSWD, DRV_ORA + "@//" + HOST + ":" + PORT + "/" + DB); tom@9671: assertEquals( tom@9671: USER + "/" + PSWD + "@" + HOST + ":" + PORT + "/" + DB, tom@9671: con); tom@9671: } tom@9671: }