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

Fix IdentificationHelperTest #2018

Merged
merged 1 commit into from
Sep 26, 2021
Merged
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
@@ -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