Skip to content

Commit 08635fd

Browse files
committed
test case code refactoring (#1901)
1 parent 95b8ec9 commit 08635fd

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/test/java/org/apache/ibatis/builder/SqlSourceBuilderTest.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,22 @@
1515
*/
1616
package org.apache.ibatis.builder;
1717

18-
import java.io.Reader;
19-
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
20-
import org.apache.ibatis.io.Resources;
2118
import org.apache.ibatis.mapping.BoundSql;
2219
import org.apache.ibatis.mapping.SqlSource;
2320
import org.apache.ibatis.session.Configuration;
2421
import org.junit.jupiter.api.Assertions;
25-
import org.junit.jupiter.api.BeforeAll;
22+
import org.junit.jupiter.api.BeforeEach;
2623
import org.junit.jupiter.api.Test;
2724

2825
public class SqlSourceBuilderTest {
2926

3027
private static Configuration configuration;
3128
private static SqlSourceBuilder sqlSourceBuilder;
32-
String sqlFromXml = "SELECT * \n FROM user\n WHERE user_id = 1";
29+
String sqlFromXml = "\\t\\n\\n SELECT * \\n FROM user\\n \\t WHERE user_id = 1\\n\\t ";
3330

34-
@BeforeAll
35-
static void setUp() throws Exception {
36-
// create an SqlSessionFactory
37-
try (Reader reader = Resources
38-
.getResourceAsReader("org/apache/ibatis/submitted/empty_row/mybatis-config.xml")) {
39-
XMLConfigBuilder parser = new XMLConfigBuilder(reader, null, null);
40-
configuration = parser.parse();
41-
}
31+
@BeforeEach
32+
void setUp() {
33+
configuration = new Configuration();
4234

4335
sqlSourceBuilder = new SqlSourceBuilder(configuration);
4436
}
@@ -53,10 +45,13 @@ void testMinifySqlEnabledIsFalse() {
5345

5446
@Test
5547
void testMinifySqlEnabledIsTrue() {
48+
String expected = "\\t\\n\\n SELECT * \\n FROM user\\n \\t WHERE user_id = 1\\n\\t";
49+
5650
configuration.setShrinkWhitespacesInSql(true);
5751
SqlSource sqlSource = sqlSourceBuilder.parse(sqlFromXml, null, null);
5852
BoundSql boundSql = sqlSource.getBoundSql(null);
5953
String actual = boundSql.getSql();
60-
Assertions.assertNotEquals(sqlFromXml, actual);
54+
55+
Assertions.assertEquals(expected, actual);
6156
}
6257
}

0 commit comments

Comments
 (0)