Skip to content

Commit

Permalink
Merge pull request #2018 from ControlSystemStudio/alarm_test_fix
Browse files Browse the repository at this point in the history
Fix IdentificationHelperTest
  • Loading branch information
kasemir authored Sep 26, 2021
2 parents 199de0c + cd91681 commit 415189d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*******************************************************************************
* Copyright (c) 2018 Oak Ridge National Laboratory.
* Copyright (c) 2018-2021 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.phoebus.applications.alarm.client;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.concurrent.TimeUnit;

Expand All @@ -27,16 +26,19 @@ public void testUserHost() throws Exception
String user = IdentificationHelper.getUser();
String host = IdentificationHelper.getHost();
System.out.println("User: '" + user + "' at host: '" + host + "'");
assertThat(user, equalTo("???"));
assertThat(host, equalTo("???"));
if ("???".equals(user) && "???".equals(host))
{
System.out.println("Initializing IdentificationHelper");
IdentificationHelper.initialize();
}
// else: Some other test that ran first already triggered initialization

// On successful initilization, there should soon be information
IdentificationHelper.initialize();
// On successful initialization, there should soon be information
int wait = 0;
while (host.equals("???"))
{
++wait;
assertThat("Timed out waiting for information", wait < 10, equalTo(true));
assertTrue("Timed out waiting for information", wait < 10);
TimeUnit.SECONDS.sleep(1);
user = IdentificationHelper.getUser();
host = IdentificationHelper.getHost();
Expand Down

0 comments on commit 415189d

Please sign in to comment.