Пример #1
0
  @Test
  public void testRemoveByRecords() throws Exception {

    testCleanDatabase();

    assertEquals(0, dnsDao.count());

    // Add 5 record
    DNSRecord record1 = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.1");
    DNSRecord record2 = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.2");
    DNSRecord record3 = DNSRecordUtils.createARecord("example2.domain.com", 86400L, "127.0.0.3");
    DNSRecord record4 =
        DNSRecordUtils.createSRVRecord(
            "_ldap_cerner._tcp.cerner.com", "example.domain.com", 86400L, 3506, 1, 1);
    DNSRecord record5 =
        DNSRecordUtils.createSRVRecord(
            "_ldap_cerner._tcp.cerner.com", "example2.domain.com", 86400L, 3506, 1, 1);
    dnsDao.add(Arrays.asList(record1, record2, record3, record4, record5));

    assertEquals(5, dnsDao.count());

    // remove the first three records
    dnsDao.remove(Arrays.asList(record1, record2, record3));

    Collection<DNSRecord> records = dnsDao.get(Type.ANY);
    assertEquals(2, records.size());
    assertTrue(records.contains(record4));
    assertTrue(records.contains(record5));

    // remove the last two records
    dnsDao.remove(Arrays.asList(record4, record5));

    records = dnsDao.get(Type.ANY);
    assertEquals(0, records.size());
  }
Пример #2
0
  @Test
  public void testCleanDatabase() throws Exception {
    Collection<DNSRecord> records = dnsDao.get(Type.ANY);

    if (records != null && records.size() > 0) {
      for (DNSRecord record : records) dnsDao.remove(record.getId());
    }
    records = dnsDao.get(Type.ANY);

    assertEquals(0, records.size());
  }
Пример #3
0
  @Test
  public void testRemoveByIds() throws Exception {

    testCleanDatabase();

    assertEquals(0, dnsDao.count());

    // Add 5 record
    DNSRecord record1 = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.1");
    DNSRecord record2 = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.2");
    DNSRecord record3 = DNSRecordUtils.createARecord("example2.domain.com", 86400L, "127.0.0.3");
    DNSRecord record4 =
        DNSRecordUtils.createSRVRecord(
            "_ldap_cerner._tcp.cerner.com", "example.domain.com", 86400L, 3506, 1, 1);
    DNSRecord record5 =
        DNSRecordUtils.createSRVRecord(
            "_ldap_cerner._tcp.cerner.com", "example2.domain.com", 86400L, 3506, 1, 1);
    dnsDao.add(Arrays.asList(record1, record2, record3, record4, record5));

    assertEquals(5, dnsDao.count());

    // remove record 3
    Collection<DNSRecord> records = dnsDao.get(record3.getName());
    assertEquals(1, records.size());
    dnsDao.remove(records.iterator().next().getId());
    records = dnsDao.get(Type.ANY);
    assertEquals(4, dnsDao.count());
    assertTrue(records.contains(record1));
    assertTrue(records.contains(record2));
    assertTrue(records.contains(record4));
    assertTrue(records.contains(record5));

    // remove the rest
    long[] ids = new long[records.size()];
    int cnt = 0;
    for (DNSRecord record : records) ids[cnt++] = record.getId();

    dnsDao.remove(ids);
    records = dnsDao.get(Type.ANY);
    assertEquals(0, records.size());
  }
Пример #4
0
  @Test
  public void testRemoveByIds_noqualifying() throws Exception {

    testCleanDatabase();

    assertEquals(0, dnsDao.count());

    dnsDao.remove(876343);

    // should result in a functional no-op
    assertEquals(0, dnsDao.count());
  }
Пример #5
0
  @Test
  public void testRemoveByRecords_noqualifying() throws Exception {

    testCleanDatabase();

    assertEquals(0, dnsDao.count());

    DNSRecord record1 = DNSRecordUtils.createARecord("example.domain.com", 86400L, "127.0.0.1");

    // should result in a functional no-op
    dnsDao.remove(Arrays.asList(record1));

    assertEquals(0, dnsDao.count());
  }
Пример #6
0
 /** {@inheritDoc} */
 @Override
 public void removeDNS(Collection<DNSRecord> records) throws ConfigurationServiceException {
   dao.remove(records);
 }
Пример #7
0
 /** {@inheritDoc} */
 @Override
 public void removeDNSByRecordIds(long[] recordIds) throws ConfigurationServiceException {
   dao.remove(recordIds);
 }