Commit 0f16031f authored by hewei's avatar hewei

测试工具优化,每次执行前重置数据,防止脏数据

parent eaa6be0e
...@@ -21,8 +21,6 @@ import org.apache.ibatis.session.SqlSession; ...@@ -21,8 +21,6 @@ import org.apache.ibatis.session.SqlSession;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
...@@ -52,7 +50,7 @@ public class ExampleEnhancedPluginTest { ...@@ -52,7 +50,7 @@ public class ExampleEnhancedPluginTest {
* 测试生成的example方法 * 测试生成的example方法
*/ */
@Test @Test
public void testExample() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testExample() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -73,7 +71,7 @@ public class ExampleEnhancedPluginTest { ...@@ -73,7 +71,7 @@ public class ExampleEnhancedPluginTest {
* 测试生成的orderBy方法 * 测试生成的orderBy方法
*/ */
@Test @Test
public void testOrderBy() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testOrderBy() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -96,7 +94,7 @@ public class ExampleEnhancedPluginTest { ...@@ -96,7 +94,7 @@ public class ExampleEnhancedPluginTest {
* 测试andIf方法 * 测试andIf方法
*/ */
@Test @Test
public void testAndIf() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testAndIf() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ExampleEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -61,7 +61,7 @@ public class LimitPluginTest { ...@@ -61,7 +61,7 @@ public class LimitPluginTest {
* 测试生成的Sql语句和具体执行 * 测试生成的Sql语句和具体执行
*/ */
@Test @Test
public void testSqlAndExecute() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testSqlAndExecute() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LimitPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LimitPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -80,7 +80,7 @@ public class LogicalDeletePluginTest { ...@@ -80,7 +80,7 @@ public class LogicalDeletePluginTest {
* 测试 logicalDeleteByExample * 测试 logicalDeleteByExample
*/ */
@Test @Test
public void testLogicalDeleteByExample() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testLogicalDeleteByExample() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -108,7 +108,7 @@ public class LogicalDeletePluginTest { ...@@ -108,7 +108,7 @@ public class LogicalDeletePluginTest {
* 测试 logicalDeleteByPrimaryKey * 测试 logicalDeleteByPrimaryKey
*/ */
@Test @Test
public void testLogicalDeleteByPrimaryKey() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testLogicalDeleteByPrimaryKey() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -132,7 +132,7 @@ public class LogicalDeletePluginTest { ...@@ -132,7 +132,7 @@ public class LogicalDeletePluginTest {
* 测试关联生成的方法和常量 * 测试关联生成的方法和常量
*/ */
@Test @Test
public void testOtherMethods() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testOtherMethods() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -159,7 +159,7 @@ public class LogicalDeletePluginTest { ...@@ -159,7 +159,7 @@ public class LogicalDeletePluginTest {
* 测试自定义常量 * 测试自定义常量
*/ */
@Test @Test
public void testCustomConst() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testCustomConst() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -186,7 +186,7 @@ public class LogicalDeletePluginTest { ...@@ -186,7 +186,7 @@ public class LogicalDeletePluginTest {
* 测试Model andLogicalDeleted 方法 * 测试Model andLogicalDeleted 方法
*/ */
@Test @Test
public void testModelAndLogicalDeletedMethod() throws InterruptedException, SQLException, InvalidConfigurationException, IOException, XMLParserException { public void testModelAndLogicalDeletedMethod() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -206,7 +206,7 @@ public class LogicalDeletePluginTest { ...@@ -206,7 +206,7 @@ public class LogicalDeletePluginTest {
* 测试 selectByPrimaryKeyWithLogicalDelete * 测试 selectByPrimaryKeyWithLogicalDelete
*/ */
@Test @Test
public void testSelectByPrimaryKeyWithLogicalDelete() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testSelectByPrimaryKeyWithLogicalDelete() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LogicalDeletePlugin/mybatis-generator-with-customConstName.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -24,8 +24,6 @@ import org.apache.ibatis.session.SqlSession; ...@@ -24,8 +24,6 @@ import org.apache.ibatis.session.SqlSession;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -51,7 +49,7 @@ public class ModelBuilderPluginTest { ...@@ -51,7 +49,7 @@ public class ModelBuilderPluginTest {
* 测试生成的model * 测试生成的model
*/ */
@Test @Test
public void test() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void test() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelBuilderPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelBuilderPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -113,7 +111,7 @@ public class ModelBuilderPluginTest { ...@@ -113,7 +111,7 @@ public class ModelBuilderPluginTest {
* 测试静态builder方法 * 测试静态builder方法
*/ */
@Test @Test
public void testBuilderMethod() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testBuilderMethod() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelBuilderPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelBuilderPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -24,8 +24,6 @@ import org.apache.ibatis.session.SqlSession; ...@@ -24,8 +24,6 @@ import org.apache.ibatis.session.SqlSession;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -51,7 +49,7 @@ public class ModelColumnPluginTest { ...@@ -51,7 +49,7 @@ public class ModelColumnPluginTest {
* 测试生成的model * 测试生成的model
*/ */
@Test @Test
public void test() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void test() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelColumnPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ModelColumnPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -65,7 +65,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -65,7 +65,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试Model * 测试Model
*/ */
@Test @Test
public void testModel() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testModel() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -91,7 +91,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -91,7 +91,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试insertSelective增强 * 测试insertSelective增强
*/ */
@Test @Test
public void testInsertSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testInsertSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -125,7 +125,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -125,7 +125,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试 updateByExampleSelective * 测试 updateByExampleSelective
*/ */
@Test @Test
public void testUpdateByExampleSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpdateByExampleSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -160,7 +160,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -160,7 +160,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试 updateByPrimaryKeySelective * 测试 updateByPrimaryKeySelective
*/ */
@Test @Test
public void testUpdateByPrimaryKeySelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpdateByPrimaryKeySelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -192,7 +192,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -192,7 +192,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试 upsertSelective * 测试 upsertSelective
*/ */
@Test @Test
public void testUpsertSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -226,7 +226,7 @@ public class OldSelectiveEnhancedPluginTest { ...@@ -226,7 +226,7 @@ public class OldSelectiveEnhancedPluginTest {
* 测试 upsertByExampleSelective * 测试 upsertByExampleSelective
*/ */
@Test @Test
public void testUpsertByExampleSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertByExampleSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/OldSelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -21,8 +21,6 @@ import org.apache.ibatis.session.SqlSession; ...@@ -21,8 +21,6 @@ import org.apache.ibatis.session.SqlSession;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -48,7 +46,7 @@ public class SelectOneByExamplePluginTest { ...@@ -48,7 +46,7 @@ public class SelectOneByExamplePluginTest {
* 测试 selectOneByExample * 测试 selectOneByExample
*/ */
@Test @Test
public void testSelectOneByExample() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testSelectOneByExample() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectOneByExamplePlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectOneByExamplePlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -75,7 +73,7 @@ public class SelectOneByExamplePluginTest { ...@@ -75,7 +73,7 @@ public class SelectOneByExamplePluginTest {
* 测试 selectOneByExampleWithBLOBs * 测试 selectOneByExampleWithBLOBs
*/ */
@Test @Test
public void testSelectOneByExampleWithBLOBs() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testSelectOneByExampleWithBLOBs() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectOneByExamplePlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectOneByExamplePlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -65,7 +65,7 @@ public class SelectiveEnhancedPluginTest { ...@@ -65,7 +65,7 @@ public class SelectiveEnhancedPluginTest {
* 测试insertSelective增强 * 测试insertSelective增强
*/ */
@Test @Test
public void testInsertSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testInsertSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -98,7 +98,7 @@ public class SelectiveEnhancedPluginTest { ...@@ -98,7 +98,7 @@ public class SelectiveEnhancedPluginTest {
* 测试 updateByExampleSelective * 测试 updateByExampleSelective
*/ */
@Test @Test
public void testUpdateByExampleSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpdateByExampleSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -132,7 +132,7 @@ public class SelectiveEnhancedPluginTest { ...@@ -132,7 +132,7 @@ public class SelectiveEnhancedPluginTest {
* 测试 updateByPrimaryKeySelective * 测试 updateByPrimaryKeySelective
*/ */
@Test @Test
public void testUpdateByPrimaryKeySelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpdateByPrimaryKeySelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -163,7 +163,7 @@ public class SelectiveEnhancedPluginTest { ...@@ -163,7 +163,7 @@ public class SelectiveEnhancedPluginTest {
* 测试 upsertSelective * 测试 upsertSelective
*/ */
@Test @Test
public void testUpsertSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -196,7 +196,7 @@ public class SelectiveEnhancedPluginTest { ...@@ -196,7 +196,7 @@ public class SelectiveEnhancedPluginTest {
* 测试 upsertByExampleSelective * 测试 upsertByExampleSelective
*/ */
@Test @Test
public void testUpsertByExampleSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertByExampleSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/SelectiveEnhancedPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
...@@ -65,7 +65,7 @@ public class UpsertPluginTest { ...@@ -65,7 +65,7 @@ public class UpsertPluginTest {
* 测试 upsert * 测试 upsert
*/ */
@Test @Test
public void testUpsert() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsert() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -97,7 +97,7 @@ public class UpsertPluginTest { ...@@ -97,7 +97,7 @@ public class UpsertPluginTest {
* 测试 upsertWithBLOBs * 测试 upsertWithBLOBs
*/ */
@Test @Test
public void testUpsertWithBLOBs() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertWithBLOBs() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -151,7 +151,7 @@ public class UpsertPluginTest { ...@@ -151,7 +151,7 @@ public class UpsertPluginTest {
* 测试 upsertSelective * 测试 upsertSelective
*/ */
@Test @Test
public void testUpsertSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -190,7 +190,7 @@ public class UpsertPluginTest { ...@@ -190,7 +190,7 @@ public class UpsertPluginTest {
* 测试 upsertByExample * 测试 upsertByExample
*/ */
@Test @Test
public void testUpsertByExample() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertByExample() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -226,7 +226,7 @@ public class UpsertPluginTest { ...@@ -226,7 +226,7 @@ public class UpsertPluginTest {
* 测试 upsertByExampleWithBLOBs * 测试 upsertByExampleWithBLOBs
*/ */
@Test @Test
public void testUpsertByExampleWithBLOBs() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertByExampleWithBLOBs() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -287,7 +287,7 @@ public class UpsertPluginTest { ...@@ -287,7 +287,7 @@ public class UpsertPluginTest {
* 测试 upsertByExampleSelective * 测试 upsertByExampleSelective
*/ */
@Test @Test
public void testUpsertByExampleSelective() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testUpsertByExampleSelective() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
...@@ -332,7 +332,7 @@ public class UpsertPluginTest { ...@@ -332,7 +332,7 @@ public class UpsertPluginTest {
* 测试 存在自增主键的情况 * 测试 存在自增主键的情况
*/ */
@Test @Test
public void testWithIdentityAndGeneratedAlwaysColumns() throws IOException, XMLParserException, InvalidConfigurationException, InterruptedException, SQLException { public void testWithIdentityAndGeneratedAlwaysColumns() throws Exception {
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml"); MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/UpsertPlugin/mybatis-generator.xml");
tool.generate(new AbstractShellCallback() { tool.generate(new AbstractShellCallback() {
@Override @Override
......
/*
* Copyright (c) 2018.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.itfsw.mybatis.generator.plugins.tools;
/**
* ---------------------------------------------------------------------------
* 回调之前执行
* ---------------------------------------------------------------------------
* @author: hewei
* @time:2018/4/25 18:42
* ---------------------------------------------------------------------------
*/
public interface IBeforeCallback {
/**
* 执行
*/
void run() throws Exception;
}
...@@ -81,19 +81,35 @@ public class MyBatisGeneratorTool { ...@@ -81,19 +81,35 @@ public class MyBatisGeneratorTool {
/** /**
* 执行MyBatisGenerator * 执行MyBatisGenerator
* @param before
* @param callback * @param callback
* @return * @return
* @throws SQLException * @throws SQLException
* @throws IOException * @throws IOException
* @throws InterruptedException * @throws InterruptedException
*/ */
public MyBatisGenerator generate(AbstractShellCallback callback) throws InvalidConfigurationException, InterruptedException, SQLException, IOException { public MyBatisGenerator generate(IBeforeCallback before, AbstractShellCallback callback) throws Exception {
before.run();
callback.setTool(this); callback.setTool(this);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null, null, null, true); myBatisGenerator.generate(null, null, null, true);
return myBatisGenerator; return myBatisGenerator;
} }
/**
* 执行MyBatisGenerator
* @param callback
* @return
* @throws SQLException
* @throws IOException
* @throws InterruptedException
*/
public MyBatisGenerator generate(AbstractShellCallback callback) throws Exception {
return this.generate(() -> {
}, callback);
}
/** /**
* 执行MyBatisGenerator(不生成文件) * 执行MyBatisGenerator(不生成文件)
* @return * @return
......
...@@ -23,7 +23,7 @@ CREATE TABLE `tb` ( ...@@ -23,7 +23,7 @@ CREATE TABLE `tb` (
`id` bigint(20) NOT NULL COMMENT '注释1', `id` bigint(20) NOT NULL COMMENT '注释1',
`field1` varchar(255) DEFAULT NULL COMMENT '注释2', `field1` varchar(255) DEFAULT NULL COMMENT '注释2',
`inc_f1` bigint(20) NOT NULL DEFAULT '0', `inc_f1` bigint(20) NOT NULL DEFAULT '0',
`inc_f2` bigint(20) NOT NULL DEFAULT '0', `inc_f2` bigint(20) DEFAULT '0',
`inc_f3` bigint(20) DEFAULT '0', `inc_f3` bigint(20) DEFAULT '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties resource="db.properties"/>
<!--导入属性配置 -->
<context id="default" targetRuntime="MyBatis3">
<!-- 插件 -->
<plugin type="com.itfsw.mybatis.generator.plugins.IncrementsPlugin" />
<plugin type="com.itfsw.mybatis.generator.plugins.ModelBuilderPlugin" />
<plugin type="com.itfsw.mybatis.generator.plugins.UpsertPlugin">
<property name="allowMultiQueries" value="true"/>
</plugin>
<plugin type="com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"/>
<plugin type="com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"/>
<!--jdbc的数据库连接 -->
<jdbcConnection driverClass="${driver}" connectionURL="${url}" userId="${username}" password="${password}" />
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator targetPackage="" targetProject="">
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator targetPackage="" targetProject="" />
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator targetPackage="" targetProject="" type="XMLMAPPER"/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table tableName="tb">
<property name="incrementsColumns" value="inc_f1"/>
</table>
<table tableName="tb_keys">
<property name="incrementsColumns" value="inc_f1,inc_f2,inc_f3"/>
</table>
<table tableName="tb_blobs">
<property name="incrementsColumns" value="inc_f1,inc_f3"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment