public void testSetters() { CertificateV2 certificate = new CertificateV2(); certificate.setName(new Name( "/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B")); certificate.getMetaInfo().setFreshnessPeriod(3600 * 1000.0d); certificate.setContent(new Blob(PUBLIC_KEY, false)); certificate.setSignature(generateFakeSignature()); Assert.AssertEquals(new Name( "/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B"), certificate.getName()); Assert.AssertEquals(new Name("/ndn/site1/KEY/ksk-1416425377094"), certificate.getKeyName()); Assert.AssertEquals(new Name("/ndn/site1"), certificate.getIdentity()); Assert.AssertEquals(new Name.Component("0123"), certificate.getIssuerId()); Assert.AssertEquals(new Name.Component("ksk-1416425377094"), certificate.getKeyId()); Assert.AssertEquals(new Name("/ndn/site1/KEY/ksk-2516425377094"), net.named_data.jndn.KeyLocator .getFromSignature(certificate.getSignature()).getKeyName()); Assert.AssertEquals(net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20141111T050000"), certificate .getValidityPeriod().getNotBefore(), 0); Assert.AssertEquals(net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20141111T060000"), certificate .getValidityPeriod().getNotAfter(), 0); try { certificate.getPublicKey(); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void testConstructor() { CertificateV2 certificate = new CertificateV2(); certificate.wireDecode(new Blob(CERT, false)); Assert.AssertEquals(new Name( "/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B"), certificate.getName()); Assert.AssertEquals(new Name("/ndn/site1/KEY/ksk-1416425377094"), certificate.getKeyName()); Assert.AssertEquals(new Name("/ndn/site1"), certificate.getIdentity()); Assert.AssertEquals(new Name.Component("0123"), certificate.getIssuerId()); Assert.AssertEquals(new Name.Component("ksk-1416425377094"), certificate.getKeyId()); Assert.AssertEquals(new Name("/ndn/site1/KEY/ksk-2516425377094"), net.named_data.jndn.KeyLocator .getFromSignature(certificate.getSignature()).getKeyName()); Assert.AssertEquals(net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150814T223739"), certificate .getValidityPeriod().getNotBefore(), 0); Assert.AssertEquals(net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150818T223738"), certificate .getValidityPeriod().getNotAfter(), 0); try { certificate.getPublicKey(); } catch (Exception ex) { Assert.Fail(ex.Message); } Data data = new Data(); data.wireDecode(new Blob(CERT, false)); CertificateV2 certificate2 = new CertificateV2(data); Assert.AssertEquals(certificate.getName(), certificate2.getName()); Assert.AssertTrue(certificate.getPublicKey().equals( certificate2.getPublicKey())); }