@Test
public void testAppRegistration() throws Exception {

  ServiceRecord record = getMarshal().fromBytes("somepath",
      APPLICATION_RECORD.getBytes());
  getRegistryDNS().register(
      "/registry/users/root/services/org-apache-slider/test1/", record);
  // start assessing whether correct records are available
  Record[] recs = assertDNSQuery("test1.root.dev.test.");
  assertEquals("wrong result", "192.168.1.5",
      ((ARecord) recs[0]).getAddress().getHostAddress());
  recs = assertDNSQuery("management-api.test1.root.dev.test.", 2);
  assertEquals("wrong target name", "test1.root.dev.test.",
      ((CNAMERecord) recs[0]).getTarget().toString());
  assertTrue("not an ARecord", recs[isSecure() ? 2 : 1] instanceof ARecord);
  recs = assertDNSQuery("appmaster-ipc-api.test1.root.dev.test.",
      Type.SRV, 1);
  assertTrue("not an SRV record", recs[0] instanceof SRVRecord);
  assertEquals("wrong port", 1026, ((SRVRecord) recs[0]).getPort());
  recs = assertDNSQuery("appmaster-ipc-api.test1.root.dev.test.", 2);
  assertEquals("wrong target name", "test1.root.dev.test.",
      ((CNAMERecord) recs[0]).getTarget().toString());
  assertTrue("not an ARecord", recs[isSecure() ? 2 : 1] instanceof ARecord);
  recs = assertDNSQuery("http-api.test1.root.dev.test.", 2);
  assertEquals("wrong target name", "test1.root.dev.test.",
      ((CNAMERecord) recs[0]).getTarget().toString());
  assertTrue("not an ARecord", recs[isSecure() ? 2 : 1] instanceof ARecord);
  recs = assertDNSQuery("http-api.test1.root.dev.test.", Type.SRV,
      1);
  assertTrue("not an SRV record", recs[0] instanceof SRVRecord);
  assertEquals("wrong port", 1027, ((SRVRecord) recs[0]).getPort());
  assertDNSQuery("test1.root.dev.test.", Type.TXT, 3);
  assertDNSQuery("appmaster-ipc-api.test1.root.dev.test.", Type.TXT, 1);
  assertDNSQuery("http-api.test1.root.dev.test.", Type.TXT, 1);
  assertDNSQuery("management-api.test1.root.dev.test.", Type.TXT, 1);
}