20 lines
467 B
Java
20 lines
467 B
Java
package test.util;
|
|
import org.junit.Test;
|
|
import java.sql.Connection;
|
|
import util.DatabaseUtil;
|
|
import static org.junit.Assert.*;
|
|
import java.sql.SQLException;
|
|
|
|
public class TestDatabaseUtil {
|
|
@Test
|
|
public void testGetConnection() {
|
|
try (Connection connection = DatabaseUtil.getConnection()) {
|
|
|
|
assertNotNull("数据库连接不应该为空", connection);
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|