Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public abstract class AbstractIndyFunctionalTest

protected File storageDir;

protected CacheProvider cacheProvider;

@SuppressWarnings( "resource" )
@Before
public void start()
Expand Down Expand Up @@ -120,6 +122,7 @@ public void run()
}

client = createIndyClient();
cacheProvider = CDI.current().select( CacheProvider.class ).get();
}
catch ( Throwable t )
{
Expand Down Expand Up @@ -196,7 +199,6 @@ public void stop()
// TODO: this is a hack due to the "shutdown action not executed" issue. Once propulsor lifecycle shutdown is applied, this can be replaced.
private void closeCacheProvider()
{
CacheProvider cacheProvider = CDI.current().select( CacheProvider.class ).get();
if ( cacheProvider != null )
{
cacheProvider.asAdminView().close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.commonjava.indy.model.core.Group;
import org.commonjava.indy.model.core.RemoteRepository;
import org.commonjava.indy.model.util.HttpUtils;
import org.commonjava.indy.util.LocationUtils;
import org.commonjava.maven.galley.model.ConcreteResource;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -83,7 +85,7 @@ public class GroupHttpHeadersFromSameRepoAsPomTest

private static final String CONTENT_2 = "This is content #2. Some more content, here.";

private static final String PATH = "/path/to/test.txt";
private static final String PATH = "path/to/test.txt";

private RemoteRepository repoX;

Expand Down Expand Up @@ -120,20 +122,9 @@ public void run()
assertContent( repoX, PATH, CONTENT_1 );
assertContent( repoY, PATH, CONTENT_2 );

// repoX.setDisabled( true );
// client.stores().update( repoX, "disabling" );

File remoteXFile = Paths.get( fixture.getBootOptions().getHomeDir(), "var/lib/indy/storage", MAVEN_PKG_KEY,
remote.singularEndpointName() + "-X", PATH ).toFile();

waitForEventPropagation();

Logger logger = LoggerFactory.getLogger( getClass() );
logger.debug( "Deleting main file: {} (leaving associated http-metadata.json file in place)", remoteXFile );

assertThat( "Failed to delete: " + remoteXFile, remoteXFile.delete(), equalTo( true ) );

waitForEventPropagation();
ConcreteResource res = new ConcreteResource( LocationUtils.toLocation( repoX ), PATH );
cacheProvider.delete( res );
logger.debug( "Deleting main file: {} (leaving associated http-metadata.json file in place)", res );

assertContentLength( groupA, PATH, content2.length );
assertContentLength( repoX, PATH, CONTENT_1.getBytes().length );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.commonjava.indy.model.core.StoreType;
import org.commonjava.indy.util.LocationUtils;
import org.commonjava.maven.galley.model.ConcreteResource;
import org.junit.Test;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -196,12 +197,10 @@ private Group updateAndRetrieve( final Group g, final String changeLog, final St
private void assertInfoContent( final ArtifactStore store, final String path, final String expectedContent )
throws Exception
{
final File infoFile = getPhysicalStorageFile( LocationUtils.toLocation( store ), path + GroupMergeHelper.MERGEINFO_SUFFIX );
assertThat( "info file doesn't exist", infoFile.exists(), equalTo( true ) );

try (final InputStream stream = new FileInputStream( infoFile ))
ConcreteResource res = new ConcreteResource( LocationUtils.toLocation( store ),
path + GroupMergeHelper.MERGEINFO_SUFFIX );
try (final InputStream stream = cacheProvider.openInputStream( res ) )
{
System.out.println( stream );
assertThat( IOUtils.toString( stream ), equalTo( expectedContent ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import org.commonjava.indy.ftest.core.category.EventDependent;
import org.commonjava.indy.model.core.HostedRepository;
import org.commonjava.indy.test.fixture.core.CoreServerFixture;
import org.commonjava.indy.util.LocationUtils;
import org.commonjava.maven.galley.model.ConcreteResource;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -91,13 +94,8 @@ public void bypassNotIndexedContentWithAuthoritativeIndex()
client.content()
.store( repo.getKey(), CACHED_AFACT_PATH, new ByteArrayInputStream( CACHED_CONTENT.getBytes() ) );

final Path nonCachedFile =
Paths.get( fixture.getBootOptions().getHomeDir(), "var/lib/indy/storage", MAVEN_PKG_KEY,
hosted.singularEndpointName() + "-" + repoName, NON_CACHED_AFACT_PATH );
Files.createDirectories( nonCachedFile.getParent() );
Files.createFile( nonCachedFile );

try (FileOutputStream stream = new FileOutputStream( nonCachedFile.toFile() ))
ConcreteResource res = new ConcreteResource( LocationUtils.toLocation( repo ), NON_CACHED_AFACT_PATH );
try (OutputStream stream = cacheProvider.openOutputStream( res ))
{
stream.write( NON_CACHED_CONTENT.getBytes() );
}
Expand Down