Search in sources :

Example 11 with XMLConfigBuilder

use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.

the class XmlConfigBuilderTest method parseIsTwice.

@Test
void parseIsTwice() throws Exception {
    String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
    try (InputStream inputStream = Resources.getResourceAsStream(resource)) {
        XMLConfigBuilder builder = new XMLConfigBuilder(inputStream);
        builder.parse();
        when(builder::parse);
        then(caughtException()).isInstanceOf(BuilderException.class).hasMessage("Each XMLConfigBuilder can only be used once.");
    }
}
Also used : InputStream(java.io.InputStream) XMLConfigBuilder(org.apache.ibatis.builder.xml.XMLConfigBuilder) Test(org.junit.jupiter.api.Test)

Example 12 with XMLConfigBuilder

use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.

the class XmlConfigBuilderTest method unknownJavaTypeOnTypeHandler.

@Test
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";
    XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
    when(builder::parse);
    then(caughtException()).isInstanceOf(BuilderException.class).hasMessageContaining("Error registering typeAlias for 'null'. Cause: ");
}
Also used : StringReader(java.io.StringReader) XMLConfigBuilder(org.apache.ibatis.builder.xml.XMLConfigBuilder) Test(org.junit.jupiter.api.Test)

Example 13 with XMLConfigBuilder

use of org.apache.ibatis.builder.xml.XMLConfigBuilder in project mybatis-3 by mybatis.

the class XmlConfigBuilderTest method propertiesSpecifyResourceAndUrlAtSameTime.

@Test
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";
    XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
    when(builder::parse);
    then(caughtException()).isInstanceOf(BuilderException.class).hasMessageContaining("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
}
Also used : StringReader(java.io.StringReader) XMLConfigBuilder(org.apache.ibatis.builder.xml.XMLConfigBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

XMLConfigBuilder (org.apache.ibatis.builder.xml.XMLConfigBuilder)13 Test (org.junit.jupiter.api.Test)10 InputStream (java.io.InputStream)7 Configuration (org.apache.ibatis.session.Configuration)6 StringReader (java.io.StringReader)4 Environment (org.apache.ibatis.mapping.Environment)4 Properties (java.util.Properties)2 JBoss6VFS (org.apache.ibatis.io.JBoss6VFS)2 Slf4jImpl (org.apache.ibatis.logging.slf4j.Slf4jImpl)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 SQLException (java.sql.SQLException)1 ParseException (java.text.ParseException)1 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)1 CustomLongTypeHandler (org.apache.ibatis.builder.CustomLongTypeHandler)1 CustomObjectWrapperFactory (org.apache.ibatis.builder.CustomObjectWrapperFactory)1 CustomReflectorFactory (org.apache.ibatis.builder.CustomReflectorFactory)1 CustomStringTypeHandler (org.apache.ibatis.builder.CustomStringTypeHandler)1 ExampleObjectFactory (org.apache.ibatis.builder.ExampleObjectFactory)1 ExamplePlugin (org.apache.ibatis.builder.ExamplePlugin)1