Search in sources :

Example 1 with TransferBatch

use of org.commonjava.maven.galley.model.TransferBatch in project galley by Commonjava.

the class AbstractTransferManagerTest method batchRetrieve_returnEmptyResultIfVirtualResourceIsEmpty.

/**
     * Addresses Issue #27 (https://github.com/Commonjava/galley/issues/27). Batches with virtual resources
     * that contain zero concrete resources should count down the latch when they return immediately, but 
     * instead are causing the countdown latch that watches the batch of transfers to hang.
     */
@Test(timeout = 2000)
public void batchRetrieve_returnEmptyResultIfVirtualResourceIsEmpty() throws Exception {
    final VirtualResource vr = new VirtualResource(Collections.<Location>emptyList(), "/path/to/nowhere");
    final TransferBatch batch = getTransferManagerImpl().batchRetrieve(new TransferBatch(Collections.<Resource>singleton(vr)), new EventMetadata());
    assertThat(batch, notNullValue());
    assertThat(batch.getErrors().isEmpty(), equalTo(true));
    assertThat(batch.getTransfers().isEmpty(), equalTo(true));
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Resource(org.commonjava.maven.galley.model.Resource) VirtualResource(org.commonjava.maven.galley.model.VirtualResource) VirtualResource(org.commonjava.maven.galley.model.VirtualResource) TransferBatch(org.commonjava.maven.galley.model.TransferBatch) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 2 with TransferBatch

use of org.commonjava.maven.galley.model.TransferBatch in project galley by Commonjava.

the class TransferManagerImpl method retrieveAll.

/* (non-Javadoc)
     * @see org.commonjava.maven.galley.TransferManager#retrieveAll(java.util.List, java.lang.String)
     */
@Override
public List<Transfer> retrieveAll(final VirtualResource virt, final EventMetadata eventMetadata) throws TransferException {
    TransferBatch batch = new TransferBatch(Collections.singleton(virt));
    batch = batchRetrieveAll(batch, eventMetadata);
    return new ArrayList<Transfer>(batch.getTransfers().values());
}
Also used : ArrayList(java.util.ArrayList) TransferBatch(org.commonjava.maven.galley.model.TransferBatch)

Aggregations

TransferBatch (org.commonjava.maven.galley.model.TransferBatch)2 ArrayList (java.util.ArrayList)1 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)1 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)1 Resource (org.commonjava.maven.galley.model.Resource)1 VirtualResource (org.commonjava.maven.galley.model.VirtualResource)1 Test (org.junit.Test)1