fb.setCardinality(Cardinality.C_1__1);
fb.setInterfaces(new Class[] { Date.class });
fb.afterPropertiesSet();
ImportedOsgiServiceProxy refAware = null;
try {
Object result = fb.getObject();
assertTrue(result instanceof Date);
// check it's our object
assertEquals(time, ((Date) result).getTime());
assertTrue(result instanceof SpringProxy);
assertTrue(result instanceof ImportedOsgiServiceProxy);
assertTrue(result instanceof InfrastructureProxy);
refAware = (ImportedOsgiServiceProxy) result;
assertNotNull(refAware.getServiceReference());
assertEquals("wrong target returned", date, ((InfrastructureProxy) result).getWrappedObject());
}
finally {
if (reg != null)
reg.unregister();
}
// test reference after the service went down
assertNotNull(refAware.getServiceReference());
assertNull(refAware.getServiceReference().getBundle());
}