/**
* Test the core of the LogicalConfigManager
*/
@Test
public void testLogicalTrans() throws IOException, FlumeSpecException {
ConfigurationManager parent = new ConfigManager();
ConfigurationManager self = new ConfigManager();
StatusManager statman = new StatusManager();
ConfigurationManager trans = new LogicalConfigurationManager(parent, self,
statman);
// make it so that the local host info is present
statman.updateHeartbeatStatus("foo", "foo", "foo", NodeState.HELLO, Clock
.unixTime());
statman.updateHeartbeatStatus("bar", "bar", "bar", NodeState.HELLO, Clock
.unixTime());
// Next spawn so that all are mapped onto a node and now gets a physical
trans.addLogicalNode("foo", "foo");
trans.addLogicalNode("bar", "bar");
// now set configs
trans.setConfig("foo", DEFAULTFLOW, "logicalSource", "null");
trans.setConfig("bar", DEFAULTFLOW, "null", "logicalSink(\"foo\")");
// update the configurations
trans.updateAll();
int port = FlumeConfiguration.get().getCollectorPort();
// check if translated
FlumeConfigData transData = trans.getConfig("bar");
assertEquals("null", transData.getSourceConfig());
assertEquals("rpcSink( \"foo\", " + port + " )", transData.getSinkConfig());
FlumeConfigData transData2 = trans.getConfig("foo");
assertEquals("rpcSource( " + port + " )", transData2.getSourceConfig());
assertEquals("null", transData2.getSinkConfig());
// self is same as translated
FlumeConfigData selfData = self.getConfig("bar");
assertEquals("null", selfData.getSourceConfig());
assertEquals("rpcSink( \"foo\", " + port + " )", selfData.getSinkConfig());
FlumeConfigData selfData2 = self.getConfig("foo");
assertEquals("rpcSource( " + port + " )", selfData2.getSourceConfig());
assertEquals("null", selfData2.getSinkConfig());
// original is the user entered values
FlumeConfigData origData = parent.getConfig("bar");