View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.builder.xsd;
17  
18  import java.io.InputStream;
19  
20  import org.apache.ibatis.builder.xml.XMLMapperBuilder;
21  import org.apache.ibatis.io.Resources;
22  import org.apache.ibatis.mapping.MappedStatement;
23  import org.apache.ibatis.mapping.ResultSetType;
24  import org.apache.ibatis.mapping.StatementType;
25  import org.apache.ibatis.session.Configuration;
26  import org.junit.jupiter.api.Assertions;
27  import org.junit.jupiter.api.Disabled;
28  import org.junit.jupiter.api.Test;
29  
30  @Disabled("We'll try a different approach. See #1393")
31  class XmlMapperBuilderTest {
32  
33    @Test
34    void mappedStatementWithOptions() throws Exception {
35      // System.setProperty(XPathParser.KEY_USE_XSD, "true");
36      Configuration configuration = new Configuration();
37      String resource = "org/apache/ibatis/builder/xsd/AuthorMapper.xml";
38      try (InputStream inputStream = Resources.getResourceAsStream(resource)) {
39        XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource,
40            configuration.getSqlFragments());
41        builder.parse();
42  
43        MappedStatement mappedStatement = configuration.getMappedStatement("selectWithOptions");
44        Assertions.assertEquals(Integer.valueOf(200), mappedStatement.getFetchSize());
45        Assertions.assertEquals(Integer.valueOf(10), mappedStatement.getTimeout());
46        Assertions.assertEquals(StatementType.PREPARED, mappedStatement.getStatementType());
47        Assertions.assertEquals(ResultSetType.SCROLL_SENSITIVE, mappedStatement.getResultSetType());
48        Assertions.assertFalse(mappedStatement.isFlushCacheRequired());
49        Assertions.assertFalse(mappedStatement.isUseCache());
50      } finally {
51        // System.clearProperty(XPathParser.KEY_USE_XSD);
52      }
53    }
54  
55  }