View Javadoc
1   /*
2    *    Copyright 2009-2021 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    *       http://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, configuration.getSqlFragments());
40        builder.parse();
41  
42        MappedStatement mappedStatement = configuration.getMappedStatement("selectWithOptions");
43        Assertions.assertEquals(Integer.valueOf(200), mappedStatement.getFetchSize());
44        Assertions.assertEquals(Integer.valueOf(10), mappedStatement.getTimeout());
45        Assertions.assertEquals(StatementType.PREPARED, mappedStatement.getStatementType());
46        Assertions.assertEquals(ResultSetType.SCROLL_SENSITIVE, mappedStatement.getResultSetType());
47        Assertions.assertFalse(mappedStatement.isFlushCacheRequired());
48        Assertions.assertFalse(mappedStatement.isUseCache());
49      } finally {
50        // System.clearProperty(XPathParser.KEY_USE_XSD);
51      }
52    }
53  
54  }