Revert "Fix ListenerErrorTest"
This reverts commit 07a0607ad11e4a09ab946e0973ad0ac26901c207.
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
diff --git a/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/LevelFiveService.java b/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/LevelFiveService.java
index a7f5d0c..fa407da 100755
--- a/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/LevelFiveService.java
+++ b/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/LevelFiveService.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,9 +16,6 @@
package org.glassfish.hk2.runlevel.tests.listener;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-
import javax.annotation.PreDestroy;
import org.glassfish.hk2.runlevel.RunLevel;
@@ -32,22 +29,17 @@
*/
@RunLevel(5)
public class LevelFiveService {
-
- private final CountDownLatch latch = new CountDownLatch(1);
- private AtomicBoolean preDestroyCalled = new AtomicBoolean(false);
-
+ private boolean preDestroyCalled = false;
+
@SuppressWarnings("unused")
@PreDestroy
private void preDestroy() {
- preDestroyCalled.set(true);
- latch.countDown();
+ preDestroyCalled = true;
+
}
/* package */ boolean isPreDestroyCalled() {
- return preDestroyCalled.get();
+ return preDestroyCalled;
}
- /* package */ CountDownLatch latch() {
- return latch;
- }
}
diff --git a/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/ListenerErrorTest.java b/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/ListenerErrorTest.java
index 138c414..7aadbb8 100755
--- a/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/ListenerErrorTest.java
+++ b/hk2-runlevel/src/test/java/org/glassfish/hk2/runlevel/tests/listener/ListenerErrorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,8 +16,6 @@
package org.glassfish.hk2.runlevel.tests.listener;
-import java.util.concurrent.TimeUnit;
-
import org.glassfish.hk2.api.Descriptor;
import org.glassfish.hk2.api.MultiException;
import org.glassfish.hk2.api.ServiceLocator;
@@ -167,10 +165,9 @@
/**
* Ensures the user can halt the downward level progression if a service
* failed when going down
- * @throws InterruptedException
*/
@Test
- public void testHaltLevelRegressionOnError() throws InterruptedException {
+ public void testHaltLevelRegressionOnError() {
ServiceLocator locator = Utilities.getServiceLocator(LevelFiveDownErrorService.class,
LevelFiveService.class,
OnProgressLevelChangerListener.class);
@@ -195,19 +192,16 @@
OnProgressLevelChangerListener listener = locator.getService(OnProgressLevelChangerListener.class);
Assert.assertEquals(4, listener.getLatestOnProgress());
-
- levelFiveService.latch().await(100, TimeUnit.MILLISECONDS);
-
+
Assert.assertTrue(levelFiveService.isPreDestroyCalled());
}
/**
* Ensures the user can halt the downward level progression if a service
* failed when going down
- * @throws InterruptedException
*/
@Test
- public void testHaltLevelRegressionOnErrorNoThreads() throws InterruptedException {
+ public void testHaltLevelRegressionOnErrorNoThreads() {
ServiceLocator locator = Utilities.getServiceLocator(LevelFiveDownErrorService.class,
LevelFiveService.class,
OnProgressLevelChangerListener.class);
@@ -234,8 +228,6 @@
Assert.assertEquals(4, listener.getLatestOnProgress());
- levelFiveService.latch().await(100, TimeUnit.MILLISECONDS);
-
Assert.assertTrue(levelFiveService.isPreDestroyCalled());
}