use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.
the class XmlConfigBuilderTest method parseIsTwice.
@Test
public void parseIsTwice() throws Exception {
String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
builder.parse();
expectedException.expect(BuilderException.class);
expectedException.expectMessage("Each XMLConfigBuilder can only be used once.");
builder.parse();
}
use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.
the class XmlConfigBuilderTest method unknownJavaTypeOnTypeHandler.
@Test
public void unknownJavaTypeOnTypeHandler() {
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" + "<configuration>\n" + " <typeAliases>\n" + " <typeAlias type=\"a.b.c.Foo\"/>\n" + " </typeAliases>\n" + "</configuration>\n";
expectedException.expect(BuilderException.class);
expectedException.expectMessage("Error registering typeAlias for 'null'. Cause: ");
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
builder.parse();
}
use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.
the class XmlConfigBuilderTest method propertiesSpecifyResourceAndUrlAtSameTime.
@Test
public void propertiesSpecifyResourceAndUrlAtSameTime() {
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" + "<configuration>\n" + " <properties resource=\"a/b/c/foo.properties\" url=\"file:./a/b/c/jdbc.properties\"/>\n" + "</configuration>\n";
expectedException.expect(BuilderException.class);
expectedException.expectMessage("The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other.");
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
builder.parse();
}
use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.
the class XmlConfigBuilderTest method registerJavaTypeInitializingTypeHandler.
@Test
public void registerJavaTypeInitializingTypeHandler() {
final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" + "<configuration>\n" + " <typeHandlers>\n" + " <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n" + " handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n" + " </typeHandlers>\n" + "</configuration>\n";
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
builder.parse();
TypeHandlerRegistry typeHandlerRegistry = builder.getConfiguration().getTypeHandlerRegistry();
TypeHandler<MyEnum> typeHandler = typeHandlerRegistry.getTypeHandler(MyEnum.class);
assertTrue(typeHandler instanceof EnumOrderTypeHandler);
assertArrayEquals(MyEnum.values(), ((EnumOrderTypeHandler) typeHandler).constants);
}
Aggregations