Skip to content

Commit

Permalink
attempt to fix the blueprint and transaction intermittent itest failu…
Browse files Browse the repository at this point in the history
…re by closing the service tracker - able to get 3 good full build

git-svn-id: https://svn.apache.org/repos/asf/incubator/aries/trunk/transaction@924504 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Lin Sun committed Mar 17, 2010
1 parent 7eaecbf commit 57b755b
Showing 1 changed file with 24 additions and 2 deletions.
Expand Up @@ -25,7 +25,11 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Customizer;
Expand All @@ -51,6 +55,22 @@ public abstract class AbstractIntegrationTest {

public static final long DEFAULT_TIMEOUT = 30000;

private List<ServiceTracker> srs;

@Before
public void setUp() {
srs = new ArrayList<ServiceTracker>();
}

@After
public void tearDown() throws Exception{
for (ServiceTracker st : srs) {
if (st != null) {
st.close();
}
}
}

@Inject
protected BundleContext bundleContext;

Expand Down Expand Up @@ -156,8 +176,10 @@ protected <T> T getOsgiService(BundleContext bc, Class<T> type, String filter,
tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
null);
tracker.open();
// Note that the tracker is not closed to keep the reference
// This is buggy, has the service reference may change i think

// add tracker to the list of trackers we close at tear down
srs.add(tracker);

Object svc = type.cast(tracker.waitForService(timeout));
if (svc == null) {
throw new RuntimeException("Gave up waiting for service " + flt);
Expand Down

0 comments on commit 57b755b

Please sign in to comment.