Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -14,12 +14,9 @@

package org.apache.aries.cdi.extension.jndi;

import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER;

import java.util.Hashtable;
import java.util.concurrent.atomic.AtomicReference;

import javax.annotation.Priority;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
import javax.enterprise.inject.spi.BeanManager;
Expand All @@ -46,8 +43,7 @@ public Object getObjectInstance(
}

void applicationScopedInitialized(
@Observes @Priority(LIBRARY_AFTER + 800)
AfterDeploymentValidation adv, BeanManager beanManager) {
@Observes AfterDeploymentValidation adv, BeanManager beanManager) {

_beanManager.set(beanManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package org.apache.aries.cdi.extension.jndi;

import org.osgi.framework.Bundle;
import org.osgi.framework.PrototypeServiceFactory;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class JndiExtensionFactory implements PrototypeServiceFactory<Object> {
public class JndiExtensionFactory implements ServiceFactory<Object> {

@Override
public Object getService(Bundle bundle, ServiceRegistration<Object> registration) {
Expand Down
6 changes: 6 additions & 0 deletions cdi-itests/base-itest.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@
org.slf4j.helpers;version=1.7.25,\
org.slf4j.spi;version=1.7.25,\
sun.misc

-runrequires.base: \
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.extra)',\
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.itests)',\
osgi.identity;filter:='(osgi.identity=org.apache.aries.jndi.core)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
5 changes: 1 addition & 4 deletions cdi-itests/owb-itest.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
#-runjdb: 8000

-runrequires: \
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.owb)',\
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.itests)',\
osgi.identity;filter:='(osgi.identity=org.apache.aries.jndi.core)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.owb)'

-runblacklist: \
osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.weld)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public CloseableTracker(BundleContext context, Filter filter, ServiceTrackerCust
super(context, filter, customizer);
}

@Override
public void close() {
super.close();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
package org.apache.aries.cdi.test.cases;

import static java.lang.Thread.sleep;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.Dictionary;
import java.util.Hashtable;
Expand Down Expand Up @@ -197,14 +201,13 @@ public void testOptionalConfiguration() throws Exception {
Bundle tb5Bundle = installBundle("tb5.jar");

Configuration configurationC = null;
ServiceTracker<BeanService, BeanService> stC = null;
ServiceTracker<BeanService, BeanService> stC = new ServiceTracker<BeanService, BeanService>(
bundleContext, bundleContext.createFilter(
"(&(objectClass=org.apache.aries.cdi.test.interfaces.BeanService)(bean=C))"), null);

try {
Thread.sleep(1000); // <---- TODO fix this

stC = new ServiceTracker<BeanService, BeanService>(
bundleContext, bundleContext.createFilter(
"(&(objectClass=org.apache.aries.cdi.test.interfaces.BeanService)(bean=C))"), null);
stC.open(true);

BeanService<Callable<int[]>> beanService = stC.waitForService(timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.naming.InitialContext;

import org.apache.aries.cdi.test.interfaces.Pojo;
import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
Expand All @@ -32,7 +31,6 @@

public class JndiExtensionTests extends SlimTestCase {

@Ignore("I think there's an issue with Aries JNDI. It doesn't work well with service objects")
@Test
public void testGetBeanManagerThroughJNDI() throws Exception {
Bundle testBundle = installBundle("tb21.jar", false);
Expand Down Expand Up @@ -106,6 +104,7 @@ public Bundle addingBundle(Bundle bundle, BundleEvent event) {
finally {
testBundle.uninstall();
bundleTracker.close();
st.close();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;

public class SlimTestCase extends AbstractTestCase {
public abstract class SlimTestCase extends AbstractTestCase {

@BeforeClass
public static void beforeClass() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public class Test152_3 extends SlimTestCase {
public void componentScopeContext() throws Exception {
Bundle tbBundle = installBundle("tb152_3.jar");

ServiceTracker<Object, Object> oneTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "one");
ServiceTracker<Object, Object> twoTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "two");
try {
getBeanManager(tbBundle);

ServiceTracker<Object, Object> oneTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "one");
oneTracker.open();
Object service = oneTracker.waitForService(timeout);

ServiceTracker<Object, Object> twoTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "two");
twoTracker.open();
twoTracker.waitForService(timeout);

Expand All @@ -48,6 +48,8 @@ public void componentScopeContext() throws Exception {
assertThat(context).isNotNull();
}
finally {
oneTracker.close();
twoTracker.close();
tbBundle.uninstall();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.apache.aries.cdi.test.cases;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Hashtable;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -90,14 +90,15 @@ public void checkSingleComponentContextEvents() throws Exception {
Function.class, onDestroyed,
new Hashtable() {{put(Constants.SERVICE_DESCRIPTION, "onDestroyed");}});

ServiceTracker<Object, Object> twoTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "two");

try {
getBeanManager(tb152_3_1Bundle);

assertThat(a.get()).isNull();
assertThat(b.get()).isNull();
assertThat(c.get()).isNull();

ServiceTracker<Object, Object> twoTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "two");
twoTracker.open();
int trackingCount = twoTracker.getTrackingCount();

Expand Down Expand Up @@ -146,6 +147,7 @@ Integer.class, new Integer(45),
assertThat(eventMetadata.getQualifiers()).contains(Service.Literal.of(new Class<?>[0]));
}
finally {
twoTracker.close();
onInitializedReg.unregister();
onBeforeDestroyedReg.unregister();
onDestroyedReg.unregister();
Expand Down Expand Up @@ -194,6 +196,7 @@ public void checkFactoryComponentContextEvents() throws Exception {
new Hashtable() {{put(Constants.SERVICE_DESCRIPTION, "onDestroyed");}});

Configuration configuration = null;
ServiceTracker<Object, Object> threeTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "three");

try {
getBeanManager(tb152_3_1Bundle);
Expand All @@ -202,7 +205,6 @@ public void checkFactoryComponentContextEvents() throws Exception {
assertThat(b.get()).isNull();
assertThat(c.get()).isNull();

ServiceTracker<Object, Object> threeTracker = track("(&(objectClass=%s)(%s=%s))", BeanService.class.getName(), Constants.SERVICE_DESCRIPTION, "three");
threeTracker.open();
int trackingCount = threeTracker.getTrackingCount();

Expand Down Expand Up @@ -263,6 +265,7 @@ Integer.class, new Integer(45),
assertThat(eventMetadata.getQualifiers()).contains(Service.Literal.of(new Class<?>[0]));
}
finally {
threeTracker.close();
configuration.delete();
onInitializedReg.unregister();
onBeforeDestroyedReg.unregister();
Expand Down
Loading