Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
* @see BeanWrapper
*/
class BeanWrapperUnitTest extends ObjectWrapperBaseTest {
class BeanWrapperUnitTest extends ObjectWrapperBase {

private RichType richType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @see CollectionWrapper
*/
@ExtendWith(MockitoExtension.class)
class CollectionWrapperUnitTest extends ObjectWrapperBaseTest {
class CollectionWrapperUnitTest extends ObjectWrapperBase {

@Mock
private Collection<Object> collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* @see MapWrapper
*/
class MapWrapperUnitTest extends ObjectWrapperBaseTest {
class MapWrapperUnitTest extends ObjectWrapperBase {

@Mock
private Map<String, Object> map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @see ObjectWrapper
*/
@ExtendWith(MockitoExtension.class)
abstract class ObjectWrapperBaseTest {
abstract class ObjectWrapperBase {

abstract void shouldGet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package org.apache.ibatis.scripting.xmltags;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand All @@ -27,6 +23,11 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


/**
* <pre>{@code
* SELECT *
Expand All @@ -46,10 +47,9 @@
* }</pre>
*
* @author <a href="1181963012mw@gmail.com">mawen12</a>
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#choose-when-otherwise">choose</a>
*/
class ChooseSqlNodeTest extends SqlNodeTest {
class ChooseSqlNodeTest extends SqlNodeBase {

private static final String FIRST_TEXT = " AND title like #{title}";
private static final String SECOND_TEXT = " AND author_name like #{author.username}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package org.apache.ibatis.scripting.xmltags;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand All @@ -27,6 +23,13 @@
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;


/**
* <pre>{@code
* SELECT *
Expand All @@ -39,10 +42,9 @@
* }</pre>
*
* @author <a href="1181963012mw@gmail.com">mawen12</a>
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#foreach">foreach</a>
*/
class ForEachSqlNodeTest extends SqlNodeTest {
class ForEachSqlNodeTest extends SqlNodeBase {

private SqlNode sqlNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;

import java.util.HashMap;

Expand All @@ -35,7 +37,7 @@
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#if">if</a>
*/
class IfSqlNodeTest extends SqlNodeTest {
class IfSqlNodeTest extends SqlNodeBase {

private static final String CONDITION = "title != null";
private static final String TEXT = "AND title like #{title}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
*/
package org.apache.ibatis.scripting.xmltags;

import static org.mockito.Mockito.verify;

import java.util.Arrays;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.mockito.Mockito.verify;


/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
*/
class MixedSqlNodeTest extends SqlNodeTest {
class MixedSqlNodeTest extends SqlNodeBase {

private static final String FIRST_TEXT = "abc";
private static final String SECOND_TEXT = "bcd";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#trim-where-set">trim-where-set</a>
*/
class SetSqlNodeTest extends SqlNodeTest {
class SetSqlNodeTest extends SqlNodeBase {

private static final String FIRST_TEXT = " username = #{username},";
private static final String SECOND_TEXT = " password = #{password}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
* @see SqlNode
*/
@ExtendWith(MockitoExtension.class)
abstract class SqlNodeTest {
abstract class SqlNodeBase {

@Mock
protected Configuration configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
*/
class StaticTextSqlNodeTest extends SqlNodeTest {
class StaticTextSqlNodeTest extends SqlNodeBase {

private static final String TEXT = "select 1 from dual";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
*/
class TextSqlNodeTest extends SqlNodeTest {
class TextSqlNodeTest extends SqlNodeBase {

private static final String TEXT = "select 1 from dual";
private static final String DYNAMIC_TEXT = "select * from user where id = ${id}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#trim-where-set">trim-where-set</a>
*/
class TrimSqlNodeTest extends SqlNodeTest {
class TrimSqlNodeTest extends SqlNodeBase {

private static final String FIRST_TEXT = " AND id = #{id}";
private static final String SECOND_TEXT = " AND name = #{name}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#bind">bind</a>
*/
class VarDeclSqlNodeTest extends SqlNodeTest {
class VarDeclSqlNodeTest extends SqlNodeBase {

private SqlNode sqlNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*
* @see <a href="https://mybatis.org/mybatis-3/dynamic-sql.html#trim-where-set">trim-where-set</a>
*/
class WhereSqlNodeTest extends SqlNodeTest {
class WhereSqlNodeTest extends SqlNodeBase {

private static final String FIRST_TEXT = " AND id = #{id}";
private static final String SECOND_TEXT = " AND name = #{name}";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2009-2024 the original author or authors.
*
* 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
*
* https://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.ibatis.transaction;

import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.lang.reflect.Field;
import java.sql.SQLException;

/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
* @see TransactionFactory
*/
@ExtendWith(MockitoExtension.class)
public abstract class TransactionFactoryBase {

public abstract void shouldSetProperties() throws Exception;

public abstract void shouldNewTransactionWithConnection() throws SQLException;

public abstract void shouldNewTransactionWithDataSource() throws Exception;

public static Object getValue(Field field, Object object) throws Exception {
field.setAccessible(true);
return field.get(object);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2009-2024 the original author or authors.
*
* 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
*
* https://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.ibatis.transaction.jdbc;

import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.sql.SQLException;

/**
* @author <a href="1181963012mw@gmail.com">mawen12</a>
* @see JdbcTransaction
*/
@ExtendWith(MockitoExtension.class)
abstract class JdbcTransactionBase {

abstract void shouldGetConnection() throws SQLException;

abstract void shouldCommitWhenConnectionIsNotAutoCommit() throws SQLException;

abstract void shouldAutoCommitWhenConnectionIsAutoCommit() throws SQLException;

abstract void shouldRollbackWhenConnectionIsNotAutoCommit() throws SQLException;

abstract void shouldAutoRollbackWhenConnectionIsAutoCommit() throws SQLException;

abstract void shouldCloseAndSetAutoCommitWhenConnectionIsNotAutoCommit() throws SQLException;

abstract void shouldCloseAndNotSetAutoCommitWhenConnectionIsAutoCommit() throws SQLException;

abstract void shouldReturnNullWhenGetTimeout() throws SQLException;
}
Loading
Loading