提交 362b8896 编写于 作者: zhouweidong's avatar zhouweidong

add

上级 95d4700d
......@@ -8,6 +8,8 @@ spring:
password: 'test'
url: jdbc:h2:mem:demo;
driver-class-name: org.h2.Driver
schema: classpath:db/schema-h2.sql
data: classpath:db/data-h2.sql
logging:
level:
......
INSERT INTO T_BOOK (bookid, bookname,pubyearisbn ,price) VALUES
(1, 'java程序设计', '清华大学出版社', '50'),
(2, 'c语言自学指南', '清华大学出版社', '60'),
(3, 'pythod从精通到入门', '清华大学出版社', '70');
\ No newline at end of file
create table IF NOT EXISTS T_BOOK
(
bookid VARCHAR2(100) not null,
createman VARCHAR2(60),
updateman VARCHAR2(60),
createdate DATE,
bookname VARCHAR2(200),
updatedate DATE ,
pubyearisbn VARCHAR2(200),
price number
);
\ No newline at end of file
......@@ -5,54 +5,27 @@ TARGET=PSSYSTEM
import ${pub.getPKGCodeName()}.demoMain;
import ${pub.getPKGCodeName()}.quickstart.domain.BOOK;
import ${pub.getPKGCodeName()}.quickstart.mapper.BOOKMapper;
import org.junit.Before;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = demoMain.class)
public class ApplicationTest {
@Autowired
private DataSource dataSource;
@Autowired
private BOOKMapper bookMapper;
@Before
public void beforeTest() {
try {
Connection connection = dataSource.getConnection();
//建表SQL
String bookSql="create table IF NOT EXISTS T_BOOK \n" +
"(\n" +
" bookid VARCHAR2(100) not null,\n" +
" createman VARCHAR2(60),\n" +
" updateman VARCHAR2(60),\n" +
" createdate DATE,\n" +
" bookname VARCHAR2(200),\n" +
" updatedate DATE ,\n" +
" pubyearisbn VARCHAR2(200),\n" +
" price number\n" +
")";
connection.createStatement().execute(bookSql);
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test
public void testMain() {
BOOK book = new BOOK();
book.setBookid("1");
book.setBookname("java程序设计");
bookMapper.insert(book);
System.out.println(("----- selectAll method test ------"));
List<BOOK> userList = bookMapper.selectList(null);
Assert.assertEquals(3, userList.size());
userList.forEach(System.out::println);
}
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册