public DataStructure createStructureToRead() { return new LeaseSet(); }
@Test public void failsToGetInvalidLease() { // create test subject LeaseSet subj = new LeaseSet(); // this shouldn't work either exception.expect(IndexOutOfBoundsException.class); subj.getLease(-1); }
@Test public void failsToGetLeaseWhenEmpty() { // create test subject LeaseSet subj = new LeaseSet(); // should contain no leases now. exception.expect(IndexOutOfBoundsException.class); subj.getLease(0); }
LeaseSet ls = new LeaseSet(); Iterator<Lease> iter = leases.iterator(); int count = Math.min(leases.size(), wanted);
@Test public void testAddLeaseNull() { // create test subject LeaseSet subj = new LeaseSet(); // now add an null lease exception.expect(IllegalArgumentException.class); exception.expectMessage("erm, null lease"); subj.addLease(null); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); // Revocation is unimplemented. // As the SPK comes before the LeaseSet, we don't know the key type. // We could have some sort of callback or state setting so we get the // expected type from the session. But for now, we just assume it's 20 bytes. // Clients outside router context should throw in a dummy 20 bytes. _signingPrivateKey = new SigningPrivateKey(); _signingPrivateKey.readBytes(in); _privateKey = new PrivateKey(); _privateKey.readBytes(in); _leaseSet = new LeaseSet(); _leaseSet.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error reading the CreateLeaseSetMessage", dfe); } }
@Test public void testAddLeaseInvalid() { // create test subject LeaseSet subj = new LeaseSet(); // try to add completely invalid lease(ie. no data) exception.expect(IllegalArgumentException.class); exception.expectMessage("erm, lease has no gateway"); subj.addLease(new Lease()); } }
@Override protected LeaseSet locked_buildNewLeaseSet() { LeaseSet ls = _context.netDb().lookupLeaseSetLocally(_aliasOf.getSettings().getDestination()); if (ls == null) return null; // copy everything so it isn't corrupted LeaseSet rv = new LeaseSet(); for (int i = 0; i < ls.getLeaseCount(); i++) { Lease old = ls.getLease(i); Lease lease = new Lease(); lease.setEndDate(old.getEndDate()); lease.setTunnelId(old.getTunnelId()); lease.setGateway(old.getGateway()); rv.addLease(lease); } return rv; }
((LeaseSet2)leaseSet).setUnpublished(); } else { leaseSet = new LeaseSet();
((LeaseSet2)leaseSet).setUnpublished(); } else { leaseSet = new LeaseSet();
/** * Immediately send a fake leaseset */ @Override protected void startCreateSessionJob(SessionConfig config) { long exp = _context.clock().now() + 10*60*1000; LeaseSet ls = new LeaseSet(); Lease lease = new Lease(); lease.setGateway(Hash.FAKE_HASH); TunnelId id = new TunnelId(1); lease.setTunnelId(id); Date date = new Date(exp); lease.setEndDate(date); ls.addLease(lease); _runner.requestLeaseSet(config.getDestination().calculateHash(), ls, exp, null, null); }
_dbEntry = new LeaseSet(); else if (dbType == DatabaseEntry.KEY_TYPE_LS2) _dbEntry = new LeaseSet2();
int type = in.read(); if (type == DatabaseEntry.KEY_TYPE_LEASESET) { _leaseSet = new LeaseSet(); } else if (type == DatabaseEntry.KEY_TYPE_LS2) { _leaseSet = new LeaseSet2();
public DataStructure createDataStructure() throws DataFormatException { LeaseSet leaseSet = new LeaseSet(); leaseSet.setDestination((Destination)(new DestinationTest()).createDataStructure()); leaseSet.setEncryptionKey((PublicKey)(new PublicKeyTest()).createDataStructure()); leaseSet.setSignature((Signature)(new SignatureTest()).createDataStructure()); leaseSet.setSigningKey((SigningPublicKey)(new SigningPublicKeyTest()).createDataStructure()); //leaseSet.setVersion(42l); return leaseSet; } public DataStructure createStructureToRead() { return new LeaseSet(); }