ConfTree tree = new ConfTree();
tree.global.put(OptionKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
AgentProviderService aps = new AgentProviderService();
ContainerLaunchContext ctx = createNiceMock(ContainerLaunchContext.class);
AggregateConf instanceDefinition = new AggregateConf();
instanceDefinition.setInternal(tree);
instanceDefinition.setAppConf(tree);
instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.APP_DEF, ".");
instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.AGENT_CONF, ".");
instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.AGENT_VERSION, ".");
Container container = createNiceMock(Container.class);
String role_hm = "HBASE_MASTER";
String role_hrs = "HBASE_REGIONSERVER";
SliderFileSystem sliderFileSystem = createNiceMock(SliderFileSystem.class);
ContainerLauncher launcher = createNiceMock(ContainerLauncher.class);
Path generatedConfPath = new Path(".", "test");
MapOperations resourceComponent = new MapOperations();
MapOperations appComponent = new MapOperations();
Path containerTmpDirPath = new Path(".", "test");
FileSystem mockFs = new MockFileSystem();
expect(sliderFileSystem.getFileSystem())
.andReturn(new FilterFileSystem(mockFs)).anyTimes();
expect(sliderFileSystem.createAmResource(anyObject(Path.class),
anyObject(LocalResourceType.class)))
.andReturn(createNiceMock(LocalResource.class)).anyTimes();
expect(container.getId()).andReturn(new MockContainerId(1)).anyTimes();
expect(container.getNodeId()).andReturn(new MockNodeId("localhost")).anyTimes();
StateAccessForProviders access = createNiceMock(StateAccessForProviders.class);
AgentProviderService mockAps = Mockito.spy(aps);
doReturn(access).when(mockAps).getAmState();
doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class), anyString());
try {
doReturn(true).when(mockAps).isMaster(anyString());
doNothing().when(mockAps).addInstallCommand(
anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
doNothing().when(mockAps).addStartCommand(
anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
doNothing().when(mockAps).addGetConfigCommand(
anyString(),
anyString(),
any(HeartBeatResponse.class));
doNothing().when(mockAps).publishComponentConfiguration(
anyString(),
anyString(),
anyCollection());
} catch (SliderException e) {
}
expect(access.isApplicationLive()).andReturn(true).anyTimes();
ClusterDescription desc = new ClusterDescription();
desc.setInfo(StatusKeys.INFO_AM_HOSTNAME, "host1");
desc.setInfo(StatusKeys.INFO_AM_AGENT_PORT, "8088");
desc.setInfo(StatusKeys.INFO_AM_SECURED_AGENT_PORT, "8089");
desc.setInfo(OptionKeys.APPLICATION_NAME, "HBASE");
expect(access.getClusterStatus()).andReturn(desc).anyTimes();
AggregateConf aggConf = new AggregateConf();
ConfTreeOperations treeOps = aggConf.getAppConfOperations();
treeOps.getOrAddComponent("HBASE_MASTER").put(AgentKeys.WAIT_HEARTBEAT, "0");
treeOps.getOrAddComponent("HBASE_REGIONSERVER").put(AgentKeys.WAIT_HEARTBEAT, "0");
expect(access.getInstanceDefinitionSnapshot()).andReturn(aggConf).anyTimes();
replay(access, ctx, container, sliderFileSystem);