|
1 | 1 | /** |
2 | | - * Copyright 2010-2019 the original author or authors. |
| 2 | + * Copyright 2010-2020 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
31 | 31 | import org.apache.ibatis.reflection.factory.ObjectFactory; |
32 | 32 | import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; |
33 | 33 | import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; |
34 | | -import org.apache.ibatis.scripting.LanguageDriver; |
35 | 34 | import org.apache.ibatis.scripting.LanguageDriverRegistry; |
36 | 35 | import org.apache.ibatis.scripting.defaults.RawLanguageDriver; |
37 | 36 | import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver; |
|
40 | 39 | import org.apache.ibatis.session.SqlSessionFactory; |
41 | 40 | import org.apache.ibatis.transaction.TransactionFactory; |
42 | 41 | import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; |
| 42 | +import org.apache.ibatis.type.EnumOrdinalTypeHandler; |
43 | 43 | import org.apache.ibatis.type.TypeAliasRegistry; |
44 | 44 | import org.apache.ibatis.type.TypeException; |
45 | | -import org.apache.ibatis.type.TypeHandler; |
46 | 45 | import org.apache.ibatis.type.TypeHandlerRegistry; |
47 | 46 | import org.junit.jupiter.api.Test; |
48 | 47 | import org.mybatis.core.jdk.type.AtomicNumberTypeHandler; |
|
52 | 51 | import org.mybatis.spring.type.SuperType; |
53 | 52 | import org.mybatis.spring.type.TypeHandlerFactory; |
54 | 53 | import org.springframework.core.io.ClassPathResource; |
55 | | -import org.springframework.core.io.Resource; |
56 | 54 |
|
57 | 55 | import com.mockrunner.mock.jdbc.MockDataSource; |
58 | 56 |
|
@@ -423,6 +421,15 @@ void testSearchATypeHandlerPackageWithSamePackage() throws Exception { |
423 | 421 | assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); |
424 | 422 | } |
425 | 423 |
|
| 424 | + @Test |
| 425 | + void testDefaultEnumTypeHandler() throws Exception { |
| 426 | + setupFactoryBean(); |
| 427 | + factoryBean.setDefaultEnumTypeHandler(EnumOrdinalTypeHandler.class); |
| 428 | + |
| 429 | + TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); |
| 430 | + assertThat(typeHandlerRegistry.getTypeHandler(MyEnum.class)).isInstanceOf(EnumOrdinalTypeHandler.class); |
| 431 | + } |
| 432 | + |
426 | 433 | @Test |
427 | 434 | void testSetObjectFactory() throws Exception { |
428 | 435 | setupFactoryBean(); |
@@ -515,4 +522,7 @@ private static class MyLanguageDriver1 extends RawLanguageDriver { |
515 | 522 | private static class MyLanguageDriver2 extends RawLanguageDriver { |
516 | 523 | } |
517 | 524 |
|
| 525 | + private static enum MyEnum { |
| 526 | + } |
| 527 | + |
518 | 528 | } |
0 commit comments