/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.shardingproxy.backend.jdbc.datasource;

import lombok.SneakyThrows;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class JDBCClassDetermineTest {
    
    private JDBCClassDetermine jdbcClassDetermine = new JDBCClassDetermine();
    
    @Test
    public void assertMySQLUrl() {
        assertEquals("com.mysql.jdbc.Driver", jdbcClassDetermine.getDriverClassName("jdbc:mysql://localhost:3306/demo_ds_master"));
    }
    
    @Test
    public void assertPostgreSQLUrl() {
        assertEquals("org.postgresql.Driver", jdbcClassDetermine.getDriverClassName("jdbc:postgresql://db.psql:5432/postgres"));
    }
    
    @Test(expected = UnsupportedOperationException.class)
    @SneakyThrows
    public void assertFailedUrl() {
        assertEquals("com.mysql.jdbc.Driver", jdbcClassDetermine.getDriverClassName("jdbc:oracle://db.psql:5432/postgres"));
    }
    
    @Test(expected = UnsupportedOperationException.class)
    @SneakyThrows
    public void assertFailedUrl2() {
        assertEquals("com.mysql.jdbc.Driver", jdbcClassDetermine.getDriverClassName("xxxx"));
    }
}

@@ -731,16 +731,60 @@
 .Test;%0A%0A
+import static org.hamcrest.CoreMatchers.is;%0A
 import s
@@ -812,22 +812,20 @@
 t.assert
-Equals
+That
 ;%0A%0Apubli
@@ -1008,40 +1008,13 @@
 sert
-Equals(%22com.mysql.jdbc.Driver%22, 
+That(
 jdbc
@@ -1092,16 +1092,45 @@
 master%22)
+, is(%22com.mysql.jdbc.Driver%22)
 );%0A    %7D
@@ -1203,40 +1203,13 @@
 sert
-Equals(%22org.postgresql.Driver%22, 
+That(
 jdbc
@@ -1276,32 +1276,61 @@
 :5432/postgres%22)
+, is(%22org.postgresql.Driver%22)
 );%0A    %7D%0A    %0A  
@@ -1457,40 +1457,13 @@
 sert
-Equals(%22com.mysql.jdbc.Driver%22, 
+That(
 jdbc
@@ -1534,16 +1534,45 @@
 stgres%22)
+, is(%22com.mysql.jdbc.Driver%22)
 );%0A    %7D
@@ -1708,40 +1708,13 @@
 sert
-Equals(%22com.mysql.jdbc.Driver%22, 
+That(
 jdbc
@@ -1754,16 +1754,45 @@
 (%22xxxx%22)
+, is(%22com.mysql.jdbc.Driver%22)
 );%0A    %7D

replace assertEqual with assertThat