Skip to content

Commit

Permalink
[AS7-6647] OSGI tests failing intermittently
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Diesler authored and bstansberry committed Mar 11, 2013
1 parent cf87a56 commit 8922d20
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@
import org.jboss.osgi.resolver.XResolveContext;
import org.jboss.osgi.resolver.XResolver;
import org.jboss.vfs.VFSUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.startlevel.BundleStartLevel;
import org.osgi.framework.startlevel.FrameworkStartLevel;
import org.osgi.service.resolver.ResolutionException;

/**
Expand Down Expand Up @@ -253,9 +255,11 @@ public void uninstall(XBundle bundle, int options) throws BundleException {
private void activateDeferredPhase(XBundle bundle, int options, DeploymentUnit depUnit, ServiceController<Phase> phaseService) throws BundleException {

// If the Framework's current start level is less than this bundle's start level
BundleManager bundleManager = injectedBundleManager.getValue();
FrameworkStartLevel frameworkStartLevel = bundleManager.getSystemBundle().adapt(FrameworkStartLevel.class);
BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class);
int startlevel = bundleStartLevel.getStartLevel();
if (startlevel > bundleStartLevel.getStartLevel()) {
if (startlevel > frameworkStartLevel.getStartLevel()) {
LOGGER.debugf("Start level [%d] not valid for: %s", startlevel, bundle);
return;
}
Expand Down Expand Up @@ -287,8 +291,20 @@ private void activateDeferredPhase(XBundle bundle, int options, DeploymentUnit d
}

// In case of failure we go back to NEVER
if (failed.size() > 0) {

if (failed.size() == 0) {
// The Bundle.ACTIVE service is not tracked by the {@link StabilityMonitor}
// Wait for it to come up explicitly
ServiceName activeName = bundleManager.getServiceName(bundle, Bundle.ACTIVE);
ServiceContainer serviceContainer = bundleManager.getServiceContainer();
ServiceController<?> activeService = serviceContainer.getRequiredService(activeName);
try {
FutureServiceValue<?> future = new FutureServiceValue<>(activeService, State.UP);
future.get(2, TimeUnit.SECONDS);
} catch (Exception ex) {
// ignore
}
} else {
// Collect the first start exception
StartException startex = null;
for (ServiceController<?> aux : failed) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<version.org.jboss.modules.jboss-modules>1.2.0.CR2</version.org.jboss.modules.jboss-modules>
<version.org.jboss.msc.jboss-msc>1.1.1.Final</version.org.jboss.msc.jboss-msc>
<version.org.jboss.osgi.deployment>2.0.0.CR1</version.org.jboss.osgi.deployment>
<version.org.jboss.osgi.framework>3.0.0.CR2</version.org.jboss.osgi.framework>
<version.org.jboss.osgi.framework>3.0.0.CR4</version.org.jboss.osgi.framework>
<version.org.jboss.osgi.logging>1.0.0.Final</version.org.jboss.osgi.logging>
<version.org.jboss.osgi.metadata>3.0.0.Alpha5</version.org.jboss.osgi.metadata>
<version.org.jboss.osgi.resolver>4.0.0.Alpha6</version.org.jboss.osgi.resolver>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* @author [email protected]
* @since 12-Dec-2012
*/
@org.junit.Ignore("AS7-6511")
public class StandaloneBootstrapTestCase {

private static final String BUNDLE_A = "bundleA";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -43,7 +42,6 @@
* @author [email protected]
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class LogServiceDynamicImportTestCase {

private static final String BUNDLE_A = "bundleA";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* @author [email protected]
*/
@RunWith(Arquillian.class)
@org.junit.Ignore("AS7-6511")
public class LogServiceStaticImportTestCase {

private static final String BUNDLE_A = "bundleA";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -47,7 +46,6 @@
* @since 23-Aug-2011
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class OptionalImportTestCase {

static final String BUNDLE_A = "optional-import-a";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
* @since 30-Sep-2012
*/
@RunWith(Arquillian.class)
@org.junit.Ignore("AS7-6511")
public class ConfigAdminIntegrationTestCase {

static final String CONFIG_ADMIN_BUNDLE_A = "config-admin-bundle-a";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* @since 07-Jun-2011
*/
@RunWith(Arquillian.class)
@org.junit.Ignore("AS7-6511")
public class StartLevelTestCase {

private static final String BUNDLE_A = "osgi-startlevel-a";
Expand All @@ -69,7 +68,7 @@ public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(ServiceTracker.class);
builder.addImportPackages(FrameworkStartLevel.class, ServiceTracker.class);
return builder.openStream();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -45,7 +44,6 @@
* @since 09-Sep-2010
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class ArquillianDeployerTestCase {

private static final String DEPLOYMENT_NAME = "arquillian-deployer-test-bundle";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -56,7 +55,6 @@
* @since 25-Sep-2012
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class DeferredResolveTestCase {

private static final String GOOD_BUNDLE = "good-bundle.jar";
Expand Down Expand Up @@ -87,7 +85,7 @@ public InputStream openStream() {
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(ModelControllerClient.class, ModelNode.class, ManagementClient.class);
builder.addImportPackages(ServiceTracker.class);
builder.addImportPackages(FrameworkStartLevel.class, FrameworkWiring.class, ServiceTracker.class);
builder.addImportPackages(XBundle.class);
return builder.openStream();
}
Expand Down Expand Up @@ -150,7 +148,6 @@ public void testFailOnDeploy() throws Exception {
}

@Test
@org.junit.Ignore("AS7-6511")
public void testFailAPICall() throws Exception {
InputStream input = deployer.getDeployment(BAD_BUNDLE);
Bundle bundle = context.installBundle(BAD_BUNDLE, input);
Expand All @@ -174,7 +171,6 @@ public void testFailAPICall() throws Exception {
}

@Test
@org.junit.Ignore("AS7-6511")
public void testFailStartLevel() throws Exception {
int orglevel = FrameworkUtils.getFrameworkStartLevel(context);
InputStream input = deployer.getDeployment(BAD_BUNDLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -45,7 +44,6 @@
* @since 19-Oct-2012
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class DeploymentMarkerTestCase {

static final String BUNDLE_A = "deploymentmarker-bundle-a";
Expand All @@ -67,6 +65,7 @@ public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(BundleStartLevel.class);
return builder.openStream();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -55,7 +54,6 @@
* @since 22-Mar-2012
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class ServerDeploymentTestCase {

static final String GOOD_BUNDLE = "good-bundle.jar";
Expand Down Expand Up @@ -98,7 +96,7 @@ public void testAutoStart() throws Exception {
String runtimeName = server.deploy("auto-start", input);

// Find the deployed bundle
Bundle bundle = context.getBundle(GOOD_BUNDLE);
Bundle bundle = context.getBundle("auto-start");
Assert.assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());

server.undeploy(runtimeName);
Expand Down Expand Up @@ -128,7 +126,7 @@ public void testRedeployAfterUndeploy() throws Exception {
String runtimeName = server.deploy("redeploy", input);

// Find the deployed bundle
Bundle bundle = context.getBundle(GOOD_BUNDLE);
Bundle bundle = context.getBundle("redeploy");
Assert.assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());

server.undeploy(runtimeName);
Expand All @@ -139,7 +137,7 @@ public void testRedeployAfterUndeploy() throws Exception {
runtimeName = server.deploy("redeploy", input);

// Find the deployed bundle
bundle = context.getBundle(GOOD_BUNDLE);
bundle = context.getBundle("redeploy");
Assert.assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());

server.undeploy(runtimeName);
Expand All @@ -156,15 +154,15 @@ public void testAttachedFragment() throws Exception {
String fragmentName = server.deploy("bundle-fragment-attached", input);

// Find the deployed bundle
Bundle fragment = context.getBundle(GOOD_FRAGMENT);
Bundle fragment = context.getBundle("bundle-fragment-attached");
Assert.assertEquals("Bundle INSTALLED", Bundle.INSTALLED, fragment.getState());

// Deploy the bundle
input = deployer.getDeployment(GOOD_BUNDLE);
String hostName = server.deploy("bundle-host-attached", input);

// Find the deployed bundle
Bundle host = context.getBundle(GOOD_BUNDLE);
Bundle host = context.getBundle("bundle-host-attached");
Assert.assertEquals("Bundle ACTIVE", Bundle.ACTIVE, host.getState());
Assert.assertEquals("Bundle RESOLVED", Bundle.RESOLVED, fragment.getState());

Expand All @@ -189,15 +187,15 @@ public void testUnattachedFragment() throws Exception {
String hostName = server.deploy("bundle-host", input);

// Find the deployed bundle
Bundle host = context.getBundle(GOOD_BUNDLE);
Bundle host = context.getBundle("bundle-host");
Assert.assertEquals("Bundle ACTIVE", Bundle.ACTIVE, host.getState());

// Deploy the fragment
input = deployer.getDeployment(GOOD_FRAGMENT);
String fragmentName = server.deploy("bundle-fragment", input);

// Find the deployed bundle
Bundle fragment = context.getBundle(GOOD_FRAGMENT);
Bundle fragment = context.getBundle("bundle-fragment");
Assert.assertEquals("Bundle INSTALLED", Bundle.INSTALLED, fragment.getState());

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
* @since 30-Aug-2012
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6647")
public class RestEndpointTestCase {

private static final String SIMPLE_WAR = "simple.war";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
Expand All @@ -55,7 +54,6 @@
* @since 23-Oct-2009
*/
@RunWith(Arquillian.class)
@Ignore("AS7-6627")
public class TransactionTestCase {

@ArquillianResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
* @since 19-Jan-2012
*/
@RunWith(Arquillian.class)
@org.junit.Ignore("AS7-6511")
public class RepositoryTestCase {

@ArquillianResource
Expand Down Expand Up @@ -102,7 +101,7 @@ public void testRepositoryService() throws Exception {
try {
bundle.start();
Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
ServiceReference sref = context.getServiceReference("org.osgi.service.event.EventAdmin");
ServiceReference<?> sref = context.getServiceReference("org.osgi.service.event.EventAdmin");
assertNotNull("EventAdmin service not null", sref);
} finally {
bundle.uninstall();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public void testSimpleBundleWithJarExtension() throws Exception {
}

@Test
@org.junit.Ignore("AS7-6511")
public void testDeferredBundleWithWabExtension() throws Exception {
InputStream input = deployer.getDeployment(BUNDLE_C_WAB);
Bundle bundle = context.installBundle(BUNDLE_C_WAB, input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
* @since 14-Oct-2010
*/
@RunWith(Arquillian.class)
@org.junit.Ignore("AS7-6511")
public class BundleAccessesModuleServiceTestCase extends AbstractXServiceTestCase {

private static final String TARGET_MODULE_NAME = "example-xservice-bam-target-module";
Expand Down Expand Up @@ -114,8 +113,8 @@ public void bundleInvokesModuleService() throws Exception {
// The client bundle activator registers a StringBuffer service that
// contains the result from the module service call
BundleContext context = clientBundle.getBundleContext();
ServiceReference sref = context.getServiceReference(StringBuffer.class.getName());
StringBuffer service = (StringBuffer) context.getService(sref);
ServiceReference<StringBuffer> sref = context.getServiceReference(StringBuffer.class);
StringBuffer service = context.getService(sref);
assertEquals("hello world", service.toString());
} finally {
// Uninstall the client bundle
Expand Down

0 comments on commit 8922d20

Please sign in to comment.