Skip to content

Commit 2f56fdf

Browse files
committed
Failing test for issue #61. This is a regression caused in 448 (see it
in gcode).
1 parent 9745e2b commit 2f56fdf

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

src/test/java/org/apache/ibatis/submitted/ognlstatic/Mapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
public interface Mapper {
1919

20-
User getUser(Integer id);
20+
User getUserStatic(Integer id);
21+
User getUserIfNode(String id);
2122

2223
}

src/test/java/org/apache/ibatis/submitted/ognlstatic/Mapper.xml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@
2020

2121
<mapper namespace="org.apache.ibatis.submitted.ognlstatic.Mapper">
2222

23-
<select id="getUser" resultType="org.apache.ibatis.submitted.ognlstatic.User">
24-
SELECT *
25-
FROM users
26-
<trim prefix="WHERE" prefixOverrides="AND |OR ">
27-
AND <foreach collection="{ (@org.apache.ibatis.submitted.ognlstatic.StaticClass@value) } " item="enum"
28-
open="name IN (" close=") " separator=", ">#{enum}</foreach>
29-
AND id = #{id}
30-
</trim>
31-
32-
</select>
23+
<select id="getUserStatic" resultType="org.apache.ibatis.submitted.ognlstatic.User">
24+
SELECT *
25+
FROM users
26+
<trim prefix="WHERE" prefixOverrides="AND |OR ">
27+
AND <foreach collection="{ (@org.apache.ibatis.submitted.ognlstatic.StaticClass@value) } " item="enum"
28+
open="name IN (" close=") " separator=", ">#{enum}</foreach>
29+
AND id = #{id}
30+
</trim>
31+
</select>
32+
33+
<select id="getUserIfNode" resultType="org.apache.ibatis.submitted.ognlstatic.User">
34+
select * from users
35+
<if test="value not in {null, ''}">
36+
where name = #{value}
37+
</if>
38+
</select>
3339

3440
</mapper>

src/test/java/org/apache/ibatis/submitted/ognlstatic/OgnlStaticTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
2626
import org.junit.Assert;
2727
import org.junit.BeforeClass;
28+
import org.junit.Ignore;
2829
import org.junit.Test;
2930

3031
public class OgnlStaticTest {
@@ -57,15 +58,28 @@ public static void setUp() throws Exception {
5758
* There are two parameter mappings but DefaulParameterHandler maps them both to input paremeter (integer)
5859
*/
5960
@Test // see issue #448
60-
public void shouldGetAUser() {
61+
public void shouldGetAUserStatic() {
6162
SqlSession sqlSession = sqlSessionFactory.openSession();
6263
try {
6364
Mapper mapper = sqlSession.getMapper(Mapper.class);
64-
User user = mapper.getUser(1);
65+
User user = mapper.getUserStatic(1);
6566
Assert.assertEquals("User1", user.getName());
6667
} finally {
6768
sqlSession.close();
6869
}
6970
}
7071

72+
@Ignore
73+
@Test // see issue #61
74+
public void shouldGetAUserWithIfNode() {
75+
SqlSession sqlSession = sqlSessionFactory.openSession();
76+
try {
77+
Mapper mapper = sqlSession.getMapper(Mapper.class);
78+
User user = mapper.getUserIfNode("User1");
79+
Assert.assertEquals("User1", user.getName());
80+
} finally {
81+
sqlSession.close();
82+
}
83+
}
84+
7185
}

0 commit comments

Comments
 (0)