1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-18 18:21:08 +01:00

Add JUnit tests

This commit is contained in:
Paul Schaub 2022-02-07 20:18:52 +01:00
parent 2e6a1dcbc5
commit b3ca06584b
5 changed files with 137 additions and 7 deletions

View file

@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d;
import java.util.HashMap;

View file

@ -11,16 +11,17 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.SynchronousQueue;
import java.util.List;
import pgp.cert_d.exception.BadDataException;
import pgp.cert_d.exception.BadNameException;
import pgp.cert_d.exception.NotAStoreException;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.MergeCallback;
import pgp.certificate_store.CertificateReaderBackend;
import pgp.certificate_store.MergeCallback;
public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDirectory {
@ -237,7 +238,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
public Iterator<Certificate> items() {
return new Iterator<Certificate>() {
private final Queue<Lazy<Certificate>> certificateQueue = new SynchronousQueue<>();
private final List<Lazy<Certificate>> certificateQueue = Collections.synchronizedList(new ArrayList<>());
// Constructor... wtf.
{
@ -283,7 +284,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
@Override
public Certificate next() {
try {
return certificateQueue.poll().get();
return certificateQueue.remove(0).get();
} catch (BadDataException e) {
throw new AssertionError("Could not retrieve item: " + e.getMessage());
}