Fixing build errors
diff --git a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
index b076adb..f12c318 100755
--- a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
+++ b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/helper/ClassLoadingHelperTests.java
@@ -8,6 +8,7 @@
* Contributors:
* Hristo Iliev, SAP AG - initial contribution
******************************************************************************/
+
package org.eclipse.virgo.shell.osgicommand.helper;
import org.eclipse.osgi.service.resolver.BundleDescription;
@@ -30,16 +31,20 @@
public class ClassLoadingHelperTests {
private static final long BUNDLE_ID = 1234;
+
private static final String BUNDLE_SYMBOLIC_NAME = "test";
+
private static final String CLASS_NAME = ClassLoadingHelperTests.class.getName();
+
private static final String CLASS_NAME_PATH = CLASS_NAME.replace(".", "/") + ".class";
+
private static final String CLASS_PACKAGE = ClassLoadingHelperTests.class.getPackage().getName();
- @SuppressWarnings({"rawtypes", "unchecked"})
+ @SuppressWarnings({ "unchecked" })
@Test
public void testIsMissingPackageExported() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
State bundleState = createMock(State.class);
@@ -55,16 +60,16 @@
replay(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
assertFalse("Class [" + CLASS_NAME + "] is reported as exported, while it is NOT",
- ClassLoadingHelper.isPackageExported(bundleContext, CLASS_NAME, bundle));
+ ClassLoadingHelper.isPackageExported(bundleContext, CLASS_NAME, bundle));
verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
+ @SuppressWarnings({ "unchecked" })
@Test
public void testIsExistingPackageExported() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
State bundleState = createMock(State.class);
@@ -75,16 +80,14 @@
expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
expect(exportPackageDescription.getName()).andReturn(CLASS_PACKAGE);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{exportPackageDescription});
+ expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[] { exportPackageDescription });
expect(platformAdmin.getState(false)).andReturn(bundleState);
expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
+ replay(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription, exportPackageDescription);
assertTrue("Class [" + CLASS_NAME + "] is reported as NOT exported, while it is",
- ClassLoadingHelper.isPackageExported(bundleContext, CLASS_PACKAGE, bundle));
+ ClassLoadingHelper.isPackageExported(bundleContext, CLASS_PACKAGE, bundle));
verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
}
@@ -97,16 +100,14 @@
replay(bundle);
- assertNull("Class [" + CLASS_NAME + "] found, while it is not existing",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
+ assertNull("Class [" + CLASS_NAME + "] found, while it is not existing", ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
verify(bundle);
}
@Test
public void testTryToLoadMissingBundle() throws Exception {
- assertNull("Class [" + CLASS_NAME + "] found, while no bundle is specified",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, null));
+ assertNull("Class [" + CLASS_NAME + "] found, while no bundle is specified", ClassLoadingHelper.tryToLoadClass(CLASS_NAME, null));
}
@Test
@@ -117,8 +118,7 @@
replay(bundle);
- assertNull("Class [" + CLASS_NAME + "] found, while it is not existing",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
+ assertNull("Class [" + CLASS_NAME + "] found, while it is not existing", ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
verify(bundle);
}
@@ -132,8 +132,7 @@
replay(bundle);
- assertNotNull("Class [" + CLASS_NAME + "] not found",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
+ assertNotNull("Class [" + CLASS_NAME + "] not found", ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
verify(bundle);
}
@@ -144,12 +143,12 @@
BundleContext bundleContext = createMock(BundleContext.class);
expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // missing class
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
+ expect(bundleContext.getBundles()).andReturn(new Bundle[] { bundle });
replay(bundle, bundleContext);
assertTrue("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should NOT be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
+ ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
verify(bundle, bundleContext);
}
@@ -161,56 +160,56 @@
BundleContext bundleContext = createMock(BundleContext.class);
expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
+ expect(bundleContext.getBundles()).andReturn(new Bundle[] { bundle });
expect(bundleContext.getBundle(0)).andReturn(bundle);
replay(bundle, bundleContext);
assertFalse("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
+ ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
verify(bundle, bundleContext);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
+ @SuppressWarnings({ "unchecked" })
@Test
public void testGetBundleLoadingMissingClass() throws Exception {
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PackageAdmin> packageAdminServiceReference = createMock(ServiceReference.class);
expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // missing class
expect(bundleContext.getServiceReference(PackageAdmin.class)).andReturn(packageAdminServiceReference);
expect(bundleContext.getService(packageAdminServiceReference)).andReturn(packageAdmin);
- expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[]{bundle});
+ expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[] { bundle });
replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
assertTrue("No bundle should be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() == 0);
+ ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() == 0);
verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
+ @SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testGetBundleByNameLoadingExistingClass() throws Exception {
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PackageAdmin> packageAdminServiceReference = createMock(ServiceReference.class);
expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
expect(bundleContext.getBundle(0)).andReturn(bundle);
expect(bundleContext.getServiceReference(PackageAdmin.class)).andReturn(packageAdminServiceReference);
expect(bundleContext.getService(packageAdminServiceReference)).andReturn(packageAdmin);
- expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[]{bundle});
+ expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[] { bundle });
replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
assertTrue("The class [" + CLASS_NAME + "] should be successfully loaded",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() != 0);
+ ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() != 0);
verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
}
@@ -228,21 +227,23 @@
replay(bundle, bundleContext);
assertTrue("The class [" + CLASS_NAME + "] should be successfully loaded",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, "" + BUNDLE_ID).size() != 0);
+ ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, "" + BUNDLE_ID).size() != 0);
verify(bundle, bundleContext);
}
@Test
public void testConvertToClassName() throws Exception {
- assertEquals("Path to resource [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME, ClassLoadingHelper.convertToClassName(CLASS_NAME_PATH));
+ assertEquals("Path to resource [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME,
+ ClassLoadingHelper.convertToClassName(CLASS_NAME_PATH));
assertEquals("Path to resource [" + CLASS_NAME + "] not converted properly", CLASS_NAME, ClassLoadingHelper.convertToClassName(CLASS_NAME));
}
@Test
public void testConvertToResourcePath() throws Exception {
assertEquals("Class name [" + CLASS_NAME + "] not converted properly", CLASS_NAME_PATH, ClassLoadingHelper.convertToResourcePath(CLASS_NAME));
- assertEquals("Class name [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME_PATH, ClassLoadingHelper.convertToResourcePath(CLASS_NAME_PATH));
+ assertEquals("Class name [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME_PATH,
+ ClassLoadingHelper.convertToResourcePath(CLASS_NAME_PATH));
}
}
diff --git a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/internal/GogoClassLoadingCommandTests.java b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/internal/GogoClassLoadingCommandTests.java
index fec7c2b..5127c3a 100755
--- a/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/internal/GogoClassLoadingCommandTests.java
+++ b/kernel/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/osgicommand/internal/GogoClassLoadingCommandTests.java
@@ -11,20 +11,6 @@
package org.eclipse.virgo.shell.osgicommand.internal;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.util.Enumeration;
-
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
@@ -37,6 +23,17 @@
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.PackageAdmin;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.util.Enumeration;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit tests for class loading commands
*/
@@ -127,7 +124,8 @@
String output = getOutput();
assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]", output.contains("" + CLASS_NAME_PATH));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]", output.contains("" + CLASS_PACKAGE_PATH));
+ assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
+ output.contains("" + CLASS_PACKAGE_PATH));
assertFalse("Command output [" + output + "] contains bundle ID [" + BUNDLE_ID + "]", output.contains("" + BUNDLE_ID));
assertFalse("Command output [" + output + "] contains bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
output.contains(BUNDLE_SYMBOLIC_NAME));
@@ -191,7 +189,7 @@
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PackageAdmin> packageAdminServiceReference = createMock(ServiceReference.class);
expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(GogoClassLoadingCommandTests.class);
expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
@@ -266,11 +264,11 @@
verify(bundle, bundleContext);
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "unchecked" })
@Test
public void testClExportWithMissingPackage() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
State bundleState = createMock(State.class);
@@ -303,7 +301,7 @@
@Test
public void testClExportWithExportedPackage() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
State bundleState = createMock(State.class);
@@ -336,11 +334,11 @@
verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription, exportPackageDescription);
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "unchecked" })
@Test
public void testClExportWithExportedPackageMissingClass() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
+ ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
State bundleState = createMock(State.class);