I am trying to test one of the classes which has a Vaadin UI parameters,
at the test execution level i have a null pointer exception
String basePath = getBasePath();
This part can not be reached by the test case because of the getBasePath() method is not reachable due to NullPointerException.
protected String getBasePath(){
String basePath = "";
String host = UI.getCurrent().getPage().getLocation().getHost();
int port = UI.getCurrent().getPage().getLocation().getPort();
String path_app = UI.getCurrent().getPage().getLocation().getPath();
String http_s = UI.getCurrent().getPage().getLocation().getScheme();
So in this part of this code,I tested that
UI.getCurrent().getPage()
Has a result, It is not null and test can reach to it. But the getLocation() has a null pointer exception.
@Before
public void init() throws URISyntaxException, NoSuchFieldException, SecurityException {
TetUI tetUI = new TetUI();
UI.setCurrent(tetUI);
UI.getCurrent().getPage().setLocation("Something");
}
I set the Location like that or could be a URI as well, But it is still null.
I tried to have some other sources about the topic on the internet and nothing came out yet.
Maybe i do it in a completely wrong way , Is this approach is correct? Any suggestions ?
Setting values through Vaadins static methods doesnt work very well.
You have two options:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.