Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public boolean startJunit(File appiumJarFile, String appiumCommand, AppiumListen
myClass = urlClassLoader.loadClass(appiumCommand);
junit.run(myClass);
return true;
} catch (ClassNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
return false;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ public boolean startJunit5(File appiumJarFile, String appiumCommand, TestExecuti
launcher.registerTestExecutionListeners(listener);
launcher.execute(request);
return true;
} catch (ClassNotFoundException e) {
} catch (Exception e) {
e.printStackTrace();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public Boolean isDeviceFree(String deviceIdentifier) {

@Scheduled(cron = "0 */3 * * * *")
public void runTask() {
logger.info("Start to run queued test task. the value of isRunning is: " + isRunning.get() + "the size of taskQueue is: " + taskQueue.size());
//only run one task at the same time
if (isRunning.get()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import com.microsoft.hydralab.center.config.SpringApplicationListener;
import com.microsoft.hydralab.center.service.DeviceAgentManagementService;
import com.microsoft.hydralab.common.entity.common.Message;
import com.microsoft.hydralab.common.util.SerializeUtil;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
Expand Down Expand Up @@ -47,8 +49,19 @@ public void onClose(Session session) {

@OnMessage
public void onMessage(ByteBuffer message, Session session) {
Message formattedMessage;
try {
deviceAgentManagementService.onMessage(SerializeUtil.byteArrToMessage(message.array()), session);
formattedMessage = SerializeUtil.byteArrToMessage(message.array());
} catch (Exception e) {
try {
session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Message format error"));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
throw new RuntimeException(e);
}
try {
deviceAgentManagementService.onMessage(formattedMessage, session);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import org.openqa.selenium.net.UrlChecker;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Nonnull;
import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
Expand Down Expand Up @@ -279,6 +282,14 @@ public WindowsDriver getWindowsRootDriver(Logger logger) {
public Boolean isDriverAlive(AppiumDriver driver) {
try {
driver.getStatus();
return true;
} catch (WebDriverException e) {
return false;
}
}

public Boolean isDriverAlive(WindowsDriver driver) {
try {
driver.getScreenshotAs(OutputType.FILE);
return true;
} catch (WebDriverException e) {
Expand Down