/** * Create an instance of {@link TimeConstraint } * */ public TimeConstraint createTimeConstraint() { return new TimeConstraint(); }
@Test public void failedRevocationDataFreshCheck() throws Exception { TimeConstraint tc = new TimeConstraint(); tc.setUnit(TimeUnit.DAYS); tc.setValue(1); tc.setLevel(Level.FAIL); XmlRevocation xr = new XmlRevocation(); Date now = new Date(); long nowMil = now.getTime(); xr.setProductionDate(new Date(nowMil - 172800000)); // 48 hours ago XmlRFC result = new XmlRFC(); RevocationDataFreshCheck rdec = new RevocationDataFreshCheck(result, new RevocationWrapper(xr), now, tc); rdec.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void testUnmarshalConstraint() throws Exception { ConstraintsParameters constraintsParameters = unmarshal(new File("src/test/resources/constraint.xml")); RevocationConstraints revocation = constraintsParameters.getRevocation(); assertNotNull(revocation); TimeConstraint revocationFreshness = revocation.getRevocationFreshness(); assertNotNull(revocationFreshness); assertEquals(Level.FAIL, revocationFreshness.getLevel()); assertEquals(TimeUnit.DAYS, revocationFreshness.getUnit()); assertNotNull(revocationFreshness.getValue()); assertEquals(0, revocationFreshness.getValue().intValue()); }
@Test public void revocationDataFreshCheck() throws Exception { TimeConstraint tc = new TimeConstraint(); tc.setUnit(TimeUnit.DAYS); tc.setValue(1); tc.setLevel(Level.FAIL); XmlRevocation xr = new XmlRevocation(); Date now = new Date(); long nowMil = now.getTime(); xr.setProductionDate(new Date(nowMil - 43200000)); // 12 hours ago XmlRFC result = new XmlRFC(); RevocationDataFreshCheck rdec = new RevocationDataFreshCheck(result, new RevocationWrapper(xr), now, tc); rdec.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }