コード例 #1
0
  /** @throws java.lang.Exception */
  @Before
  public void setUpBefore() throws Exception {
    mockedRequest = Mockito.mock(HttpServletRequest.class);
    mockedResponse = Mockito.mock(HttpServletResponse.class);

    URL testfile = NewModelHandlerTest.class.getResource("/data/newmodelhandler/test1_svg.xml");
    File file = new File(testfile.toURI());
    svg = FileUtils.readFileToString(file, "UTF-8");

    testfile =
        NewModelHandlerTest.class.getResource("/data/newmodelhandler/test1_content_json.txt");
    file = new File(testfile.toURI());
    data = FileUtils.readFileToString(file, "UTF-8");

    // --
    // DataDefaults.all();
    Reader reader = Resources.getResourceAsReader("org/b3mn/poem/tests/myibitis-config.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();

    SqlSession session = sqlSessionFactory.openSession();
    Connection conn = session.getConnection();
    reader = Resources.getResourceAsReader("org/b3mn/poem/tests/test_reset_mysql_db_schema.sql");
    ScriptRunner runner = new ScriptRunner(conn);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    reader.close();

    reader = Resources.getResourceAsReader("org/b3mn/poem/tests/test_data.sql");
    runner = new ScriptRunner(conn);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    reader.close();

    session.close();

    title = "Job #1";
    type = "http://b3mn.org/stencilset/reporting#";
    summary = "";
    newModelIdentity = null;
    user = new User("public");

    handler = new NewModelHandler();
    assertNotNull(handler);

    handler.init();
  }
コード例 #2
0
 @BeforeClass
 public static void setup() throws Exception {
   SqlSession session = IbatisConfig.getSession();
   Connection conn = session.getConnection();
   ScriptRunner runner = new ScriptRunner(conn);
   runner.setLogWriter(null);
   runner.setErrorLogWriter(null);
   Reader reader =
       Resources.getResourceAsReader(
           "org/apache/ibatis/submitted/primitive_result_type/create.sql");
   runner.runScript(reader);
 }
コード例 #3
0
ファイル: BaseDataTest.java プロジェクト: jxcypress/mybatis
 public static void runScript(DataSource ds, String resource) throws IOException, SQLException {
   Connection connection = ds.getConnection();
   try {
     ScriptRunner runner = new ScriptRunner(connection);
     runner.setAutoCommit(true);
     runner.setStopOnError(false);
     runner.setLogWriter(null);
     runner.setErrorLogWriter(null);
     runScript(runner, resource);
   } finally {
     connection.close();
   }
 }
コード例 #4
0
  @Before
  public void setUp() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:attest", "sa", "");

    Reader reader =
        Resources.getResourceAsReader("org/apache/ibatis/submitted/awful_table/CreateDB.sql");

    ScriptRunner runner = new ScriptRunner(conn);
    runner.setLogWriter(null);
    runner.setErrorLogWriter(null);
    runner.runScript(reader);
    conn.commit();
    reader.close();

    reader =
        Resources.getResourceAsReader("org/apache/ibatis/submitted/awful_table/MapperConfig.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    reader.close();
  }