Example usage for java.util.concurrent ConcurrentHashMap isEmpty

List of usage examples for java.util.concurrent ConcurrentHashMap isEmpty

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Usage

From source file:com.steffi.index.ImgMapIndex.java

@Override
public ImgIndexHits<T> get(String key, Object value) {
    IndexKeyValue indexKeyValue = new IndexKeyValue(key, value);
    ConcurrentHashMap<Object, Boolean> idElements = getMap().get(indexKeyValue);

    if (idElements == null || idElements.isEmpty())
        return new ImgMapIndexHits<T>(IteratorUtils.emptyIterator(), 0, indexClass);
    else//  w  ww  .j  av a  2 s  .c  om
        return new ImgMapIndexHits<T>(idElements.keySet().iterator(), idElements.size(), indexClass);

}

From source file:org.wso2.carbon.event.input.adaptor.soap.SoapEventAdaptorType.java

@Override
public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration,
        InputEventAdaptorConfiguration inputEventAdaptorConfiguration,

        AxisConfiguration axisConfiguration, String subscriptionId) {

    String operationName = inputEventAdaptorMessageConfiguration.getInputMessageProperties()
            .get(SoapEventAdaptorConstants.ADAPTOR_MESSAGE_OPERATION_NAME);

    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    Map<String, ConcurrentHashMap<String, ConcurrentHashMap<String, SoapAdaptorListener>>> tenantSpecificListenerMap = inputEventAdaptorListenerMap
            .get(tenantId);/*from w ww  . j  a  va 2  s.c  o  m*/
    if (tenantSpecificListenerMap != null) {
        ConcurrentHashMap<String, ConcurrentHashMap<String, SoapAdaptorListener>> adaptorSpecificListeners = tenantSpecificListenerMap
                .get(inputEventAdaptorConfiguration.getName());

        if (adaptorSpecificListeners != null) {
            ConcurrentHashMap<String, SoapAdaptorListener> operationSpecificListeners = adaptorSpecificListeners
                    .get(operationName);
            if (operationSpecificListeners != null) {
                operationSpecificListeners.remove(subscriptionId);
                if (operationSpecificListeners.isEmpty()) {
                    tenantSpecificListenerMap.remove(operationName);
                    try {
                        Axis2Util.removeOperation(inputEventAdaptorMessageConfiguration,
                                inputEventAdaptorConfiguration, axisConfiguration, subscriptionId);
                    } catch (AxisFault axisFault) {
                        throw new InputEventAdaptorEventProcessingException("Can not remove operation ",
                                axisFault);
                    }
                }
            }
        }
    }

}

From source file:org.kde.kdeconnect.UserInterface.DeviceFragment.java

