/**
 * Copyright 2006-2012 the original author or authors.
 *
 * 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.
 */
package org.objenesis.tck;

import java.io.IOException;
import java.io.Serializable;

import org.objenesis.Objenesis;
import org.objenesis.ObjenesisHelper;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;

/**
 * @author Henri Tremblay
 */
public class OsgiTest extends AbstractConfigurableBundleCreatorTests implements Serializable {

   private static final long serialVersionUID = 1L;

   protected String[] getTestBundlesNames() {
      final String version = getImplementationVersion(Objenesis.class);
      return new String[] {"org.objenesis, objenesis, " + version};
   }

   public void testCanInstantiate() throws IOException {
      assertSame(OsgiTest.class, ObjenesisHelper.newInstance(getClass()).getClass());
   }

   public void testCanInstantiateSerialize() throws IOException {
      assertSame(OsgiTest.class, ObjenesisHelper.newSerializableInstance(getClass()).getClass());
   }

   protected String getImplementationVersion(final Class c) {
      return c.getPackage().getImplementationVersion();
   }
}

@@ -655,24 +655,46 @@
 sis.tck;%0D%0A%0D%0A
+import java.io.File;%0D%0A
 import java.
@@ -738,24 +738,279 @@
 lizable;%0D%0A%0D%0A
+import javax.xml.parsers.DocumentBuilder;%0D%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0D%0Aimport javax.xml.xpath.XPath;%0D%0Aimport javax.xml.xpath.XPathExpression;%0D%0Aimport javax.xml.xpath.XPathExpressionException;%0D%0Aimport javax.xml.xpath.XPathFactory;%0D%0A%0D%0A
 import org.o
@@ -1146,16 +1146,46 @@
 rTests;%0D
+%0Aimport org.w3c.dom.Document;%0D
 %0A%0D%0A/**%0D%0A
@@ -1422,22 +1422,16 @@
 %0D%0A      
-final 
 String v
@@ -1483,16 +1483,1258 @@
 lass);%0D%0A
+      // Null means we are an IDE, not in Maven. So we have an IDE project dependency instead%0D%0A      // of a Maven dependency with the jar. Which explains why the version is null (no Manifest%0D%0A      // since there's no jar. In that case we get the version from the pom.xml and hope the Maven%0D%0A      // jar is up-to-date in the local repository%0D%0A      if(version == null) %7B%0D%0A         try %7B%0D%0A            XPathFactory xPathFactory = XPathFactory.newInstance();%0D%0A            final XPath xPath = xPathFactory.newXPath();%0D%0A            XPathExpression xPathExpression;%0D%0A            try %7B%0D%0A               xPathExpression = xPath.compile(%22/project/parent/version%22);%0D%0A            %7D%0D%0A            catch(final XPathExpressionException e) %7B%0D%0A               throw new RuntimeException(e);%0D%0A            %7D%0D%0A%0D%0A            final DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance();%0D%0A            xmlFact.setNamespaceAware(false);%0D%0A            final DocumentBuilder builder = xmlFact.newDocumentBuilder();%0D%0A            final Document doc = builder.parse(new File(%22pom.xml%22));%0D%0A            version = xPathExpression.evaluate(doc);%0D%0A         %7D%0D%0A         catch(final Exception e) %7B%0D%0A            throw new RuntimeException(e);%0D%0A         %7D%0D%0A      %7D%0D%0A
       re

Make the OSGi test work in Eclipse