summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Bateman2013-08-16 18:28:22 (EDT)
committerCameron Bateman2013-08-16 18:28:22 (EDT)
commit26e684870eb49cdc37fcd91f14424f1d22f73430 (patch)
tree9dbd3a16f315fc89cb17bed9e03b84e97e2c2e33
parent8f0cb2a5839eb5d849d2e5e72f1f98ac8e1225f6 (diff)
downloadwebtools.jsf.tests-26e684870eb49cdc37fcd91f14424f1d22f73430.zip
webtools.jsf.tests-26e684870eb49cdc37fcd91f14424f1d22f73430.tar.gz
webtools.jsf.tests-26e684870eb49cdc37fcd91f14424f1d22f73430.tar.bz2
Fix mock workspace objects affected by Luna changes to OSGI internals.v201308280918
-rw-r--r--jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/junit4/WorkspaceRunner.java7
-rw-r--r--jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/BundleHacker.java39
-rw-r--r--jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/MockFrameworkAdaptor.java415
3 files changed, 28 insertions, 433 deletions
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/junit4/WorkspaceRunner.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/junit4/WorkspaceRunner.java
index 63c2b3d..5af1ae1 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/junit4/WorkspaceRunner.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/junit4/WorkspaceRunner.java
@@ -10,7 +10,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jst.jsf.test.util.JSFTestUtil;
import org.eclipse.jst.jsf.test.util.mock.IWorkspaceContext;
import org.eclipse.jst.jsf.test.util.mock.MockWorkspaceContext;
-import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
+import org.eclipse.osgi.internal.loader.ModuleClassLoader;
import org.junit.Rule;
import org.junit.rules.MethodRule;
import org.junit.runners.BlockJUnit4ClassRunner;
@@ -27,6 +27,7 @@ import org.osgi.framework.Bundle;
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=343672
*
*/
+@SuppressWarnings("deprecation")
public class WorkspaceRunner extends BlockJUnit4ClassRunner
{
@Rule
@@ -64,9 +65,9 @@ public class WorkspaceRunner extends BlockJUnit4ClassRunner
: new MockWorkspaceContext();
context.init();
File baseLoc = null;
- if (Platform.isRunning() && classLoader instanceof BaseClassLoader)
+ if (Platform.isRunning() && classLoader instanceof ModuleClassLoader)
{
- final Bundle bundle = ((BaseClassLoader) classLoader).getBundle();
+ final Bundle bundle = ((ModuleClassLoader) classLoader).getBundle();
final IPath absolutePath = JSFTestUtil.getAbsolutePath(bundle, "/");
baseLoc = absolutePath.toFile();
} else
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/BundleHacker.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/BundleHacker.java
index dbf7962..d7918fe 100644
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/BundleHacker.java
+++ b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/BundleHacker.java
@@ -12,11 +12,13 @@
package org.eclipse.jst.jsf.test.util.mock.osgi;
import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.EnumSet;
-import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
-import org.eclipse.osgi.framework.internal.core.BundleContextImpl;
-import org.eclipse.osgi.framework.internal.core.BundleHost;
-import org.eclipse.osgi.framework.internal.core.Framework;
+import org.eclipse.osgi.container.Module.Settings;
+import org.eclipse.osgi.internal.framework.BundleContextImpl;
+import org.eclipse.osgi.internal.framework.EquinoxBundle;
+import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -43,19 +45,26 @@ public class BundleHacker
final Field declaredField = clazz.getDeclaredField("context");
declaredField.setAccessible(true);
- final BundleHost host = createMockBundleHost();
- BundleContextImpl bundleContextImpl = new BundleContextImpl(host)
- {
- };
+ @SuppressWarnings("unchecked")
+ EquinoxContainer container = new EquinoxContainer(Collections.EMPTY_MAP);
+ EquinoxBundle bundle = createEquinoxBundle(container);
+
+ BundleContextImpl bundleContextImpl = new BundleContextImpl(bundle,container);
+// {
+// };
declaredField.set(instance, bundleContextImpl);
return bundleContextImpl;
}
- private BundleHost createMockBundleHost() throws BundleException
- {
- final FrameworkAdaptor adaptor = new MockFrameworkAdaptor();
- final Framework framework = new Framework(adaptor);
- final BundleHost host = new BundleHost(null, framework);
- return host;
- }
+ private EquinoxBundle createEquinoxBundle(EquinoxContainer equinoxContainer) {
+ return new EquinoxBundle(-1L, null, null, EnumSet.of(Settings.USE_ACTIVATION_POLICY), 3, equinoxContainer);
+ }
+
+// private BundleHost createMockBundleHost() throws BundleException
+// {
+// final FrameworkAdaptor adaptor = new MockFrameworkAdaptor();
+// final Framework framework = new Framework(adaptor);
+// final BundleHost host = new BundleHost(null, framework);
+// return host;
+// }
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/MockFrameworkAdaptor.java b/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/MockFrameworkAdaptor.java
deleted file mode 100644
index aaa2540..0000000
--- a/jsf/tests/org.eclipse.jst.jsf.test.util/src/org/eclipse/jst/jsf/test/util/mock/osgi/MockFrameworkAdaptor.java
+++ /dev/null
@@ -1,415 +0,0 @@
-package org.eclipse.jst.jsf.test.util.mock.osgi;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
-import org.eclipse.osgi.framework.adaptor.BundleData;
-import org.eclipse.osgi.framework.adaptor.BundleOperation;
-import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
-import org.eclipse.osgi.framework.adaptor.BundleWatcher;
-import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
-import org.eclipse.osgi.framework.adaptor.EventPublisher;
-import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
-import org.eclipse.osgi.framework.adaptor.PermissionStorage;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.framework.log.FrameworkLogEntry;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
-import org.eclipse.osgi.service.resolver.State;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.Version;
-
-public class MockFrameworkAdaptor implements FrameworkAdaptor
-{
- public void initialize(final EventPublisher eventPublisher)
- {
- // throw new UnsupportedOperationException();
- }
-
- public void initializeStorage() throws IOException
- {
- // throw new UnsupportedOperationException();
- }
-
- public void compactStorage() throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public Properties getProperties()
- {
- return new Properties();
- }
-
- public BundleData[] getInstalledBundles()
- {
- return null;
- }
-
- public URLConnection mapLocationToURLConnection(final String location)
- throws BundleException
- {
- throw new UnsupportedOperationException();
- }
-
- public BundleOperation installBundle(final String location,
- final URLConnection source)
- {
- throw new UnsupportedOperationException();
- }
-
- public BundleOperation updateBundle(final BundleData bundledata,
- final URLConnection source)
- {
- throw new UnsupportedOperationException();
-
- }
-
- public BundleOperation uninstallBundle(final BundleData bundledata)
- {
- throw new UnsupportedOperationException();
- }
-
- public long getTotalFreeSpace() throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- public PermissionStorage getPermissionStorage() throws IOException
- {
- return new PermissionStorage()
- {
-
- public void setPermissionData(final String location,
- final String[] data) throws IOException
- {
- throw new UnsupportedOperationException();
-
- }
-
- public void saveConditionalPermissionInfos(final String[] infos)
- throws IOException
- {
- throw new UnsupportedOperationException();
-
- }
-
- public String[] getPermissionData(final String location)
- throws IOException
- {
- return null;
- }
-
- public String[] getLocations() throws IOException
- {
- return null;
- }
-
- public String[] getConditionalPermissionInfos()
- throws IOException
- {
- return null;
- }
- };
- }
-
- public void frameworkStart(final BundleContext context)
- throws BundleException
- {
- throw new UnsupportedOperationException();
- }
-
- public void frameworkStop(final BundleContext context)
- throws BundleException
- {
- throw new UnsupportedOperationException();
- }
-
- public void frameworkStopping(final BundleContext context)
- {
- throw new UnsupportedOperationException();
- }
-
- public int getInitialBundleStartLevel()
- {
- throw new UnsupportedOperationException();
- }
-
- public void setInitialBundleStartLevel(final int value)
- {
- throw new UnsupportedOperationException();
- }
-
- public FrameworkLog getFrameworkLog()
- {
- return new FrameworkLog()
- {
-
- public void log(final FrameworkEvent frameworkEvent)
- {
- log(new FrameworkLogEntry(
- frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent
- .getBundle().getLocation() : frameworkEvent
- .getBundle().getSymbolicName(),
- FrameworkLogEntry.ERROR,
- 0,
- "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null)); //$NON-NLS-1$
- }
-
- public void log(final FrameworkLogEntry logEntry)
- {
- System.err.print(logEntry.getEntry() + " "); //$NON-NLS-1$
- System.err.println(logEntry.getMessage());
- if (logEntry.getThrowable() != null)
- {
- logEntry.getThrowable().printStackTrace(System.err);
- }
- }
-
- public void setWriter(final Writer newWriter,
- final boolean append)
- {
- // do nothing
- }
-
- public void setFile(final File newFile, final boolean append)
- throws IOException
- {
- // do nothing
- }
-
- public File getFile()
- {
- // do nothing
- return null;
- }
-
- public void setConsoleLog(final boolean consoleLog)
- {
- // do nothing
- }
-
- public void close()
- {
- // do nothing
- }
- };
- }
-
- public BundleData createSystemBundleData() throws BundleException
- {
- return new BundleData()
- {
-
- public void setStatus(final int value)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setStartLevel(final int value)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setBundle(final Bundle bundle)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void save() throws IOException
- {
- // TODO Auto-generated method stub
-
- }
-
- public void open() throws IOException
- {
- // TODO Auto-generated method stub
-
- }
-
- public void installNativeCode(final String[] nativepaths)
- throws BundleException
- {
- // TODO Auto-generated method stub
-
- }
-
- public Version getVersion()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getType()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getSymbolicName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getStatus()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getStartLevel()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Dictionary<String, String> getManifest() throws BundleException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getLocation()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public long getLastModified()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getExecutionEnvironment()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Enumeration<String> getEntryPaths(final String path)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public URL getEntry(final String path)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getDynamicImports()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public File getDataFile(final String path)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getClassPath() throws BundleException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public long getBundleID()
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getActivator()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String findLibrary(final String libname)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public BundleClassLoader createClassLoader(
- final ClassLoaderDelegate delegate,
- final BundleProtectionDomain domain,
- final String[] bundleclasspath)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void close() throws IOException
- {
- // TODO Auto-generated method stub
-
- }
-
- public Bundle getBundle()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Enumeration<URL> findLocalResources(String path)
- {
- // TODO Auto-generated method stub
- return null;
- }
- };
- }
-
- public BundleWatcher getBundleWatcher()
- {
- throw new UnsupportedOperationException();
-
- }
-
- public PlatformAdmin getPlatformAdmin()
- {
- throw new UnsupportedOperationException();
-
- }
-
- public State getState()
- {
- throw new UnsupportedOperationException();
-
- }
-
- public ClassLoader getBundleClassLoaderParent()
- {
- throw new UnsupportedOperationException();
-
- }
-
- public void handleRuntimeError(final Throwable error)
- {
- throw new UnsupportedOperationException();
- }
-
- public Enumeration<URL> findEntries(List<BundleData> datas, String path,
- String filePattern, int options) {
- return null;
- }
-} \ No newline at end of file