@Test public void testActivate() { BundleContext bundleContext = createNiceMock(BundleContext.class); expect(bundleContext.getProperty(OPT_INSTANCE_NAME)).andStubReturn(null); replay(bundleContext); ComponentContext context = createNiceMock(ComponentContext.class); expect(context.getBundleContext()).andStubReturn(bundleContext); replay(context); service.activate(context); assertNull(service.getName()); bundleContext = createNiceMock(BundleContext.class); expect(bundleContext.getProperty(OPT_INSTANCE_NAME)).andStubReturn("instance01"); replay(bundleContext); context = createNiceMock(ComponentContext.class); expect(context.getBundleContext()).andStubReturn(bundleContext); replay(context); service.activate(context); assertEquals("instance01", service.getName()); }
void activate(ComponentContext context) { if (context == null) throw new IllegalArgumentException("Component context must not be null"); name = StringUtils.trimToNull(context.getBundleContext().getProperty(OPT_INSTANCE_NAME)); if (name != null) logger.info("Instance name is '{}'", name); else logger.debug("No explicit instance name has been set"); }
InstanceInformation { void activate(ComponentContext context) { if (context == null) throw new IllegalArgumentException("Component context must not be null"); name = StringUtils.trimToNull(context.getBundleContext().getProperty(OPT_INSTANCE_NAME)); if (name != null) logger.info("Instance name is '{}'", name); else logger.debug("No explicit instance name has been set"); } }
InstanceInformation { void activate(ComponentContext context) { if (context == null) throw new IllegalArgumentException("Component context must not be null"); name = StringUtils.trimToNull(context.getBundleContext().getProperty(OPT_INSTANCE_NAME)); if (name != null) logger.info("Instance name is '{}'", name); else logger.debug("No explicit instance name has been set"); }  }
InstanceInformation { void activate(ComponentContext context) { if (context == null) throw new IllegalArgumentException("Component context must not be null"); name = StringUtils.trimToNull(context.getBundleContext().getProperty(OPT_INSTANCE_NAME)); if (name != null) logger.info("Instance name is '{}'", name); else logger.debug("No explicit instance name has been set"); }  String getName(); }
InstanceInformation { void activate(ComponentContext context) { if (context == null) throw new IllegalArgumentException("Component context must not be null"); name = StringUtils.trimToNull(context.getBundleContext().getProperty(OPT_INSTANCE_NAME)); if (name != null) logger.info("Instance name is '{}'", name); else logger.debug("No explicit instance name has been set"); }  String getName();  }