use of org.apache.helix.mock.MockManager in project helix by apache.
the class TestRoutingTable method setup.
@BeforeClass()
public synchronized void setup() {
final String[] array = new String[] { "localhost_8900", "localhost_8901" };
HelixManager manager = new MockManager() {
private MockAccessor _mockAccessor;
@Override
public // public DataAccessor getDataAccessor()
HelixDataAccessor getHelixDataAccessor() {
if (_mockAccessor == null) {
_mockAccessor = new MockAccessor() {
@SuppressWarnings("unchecked")
@Override
public <T extends HelixProperty> List<T> getChildValues(PropertyKey key) {
PropertyType type = key.getType();
String[] keys = key.getParams();
if (type == PropertyType.CONFIGS && keys != null && keys.length > 1 && keys[1].equalsIgnoreCase(ConfigScopeProperty.PARTICIPANT.toString())) {
List<InstanceConfig> configs = new ArrayList<InstanceConfig>();
for (String instanceName : array) {
InstanceConfig config = new InstanceConfig(instanceName);
String[] splits = instanceName.split("_");
config.setHostName(splits[0]);
config.setPort(splits[1]);
configs.add(config);
}
return (List<T>) configs;
}
return Collections.emptyList();
}
};
}
return _mockAccessor;
}
};
changeContext = new NotificationContext(manager);
}
use of org.apache.helix.mock.MockManager in project helix by apache.
the class TestDefaultMessagingService method testMultipleMessageTypeRegisteration.
@Test
public void testMultipleMessageTypeRegisteration() {
HelixManager manager = new MockManager();
MockDefaultMessagingService svc = new MockDefaultMessagingService(manager);
TestStateTransitionHandlerFactory factory = new TestStateTransitionHandlerFactory();
svc.registerMessageHandlerFactory(factory.getMessageTypes(), factory);
Assert.assertTrue(svc.getMessageHandlerFactoryMap().containsKey(Message.MessageType.STATE_TRANSITION.name()));
Assert.assertTrue(svc.getMessageHandlerFactoryMap().containsKey(Message.MessageType.STATE_TRANSITION_CANCELLATION.name()));
Assert.assertTrue(svc.getMessageHandlerFactoryMap().containsKey(Message.MessageType.CONTROLLER_MSG.name()));
}
Aggregations