Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default URL to HTTPS. #37

Merged
merged 5 commits into from
Mar 8, 2021
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
2 changes: 1 addition & 1 deletion src/main/java/org/vanvalenlab/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private Constants() {
// Configurable options
private static final Map<String, Object> DEFAULTS = new LinkedHashMap<String, Object>();
static {
DEFAULTS.put(KIOSK_HOST, "http://deepcell.org");
DEFAULTS.put(KIOSK_HOST, "https://deepcell.org");
DEFAULTS.put(UPDATE_STATUS_MILLISECONDS, 5000);
DEFAULTS.put(EXPIRE_TIME_SECONDS, 3600);
}
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/org/vanvalenlab/KioskJobManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ public static String selectJobType(String host) throws IOException {

// radio button group for job selection
gd.addRadioButtonGroup(
Constants.SELECT_JOB_TITLE,
jobTypes,
jobTypes.length,
1,
jobTypes[0]);
Constants.SELECT_JOB_TITLE,
jobTypes,
jobTypes.length,
1,
jobTypes[0]
);

System.out.println("About to show dialog");
gd.showDialog();
System.out.println("Dialog shown");
if (!gd.wasCanceled()) {
jobType = gd.getNextRadioButton();
}
Expand All @@ -77,15 +76,15 @@ public static Map<String, Object> configureOptions() {

// job status update interval
gd.addNumericField(
Constants.UPDATE_STATUS_MILLISECONDS,
(int)Constants.getDefault(Constants.UPDATE_STATUS_MILLISECONDS),
0);
Constants.UPDATE_STATUS_MILLISECONDS,
(int)Constants.getDefault(Constants.UPDATE_STATUS_MILLISECONDS),
0);

// job expiration time
gd.addNumericField(
Constants.EXPIRE_TIME_SECONDS,
(int)Constants.getDefault(Constants.EXPIRE_TIME_SECONDS),
0);
Constants.EXPIRE_TIME_SECONDS,
(int)Constants.getDefault(Constants.EXPIRE_TIME_SECONDS),
0);

gd.showDialog();
if (gd.wasCanceled()) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/vanvalenlab/LabelROIConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ static PolygonRoi wandToRoi(Wand wand) {
// so used trimmed arrays where this is the case
if (wand.xpoints.length > wand.npoints * 1.25)
roi = new PolygonRoi(
Arrays.copyOf(wand.xpoints, wand.npoints),
Arrays.copyOf(wand.ypoints, wand.npoints),
wand.npoints,
Roi.TRACED_ROI
Arrays.copyOf(wand.xpoints, wand.npoints),
Arrays.copyOf(wand.ypoints, wand.npoints),
wand.npoints,
Roi.TRACED_ROI
);
else
roi = new PolygonRoi(wand.xpoints, wand.ypoints, wand.npoints, Roi.TRACED_ROI);
Expand Down
59 changes: 42 additions & 17 deletions src/test/java/org/vanvalenlab/KioskJobManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,27 @@ public void testGetFilePath() throws IOException {
}

@Test
public void testConfigureOptions() {
public void testConfigureOptions() throws AWTException {
// TODO: GUI window is not in focus so keyPress events are ignored.
// Map<String, Object> options;

// ExecutorService executor = Executors.newFixedThreadPool(2);
// final Robot robot = new Robot();
// robot.setAutoDelay(100);
// robot.setAutoWaitForIdle(true);

// executor.submit(() -> {
// robot.delay(1000);
// // Push Enter to confirm options.
// robot.keyPress(KeyEvent.VK_ENTER);
// robot.keyRelease(KeyEvent.VK_ENTER);
// robot.delay(50);
// });
// options = KioskJobManager.configureOptions();
// assertEquals(
// options.get(Constants.KIOSK_HOST),
// Constants.getDefault(Constants.KIOSK_HOST)
// );
}

@Test
Expand All @@ -84,19 +103,6 @@ public void testSelectJobType() throws AWTException, IOException {
robot.setAutoDelay(100);
robot.setAutoWaitForIdle(true);

// test successful request
// server.enqueue(new MockResponse().setBody(responseStr));
// executor.submit(() -> {
// System.out.println("First robot delay");
// robot.delay(100);
// System.out.println("About to push key");
// robot.keyPress(InputEvent.BUTTON1_DOWN_MASK);
// System.out.println("key has been pressed");
// });
// jobType = KioskJobManager.selectJobType(baseUrl.toString());
// System.out.println("jobType");
// assertEquals(expectedJobType, jobType);

// test failed http request
for (int i = 0; i < Constants.MAX_HTTP_RETRIES; i++) {
server.enqueue(new MockResponse().setResponseCode(500).setBody("{}"));
Expand All @@ -106,12 +112,31 @@ public void testSelectJobType() throws AWTException, IOException {
);

// test empty json body
for (int i = 0; i < Constants.MAX_HTTP_RETRIES; i++) {
server.enqueue(new MockResponse().setResponseCode(500).setBody("{}"));
}
server.enqueue(new MockResponse().setBody("{}"));
assertThrows(IOException.class, () ->
KioskJobManager.selectJobType(baseUrl.toString())
);

// test successful request
// TODO: GUI window is not in focus so keyPress events are ignored.
// server.enqueue(new MockResponse().setBody(responseStr));
// executor.submit(() -> {
// robot.delay(500);
// // press tab twice to move to OK
// robot.keyPress(KeyEvent.VK_TAB);
// robot.keyRelease(KeyEvent.VK_TAB);
// robot.delay(50);
// robot.keyPress(KeyEvent.VK_TAB);
// robot.keyRelease(KeyEvent.VK_TAB);
// robot.delay(50);
// // OK button is selected, press enter.
// robot.keyPress(KeyEvent.VK_ENTER);
// robot.keyRelease(KeyEvent.VK_ENTER);
// robot.delay(50);
// });
// jobType = KioskJobManager.selectJobType(baseUrl.toString());
// System.out.println(jobType);
// assertEquals(expectedJobType, jobType);
}

@Test
Expand Down