demo.org.powermock.examples.tutorial.staticmocking.impl.withoutpowermock
Class ServiceRegistratorWithoutPowerMock

java.lang.Object
  extended by demo.org.powermock.examples.tutorial.staticmocking.impl.withoutpowermock.ServiceRegistratorWithoutPowerMock
All Implemented Interfaces:
IServiceRegistrator

public class ServiceRegistratorWithoutPowerMock
extends Object
implements IServiceRegistrator

This refactored implementation demonstrate how one could test the ServiceRegistrator class without using PowerMock.


Constructor Summary
ServiceRegistratorWithoutPowerMock()
          Default constructor, initializes internal state.
 
Method Summary
protected  long generateId()
           
 long registerService(String name, Object serviceImplementation)
          Registers a service to the service framework.
 void unregisterService(long id)
          Unregisters a service from the service framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceRegistratorWithoutPowerMock

public ServiceRegistratorWithoutPowerMock()
Default constructor, initializes internal state.

Method Detail

registerService

public long registerService(String name,
                            Object serviceImplementation)
Registers a service to the service framework.

Specified by:
registerService in interface IServiceRegistrator
Parameters:
name - The name of the service the register.
serviceImplementation - The implementation of the service.
Returns:
An id of the service that got registered. Should be used when unregistering the service.

generateId

protected long generateId()
Returns:
A new id

unregisterService

public void unregisterService(long id)
Unregisters a service from the service framework.

Specified by:
unregisterService in interface IServiceRegistrator
Parameters:
id - The id of the service that should be removed. The id was generated by IServiceRegistrator.registerService(String, Object).


Copyright © 2007-2012. All Rights Reserved.