List of usage examples for org.apache.ibatis.session ExecutorType SIMPLE
ExecutorType SIMPLE
To view the source code for org.apache.ibatis.session ExecutorType SIMPLE.
Click Source Link
From source file:org.mybatis.guice.MyBatisModuleTest.java
License:Apache License
@Test public void executorType_Default() { Injector injector = Guice.createInjector(new MyBatisModule() { @Override/* ww w .j a va 2 s.com*/ protected void initialize() { environmentId("test_environment"); bindDataSourceProvider(dataSourceProvider); bindTransactionFactory(transactionFactoryProvider); } }); Configuration configuration = injector.getInstance(Configuration.class); assertEquals(ExecutorType.SIMPLE, configuration.getDefaultExecutorType()); }
From source file:org.mybatis.spring.batch.builder.MyBatisCursorItemReaderBuilderTest.java
License:Apache License
@BeforeEach void setUp() {// w ww . j a v a 2s . co m MockitoAnnotations.initMocks(this); Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); Mockito.when(this.sqlSession.selectCursor("selectFoo", Collections.singletonMap("id", 1))) .thenReturn(this.cursor); }
From source file:org.mybatis.spring.batch.MyBatisCursorItemReader.java
License:Apache License
@Override protected void doOpen() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); if (parameterValues != null) { parameters.putAll(parameterValues); }/*from w w w .j a v a 2 s .c o m*/ sqlSession = sqlSessionFactory.openSession(ExecutorType.SIMPLE); cursor = sqlSession.selectCursor(queryId, parameters); cursorIterator = cursor.iterator(); }
From source file:org.mybatis.spring.batch.MyBatisCursorItemReaderTest.java
License:Apache License
@Test void testCloseOnFailing() throws Exception { Mockito.when(this.sqlSessionFactory.openSession(ExecutorType.SIMPLE)).thenReturn(this.sqlSession); Mockito.when(this.cursor.iterator()).thenReturn(getFoos().iterator()); Mockito.when(this.sqlSession.selectCursor("selectFoo", Collections.singletonMap("id", 1))) .thenThrow(new RuntimeException("error.")); MyBatisCursorItemReader<Foo> itemReader = new MyBatisCursorItemReader<>(); itemReader.setSqlSessionFactory(this.sqlSessionFactory); itemReader.setQueryId("selectFoo"); itemReader.setParameterValues(Collections.singletonMap("id", 1)); itemReader.afterPropertiesSet();/*from ww w .j a va 2 s .c om*/ ExecutionContext executionContext = new ExecutionContext(); try { itemReader.open(executionContext); fail(); } catch (ItemStreamException e) { Assertions.assertThat(e).hasMessage("Failed to initialize the reader") .hasCause(new RuntimeException("error.")); } finally { itemReader.close(); Mockito.verify(this.sqlSession).close(); } }
From source file:org.mybatis.spring.boot.autoconfigure.MybatisAutoConfigurationTest.java
License:Apache License
@Test public void testDefaultConfiguration() { this.context.register(EmbeddedDataSourceConfiguration.class, MybatisScanMapperConfiguration.class, MybatisAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); assertEquals(1, this.context.getBeanNamesForType(SqlSessionFactory.class).length); assertEquals(1, this.context.getBeanNamesForType(SqlSessionTemplate.class).length); assertEquals(1, this.context.getBeanNamesForType(CityMapper.class).length); assertEquals(ExecutorType.SIMPLE, this.context.getBean(SqlSessionTemplate.class).getExecutorType()); assertFalse(this.context.getBean(SqlSessionFactory.class).getConfiguration().isMapUnderscoreToCamelCase()); }