void refreshUI() {
    //Log.e("DeviceFragment", "refreshUI");

    if (device == null || rootView == null) {
        return;//from   w w w . j av  a 2 s.c o m
    }

    //Once in-app, there is no point in keep displaying the notification if any
    device.hidePairingNotification();

    mActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {

            if (device.isPairRequestedByPeer()) {
                ((TextView) rootView.findViewById(R.id.pair_message)).setText(R.string.pair_requested);
                rootView.findViewById(R.id.pair_progress).setVisibility(View.GONE);
                rootView.findViewById(R.id.pair_button).setVisibility(View.GONE);
                rootView.findViewById(R.id.pair_request).setVisibility(View.VISIBLE);
            } else {

                boolean paired = device.isPaired();
                boolean reachable = device.isReachable();
                boolean onData = NetworkHelper.isOnMobileNetwork(getContext());

                rootView.findViewById(R.id.pairing_buttons).setVisibility(paired ? View.GONE : View.VISIBLE);
                rootView.findViewById(R.id.not_reachable_message)
                        .setVisibility((paired && !reachable && !onData) ? View.VISIBLE : View.GONE);
                rootView.findViewById(R.id.on_data_message)
                        .setVisibility((paired && !reachable && onData) ? View.VISIBLE : View.GONE);

                try {
                    ArrayList<ListAdapter.Item> items = new ArrayList<>();

                    //Plugins button list
                    final Collection<Plugin> plugins = device.getLoadedPlugins().values();
                    for (final Plugin p : plugins) {
                        if (!p.hasMainActivity())
                            continue;
                        if (p.displayInContextMenu())
                            continue;

                        items.add(new PluginItem(p, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                p.startMainActivity(mActivity);
                            }
                        }));
                    }

                    //Failed plugins List
                    final ConcurrentHashMap<String, Plugin> failed = device.getFailedPlugins();
                    if (!failed.isEmpty()) {
                        if (errorHeader == null) {
                            errorHeader = new TextView(mActivity);
                            errorHeader.setPadding(0, ((int) (28 * getResources().getDisplayMetrics().density)),
                                    0, ((int) (8 * getResources().getDisplayMetrics().density)));
                            errorHeader.setOnClickListener(null);
                            errorHeader.setOnLongClickListener(null);
                            errorHeader.setText(getResources().getString(R.string.plugins_failed_to_load));
                        }
                        items.add(new CustomItem(errorHeader));
                        for (Map.Entry<String, Plugin> entry : failed.entrySet()) {
                            String pluginKey = entry.getKey();
                            final Plugin plugin = entry.getValue();
                            if (plugin == null) {
                                items.add(new SmallEntryItem(pluginKey));
                            } else {
                                items.add(
                                        new SmallEntryItem(plugin.getDisplayName(), new View.OnClickListener() {
                                            @Override
                                            public void onClick(View v) {
                                                plugin.getErrorDialog(mActivity).show();
                                            }
                                        }));
                            }
                        }
                    }

                    ListView buttonsList = (ListView) rootView.findViewById(R.id.buttons_list);
                    ListAdapter adapter = new ListAdapter(mActivity, items);
                    buttonsList.setAdapter(adapter);

                    mActivity.invalidateOptionsMenu();

                } catch (IllegalStateException e) {
                    e.printStackTrace();
                    //Ignore: The activity was closed while we were trying to update it
                } catch (ConcurrentModificationException e) {
                    Log.e("DeviceActivity", "ConcurrentModificationException");
                    this.run(); //Try again
                }

            }
        }
    });

}

From source file:com.aliyun.odps.rest.RestClient.java

private void uploadDeprecatedLog() {
    try {/*w  w w  .j  a va2  s  . c  o  m*/
        ConcurrentHashMap<String, Long> deprecatedMaps = OdpsDeprecatedLogger.getDeprecatedCalls();
        if (deprecatedMaps.isEmpty()) {
            return;
        }
        String deprecatedLogs = JSON.toJSONString(deprecatedMaps);
        OdpsDeprecatedLogger.getDeprecatedCalls().clear();

        String project = getDefaultProject();
        if (project == null) {
            return;
        }
        String resource = ResourceBuilder.buildProjectResource(project);
        resource += "/logs";
        byte[] bytes = deprecatedLogs.getBytes(CHARSET);
        ByteArrayInputStream body = new ByteArrayInputStream(bytes);
        requestWithNoRetry(resource, "PUT", null, null, body, bytes.length);
    } catch (Throwable e) {
        //do nothing if error occured
    }
}

From source file:org.wrml.runtime.rest.Resource.java

