Skip to content

Commit

Permalink
Revert "Fix ListenerErrorTest"
Browse files Browse the repository at this point in the history
This reverts commit 07a0607.

Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Jan 30, 2024
1 parent f4e4059 commit 17364f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -167,10 +165,9 @@ public void testComingDownDoesNotCallOtherServicesNoThreads() {
/**
* 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);
Expand All @@ -195,19 +192,16 @@ public void testHaltLevelRegressionOnError() throws InterruptedException {
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);
Expand All @@ -234,8 +228,6 @@ public void testHaltLevelRegressionOnErrorNoThreads() throws InterruptedExceptio

Assert.assertEquals(4, listener.getLatestOnProgress());

levelFiveService.latch().await(100, TimeUnit.MILLISECONDS);

Assert.assertTrue(levelFiveService.isPreDestroyCalled());
}

Expand Down

0 comments on commit 17364f6

Please sign in to comment.