mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: protect dispose method @AfterEach from possible NullPointer
parent
3baa72396f
commit
47792608ce
|
@ -392,37 +392,41 @@ public class AbstractOpenViduTestAppE2eTest {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
protected void dispose() {
|
protected void dispose() {
|
||||||
|
// Close all remaining OpenVidu sessions
|
||||||
this.closeAllSessions(OV);
|
this.closeAllSessions(OV);
|
||||||
|
// Remove all recordings
|
||||||
if (isRecordingTest) {
|
if (isRecordingTest) {
|
||||||
deleteAllRecordings(OV);
|
deleteAllRecordings(OV);
|
||||||
isRecordingTest = false;
|
isRecordingTest = false;
|
||||||
}
|
}
|
||||||
|
// Reset Media Server
|
||||||
if (isKurentoRestartTest) {
|
if (isKurentoRestartTest) {
|
||||||
this.stopMediaServer(false);
|
this.stopMediaServer(false);
|
||||||
this.startMediaServer(true);
|
this.startMediaServer(true);
|
||||||
isKurentoRestartTest = false;
|
isKurentoRestartTest = false;
|
||||||
}
|
}
|
||||||
|
// Dispose all browsers
|
||||||
Iterator<MyUser> it = users.iterator();
|
Iterator<MyUser> it = users.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
MyUser u = it.next();
|
MyUser u = it.next();
|
||||||
u.dispose();
|
u.dispose();
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
if (chrome.isRunning()) {
|
// Stop and remove all browser containers if necessary
|
||||||
chrome.stop();
|
stopContainerIfPossible(chrome);
|
||||||
}
|
stopContainerIfPossible(firefox);
|
||||||
if (firefox.isRunning()) {
|
stopContainerIfPossible(opera);
|
||||||
firefox.stop();
|
stopContainerIfPossible(edge);
|
||||||
}
|
// Reset REST client
|
||||||
if (opera.isRunning()) {
|
|
||||||
opera.stop();
|
|
||||||
}
|
|
||||||
if (edge.isRunning()) {
|
|
||||||
edge.stop();
|
|
||||||
}
|
|
||||||
OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopContainerIfPossible(GenericContainer<?> container) {
|
||||||
|
if (container != null && container.isRunning()) {
|
||||||
|
container.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void closeAllSessions(OpenVidu client) {
|
protected void closeAllSessions(OpenVidu client) {
|
||||||
try {
|
try {
|
||||||
client.fetch();
|
client.fetch();
|
||||||
|
|
Loading…
Reference in New Issue