public URI getDefaultDocumentUri() {

    final UriTemplate uriTemplate = getUriTemplate();

    final String[] parameterNames = uriTemplate.getParameterNames();
    final Map<String, Object> parameterMap = new LinkedHashMap<>();

    if (parameterNames != null && parameterNames.length > 0) {

        final Api api = getApiNavigator().getApi();
        final Context context = api.getContext();
        final SchemaLoader schemaLoader = context.getSchemaLoader();

        final URI defaultSchemaUri = getDefaultSchemaUri();
        final Prototype defaultPrototype = (defaultSchemaUri != null)
                ? schemaLoader.getPrototype(defaultSchemaUri)
                : null;/* w  w w . ja v  a  2s  .  c  o m*/

        for (int i = 0; i < parameterNames.length; i++) {
            final String parameterName = parameterNames[i];

            URI keyedSchemaUri = null;

            if (defaultPrototype != null) {
                final Set<String> allKeySlotNames = defaultPrototype.getAllKeySlotNames();
                if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) {
                    keyedSchemaUri = defaultSchemaUri;
                }
            }

            if (keyedSchemaUri == null) {

                final ConcurrentHashMap<URI, LinkTemplate> referenceTemplates = getReferenceTemplates();

                if (referenceTemplates != null && !referenceTemplates.isEmpty()) {

                    final Set<URI> referenceLinkRelationUris = getReferenceLinkRelationUris(Method.Get);
                    if (referenceLinkRelationUris != null && !referenceLinkRelationUris.isEmpty()) {
                        for (URI linkRelationUri : referenceLinkRelationUris) {
                            final LinkTemplate referenceTemplate = referenceTemplates.get(linkRelationUri);
                            final URI responseSchemaUri = referenceTemplate.getResponseSchemaUri();
                            final Prototype responseSchemaPrototype = schemaLoader
                                    .getPrototype(responseSchemaUri);
                            if (responseSchemaPrototype != null) {
                                final Set<String> allKeySlotNames = responseSchemaPrototype
                                        .getAllKeySlotNames();
                                if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) {
                                    keyedSchemaUri = responseSchemaUri;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            Object defaultValue = null;

            if (keyedSchemaUri != null) {

                final Prototype keyedPrototype = schemaLoader.getPrototype(keyedSchemaUri);
                final ProtoSlot keyProtoSlot = keyedPrototype.getProtoSlot(parameterName);
                if (keyProtoSlot instanceof PropertyProtoSlot) {
                    final PropertyProtoSlot keyPropertyProtoSlot = (PropertyProtoSlot) keyProtoSlot;

                    // TODO: Allow more fine grain control of the default parameter value

                    defaultValue = keyPropertyProtoSlot.getDefaultValue();

                    if (defaultValue == null) {
                        defaultValue = keyPropertyProtoSlot.getValueType().getDefaultValue();
                    }

                }
            }

            parameterMap.put(parameterName, defaultValue);
        }
    }

    return uriTemplate.evaluate(parameterMap, true);
}

From source file:org.wrml.runtime.format.text.html.WrmldocFormatter.java

protected ArrayNode buildReferencesArrayNode(final ObjectMapper objectMapper,
        final Map<URI, ObjectNode> schemaNodes, final Map<URI, LinkRelation> linkRelationCache,
        final Resource resource, final Prototype defaultPrototype) {

    final Context context = getContext();
    final SchemaLoader schemaLoader = context.getSchemaLoader();
    final SyntaxLoader syntaxLoader = context.getSyntaxLoader();

    final URI defaultSchemaUri = (defaultPrototype != null) ? defaultPrototype.getSchemaUri() : null;
    final String defaultSchemaName = (defaultPrototype != null)
            ? defaultPrototype.getUniqueName().getLocalName()
            : null;//from  w w w .  j a  v  a2 s.c o  m

    final ArrayNode referencesNode = objectMapper.createArrayNode();

    final ConcurrentHashMap<URI, LinkTemplate> referenceTemplates = resource.getReferenceTemplates();
    final Set<URI> referenceRelationUris = referenceTemplates.keySet();

    if (referenceTemplates != null && !referenceTemplates.isEmpty()) {

        String selfResponseSchemaName = null;

        List<String> resourceParameterList = null;
        final UriTemplate uriTemplate = resource.getUriTemplate();
        final String[] parameterNames = uriTemplate.getParameterNames();
        if (parameterNames != null && parameterNames.length > 0) {

            resourceParameterList = new ArrayList<>();

            for (int i = 0; i < parameterNames.length; i++) {
                final String parameterName = parameterNames[i];

                URI keyedSchemaUri = null;

                if (defaultPrototype != null) {
                    final Set<String> allKeySlotNames = defaultPrototype.getAllKeySlotNames();
                    if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) {
                        keyedSchemaUri = defaultSchemaUri;
                    }
                }

                if (keyedSchemaUri == null) {

                    final Set<URI> referenceLinkRelationUris = resource
                            .getReferenceLinkRelationUris(Method.Get);
                    if (referenceLinkRelationUris != null && !referenceLinkRelationUris.isEmpty()) {
                        for (URI linkRelationUri : referenceLinkRelationUris) {
                            final LinkTemplate referenceTemplate = referenceTemplates.get(linkRelationUri);
                            final URI responseSchemaUri = referenceTemplate.getResponseSchemaUri();
                            final Prototype responseSchemaPrototype = schemaLoader
                                    .getPrototype(responseSchemaUri);
                            if (responseSchemaPrototype != null) {
                                final Set<String> allKeySlotNames = responseSchemaPrototype
                                        .getAllKeySlotNames();
                                if (allKeySlotNames != null && allKeySlotNames.contains(parameterName)) {
                                    keyedSchemaUri = responseSchemaUri;
                                    break;
                                }
                            }
                        }
                    }
                }

                String parameterTypeString = "?";

                if (keyedSchemaUri != null) {

                    final Prototype keyedPrototype = schemaLoader.getPrototype(keyedSchemaUri);
                    final ProtoSlot keyProtoSlot = keyedPrototype.getProtoSlot(parameterName);
                    if (keyProtoSlot instanceof PropertyProtoSlot) {
                        final PropertyProtoSlot keyPropertyProtoSlot = (PropertyProtoSlot) keyProtoSlot;
                        final ValueType parameterValueType = keyPropertyProtoSlot.getValueType();
                        final Type parameterHeapType = keyPropertyProtoSlot.getHeapValueType();
                        switch (parameterValueType) {
                        case Text: {
                            if (!String.class.equals(parameterHeapType)) {
                                final Class<?> syntaxClass = (Class<?>) parameterHeapType;
                                parameterTypeString = syntaxClass.getSimpleName();
                            } else {
                                parameterTypeString = parameterValueType.name();
                            }

                            break;
                        }
                        case SingleSelect: {
                            final Class<?> choicesEnumClass = (Class<?>) parameterHeapType;

                            if (choicesEnumClass.isEnum()) {
                                parameterTypeString = choicesEnumClass.getSimpleName();
                            } else {
                                // ?
                                parameterTypeString = parameterValueType.name();
                            }

                            break;
                        }
                        default: {
                            parameterTypeString = parameterValueType.name();
                            break;
                        }
                        }
                    }

                }

                resourceParameterList.add(parameterTypeString + " " + parameterName);
            }
        }

        for (final Method method : Method.values()) {
            for (final URI linkRelationUri : referenceRelationUris) {

                final LinkTemplate referenceTemplate = referenceTemplates.get(linkRelationUri);
                final LinkRelation linkRelation = getLinkRelation(linkRelationCache, linkRelationUri);

                if (method != linkRelation.getMethod()) {
                    continue;
                }

                final ObjectNode referenceNode = objectMapper.createObjectNode();
                referencesNode.add(referenceNode);

                referenceNode.put(PropertyName.method.name(), method.getProtocolGivenName());
                referenceNode.put(PropertyName.rel.name(), syntaxLoader.formatSyntaxValue(linkRelationUri));

                final String relationTitle = linkRelation.getTitle();
                referenceNode.put(PropertyName.relationTitle.name(), relationTitle);

                final URI responseSchemaUri = referenceTemplate.getResponseSchemaUri();
                String responseSchemaName = null;
                if (responseSchemaUri != null) {
                    final ObjectNode responseSchemaNode = getSchemaNode(objectMapper, schemaNodes,
                            responseSchemaUri, schemaLoader);
                    referenceNode.put(PropertyName.responseSchema.name(), responseSchemaNode);

                    responseSchemaName = responseSchemaNode
                            .get(SchemaDesignFormatter.PropertyName.localName.name()).asText();
                }

                final URI requestSchemaUri = referenceTemplate.getRequestSchemaUri();

                String requestSchemaName = null;
                if (requestSchemaUri != null) {
                    final ObjectNode requestSchemaNode = getSchemaNode(objectMapper, schemaNodes,
                            requestSchemaUri, schemaLoader);
                    referenceNode.put(PropertyName.requestSchema.name(), requestSchemaNode);

                    requestSchemaName = requestSchemaNode
                            .get(SchemaDesignFormatter.PropertyName.localName.name()).asText();
                }

                final StringBuilder signatureBuilder = new StringBuilder();

                if (responseSchemaName != null) {
                    signatureBuilder.append(responseSchemaName);
                } else {
                    signatureBuilder.append("void");
                }

                signatureBuilder.append(" ");

                String functionName = relationTitle;

                if (SystemLinkRelation.self.getUri().equals(linkRelationUri)) {
                    functionName = "get" + responseSchemaName;
                    selfResponseSchemaName = responseSchemaName;
                } else if (SystemLinkRelation.save.getUri().equals(linkRelationUri)) {
                    functionName = "save" + responseSchemaName;
                } else if (SystemLinkRelation.delete.getUri().equals(linkRelationUri)) {
                    functionName = "delete";
                    if (defaultSchemaName != null) {
                        functionName += defaultSchemaName;
                    } else if (selfResponseSchemaName != null) {
                        functionName += selfResponseSchemaName;
                    }
                }

                signatureBuilder.append(functionName).append(" ( ");

                String parameterString = null;
                if (resourceParameterList != null) {
                    final StringBuilder parameterStringBuilder = new StringBuilder();
                    final int parameterCount = resourceParameterList.size();
                    for (int i = 0; i < parameterCount; i++) {
                        final String parameter = resourceParameterList.get(i);
                        parameterStringBuilder.append(parameter);
                        if (i < parameterCount - 1) {
                            parameterStringBuilder.append(" , ");
                        }
                    }

                    parameterString = parameterStringBuilder.toString();
                    signatureBuilder.append(parameterString);
                }

                if (requestSchemaName != null) {
                    if (StringUtils.isNotBlank(parameterString)) {
                        signatureBuilder.append(" , ");
                    }

                    signatureBuilder.append(requestSchemaName);

                    signatureBuilder.append(" ");

                    final String parameterName = Character.toLowerCase(requestSchemaName.charAt(0))
                            + requestSchemaName.substring(1);
                    signatureBuilder.append(parameterName);
                }

                signatureBuilder.append(" ) ");

                final String signature = signatureBuilder.toString();
                referenceNode.put(PropertyName.signature.name(), signature);
            }

        }

    }

    return referencesNode;
}

From source file:org.apache.nifi.lookup.CSVRecordLookupService.java

private void loadCache() throws IllegalStateException, IOException {
    if (lock.tryLock()) {
        try {//from   w  w w  .ja v  a2  s  .  c o m
            final ComponentLog logger = getLogger();
            if (logger.isDebugEnabled()) {
                logger.debug("Loading lookup table from file: " + csvFile);
            }

            final FileReader reader = new FileReader(csvFile);
            final CSVParser records = csvFormat.withFirstRecordAsHeader().parse(reader);
            ConcurrentHashMap<String, Record> cache = new ConcurrentHashMap<>();
            RecordSchema lookupRecordSchema = null;
            for (final CSVRecord record : records) {
                final String key = record.get(lookupKeyColumn);

                if (StringUtils.isBlank(key)) {
                    throw new IllegalStateException("Empty lookup key encountered in: " + csvFile);
                } else if (!ignoreDuplicates && cache.containsKey(key)) {
                    throw new IllegalStateException(
                            "Duplicate lookup key encountered: " + key + " in " + csvFile);
                } else if (ignoreDuplicates && cache.containsKey(key)) {
                    logger.warn("Duplicate lookup key encountered: {} in {}", new Object[] { key, csvFile });
                }

                // Put each key/value pair (except the lookup) into the properties
                final Map<String, Object> properties = new HashMap<>();
                record.toMap().forEach((k, v) -> {
                    if (!lookupKeyColumn.equals(k)) {
                        properties.put(k, v);
                    }
                });

                if (lookupRecordSchema == null) {
                    List<RecordField> recordFields = new ArrayList<>(properties.size());
                    properties.forEach((k, v) -> recordFields
                            .add(new RecordField(k, RecordFieldType.STRING.getDataType())));
                    lookupRecordSchema = new SimpleRecordSchema(recordFields);
                }

                cache.put(key, new MapRecord(lookupRecordSchema, properties));
            }

            this.cache = cache;

            if (cache.isEmpty()) {
                logger.warn("Lookup table is empty after reading file: " + csvFile);
            }
        } finally {
            lock.unlock();
        }
    }
}

From source file:com.redhat.red.offliner.ftest.SinglePlaintextDownloadOfTarballFTest.java

/**
 * In general, we should only have one test method per functional test. This allows for the best parallelism when we
 * execute the tests, especially if the setup takes some time.
 *
 * @throws Exception In case anything (anything at all) goes wrong!
 *//*from w ww. jav  a2  s  .c o m*/
@Test
public void run() throws Exception {
    // Generate some test content
    String path = contentGenerator.newArtifactPath("tar.gz");
    Map<String, byte[]> entries = new HashMap<>();
    entries.put(contentGenerator.newArtifactPath("jar"), contentGenerator.newBinaryContent(2400));
    entries.put(contentGenerator.newArtifactPath("jar"), contentGenerator.newBinaryContent(2400));

    final File tgz = makeTarball(entries);

    System.out.println("tar content array has length: " + tgz.length());

    // We only need one repo server.
    ExpectationServer server = new ExpectationServer();
    server.start();

    // Register the generated content by writing it to the path within the repo server's dir structure.
    // This way when the path is requested it can be downloaded instead of returning a 404.
    server.expect("GET", server.formatUrl(path), (req, resp) -> {
        //            Content-Length: 47175
        //            Content-Type: application/x-gzip
        resp.setHeader("Content-Encoding", "gzip");
        resp.setHeader("Content-Type", "application/x-gzip");

        byte[] raw = FileUtils.readFileToByteArray(tgz);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GzipCompressorOutputStream gzout = new GzipCompressorOutputStream(baos);
        gzout.write(raw);
        gzout.finish();

        byte[] content = baos.toByteArray();

        resp.setHeader("Content-Length", Long.toString(content.length));
        OutputStream respStream = resp.getOutputStream();
        respStream.write(content);
        respStream.flush();

        System.out.println("Wrote content with length: " + content.length);
    });

    byte[] content = FileUtils.readFileToByteArray(tgz);

    server.expect("GET", server.formatUrl(path + Main.SHA_SUFFIX), 200, sha1Hex(content));
    server.expect("GET", server.formatUrl(path + Main.MD5_SUFFIX), 200, md5Hex(content));

    // Write the plaintext file we'll use as input.
    File plaintextList = temporaryFolder.newFile("artifact-list." + getClass().getSimpleName() + ".txt");
    String pathWithChecksum = contentGenerator.newPlaintextEntryWithChecksum(path, content);
    FileUtils.write(plaintextList, pathWithChecksum);

    Options opts = new Options();
    opts.setBaseUrls(Collections.singletonList(server.getBaseUri()));

    // Capture the downloads here so we can verify the content.
    File downloads = temporaryFolder.newFolder();

    opts.setDownloads(downloads);
    opts.setLocations(Collections.singletonList(plaintextList.getAbsolutePath()));
    opts.setConnections(1);

    // run `new Main(opts).run()` and return the Main instance so we can query it for errors, etc.
    Main finishedMain = run(opts);
    ConcurrentHashMap<String, Throwable> errors = finishedMain.getErrors();
    System.out.printf("ERRORS:\n\n%s\n\n\n",
            StringUtils.join(errors.keySet().stream()
                    .map(k -> "ERROR: " + k + ": " + errors.get(k).getMessage() + "\n  "
                            + StringUtils.join(errors.get(k).getStackTrace(), "\n  "))
                    .collect(Collectors.toList()), "\n\n"));

    File downloaded = new File(downloads, path);
    assertThat("File: " + path + " doesn't seem to have been downloaded!", downloaded.exists(), equalTo(true));
    //        assertThat( "Downloaded file: " + path + " contains the wrong content!",
    //                    FileUtils.readFileToByteArray( downloaded ), equalTo( content ) );

    File tarball = new File(downloads, path);
    System.out.println("Length of downloaded file: " + tarball.length());

    File tmp = new File("/tmp/download.tar.gz");
    File tmp2 = new File("/tmp/content.tar.gz");
    FileUtils.writeByteArrayToFile(tmp2, content);
    FileUtils.copyFile(tarball, tmp);

    try (TarArchiveInputStream tarIn = new TarArchiveInputStream(
            new GzipCompressorInputStream(new FileInputStream(tarball)))) {
        TarArchiveEntry entry = null;
        while ((entry = tarIn.getNextTarEntry()) != null) {
            byte[] entryData = new byte[(int) entry.getSize()];
            int read = tarIn.read(entryData, 0, entryData.length);
            assertThat("Not enough bytes read for: " + entry.getName(), read, equalTo((int) entry.getSize()));
            assertThat(entry.getName() + ": data doesn't match input",
                    Arrays.equals(entries.get(entry.getName()), entryData), equalTo(true));
        }
    }

    assertThat("Wrong number of downloads logged. Should have been 3 including checksums.",
            finishedMain.getDownloaded(), equalTo(3));
    assertThat("Errors should be empty!", errors.isEmpty(), equalTo(true));

}