package org.yannis.master4j;

import java.util.Arrays;
import junit.framework.TestCase;
import org.yannis.master4j.config.DBConfig;
import org.yannis.master4j.config.ProjectConfig;
import org.yannis.master4j.core.GeneratorFactoryProvider;
import org.yannis.master4j.core.SSMGeneratorFactoryProvider;
import org.yannis.master4j.core.SingleGeneratorFactoryProvider;
import org.yannis.master4j.enums.CodeStyle;

/**
 * Unit test for simple App.
 */
public class AppTest
    extends TestCase {

    static {
       /* Properties props = new Properties();
        try {
            props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("log4j.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        PropertyConfigurator.configure(props);*/
    }

    public void test() {

        ProjectConfig projectConfig = new ProjectConfig();

        /* configure database information */
        DBConfig dbConfig = new DBConfig();
        dbConfig.setDatabase("co_paper");
        dbConfig.setIp("127.0.0.1");
        dbConfig.setDriverPackage("com.mysql.jdbc.Driver");
        dbConfig.setUsername("root");
        dbConfig.setPassword("111111");
        dbConfig.setExcludeTables(Arrays.asList("sys_resource", "sys_role", "sys_user", "user_group"));
        dbConfig.setTablePrefix("t_");
        projectConfig.setDbConfig(dbConfig);

        /* configure project & output path information */
        projectConfig.setOutputPath("/development/projects/master4j_gen");
        projectConfig.setProjectName("co-paper");
        projectConfig.setBasePackageName("com.ximalaya.corp.paper");
        projectConfig.setCodeStyle(CodeStyle.SSM);

        /* bootstrap the app */
        GeneratorFactoryProvider provider = null;
        switch (projectConfig.getCodeStyle()) {
            case SPRINGMVC:
                provider = new SingleGeneratorFactoryProvider();
                break;
            case SSM:
                provider = new SSMGeneratorFactoryProvider();
                break;
            case SSH:
                System.out.println("Not Support yet!");
                return;
        }
        Motor motor = new Motor(provider);
        motor.fire(projectConfig);
    }
}

@@ -1012,16 +1012,13 @@
 se(%22
-co_paper
+snail
 %22);%0A
@@ -1300,47 +1300,8 @@
 ));%0A
-        dbConfig.setTablePrefix(%22t_%22);%0A
     
@@ -1517,16 +1517,13 @@
 me(%22
-co-paper
+snail
 %22);%0A
@@ -1568,31 +1568,24 @@
 me(%22
-com.ximalaya.corp.paper
+org.yannis.snail
 %22);%0A
@@ -1630,18 +1630,24 @@
 eStyle.S
-SM
+PRINGMVC
 );%0A%0A    

modify test