我必须写一些单元测试,但我有模拟ResultSet和jdbc的问题Connection.
我有这个方法:
@Test
public void test3() throws SQLException, IOException {
Connection jdbcConnection = Mockito.mock(Connection.class);
ResultSet resultSet = Mockito.mock(ResultSet.class);
Mockito.when(resultSet.next()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false);
Mockito.when(resultSet.getString(1)).thenReturn("table_r3").thenReturn("table_r1").thenReturn("table_r2");
Mockito.when(jdbcConnection
.createStatement()
.executeQuery("SELECT name FROM tables"))
.thenReturn(resultSet);
//when
List<String> nameOfTablesList = null;
try {
nameOfTablesList = Helper.getTablesName(jdbcConnection);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//then
Assert.assertEquals(nameOfTablesList.size(), 3);
}
Run Code Online (Sandbox Code Playgroud)
错误显示在行中executeQuery("SELECT name FROM tables"),听起来像这样:
java.lang.NullPointerException HelperTest.test3(HelperTest.java:71)
Run Code Online (Sandbox Code Playgroud)
任何想法都出错了?
我在javafx的webview组件中打开login.microsoftonline.com页面时遇到问题.我只是应该打开这个页面的代码没有任何麻烦:
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
var url = "https://login.microsoftonline.com/";
webEngine.load(url);
VBox root = new VBox();
root.getChildren().add(webView);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
webEngine.getLoadWorker().stateProperty().addListener((obs, oldValue, newValue) -> {
System.out.println(webEngine.getLocation());
});
Run Code Online (Sandbox Code Playgroud)
当我尝试在带有Windows操作系统的机器上执行此代码时,我会收到空白页:
当我在macbook上执行相同的代码时,网站正在打开:

我正在使用java 10,真的不知道出了什么问题.有没有人有同样的问题?知道如何解决这个问题吗?也许有其他组件而不是webview我可以用来做我的东西?
我知道可以在 cognito 提供的登录页面上自定义一些值。但这对我来说还不够。是否可以完全自定义?我只使用来自 Web 应用程序的第三方联合标识。是否有可能改变灰色背景?或者说有完全不同的看法?