Skip to content

Commit

Permalink
Add test cases on TimestampLoadingSQLProvider (#33042)
Browse files Browse the repository at this point in the history
* Add test cases on TimestampLoadingSQLProvider

* Add test cases on TimestampLoadingSQLProvider
  • Loading branch information
terrymanu authored Sep 28, 2024
1 parent 619c8dd commit 50896d1
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.shardingsphere.timeservice.type.database.provider.dialect;

import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class MySQLTimestampLoadingSQLProviderTest {

private TimestampLoadingSQLProvider provider;

@BeforeEach
void setUp() {
provider = TypedSPILoader.getService(TimestampLoadingSQLProvider.class, TypedSPILoader.getService(DatabaseType.class, "MySQL"));
}

@Test
void assertGetTimestampLoadingSQL() {
assertThat(provider.getTimestampLoadingSQL(), is("SELECT NOW()"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.shardingsphere.timeservice.type.database.provider.dialect;

import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class OracleTimestampLoadingSQLProviderTest {

private TimestampLoadingSQLProvider provider;

@BeforeEach
void setUp() {
provider = TypedSPILoader.getService(TimestampLoadingSQLProvider.class, TypedSPILoader.getService(DatabaseType.class, "Oracle"));
}

@Test
void assertGetTimestampLoadingSQL() {
assertThat(provider.getTimestampLoadingSQL(), is("SELECT sysdate FROM DUAL"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.shardingsphere.timeservice.type.database.provider.dialect;

import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class PostgreSQLTimestampLoadingSQLProviderTest {

private TimestampLoadingSQLProvider provider;

@BeforeEach
void setUp() {
provider = TypedSPILoader.getService(TimestampLoadingSQLProvider.class, TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"));
}

@Test
void assertGetTimestampLoadingSQL() {
assertThat(provider.getTimestampLoadingSQL(), is("SELECT NOW()"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.shardingsphere.timeservice.type.database.provider.dialect;

import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.timeservice.type.database.provider.TimestampLoadingSQLProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class SQLServerTimestampLoadingSQLProviderTest {

private TimestampLoadingSQLProvider provider;

@BeforeEach
void setUp() {
provider = TypedSPILoader.getService(TimestampLoadingSQLProvider.class, TypedSPILoader.getService(DatabaseType.class, "SQLServer"));
}

@Test
void assertGetTimestampLoadingSQL() {
assertThat(provider.getTimestampLoadingSQL(), is("SELECT GETDATE()"));
}
}

0 comments on commit 50896d1

Please sign in to comment.