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
14 changes: 9 additions & 5 deletions src/test/java/com/ibatis/common/beans/BadBeanTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2023 the original author or authors.
* Copyright 2004-2025 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.
Expand All @@ -24,16 +24,20 @@

import org.junit.jupiter.api.Test;

import badbeans.*;
import badbeans.BeanWithDifferentTypeGetterSetter;
import badbeans.BeanWithDifferentTypeOverloadedSetter;
import badbeans.BeanWithNoGetterOverloadedSetters;
import badbeans.BeanWithOverloadedSetter;
import badbeans.GoodBean;

class BadBeanTest {

private static final String PROPNAME = "value";
private static final Object STRING_VALUE = "1";
private static final Object INT_VALUE = Integer.valueOf(1);
private static final Object[] NO_VALUE = new Object[] {};
private static final Object[] STRING_PARAMS = new Object[] { STRING_VALUE };
private static final Object[] INT_PARAMS = new Object[] { INT_VALUE };
private static final Object[] NO_VALUE = {};
private static final Object[] STRING_PARAMS = { STRING_VALUE };
private static final Object[] INT_PARAMS = { INT_VALUE };

@Test
void testShouldSuccessfullyGetAndSetValueOnGoodBean() throws Exception {
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/com/ibatis/common/beans/JavaBeanProbeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -81,8 +81,7 @@ private Probe getProbe(Object o) {
}

private TestBean getBean() {
TestBean returnValue = new TestBean();
return returnValue;
return new TestBean();
}

public class TestBean {
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/com/ibatis/common/resources/ResourcesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -88,9 +88,8 @@ void testGetResourceURLString() {
void testGetResourceURLClassLoaderString() {
String resourceName;
URL url;
ClassLoader classLoader;
ClassLoader classLoader = new TestCL(this.getClass().getClassLoader());

classLoader = new TestCL(this.getClass().getClassLoader());
resourceName = "java/lang/String.class";
url = null;
isUsingPrivateClassloader = false;
Expand Down Expand Up @@ -124,9 +123,8 @@ void testGetResourceURLClassLoaderString() {
@Test
void testGetResourceAsStreamString() {
InputStream inputStream;
String resourceName;
String resourceName = "java/lang/String.class";

resourceName = "java/lang/String.class";
inputStream = null;
try {
inputStream = Resources.getResourceAsStream(resourceName);
Expand All @@ -153,9 +151,8 @@ void testGetResourceAsStreamString() {
void testGetResourceAsStreamClassLoaderString() {
InputStream inputStream;
String resourceName;
ClassLoader classLoader;
ClassLoader classLoader = new TestCL(this.getClass().getClassLoader());

classLoader = new TestCL(this.getClass().getClassLoader());
resourceName = "java/lang/String.class";
inputStream = null;
isUsingPrivateClassloader = false;
Expand Down
9 changes: 7 additions & 2 deletions src/test/java/com/ibatis/sqlmap/BaseSqlMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand All @@ -25,7 +25,12 @@

import java.io.Reader;
import java.sql.Connection;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.sql.DataSource;

Expand Down
42 changes: 20 additions & 22 deletions src/test/java/com/ibatis/sqlmap/BatchTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2023 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -44,7 +44,7 @@ void setUp() throws Exception {

@Test
void testExecutebatchDetailed() {
List<Account> accountList1 = new ArrayList<Account>();
List<Account> accountList1 = new ArrayList<>();
Account account = new Account();
account.setId(10);
account.setFirstName("fred");
Expand Down Expand Up @@ -80,7 +80,7 @@ void testExecutebatchDetailed() {
account.setEmailAddress("fred.flintstone@gmail.com");
accountList1.add(account);

List<Account> accountList2 = new ArrayList<Account>();
List<Account> accountList2 = new ArrayList<>();
account = new Account();
account.setId(15);
account.setFirstName("fred");
Expand Down Expand Up @@ -114,8 +114,8 @@ void testExecutebatchDetailed() {
sqlMap.startBatch();

// insert 5 accounts
for (int i = 0; i < accountList1.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList1.get(i));
for (Account element : accountList1) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

// update 1 account
Expand All @@ -128,8 +128,8 @@ void testExecutebatchDetailed() {
sqlMap.update("updateAccountViaInlineParameters", account);

// insert 4 accounts
for (int i = 0; i < accountList2.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList2.get(i));
for (Account element : accountList2) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

List<?> results = sqlMap.executeBatchDetailed();
Expand All @@ -146,9 +146,7 @@ void testExecutebatchDetailed() {
br = (BatchResult) results.get(2);
assertEquals(4, br.getUpdateCounts().length);

} catch (BatchException e) {
fail(e.getMessage());
} catch (SQLException e) {
} catch (BatchException | SQLException e) {
fail(e.getMessage());
} finally {
try {
Expand All @@ -161,7 +159,7 @@ void testExecutebatchDetailed() {

@Test
void testExecutebatchDetailedWithError() {
List<Account> accountList1 = new ArrayList<Account>();
List<Account> accountList1 = new ArrayList<>();
Account account = new Account();
account.setId(10);
account.setFirstName("fred");
Expand Down Expand Up @@ -197,7 +195,7 @@ void testExecutebatchDetailedWithError() {
account.setEmailAddress("fred.flintstone@gmail.com");
accountList1.add(account);

List<Account> accountList2 = new ArrayList<Account>();
List<Account> accountList2 = new ArrayList<>();
account = new Account();
account.setId(15);
account.setFirstName("fred");
Expand Down Expand Up @@ -231,8 +229,8 @@ void testExecutebatchDetailedWithError() {
sqlMap.startBatch();

// insert 5 accounts
for (int i = 0; i < accountList1.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList1.get(i));
for (Account element : accountList1) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

// update 1 account
Expand Down Expand Up @@ -267,8 +265,8 @@ void testExecutebatchDetailedWithError() {
sqlMap.update("updateAccountViaInlineParameters", account);

// insert 4 accounts
for (int i = 0; i < accountList2.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList2.get(i));
for (Account element : accountList2) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

sqlMap.executeBatchDetailed();
Expand Down Expand Up @@ -297,7 +295,7 @@ void testExecutebatchDetailedWithError() {

@Test
void testExecutebatch() {
List<Account> accountList1 = new ArrayList<Account>();
List<Account> accountList1 = new ArrayList<>();
Account account = new Account();
account.setId(10);
account.setFirstName("fred");
Expand Down Expand Up @@ -333,7 +331,7 @@ void testExecutebatch() {
account.setEmailAddress("fred.flintstone@gmail.com");
accountList1.add(account);

List<Account> accountList2 = new ArrayList<Account>();
List<Account> accountList2 = new ArrayList<>();
account = new Account();
account.setId(15);
account.setFirstName("fred");
Expand Down Expand Up @@ -367,8 +365,8 @@ void testExecutebatch() {
sqlMap.startBatch();

// insert 5 accounts
for (int i = 0; i < accountList1.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList1.get(i));
for (Account element : accountList1) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

// update 1 account
Expand All @@ -381,8 +379,8 @@ void testExecutebatch() {
sqlMap.update("updateAccountViaInlineParameters", account);

// insert 4 accounts
for (int i = 0; i < accountList2.size(); i++) {
sqlMap.insert("insertAccountViaInlineParameters", accountList2.get(i));
for (Account element : accountList2) {
sqlMap.insert("insertAccountViaInlineParameters", element);
}

int results = sqlMap.executeBatch();
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/ibatis/sqlmap/CacheStatementTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -201,7 +201,7 @@ void testFlushDataCacheOnExecuteInBatchWithTx() throws SQLException {
@Test
void testMappedStatementQueryWithThreadedCache() throws SQLException {

Map<String, Object> results = new HashMap<String, Object>();
Map<String, Object> results = new HashMap<>();

TestCacheThread.startThread(sqlMap, results, "getCachedAccountsViaResultMap");
Integer firstId = (Integer) results.get("id");
Expand All @@ -228,7 +228,7 @@ void testMappedStatementQueryWithThreadedCache() throws SQLException {
@Test
void testMappedStatementQueryWithThreadedReadWriteCache() throws SQLException {

Map<String, Object> results = new HashMap<String, Object>();
Map<String, Object> results = new HashMap<>();

TestCacheThread.startThread(sqlMap, results, "getRWCachedAccountsViaResultMap");
Integer firstId = (Integer) results.get("id");
Expand Down Expand Up @@ -295,9 +295,9 @@ public void run() {
try {
SqlMapSession session = sqlMap.openSession();
List<?> list = session.queryForList(statementName, null);
int firstId = System.identityHashCode(list);
System.identityHashCode(list);
list = session.queryForList(statementName, null);
int secondId = System.identityHashCode(list);
System.identityHashCode(list);
// assertEquals(firstId, secondId);
results.put("id", Integer.valueOf(System.identityHashCode(list)));
results.put("list", list);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/ibatis/sqlmap/ComplexTypeTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -41,7 +41,7 @@ void setUp() throws Exception {
void testMapBeanMap() throws Exception {
Map<String, ComplexBean> map = new HashMap<>();
ComplexBean bean = new ComplexBean();
bean.setMap(new HashMap<String, Integer>());
bean.setMap(new HashMap<>());
bean.getMap().put("id", Integer.valueOf(1));
map.put("bean", bean);

Expand Down
18 changes: 9 additions & 9 deletions src/test/java/com/ibatis/sqlmap/DynamicPrependTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2025 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.
Expand Down Expand Up @@ -40,15 +40,15 @@ void setUp() throws Exception {

@Test
void testIterateWithPrepend1() throws SQLException {
List<Integer> params = Arrays.asList(new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) });
List<Integer> params = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
List<?> list = sqlMap.queryForList("dynamicIterateWithPrepend1", params);
assertAccount1((Account) list.get(0));
assertEquals(3, list.size());
}

@Test
void testIterateWithPrepend2() throws SQLException {
List<Integer> params = Arrays.asList(new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) });
List<Integer> params = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
List<?> list = sqlMap.queryForList("dynamicIterateWithPrepend2", params);
assertAccount1((Account) list.get(0));
assertEquals(3, list.size());
Expand All @@ -67,7 +67,7 @@ void testIterateWithPrepend2b() throws SQLException {
account3 = new Account();
account3.setId(3);

List<Account> params = Arrays.asList(new Account[] { account1, account2, account3 });
List<Account> params = Arrays.asList(account1, account2, account3);
List<?> list = sqlMap.queryForList("dynamicIterateWithPrepend2b", params);
assertAccount1((Account) list.get(0));
assertEquals(3, list.size());
Expand All @@ -86,7 +86,7 @@ void testIterateWithPrepend2c() throws SQLException {
account3 = new Account();
account3.setId(3);

List<?> params = Arrays.asList(new Account[] { account1, account2, account3 });
List<?> params = Arrays.asList(account1, account2, account3);

MyBean x = new MyBean();
x.setMyList(params);
Expand All @@ -102,7 +102,7 @@ void testIterateWithPrepend2c() throws SQLException {
@Test
void testIterateWithPrepend2d() throws SQLException {

List<?> params = Arrays.asList(new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) });
List<?> params = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));

MyBean x = new MyBean();
x.setMyList(params);
Expand All @@ -118,7 +118,7 @@ void testIterateWithPrepend2d() throws SQLException {
@Test
void testIterateWithPrepend2e() throws SQLException {

Object[] params = new Object[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };
Object[] params = { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) };

MyBean x = new MyBean();
x.setMyArray(params);
Expand All @@ -134,7 +134,7 @@ void testIterateWithPrepend2e() throws SQLException {
@Test
void testIterateWithPrepend2f() throws SQLException {

int[] params = new int[] { 1, 2, 3 };
int[] params = { 1, 2, 3 };

MyBean x = new MyBean();
x.setIntArray(params);
Expand All @@ -149,7 +149,7 @@ void testIterateWithPrepend2f() throws SQLException {

@Test
void testIterateWithPrepend3() throws SQLException {
List<Integer> params = Arrays.asList(new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) });
List<Integer> params = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
List<?> list = sqlMap.queryForList("dynamicIterateWithPrepend3", params);
assertAccount1((Account) list.get(0));
assertEquals(3, list.size());
Expand Down
Loading
Loading