Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorootto2017-12-28 23:54:23 +0000
committerootto2017-12-28 23:54:23 +0000
commit8c95dac185dc64bea2f9037c726745f5a9bc1e2a (patch)
treefd3d60e125bfad99b9fa305db8f896e18f7357c8
parenta8bc65688b1010deef1d0c153e3dd6d0bf73e9ab (diff)
downloadorg.eclipse.gemini.blueprint-8c95dac185dc64bea2f9037c726745f5a9bc1e2a.tar.gz
org.eclipse.gemini.blueprint-8c95dac185dc64bea2f9037c726745f5a9bc1e2a.tar.xz
org.eclipse.gemini.blueprint-8c95dac185dc64bea2f9037c726745f5a9bc1e2a.zip
528188 Update to Spring 5
Adapted test assumptions to Spring 5 changes Removed OrderManagedProperties. There is no specification or requirement for its existence, and it is conceptually flawed as it opposed the semantics of its super class (Properties). Removed test cases no longer applicable or empty. Signed-off-by: ootto <olaf@x100.de>
-rw-r--r--core/src/main/java/org/eclipse/gemini/blueprint/blueprint/config/internal/BlueprintParser.java23
-rw-r--r--core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/BeanMetadataElementFactory.java11
-rw-r--r--core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/internal/support/OrderedManagedProperties.java181
-rw-r--r--core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java171
-rw-r--r--core/src/test/resources/org/eclipse/gemini/blueprint/config/osgiServiceNamespaceHandlerTests.xml14
-rw-r--r--integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/clogging/CommonsLogging104Test.java75
6 files changed, 93 insertions, 382 deletions
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/config/internal/BlueprintParser.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/config/internal/BlueprintParser.java
index f0fcd49..7a48063 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/config/internal/BlueprintParser.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/config/internal/BlueprintParser.java
@@ -14,20 +14,9 @@
package org.eclipse.gemini.blueprint.blueprint.config.internal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.gemini.blueprint.blueprint.config.internal.support.InstanceEqualityRuntimeBeanReference;
-import org.eclipse.gemini.blueprint.blueprint.reflect.internal.support.OrderedManagedProperties;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
@@ -56,6 +45,16 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
/**
* Stateful class that handles the parsing details of a &lt;component&gt; elements. Borrows heavily from
* {@link BeanDefinitionParserDelegate}.
@@ -792,7 +791,7 @@ public class BlueprintParser {
* Parse a props element.
*/
public Properties parsePropsElement(Element propsEle) {
- ManagedProperties props = new OrderedManagedProperties();
+ ManagedProperties props = new ManagedProperties();
props.setSource(extractSource(propsEle));
props.setMergeEnabled(parseMergeAttribute(propsEle));
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/BeanMetadataElementFactory.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/BeanMetadataElementFactory.java
index 26cb8b2..db9ac51 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/BeanMetadataElementFactory.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/BeanMetadataElementFactory.java
@@ -14,11 +14,6 @@
package org.eclipse.gemini.blueprint.blueprint.reflect;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.gemini.blueprint.blueprint.reflect.internal.support.OrderedManagedProperties;
import org.osgi.service.blueprint.reflect.CollectionMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.IdRefMetadata;
@@ -39,6 +34,10 @@ import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedProperties;
import org.springframework.beans.factory.support.ManagedSet;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
/**
* Adapter between OSGi's Blueprint {@link Value} and Spring {@link BeanMetadataElement}.
*
@@ -142,7 +141,7 @@ class BeanMetadataElementFactory {
PropsMetadata propertiesValue = (PropsMetadata) value;
List<MapEntry> entries = propertiesValue.getEntries();
- ManagedProperties managedProperties = new OrderedManagedProperties();
+ ManagedProperties managedProperties = new ManagedProperties();
for (MapEntry mapEntry : entries) {
managedProperties.put(BeanMetadataElementFactory.buildBeanMetadata(mapEntry.getKey()),
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/internal/support/OrderedManagedProperties.java b/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/internal/support/OrderedManagedProperties.java
deleted file mode 100644
index b5d7e87..0000000
--- a/core/src/main/java/org/eclipse/gemini/blueprint/blueprint/reflect/internal/support/OrderedManagedProperties.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2006, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Apache License v2.0 which accompanies this distribution.
- * The Eclipse Public License is available at
- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
- * is available at http://www.opensource.org/licenses/apache2.0.php.
- * You may elect to redistribute this code under either of these licenses.
- *
- * Contributors:
- * VMware Inc.
- *****************************************************************************/
-
-package org.eclipse.gemini.blueprint.blueprint.reflect.internal.support;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.Set;
-
-import org.springframework.beans.factory.support.ManagedProperties;
-
-/**
- * Extension that adds ordering to {@link ManagedProperties} class intended for preserving declaration order.
- *
- * @author Costin Leau
- */
-public class OrderedManagedProperties extends ManagedProperties {
-
- private final Map<Object, Object> orderedStorage = new LinkedHashMap<Object, Object>();
-
- public void clear() {
- orderedStorage.clear();
- }
-
- public boolean containsKey(Object key) {
- return orderedStorage.containsKey(key);
- }
-
- public boolean containsValue(Object value) {
- return orderedStorage.containsValue(value);
- }
-
- public Set<java.util.Map.Entry<Object, Object>> entrySet() {
- return orderedStorage.entrySet();
- }
-
- public boolean equals(Object o) {
- return orderedStorage.equals(o);
- }
-
- public Object get(Object key) {
- return orderedStorage.get(key);
- }
-
- public int hashCode() {
- return orderedStorage.hashCode();
- }
-
- public boolean isEmpty() {
- return orderedStorage.isEmpty();
- }
-
- public Set<Object> keySet() {
- return orderedStorage.keySet();
- }
-
- public Object put(Object key, Object value) {
- return orderedStorage.put(key, value);
- }
-
- public void putAll(Map<? extends Object, ? extends Object> t) {
- orderedStorage.putAll(t);
- }
-
- public Object remove(Object key) {
- return orderedStorage.remove(key);
- }
-
- public int size() {
- return orderedStorage.size();
- }
-
- public Collection<Object> values() {
- return orderedStorage.values();
- }
-
- @Override
- public String getProperty(String key, String defaultValue) {
- String val = getProperty(key);
- return (val == null ? defaultValue : val);
- }
-
- @Override
- public String getProperty(String key) {
- Object val = orderedStorage.get(key);
- return (val instanceof String ? (String) val : null);
- }
-
- @Override
- public Enumeration<?> propertyNames() {
- return new ArrayEnumeration<String>(filter(orderedStorage.keySet(), String.class));
- }
-
- @Override
- public synchronized Object setProperty(String key, String value) {
- return orderedStorage.put(key, value);
- }
-
- @Override
- public synchronized boolean contains(Object value) {
- return orderedStorage.containsKey(value);
- }
-
- @Override
- public synchronized Enumeration<Object> elements() {
- return new ArrayEnumeration<Object>(filter(orderedStorage.values(), Object.class));
- }
-
- @Override
- public synchronized Enumeration<Object> keys() {
- return new ArrayEnumeration<Object>(filter(orderedStorage.keySet(), Object.class));
- }
-
- @Override
- public synchronized String toString() {
- return orderedStorage.toString();
- }
-
- public Object merge(Object parent) {
- if (!isMergeEnabled()) {
- throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'");
- }
- if (parent == null) {
- return this;
- }
- if (!(parent instanceof Properties)) {
- throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]");
- }
- Properties merged = new OrderedManagedProperties();
- merged.putAll((Properties) parent);
- merged.putAll(this);
- return merged;
- }
-
- private <T> T[] filter(Collection<?> collection, Class<T> type) {
- List<T> list = new ArrayList<T>();
- for (Object member : collection) {
- if (type.isInstance(member)) {
- list.add((T) member);
- }
- }
- return (T[]) list.toArray(new Object[list.size()]);
- }
-
- private static class ArrayEnumeration<E> implements Enumeration<E> {
-
- private final E[] array;
- private int counter = 0;
-
- ArrayEnumeration(E[] array) {
- this.array = array;
- }
-
- public boolean hasMoreElements() {
- return (counter < array.length);
- }
-
- public E nextElement() {
- if (hasMoreElements())
- return array[counter++];
- throw new NoSuchElementException();
- }
- }
-} \ No newline at end of file
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java
index 34e0036..6dcb7f9 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/util/ClassUtilsTest.java
@@ -7,21 +7,14 @@
* http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
* is available at http://www.opensource.org/licenses/apache2.0.php.
* You may elect to redistribute this code under either of these licenses.
- *
+ *
* Contributors:
* VMware Inc.
*****************************************************************************/
package org.eclipse.gemini.blueprint.util;
-import java.io.Closeable;
-import java.io.Serializable;
-import java.util.AbstractMap;
-import java.util.HashMap;
-import java.util.Map;
-
import junit.framework.TestCase;
-
import org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext;
import org.eclipse.gemini.blueprint.context.DelegatedExecutionOsgiBundleApplicationContext;
import org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext;
@@ -29,7 +22,6 @@ import org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicatio
import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
import org.eclipse.gemini.blueprint.util.internal.ClassUtils;
import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.context.ApplicationContext;
@@ -43,101 +35,80 @@ import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.util.ObjectUtils;
+
+import java.io.Closeable;
+import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.eclipse.gemini.blueprint.util.internal.ClassUtils.ClassSet.ALL_CLASSES;
+import static org.eclipse.gemini.blueprint.util.internal.ClassUtils.ClassSet.CLASS_HIERARCHY;
+import static org.eclipse.gemini.blueprint.util.internal.ClassUtils.ClassSet.INTERFACES;
+import static org.eclipse.gemini.blueprint.util.internal.ClassUtils.getClassHierarchy;
/**
* @author Costin Leau
- *
+ * @author Olaf Otto
*/
public class ClassUtilsTest extends TestCase {
- public void testAutoDetectClassesForPublishingDisabled() throws Exception {
- Class<?>[] clazz = ClassUtils.getClassHierarchy(Integer.class, ClassUtils.ClassSet.INTERFACES);
- assertFalse(ObjectUtils.isEmpty(clazz));
- assertEquals(2, clazz.length);
- }
-
- public void testAutoDetectClassesForPublishingInterfaces() throws Exception {
- Class<?>[] clazz = ClassUtils.getClassHierarchy(HashMap.class, ClassUtils.ClassSet.INTERFACES);
- Class<?>[] expected = new Class<?>[] { Cloneable.class, Serializable.class, Map.class };
-
- assertTrue(compareArrays(expected, clazz));
- }
-
- public void testAutoDetectClassesForPublishingClassHierarchy() throws Exception {
- Class<?>[] clazz = ClassUtils.getClassHierarchy(HashMap.class, ClassUtils.ClassSet.CLASS_HIERARCHY);
- Class<?>[] expected = new Class<?>[] { HashMap.class, AbstractMap.class };
- assertTrue(compareArrays(expected, clazz));
- }
-
- public void testAutoDetectClassesForPublishingAll() throws Exception {
- Class<?>[] clazz = ClassUtils.getClassHierarchy(HashMap.class, ClassUtils.ClassSet.ALL_CLASSES);
- Class<?>[] expected =
- new Class<?>[] { Map.class, Cloneable.class, Serializable.class, HashMap.class, AbstractMap.class };
-
- assertTrue(compareArrays(expected, clazz));
- }
-
- public void testInterfacesHierarchy() {
- //Closeable.class,
- Class<?>[] clazz = ClassUtils.getAllInterfaces(DelegatedExecutionOsgiBundleApplicationContext.class);
- Class<?>[] expected =
- { ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class,
- ApplicationContext.class, Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
- HierarchicalBeanFactory.class, MessageSource.class, ApplicationEventPublisher.class,
- ResourcePatternResolver.class, BeanFactory.class, ResourceLoader.class, AutoCloseable.class };
-
- assertTrue(compareArrays(expected, clazz));
- }
-
- public void testAppContextClassHierarchy() {
- Class<?>[] clazz =
- ClassUtils.getClassHierarchy(OsgiBundleXmlApplicationContext.class, ClassUtils.ClassSet.ALL_CLASSES);
-
- //Closeable.class,
- Class<?>[] expected =
- new Class<?>[] { OsgiBundleXmlApplicationContext.class,
- AbstractDelegatedExecutionApplicationContext.class, AbstractOsgiBundleApplicationContext.class,
- AbstractRefreshableApplicationContext.class, AbstractApplicationContext.class,
- DefaultResourceLoader.class, ResourceLoader.class,
- AutoCloseable.class,
- DelegatedExecutionOsgiBundleApplicationContext.class,
- ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class,
- ApplicationContext.class, Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
- HierarchicalBeanFactory.class, ApplicationEventPublisher.class, ResourcePatternResolver.class,
- MessageSource.class, BeanFactory.class, DisposableBean.class };
-
- assertTrue(compareArrays(expected, clazz));
- }
-
- private boolean compareArrays(Object[] a, Object[] b) {
- if ((a == null && b != null) || (b == null && a != null))
- return false;
-
- if (a == null && b == null)
- return true;
-
- if (a == b)
- return true;
-
- if (a.length != b.length)
- return false;
-
- for (int i = 0; i < a.length; i++) {
- boolean found = false;
- for (int j = 0; j < b.length; j++) {
- if (a[i].equals(b[j])) {
- found = true;
- break;
- }
- }
- if (!found) {
- System.out.println("did not find " + a[i]);
- return false;
- }
-
- }
- return true;
- }
-
+ public void testAutoDetectClassesForPublishingDisabled() {
+ Class<?>[] resolved = getClassHierarchy(Integer.class, INTERFACES);
+ assertThat(resolved).hasSize(2);
+ }
+
+ public void testAutoDetectClassesForPublishingInterfaces() {
+ Class<?>[] resolved = getClassHierarchy(HashMap.class, INTERFACES);
+ assertThat(resolved).containsExactly(Map.class, Cloneable.class, Serializable.class);
+ }
+
+ public void testAutoDetectClassesForPublishingClassHierarchy() {
+ Class<?>[] resolved = getClassHierarchy(HashMap.class, CLASS_HIERARCHY);
+ assertThat(resolved).containsExactly(HashMap.class, AbstractMap.class);
+ }
+
+ public void testAutoDetectClassesForPublishingAll() {
+ Class<?>[] resolved = getClassHierarchy(HashMap.class, ALL_CLASSES);
+
+ assertThat(resolved).containsExactly(HashMap.class, Map.class, Cloneable.class, Serializable.class, AbstractMap.class);
+ }
+
+ public void testInterfacesHierarchy() {
+ Class<?>[] resolved = ClassUtils.getAllInterfaces(DelegatedExecutionOsgiBundleApplicationContext.class);
+
+ assertThat(resolved).containsExactly(ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class,
+ ApplicationContext.class, Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
+ HierarchicalBeanFactory.class, MessageSource.class, ApplicationEventPublisher.class,
+ ResourcePatternResolver.class, BeanFactory.class, ResourceLoader.class, AutoCloseable.class);
+ }
+
+ public void testAppContextClassHierarchy() {
+ Class<?>[] resolved = getClassHierarchy(OsgiBundleXmlApplicationContext.class, ALL_CLASSES);
+
+ assertThat(resolved).containsExactly(
+ OsgiBundleXmlApplicationContext.class,
+ AbstractDelegatedExecutionApplicationContext.class,
+ DelegatedExecutionOsgiBundleApplicationContext.class,
+ ConfigurableOsgiBundleApplicationContext.class,
+ ConfigurableApplicationContext.class,
+ ApplicationContext.class,
+ Lifecycle.class,
+ Closeable.class,
+ EnvironmentCapable.class,
+ ListableBeanFactory.class,
+ HierarchicalBeanFactory.class,
+ MessageSource.class,
+ ApplicationEventPublisher.class,
+ ResourcePatternResolver.class,
+ BeanFactory.class,
+ ResourceLoader.class,
+ AutoCloseable.class,
+ AbstractOsgiBundleApplicationContext.class,
+ AbstractRefreshableApplicationContext.class,
+ AbstractApplicationContext.class,
+ DefaultResourceLoader.class
+ );
+ }
}
diff --git a/core/src/test/resources/org/eclipse/gemini/blueprint/config/osgiServiceNamespaceHandlerTests.xml b/core/src/test/resources/org/eclipse/gemini/blueprint/config/osgiServiceNamespaceHandlerTests.xml
index a9a41e7..aeff9ee 100644
--- a/core/src/test/resources/org/eclipse/gemini/blueprint/config/osgiServiceNamespaceHandlerTests.xml
+++ b/core/src/test/resources/org/eclipse/gemini/blueprint/config/osgiServiceNamespaceHandlerTests.xml
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:osgi="http://www.springframework.org/schema/osgi"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<!-- osgi:reference -->
@@ -32,7 +30,7 @@
<entry key="foo" value="bar" />
<entry key="white" value="horse" />
</osgi:service-properties>
- <ref local="string" />
+ <ref bean="string" />
</osgi:service>
<!-- service -->
@@ -61,7 +59,7 @@
<osgi:service-properties>
<entry key="string" value="myprop" />
</osgi:service-properties>
- <ref local="map"/>
+ <ref bean="map"/>
</osgi:service>
<bean id="map" class="java.util.HashMap" />
diff --git a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/clogging/CommonsLogging104Test.java b/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/clogging/CommonsLogging104Test.java
deleted file mode 100644
index abb4e83..0000000
--- a/integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/clogging/CommonsLogging104Test.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2006, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Apache License v2.0 which accompanies this distribution.
- * The Eclipse Public License is available at
- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
- * is available at http://www.opensource.org/licenses/apache2.0.php.
- * You may elect to redistribute this code under either of these licenses.
- *
- * Contributors:
- * VMware Inc.
- *****************************************************************************/
-
-package org.eclipse.gemini.blueprint.iandt.clogging;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.gemini.blueprint.iandt.BaseIntegrationTest;
-import org.osgi.framework.BundleContext;
-import org.springframework.util.CollectionUtils;
-
-/**
- * Integration test for commons logging 1.0.4 and its broken logging discovery.
- *
- * @author Costin Leau
- *
- */
-public abstract class CommonsLogging104Test extends BaseIntegrationTest {
-
- /** logger */
- private static final Log log = LogFactory.getLog(CommonsLogging104Test.class);
-
-
- protected String[] getTestFrameworkBundlesNames() {
- String[] bundles = super.getTestFrameworkBundlesNames();
-
- // remove slf4j
- Collection bnds = new ArrayList(bundles.length);
- CollectionUtils.mergeArrayIntoCollection(bundles, bnds);
-
- for (Iterator iterator = bnds.iterator(); iterator.hasNext();) {
- String object = (String) iterator.next();
- // remove slf4j
- if (object.startsWith("org.slf4j"))
- iterator.remove();
- }
- // add commons logging
- bnds.add("org.eclipse.bundles,commons-logging,20070611");
-
- return (String[]) bnds.toArray(new String[bnds.size()]);
- }
-
- public void testSimpleLoggingStatement() throws Exception {
- log.info("logging statement");
- }
-
- protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
-
- // all below fail
- LogFactory.releaseAll();
- //System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.NoOpLog");
- System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
-
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- // System.out.println("TCCL is " + cl);
- Thread.currentThread().setContextClassLoader(null);
- super.preProcessBundleContext(platformBundleContext);
- }
-
-}

Back to the top