use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FilesystemForeignSourceRepositoryTest method createRequisition.
private Requisition createRequisition() throws Exception {
Requisition r = m_foreignSourceRepository.importResourceRequisition(new ClassPathResource("/requisition-test.xml"));
m_foreignSourceRepository.save(r);
m_foreignSourceRepository.flush();
return r;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FusedForeignSourceRepositoryTest method doImport.
protected void doImport(final Resource resource) {
final Requisition req = m_repository.importResourceRequisition(resource);
req.updateLastImported();
m_repository.save(req);
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FusedForeignSourceRepositoryTest method testSpc674RaceCondition.
@Test
public void testSpc674RaceCondition() throws Exception {
final String foreignSource = "spc674";
System.err.println("=== create a requisition like the ReST service does, import it immediately ===");
final Requisition initial = new Requisition(foreignSource);
initial.putNode(createNode("1"));
initial.updateDateStamp();
m_pending.save(initial);
final URL node1Snapshot = createSnapshot(foreignSource);
Resource resource = new UrlResource(node1Snapshot);
doImport(resource);
Thread.sleep(5);
List<String> files = getImports(foreignSource);
assertEquals(1, files.size());
System.err.println("=== create another snapshot, but don't import it yet ===");
initial.putNode(createNode("2"));
initial.updateDateStamp();
m_pending.save(initial);
final URL node2Snapshot = createSnapshot(foreignSource);
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(3, files.size());
System.err.println("=== create yet another snapshot, and don't import it yet ===");
initial.putNode(createNode("3"));
initial.updateDateStamp();
m_pending.save(initial);
final URL node3Snapshot = createSnapshot(foreignSource);
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(4, files.size());
System.err.println("=== import of the second file finishes ===");
doImport(new UrlResource(node2Snapshot));
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(2, files.size());
System.err.println("=== fourth node is sent to the ReST interface ===");
final Requisition currentPending = RequisitionFileUtils.getLatestPendingOrSnapshotRequisition(m_pending, foreignSource);
assertNotNull(currentPending);
assertEquals(initial.getDate(), currentPending.getDate());
currentPending.putNode(createNode("4"));
currentPending.updateDateStamp();
m_pending.save(currentPending);
final URL node4Snapshot = createSnapshot(foreignSource);
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(4, files.size());
System.err.println("=== import of the third file finishes ===");
doImport(new UrlResource(node3Snapshot));
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(2, files.size());
System.err.println("=== import of the fourth file finishes ===");
doImport(new UrlResource(node4Snapshot));
Thread.sleep(5);
files = getImports(foreignSource);
assertEquals(1, files.size());
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FusedForeignSourceRepositoryTest method tearDown.
@After
public final void tearDown() {
/*
* since we share the filesystem with other tests, best
* to make sure it's totally clean here.
*/
for (ForeignSource fs : m_pending.getForeignSources()) {
m_pending.delete(fs);
}
for (ForeignSource fs : m_active.getForeignSources()) {
m_active.delete(fs);
}
for (Requisition r : m_pending.getRequisitions()) {
m_pending.delete(r);
}
for (Requisition r : m_active.getRequisitions()) {
m_active.delete(r);
}
m_pending.flush();
m_active.flush();
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class QueueingForeignSourceRepositoryTest method testGetRequisition.
@Test
public void testGetRequisition() throws Exception {
Requisition requisition = createRequisition();
ForeignSource foreignSource = createForeignSource(m_defaultForeignSourceName);
assertRequisitionsMatch("requisitions must match", m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName), m_foreignSourceRepository.getRequisition(foreignSource));
assertRequisitionsMatch("foreign source is the expected one", requisition, m_foreignSourceRepository.getRequisition(foreignSource));
}
Aggregations