Collection<PublisherQueueData> c = publisherQueueSession.getPendingEntriesForPublisher(12345);
assertEquals(0, c.size());
c = publisherQueueSession.getPendingEntriesForPublisher(123456);
assertEquals(1, c.size());
Iterator<PublisherQueueData> i = c.iterator();
PublisherQueueData d = i.next();
assertEquals("XX", d.getFingerprint());
Date lastUpdate1 = d.getLastUpdate();
assertNotNull(lastUpdate1);
assertNotNull(d.getTimeCreated());
assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
assertEquals(0,d.getTryCounter());
assertNull(d.getVolatileData());
String xxpk = d.getPk(); // Keep for later so we can set to success
PublisherQueueVolatileData vd = new PublisherQueueVolatileData();
vd.setUsername("foo");
vd.setPassword("bar");
ExtendedInformation ei = new ExtendedInformation();
ei.setSubjectDirectoryAttributes("directoryAttr");
vd.setExtendedInformation(ei);
publisherQueueSession.addQueueData(123456, PublisherConst.PUBLISH_TYPE_CRL, "YY", vd, PublisherConst.STATUS_PENDING);
c = publisherQueueSession.getPendingEntriesForPublisher(123456);
assertEquals(2, c.size());
boolean testedXX = false;
boolean testedYY = false;
i = c.iterator();
while (i.hasNext()) {
d = i.next();
if (d.getFingerprint().equals("XX")) {
assertEquals(PublisherConst.PUBLISH_TYPE_CERT, d.getPublishType());
assertNotNull(d.getLastUpdate());
assertNotNull(d.getTimeCreated());
assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
assertEquals(0,d.getTryCounter());
testedXX = true;
}
if (d.getFingerprint().equals("YY")) {
assertEquals(PublisherConst.PUBLISH_TYPE_CRL, d.getPublishType());
assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
assertEquals(0,d.getTryCounter());
PublisherQueueVolatileData v = d.getVolatileData();
assertEquals("bar", v.getPassword());
assertEquals("foo", v.getUsername());
ExtendedInformation e = v.getExtendedInformation();
assertNotNull(e);
assertEquals("directoryAttr", e.getSubjectDirectoryAttributes());
testedYY = true;
}
}
assertTrue(testedXX);
assertTrue(testedYY);
publisherQueueSession.updateData(xxpk, PublisherConst.STATUS_SUCCESS, 4);
c = publisherQueueSession.getEntriesByFingerprint("XX");
assertEquals(1, c.size());
i = c.iterator();
d = i.next();
assertEquals("XX", d.getFingerprint());
Date lastUpdate2 = d.getLastUpdate();
assertTrue(lastUpdate2.after(lastUpdate1));
assertNotNull(d.getTimeCreated());
assertEquals(PublisherConst.STATUS_SUCCESS, d.getPublishStatus());
assertEquals(4,d.getTryCounter());
}