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
2 changes: 1 addition & 1 deletion cdi-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.13.200</version>
<version>3.15.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ public <T, R> Promise<T> submit(Op op, Callable<T> task) {
return promise;
}

@Override
public String toString() {
return _bundle.toString();
}

private final BundleClassLoader _aggregateClassLoader;
private volatile Deferred<BeanManager> _beanManagerDeferred;
private final BeansModel _beansModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

package org.apache.aries.cdi.container.internal.phase;

import static org.apache.aries.cdi.container.internal.util.Reflection.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.apache.aries.cdi.container.internal.util.Reflection.cast;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.Collection;
Expand Down
3 changes: 2 additions & 1 deletion cdi-itests/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ p = org.apache.aries.cdi.test
tb17.jar,\
tb18.jar,\
tb19.jar,\
tb20.jar
tb20.jar,\
tb21.jar

# Don't forget that we had to coax the `maven-jar-plugin` NOT to include the `sub-bundle` packages in
# the root bundle:
Expand Down
13 changes: 13 additions & 0 deletions cdi-itests/bnd/tb21.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Export-Package: ${p}.tb21.*;-split-package:=first
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
*/

@Beans
@Requirement(
namespace = CDIConstants.CDI_EXTENSION_PROPERTY,
name = "aries.cdi.jndi"
)
package org.apache.aries.cdi.test.beans;

import org.osgi.annotation.bundle.Requirement;
import org.osgi.service.cdi.CDIConstants;
import org.osgi.service.cdi.annotations.Beans;
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.util.tracker.BundleTracker;
import org.osgi.util.tracker.ServiceTracker;

public class JndiExtensionTests extends AbstractTestCase {
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 {
assertNotNull(getBeanManager(cdiBundle));
Bundle testBundle = installBundle("tb21.jar", false);

testBundle.start();

assertNotNull(getBeanManager(testBundle));

Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
try {
BundleWiring bundleWiring = cdiBundle.adapt(BundleWiring.class);
BundleWiring bundleWiring = testBundle.adapt(BundleWiring.class);
currentThread.setContextClassLoader(bundleWiring.getClassLoader());

BeanManager beanManager = (BeanManager)InitialContext.doLookup("java:comp/BeanManager");
Expand All @@ -65,12 +70,20 @@ public Bundle addingBundle(Bundle bundle, BundleEvent event) {
};
bundleTracker.open();

Bundle testBundle = installBundle("tb21.jar", false);

testBundle.start();

ServiceTracker<Pojo, Pojo> st = new ServiceTracker<Pojo, Pojo>(
bundleContext, Pojo.class, null);
st.open(true);

try {
assertFalse(bundleTracker.isEmpty());

Bundle extensionBundle = bundleTracker.getBundles()[0];

try (CloseableTracker<BeanManager, BeanManager> bmTracker = trackBM(cdiBundle);) {
try (CloseableTracker<BeanManager, BeanManager> bmTracker = trackBM(testBundle);) {
assertNotNull(bmTracker.waitForService(timeout));

extensionBundle.stop();
Expand All @@ -79,18 +92,19 @@ public Bundle addingBundle(Bundle bundle, BundleEvent event) {
Thread.sleep(100);
}

assertThat(bmTracker).matches(CloseableTracker::isEmpty);
assertThat(bmTracker).matches(CloseableTracker::isEmpty, "Is empty");

extensionBundle.start();

for (int i = 20; (i > 0) && bmTracker.isEmpty(); i--) {
for (int i = 100; (i > 0) && bmTracker.isEmpty(); i--) {
Thread.sleep(100);
}

assertThat(bmTracker).matches(c -> !c.isEmpty());
assertThat(bmTracker).matches(c -> !c.isEmpty(), "Not empty");
}
}
finally {
testBundle.uninstall();
bundleTracker.close();
}
}
Expand Down
Loading