Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2011-05-13 06:37:14 -0400
committerChristopher Frost2011-05-13 06:37:14 -0400
commitb0f8f42c7c899c1a3f55117b42d533105444ff6f (patch)
tree48c2b5833abc81340d113c9d1ac92b9f5c66e096
parentaf6790d661aa64212f494b6ebffdaf98901f012c (diff)
downloadorg.eclipse.virgo.kernel-b0f8f42c7c899c1a3f55117b42d533105444ff6f.tar.gz
org.eclipse.virgo.kernel-b0f8f42c7c899c1a3f55117b42d533105444ff6f.tar.xz
org.eclipse.virgo.kernel-b0f8f42c7c899c1a3f55117b42d533105444ff6f.zip
Tidy up of test code to remove compiler warning.
-rw-r--r--org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/AgentActivator.java6
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java3
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java5
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java6
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/AnnotationBasedCommandResolverTests.java4
-rw-r--r--org.eclipse.virgo.kernel.smoketest/src/test/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java17
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java5
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java1
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiParameterised.java2
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/ServiceScopingStrategyTests.java18
11 files changed, 29 insertions, 38 deletions
diff --git a/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/AgentActivator.java b/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/AgentActivator.java
index 35ed7163..55bad48c 100644
--- a/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/AgentActivator.java
+++ b/org.eclipse.virgo.kernel.agent.dm/src/main/java/org/eclipse/virgo/kernel/agent/dm/internal/AgentActivator.java
@@ -69,10 +69,9 @@ public final class AgentActivator {
this.registrationTracker.unregisterAll();
}
- @SuppressWarnings("unchecked")
private <T> T getRequiredService(BundleContext context, Class<T> clazz) {
T result = null;
- ServiceReference ref = context.getServiceReference(clazz.getName());
+ ServiceReference<T> ref = context.getServiceReference(clazz);
if (ref != null) {
result = (T) context.getService(ref);
}
@@ -82,8 +81,7 @@ public final class AgentActivator {
// if (ref != null) {
// context.ungetService(ref);
// }
- throw new IllegalStateException("Unable to access required service of type '" + clazz.getName() + "' from bundle '"
- + context.getBundle().getSymbolicName() + "'");
+ throw new IllegalStateException("Unable to access required service of type '" + clazz.getName() + "' from bundle '" + context.getBundle().getSymbolicName() + "'");
}
return result;
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
index a99ff9a5..c7c46de7 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/AbztractArtifactTests.java
@@ -103,13 +103,12 @@ public class AbztractArtifactTests {
assertEquals("test-region", artifact.getRegion().getName());
}
- @SuppressWarnings("unchecked")
@Test
public void getDependents() {
assertEquals(0, artifact.getDependents().size());
DependencyDeterminer determiner = createMock(DependencyDeterminer.class);
- Dictionary properties = new Hashtable();
+ Dictionary<String, String> properties = new Hashtable<String, String>();
properties.put("artifactType", "test-type");
bundleContext.registerService(DependencyDeterminer.class.getCanonicalName(), determiner, properties);
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
index 15e80978..e2e5afab 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/BundleDependencyDeterminerTests.java
@@ -101,15 +101,16 @@ public class BundleDependencyDeterminerTests {
expect(bundle2.getVersion()).andReturn(Version.emptyVersion);
expect(bundle2.getBundleId()).andReturn(100l);
expect(regionDigraph.getRegion(100l)).andReturn(regionB);
+ expect(regionB.getName()).andReturn("regionB-name").anyTimes();
expect(bundle2.getImportPackages()).andReturn(new ArrayList<QuasiImportPackage>());
- replay(quasiFrameworkFactory, regionDigraph, framework, bundle1, bundle2);
+ replay(quasiFrameworkFactory, regionDigraph, framework, bundle1, bundle2, regionB);
Set<Artifact> dependents = this.determiner.getDependents(new StubCompositeArtifact("bundle", "bundle", regionB));
assertEquals(Collections.<Artifact> emptySet(), dependents);
- verify(quasiFrameworkFactory, regionDigraph, framework, bundle1, bundle2);
+ verify(quasiFrameworkFactory, regionDigraph, framework, bundle1, bundle2, regionB);
}
private List<QuasiBundle> getTestBundleSet(){
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java b/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java
index 18e091ed..fcfdad90 100644
--- a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java
+++ b/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java
@@ -56,6 +56,7 @@ public class ClassLoadingSupportTests {
RESULT_EXPORT_ARRAY.add(loadingBundle);
}
+ @SuppressWarnings("rawtypes")
@Test
public void testGetBundlesLoadingClass() throws Exception {
Bundle bundle = createMock(Bundle.class);
@@ -79,9 +80,9 @@ public class ClassLoadingSupportTests {
}
@Test
- @SuppressWarnings("unchecked")
public void testGetBundlesExportingPackage() throws Exception {
PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
+ @SuppressWarnings("unchecked")
ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
Bundle bundle = createMock(Bundle.class);
BundleContext bundleContext = createMock(BundleContext.class);
@@ -112,11 +113,12 @@ public class ClassLoadingSupportTests {
verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
}
+ @SuppressWarnings("rawtypes")
@Test
public void testTryToLoadClassFromBundle() throws Exception {
Bundle bundle = createMock(Bundle.class);
expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect((Class) bundle.loadClass(CLASS_NAME + CLASS_NAME)).andReturn(null);
+ expect((Class<?>) bundle.loadClass(CLASS_NAME + CLASS_NAME)).andReturn(null);
BundleContext bundleContext = createMock(BundleContext.class);
expect(bundleContext.getBundle(BUNDLE_ID)).andReturn(bundle).times(2);
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/AnnotationBasedCommandResolverTests.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/AnnotationBasedCommandResolverTests.java
index 8f456adc..5cad18b7 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/AnnotationBasedCommandResolverTests.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/AnnotationBasedCommandResolverTests.java
@@ -57,11 +57,13 @@ public class AnnotationBasedCommandResolverTests {
@Command("test")
private static class TestCommands {
+ @SuppressWarnings("unused")
@Command("one")
public void foo() {
}
+ @SuppressWarnings("unused")
@Command("two")
public void bar() {
@@ -71,11 +73,13 @@ public class AnnotationBasedCommandResolverTests {
@Command("test-sub")
private static final class SubTestCommands extends TestCommands {
+ @SuppressWarnings("unused")
@Command("three")
public void alpha() {
}
+ @SuppressWarnings("unused")
@Command("four")
public void bravo() {
diff --git a/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore b/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.smoketest/src/test/.gitignore
+++ /dev/null
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
index 073175d7..683f9cc9 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader.java
@@ -129,10 +129,9 @@ public final class KernelBundleClassLoader extends DefaultClassLoader implements
* {@inheritDoc}
*/
@Override
- @SuppressWarnings("unchecked")
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
try {
- Class loadedClass = super.loadClass(name, resolve);
+ Class<?> loadedClass = super.loadClass(name, resolve);
storeClassIfDriver(loadedClass);
return loadedClass;
} catch (ClassNotFoundException e) {
@@ -261,7 +260,6 @@ public final class KernelBundleClassLoader extends DefaultClassLoader implements
clearJdbcDrivers();
}
- @SuppressWarnings("unchecked")
private void clearJdbcDrivers() {
Set<Class<Driver>> localLoadedDriverClasses;
synchronized (this.monitor) {
@@ -272,10 +270,10 @@ public final class KernelBundleClassLoader extends DefaultClassLoader implements
try {
Field writeDriversField = DriverManager.class.getDeclaredField("writeDrivers");
writeDriversField.setAccessible(true);
- Vector writeDrivers = (Vector)writeDriversField.get(null);
-
- Iterator driverElements = writeDrivers.iterator();
-
+ Vector<?> writeDrivers = (Vector<?>)writeDriversField.get(null);
+
+ Iterator<?> driverElements = writeDrivers.iterator();
+
while(driverElements.hasNext()) {
Object driverObj = driverElements.next();
Field driverField = driverObj.getClass().getDeclaredField("driver");
@@ -284,12 +282,11 @@ public final class KernelBundleClassLoader extends DefaultClassLoader implements
driverElements.remove();
}
}
-
- Vector readDrivers = (Vector)writeDrivers.clone();
+
+ Vector<?> readDrivers = (Vector<?>)writeDrivers.clone();
Field readDriversField = DriverManager.class.getDeclaredField("readDrivers");
readDriversField.setAccessible(true);
readDriversField.set(null, readDrivers);
-
} catch (Exception e) {
LOGGER.warn("Failure when clearing JDBC drivers for " + this, e);
}
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
index 5e097fe5..52cf0f7d 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/equinox/TransformedManifestProvidingBundleFileWrapper.java
@@ -179,11 +179,10 @@ public class TransformedManifestProvidingBundleFileWrapper implements BundleFile
/**
* {@inheritDoc}
*/
- @Override
@SuppressWarnings("unchecked")
+ @Override
public Enumeration getEntryPaths(String path) {
- Enumeration paths = this.bundleFile.getEntryPaths(path);
- return paths;
+ return this.bundleFile.getEntryPaths(path);
}
/**
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
index 2754e842..617354d3 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/importexpansion/ImportExpansionHandler.java
@@ -554,7 +554,6 @@ public final class ImportExpansionHandler implements ImportExpander {
* @param bundle the bundle whose definition is required
* @return the bundle definition or <code>null</code> if no definition can be created
*/
- @SuppressWarnings("unchecked")
private BundleManifest getBundleManifest(Bundle bundle) {
return BundleManifestFactory.createBundleManifest(bundle.getHeaders());
}
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiParameterised.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiParameterised.java
index 9dd2224d..45edd3e5 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiParameterised.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiParameterised.java
@@ -48,7 +48,6 @@ public class StandardQuasiParameterised implements QuasiParameterised {
*
* @param importPackageSpecification
*/
- @SuppressWarnings("unchecked")
public StandardQuasiParameterised(ImportPackageSpecification importPackageSpecification) {
this.attributes = normalise(importPackageSpecification.getAttributes());
this.directives = normalise(importPackageSpecification.getDirectives());
@@ -66,7 +65,6 @@ public class StandardQuasiParameterised implements QuasiParameterised {
}
}
- @SuppressWarnings("unchecked")
public StandardQuasiParameterised(ExportPackageDescription exportPackageDescription) {
this.attributes = normalise(exportPackageDescription.getAttributes());
this.directives = normalise(exportPackageDescription.getDirectives());
diff --git a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/ServiceScopingStrategyTests.java b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/ServiceScopingStrategyTests.java
index 162a8768..682e3f23 100644
--- a/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/ServiceScopingStrategyTests.java
+++ b/org.eclipse.virgo.kernel.userregion/src/test/java/org/eclipse/virgo/kernel/userregion/internal/ServiceScopingStrategyTests.java
@@ -141,7 +141,6 @@ public class ServiceScopingStrategyTests {
verify(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesUnscopedServiceUnscopedApplication() throws InvalidSyntaxException {
setUpUnscopedServiceReference();
@@ -149,14 +148,13 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(false).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
- Collection references = new ShrinkableSet(this.unscopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.unscopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.unscopedBundleContext, CLASS_NAME, FILTER);
assertTrue(references.contains(this.unscopedServiceReference));
verify(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesScopedServiceUnscopedApplication() throws InvalidSyntaxException {
setUpScopedServiceReference();
@@ -164,14 +162,13 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(false).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
- Collection references = new ShrinkableSet(this.scopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.scopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.unscopedBundleContext, CLASS_NAME, FILTER);
assertFalse(references.contains(this.unscopedServiceReference));
verify(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesScopedServiceInModelScopedApplication() throws InvalidSyntaxException {
setUpScopedServiceReference();
@@ -179,14 +176,13 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(true).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
- Collection references = new ShrinkableSet(this.scopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.scopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.scopedBundleContext, CLASS_NAME, FILTER);
assertTrue(references.contains(this.scopedServiceReference));
verify(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesScopedServiceNotInModelScopedApplication() throws InvalidSyntaxException {
setUpScopedServiceReference();
@@ -194,14 +190,13 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(false).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
- Collection references = new ShrinkableSet(this.scopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.scopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.scopedBundleContext, CLASS_NAME, FILTER);
assertTrue(references.contains(this.scopedServiceReference));
verify(this.scopeFactory, this.scopeServiceRepository, this.scopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesUnscopedUnshadowedServiceScopedApplication() throws InvalidSyntaxException {
setUpUnscopedServiceReference();
@@ -209,14 +204,13 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(false).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
- Collection references = new ShrinkableSet(this.unscopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.unscopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.scopedBundleContext, CLASS_NAME, FILTER);
assertTrue(references.contains(this.unscopedServiceReference));
verify(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
}
- @SuppressWarnings("unchecked")
@Test
public void testScopeReferencesUnscopedShadowedServiceScopedApplication() throws InvalidSyntaxException {
setUpUnscopedServiceReference();
@@ -224,7 +218,7 @@ public class ServiceScopingStrategyTests {
expect(this.scopeServiceRepository.scopeHasMatchingService(eq(SCOPE_NAME), eq(CLASS_NAME), eq(FILTER))).andReturn(true).anyTimes();
replay(this.scopeFactory, this.scopeServiceRepository, this.unscopedServiceReference);
- Collection references = new ShrinkableSet(this.unscopedServiceReference);
+ Collection<ServiceReference<?>> references = new ShrinkableSet(this.unscopedServiceReference);
this.serviceScopingStrategy.scopeReferences(references, this.scopedBundleContext, CLASS_NAME, FILTER);
assertFalse(references.contains(this.unscopedServiceReference));

Back to the top