void ConfigTest::testAdapter()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "Adapters { LinuxCNC { \n"
                    "Port = 23\n"
                    "Host = 10.211.55.1\n"
                    "FilterDuplicates = true\n"
                    "AutoAvailable = true\n"
                    "IgnoreTimestamps = true\n"
                    "PreserveUUID = true\n"
                    "LegacyTimeout = 2000\n"
                    "} }\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];
  Adapter *adapter = device->mAdapters[0];

  CPPUNIT_ASSERT_EQUAL(23, (int) adapter->getPort());
  CPPUNIT_ASSERT_EQUAL((string) "10.211.55.1", adapter->getServer());
  CPPUNIT_ASSERT(adapter->isDupChecking());
  CPPUNIT_ASSERT(adapter->isAutoAvailable());
  CPPUNIT_ASSERT(adapter->isIgnoringTimestamps());
  CPPUNIT_ASSERT_EQUAL(2000, adapter->getLegacyTimeout());
  CPPUNIT_ASSERT(device->mPreserveUuid);
}
/* ComponentTest protected methods */
void ConfigTest::testBlankConfig()
{
  istringstream str("");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  CPPUNIT_ASSERT_EQUAL(1, (int) agent->getDevices().size());
}
void ConfigTest::testDefaultPreserveUUID()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "PreserveUUID = true\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];

  CPPUNIT_ASSERT(device->mPreserveUuid);
}
void ConfigTest::testLegacyTimeout()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "LegacyTimeout = 2000\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];
  Adapter *adapter = device->mAdapters[0];
  
  CPPUNIT_ASSERT_EQUAL(2000, adapter->getLegacyTimeout());
}
void ConfigTest::testIgnoreTimestamps()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "IgnoreTimestamps = true\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];
  Adapter *adapter = device->mAdapters[0];
  
  CPPUNIT_ASSERT(adapter->isIgnoringTimestamps());

}
void ConfigTest::testDefaultPreserveOverride()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "PreserveUUID = true\n"
                    "Adapters { LinuxCNC { \n"
                    "PreserveUUID = false\n"
                    "} }\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];

  CPPUNIT_ASSERT(!device->mPreserveUuid);
}
void ConfigTest::testDevice()
{
  istringstream str("Devices = ../samples/test_config.xml\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];
  Adapter *adapter = device->mAdapters[0];

  CPPUNIT_ASSERT_EQUAL((string) "LinuxCNC", device->getName());
  CPPUNIT_ASSERT(!adapter->isDupChecking());
  CPPUNIT_ASSERT(!adapter->isAutoAvailable());
  CPPUNIT_ASSERT(!adapter->isIgnoringTimestamps());
  CPPUNIT_ASSERT(device->mPreserveUuid);
}