mirror of https://github.com/apache/archiva.git
refactor service tests
Split out scan call to be explicit to make it easier to refactor duplicate sections, then move repeated configuration to before/after methods. Make sure scanning has finished before operations that might concurrently try to modify the metadata. This also means we can now verify the deletion of the repository is successful
This commit is contained in:
parent
2b8f78afe2
commit
8b1e1ffa71
|
@ -64,6 +64,7 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
|
|||
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScanner;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScannerException;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScannerInstance;
|
||||
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
||||
import org.apache.archiva.rest.api.model.StringList;
|
||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
|
@ -169,6 +170,13 @@ public class DefaultRepositoriesService
|
|||
@Override
|
||||
public Boolean alreadyScanning( String repositoryId )
|
||||
{
|
||||
for ( RepositoryScannerInstance scan : repoScanner.getInProgressScans() )
|
||||
{
|
||||
if ( scan.getRepository().getId().equals( repositoryId ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId );
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@ package org.apache.archiva.rest.services;
|
|||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.common.utils.FileUtil;
|
||||
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
||||
import org.apache.archiva.redback.rest.services.AbstractRestServicesTest;
|
||||
import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
|
||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
|
||||
import org.apache.archiva.rest.api.services.BrowseService;
|
||||
import org.apache.archiva.rest.api.services.CommonServices;
|
||||
|
@ -51,6 +53,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import org.apache.archiva.rest.api.services.PluginsService;
|
||||
|
@ -417,14 +420,8 @@ public abstract class AbstractArchivaRestTest
|
|||
|
||||
}
|
||||
|
||||
protected void createAndIndexRepo( String testRepoId, String repoPath, boolean scan )
|
||||
throws Exception
|
||||
{
|
||||
createAndIndexRepo( testRepoId, repoPath, scan, false );
|
||||
}
|
||||
|
||||
protected void createAndIndexRepo( String testRepoId, String repoPath, boolean scan, boolean stageNeeded )
|
||||
throws Exception
|
||||
protected void createAndIndexRepo( String testRepoId, String repoPath, boolean stageNeeded )
|
||||
throws ArchivaRestServiceException, IOException, RedbackServiceException
|
||||
{
|
||||
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( testRepoId ) != null )
|
||||
{
|
||||
|
@ -464,23 +461,30 @@ public abstract class AbstractArchivaRestTest
|
|||
|
||||
getRoleManagementService( authorizationHeader ).assignTemplatedRole(
|
||||
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, testRepoId, "guest" );
|
||||
if ( scan )
|
||||
{
|
||||
getRepositoriesService( authorizationHeader ).scanRepositoryNow( testRepoId, true );
|
||||
}
|
||||
}
|
||||
|
||||
protected void scanRepo( String testRepoId )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
getRepositoriesService( authorizationHeader ).scanRepositoryNow( testRepoId, true );
|
||||
}
|
||||
|
||||
protected void createAndIndexRepo( String testRepoId, String repoPath )
|
||||
throws Exception
|
||||
{
|
||||
createAndIndexRepo( testRepoId, repoPath, true, false );
|
||||
createAndIndexRepo( testRepoId, repoPath, false );
|
||||
scanRepo( testRepoId );
|
||||
}
|
||||
|
||||
protected void createStagedNeededRepo( String testRepoId, String repoPath, boolean scan )
|
||||
throws Exception
|
||||
{
|
||||
createAndIndexRepo( testRepoId, repoPath, scan, true );
|
||||
createAndIndexRepo( testRepoId, repoPath, true );
|
||||
if ( scan )
|
||||
{
|
||||
scanRepo( testRepoId );
|
||||
}
|
||||
|
||||
RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
|
||||
repositoriesService.scanRepositoryDirectoriesNow( testRepoId );
|
||||
if ( scan )
|
||||
|
@ -494,16 +498,9 @@ public abstract class AbstractArchivaRestTest
|
|||
protected void deleteTestRepo( String id )
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( id ) != null )
|
||||
{
|
||||
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( id ) != null )
|
||||
{
|
||||
getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( id, false );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.warn( "skip error deleting repo {}", id, e );
|
||||
getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( id, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,4 +508,13 @@ public abstract class AbstractArchivaRestTest
|
|||
{
|
||||
return System.getProperty( "basedir" );
|
||||
}
|
||||
|
||||
protected void waitForScanToComplete( String repoId )
|
||||
throws ArchivaRestServiceException, InterruptedException
|
||||
{
|
||||
while ( getRepositoriesService( authorizationHeader ).alreadyScanning( repoId ) ) {
|
||||
// Would be better to cancel, if we had that capacity
|
||||
Thread.sleep( 100 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,23 +20,27 @@ package org.apache.archiva.rest.services;
|
|||
|
||||
import org.apache.archiva.maven2.model.Artifact;
|
||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
||||
import org.apache.archiva.rest.api.model.ArtifactContentEntry;
|
||||
import org.apache.archiva.rest.api.model.BrowseResult;
|
||||
import org.apache.archiva.rest.api.model.BrowseResultEntry;
|
||||
import org.apache.archiva.rest.api.model.Entry;
|
||||
import org.apache.archiva.rest.api.model.MetadataAddRequest;
|
||||
import org.apache.archiva.rest.api.model.VersionsList;
|
||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
import org.apache.archiva.rest.api.services.BrowseService;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
|
||||
import org.assertj.core.data.MapEntry;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
@ -46,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class BrowseServiceTest
|
||||
extends AbstractArchivaRestTest
|
||||
{
|
||||
private static final String TEST_REPO_ID = "test-repo";
|
||||
|
||||
Map<String, String> toMap( List<Entry> entries )
|
||||
{
|
||||
|
@ -64,31 +69,20 @@ public class BrowseServiceTest
|
|||
public void metadatagetthenadd()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath() );
|
||||
scanRepo( TEST_REPO_ID );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
Map<String, String> metadatas =
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isEmpty();
|
||||
|
||||
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", testRepoId );
|
||||
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID );
|
||||
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isNotEmpty().contains( MapEntry.entry( "wine", "bordeaux" ) );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,89 +90,52 @@ public class BrowseServiceTest
|
|||
public void metadatagetthenaddthendelete()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath() );
|
||||
scanRepo( TEST_REPO_ID );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
Map<String, String> metadatas =
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isEmpty();
|
||||
|
||||
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", testRepoId );
|
||||
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID );
|
||||
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isNotEmpty().contains( MapEntry.entry( "wine", "bordeaux" ) );
|
||||
|
||||
browseService.deleteMetadata( "commons-cli", "commons-cli", "1.0", "wine", testRepoId );
|
||||
browseService.deleteMetadata( "commons-cli", "commons-cli", "1.0", "wine", TEST_REPO_ID );
|
||||
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isEmpty();
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void browserootGroups()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
BrowseResult browseResult = browseService.getRootGroups( testRepoId );
|
||||
BrowseResult browseResult = browseService.getRootGroups( TEST_REPO_ID );
|
||||
assertThat( browseResult ).isNotNull();
|
||||
assertThat( browseResult.getBrowseResultEntries() ).isNotNull().isNotEmpty().hasSize( 3 ).contains(
|
||||
new BrowseResultEntry( "commons-cli", false ), new BrowseResultEntry( "commons-logging", false ),
|
||||
new BrowseResultEntry( "org.apache", false ) );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void browsegroupId()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
BrowseResult browseResult = browseService.browseGroupId( "org.apache", testRepoId );
|
||||
BrowseResult browseResult = browseService.browseGroupId( "org.apache", TEST_REPO_ID );
|
||||
assertThat( browseResult ).isNotNull();
|
||||
assertThat( browseResult.getBrowseResultEntries() ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
|
||||
new BrowseResultEntry( "org.apache.felix", false ),
|
||||
new BrowseResultEntry( "org.apache.karaf.features", false ) );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,183 +143,96 @@ public class BrowseServiceTest
|
|||
public void browsegroupIdWithReleaseStartNumber()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
BrowseResult browseResult = browseService.browseGroupId( "commons-logging.commons-logging", testRepoId );
|
||||
BrowseResult browseResult = browseService.browseGroupId( "commons-logging.commons-logging", TEST_REPO_ID );
|
||||
log.info( "browseResult: {}", browseResult );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void versionsList()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
VersionsList versions =
|
||||
browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core", testRepoId );
|
||||
browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core", TEST_REPO_ID );
|
||||
assertThat( versions ).isNotNull();
|
||||
assertThat( versions.getVersions() ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "2.2.1", "2.2.2" );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getProjectVersionMetadata()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
ProjectVersionMetadata metadata =
|
||||
browseService.getProjectVersionMetadata( "org.apache.karaf.features", "org.apache.karaf.features.core",
|
||||
testRepoId );
|
||||
ProjectVersionMetadata metadata = browseService.getProjectVersionMetadata( "org.apache.karaf.features",
|
||||
"org.apache.karaf.features.core",
|
||||
TEST_REPO_ID );
|
||||
|
||||
assertThat( metadata ).isNotNull();
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readArtifactContentEntries()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
List<ArtifactContentEntry> artifactContentEntries =
|
||||
browseService.getArtifactContentEntries( "commons-logging", "commons-logging", "1.1", null, null, null,
|
||||
testRepoId );
|
||||
TEST_REPO_ID );
|
||||
|
||||
log.info( "artifactContentEntries: {}", artifactContentEntries );
|
||||
|
||||
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
|
||||
new ArtifactContentEntry( "org", false, 0, testRepoId ),
|
||||
new ArtifactContentEntry( "META-INF", false, 0, testRepoId ) );
|
||||
deleteTestRepo( testRepoId );
|
||||
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains( new ArtifactContentEntry(
|
||||
"org", false, 0, TEST_REPO_ID ), new ArtifactContentEntry( "META-INF", false, 0, TEST_REPO_ID ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readArtifactContentEntriesRootPath()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
List<ArtifactContentEntry> artifactContentEntries =
|
||||
browseService.getArtifactContentEntries( "commons-logging", "commons-logging", "1.1", null, null, "org/",
|
||||
testRepoId );
|
||||
TEST_REPO_ID );
|
||||
|
||||
log.info( "artifactContentEntries: {}", artifactContentEntries );
|
||||
|
||||
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
|
||||
new ArtifactContentEntry( "org/apache", false, 1, testRepoId ) );
|
||||
deleteTestRepo( testRepoId );
|
||||
new ArtifactContentEntry( "org/apache", false, 1, TEST_REPO_ID ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readArtifactContentEntriesFilesAndDirectories()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
List<ArtifactContentEntry> artifactContentEntries =
|
||||
browseService.getArtifactContentEntries( "commons-logging", "commons-logging", "1.1", null, null,
|
||||
"org/apache/commons/logging/", testRepoId );
|
||||
"org/apache/commons/logging/", TEST_REPO_ID );
|
||||
|
||||
log.info( "artifactContentEntries: {}", artifactContentEntries );
|
||||
|
||||
assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
|
||||
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, testRepoId ),
|
||||
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, testRepoId ) );
|
||||
deleteTestRepo( testRepoId );
|
||||
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, TEST_REPO_ID ),
|
||||
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, TEST_REPO_ID ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArtifactDownloadInfos()
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(),
|
||||
false );
|
||||
List<Artifact> artifactDownloadInfos =
|
||||
browseService.getArtifactDownloadInfos( "commons-logging", "commons-logging", "1.1", TEST_REPO_ID );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
List<Artifact> artifactDownloadInfos =
|
||||
browseService.getArtifactDownloadInfos( "commons-logging", "commons-logging", "1.1", testRepoId );
|
||||
|
||||
log.info( "artifactDownloadInfos {}", artifactDownloadInfos );
|
||||
assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 3 );
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
log.info( "artifactDownloadInfos {}", artifactDownloadInfos );
|
||||
assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 3 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -370,35 +240,18 @@ public class BrowseServiceTest
|
|||
public void readArtifactContentText()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
WebClient.client( browseService ).accept( MediaType.TEXT_PLAIN );
|
||||
|
||||
try
|
||||
{
|
||||
String text =
|
||||
browseService.getArtifactContentText( "commons-logging", "commons-logging", "1.1", "sources", null,
|
||||
"org/apache/commons/logging/LogSource.java",
|
||||
testRepoId ).getContent();
|
||||
String text =
|
||||
browseService.getArtifactContentText( "commons-logging", "commons-logging", "1.1", "sources", null,
|
||||
"org/apache/commons/logging/LogSource.java",
|
||||
TEST_REPO_ID ).getContent();
|
||||
|
||||
log.debug( "text: {}", text );
|
||||
log.debug( "text: {}", text );
|
||||
|
||||
assertThat( text ).contains( "package org.apache.commons.logging;" ).contains( "public class LogSource {" );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
assertThat( text ).contains( "package org.apache.commons.logging;" ).contains( "public class LogSource {" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,36 +259,19 @@ public class BrowseServiceTest
|
|||
public void readArtifactContentTextPom()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
WebClient.client( browseService ).accept( MediaType.TEXT_PLAIN );
|
||||
|
||||
try
|
||||
{
|
||||
String text =
|
||||
browseService.getArtifactContentText( "commons-logging", "commons-logging", "1.1", null, "pom", null,
|
||||
testRepoId ).getContent();
|
||||
String text =
|
||||
browseService.getArtifactContentText( "commons-logging", "commons-logging", "1.1", null, "pom", null,
|
||||
TEST_REPO_ID ).getContent();
|
||||
|
||||
log.info( "text: {}", text );
|
||||
log.info( "text: {}", text );
|
||||
|
||||
assertThat( text ).contains(
|
||||
"<url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>" ).contains(
|
||||
"<subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>" );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
assertThat( text ).contains(
|
||||
"<url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>" ).contains(
|
||||
"<subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -443,47 +279,22 @@ public class BrowseServiceTest
|
|||
public void artifactsNumber()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(), false );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, true );
|
||||
|
||||
//WebClient.client( browseService ).accept( MediaType.TEXT_PLAIN );
|
||||
|
||||
try
|
||||
{
|
||||
int number = browseService.getArtifacts( testRepoId ).size();
|
||||
int number = browseService.getArtifacts( TEST_REPO_ID ).size();
|
||||
|
||||
log.info( "getArtifactsNumber: {}", number );
|
||||
log.info( "getArtifactsNumber: {}", number );
|
||||
|
||||
assertTrue( number > 1 );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
assertTrue( number > 1 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metadatainbatchmode()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath() );
|
||||
scanRepo( TEST_REPO_ID );
|
||||
|
||||
BrowseService browseService = getBrowseService( authorizationHeader, false );
|
||||
|
||||
|
@ -497,15 +308,35 @@ public class BrowseServiceTest
|
|||
metadataAddRequest.setArtifactId( "commons-cli" );
|
||||
metadataAddRequest.setVersion( "1.0" );
|
||||
metadataAddRequest.setMetadatas( inputMetadata );
|
||||
browseService.importMetadata( metadataAddRequest, testRepoId );
|
||||
browseService.importMetadata( metadataAddRequest, TEST_REPO_ID );
|
||||
|
||||
Map<String, String> metadatas =
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
|
||||
toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", TEST_REPO_ID ) );
|
||||
|
||||
assertThat( metadatas ).isNotNull().isNotEmpty().contains( MapEntry.entry( "buildNumber", "1" ) ).contains(
|
||||
MapEntry.entry( "author", "alecharp" ) ).contains( MapEntry.entry( "jenkins_version", "1.486" ) );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initialiseTestRepo()
|
||||
throws RedbackServiceException, ArchivaRestServiceException, IOException, InterruptedException
|
||||
{
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( TEST_REPO_ID, new File( getBasedir(), "src/test/repo-with-osgi" ).getAbsolutePath(),
|
||||
false );
|
||||
|
||||
waitForScanToComplete( TEST_REPO_ID );
|
||||
}
|
||||
|
||||
@After
|
||||
public void deleteTestRepo()
|
||||
throws Exception
|
||||
{
|
||||
deleteTestRepo( TEST_REPO_ID );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,98 +36,66 @@ public class MergeRepositoriesServiceTest
|
|||
extends AbstractArchivaRestTest
|
||||
{
|
||||
|
||||
private static final String TEST_REPOSITORY = "test-repository";
|
||||
|
||||
private File repo = new File( System.getProperty( "builddir" ), "test-repository" );
|
||||
|
||||
private File repoStage = new File( System.getProperty( "builddir" ), "test-repository-stage" );
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void startServer()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi" ), repo );
|
||||
FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi-stage" ),
|
||||
repoStage );
|
||||
super.startServer();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void stopServer()
|
||||
throws Exception
|
||||
{
|
||||
// TODO delete repositories
|
||||
super.stopServer();
|
||||
FileUtils.deleteDirectory( repo );
|
||||
FileUtils.deleteDirectory( repoStage );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMergeConflictedArtifacts()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repository";
|
||||
try
|
||||
{
|
||||
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
|
||||
|
||||
createStagedNeededRepo( testRepoId, repo.getAbsolutePath(), true );
|
||||
List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY + "-stage",
|
||||
TEST_REPOSITORY );
|
||||
|
||||
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
|
||||
log.info( "conflicts: {}", artifactMetadatas );
|
||||
|
||||
List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( testRepoId + "-stage", testRepoId );
|
||||
|
||||
log.info( "conflicts: {}", artifactMetadatas );
|
||||
|
||||
assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
|
||||
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void merge()
|
||||
throws Exception
|
||||
{
|
||||
String testRepoId = "test-repository";
|
||||
try
|
||||
{
|
||||
createStagedNeededRepo( testRepoId, repo.getAbsolutePath(), true );
|
||||
String mergedArtifactPath =
|
||||
"org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.jar";
|
||||
String mergedArtifactPomPath =
|
||||
"org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.pom";
|
||||
|
||||
String mergedArtifactPath =
|
||||
"org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.jar";
|
||||
String mergedArtifactPomPath =
|
||||
"org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.pom";
|
||||
assertTrue( new File( repoStage, mergedArtifactPath ).exists() );
|
||||
assertTrue( new File( repoStage, mergedArtifactPomPath ).exists() );
|
||||
|
||||
assertTrue( new File( repoStage, mergedArtifactPath ).exists() );
|
||||
assertTrue( new File( repoStage, mergedArtifactPomPath ).exists() );
|
||||
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
|
||||
|
||||
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
|
||||
service.mergeRepositories( TEST_REPOSITORY + "-stage", TEST_REPOSITORY, true );
|
||||
|
||||
service.mergeRepositories( testRepoId + "-stage", testRepoId, true );
|
||||
assertTrue( new File( repo, mergedArtifactPath ).exists() );
|
||||
assertTrue( new File( repo, mergedArtifactPomPath ).exists() );
|
||||
}
|
||||
|
||||
assertTrue( new File( repo, mergedArtifactPath ).exists() );
|
||||
assertTrue( new File( repo, mergedArtifactPomPath ).exists() );
|
||||
@After
|
||||
public void deleteStageRepo()
|
||||
throws Exception
|
||||
{
|
||||
waitForScanToComplete( TEST_REPOSITORY );
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
deleteTestRepo( TEST_REPOSITORY );
|
||||
|
||||
FileUtils.deleteDirectory( repo );
|
||||
FileUtils.deleteDirectory( repoStage );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void createStageRepo()
|
||||
throws Exception
|
||||
{
|
||||
FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi" ), repo );
|
||||
FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi-stage" ),
|
||||
repoStage );
|
||||
|
||||
createStagedNeededRepo( TEST_REPOSITORY, repo.getAbsolutePath(), true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.archiva.maven2.model.Artifact;
|
|||
import org.apache.archiva.rest.api.model.SearchRequest;
|
||||
import org.apache.archiva.rest.api.services.SearchService;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -37,22 +39,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class SearchServiceTest
|
||||
extends AbstractArchivaRestTest
|
||||
{
|
||||
|
||||
private static final String TEST_REPO = "test-repo";
|
||||
|
||||
@Test
|
||||
public void quickSearchOnArtifactId()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
// START SNIPPET: quick-search
|
||||
|
@ -65,8 +57,6 @@ public class SearchServiceTest
|
|||
assertTrue( " not 6 results for commons-logging search but " + artifacts.size() + ":" + artifacts,
|
||||
artifacts.size() == 6 );
|
||||
log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,16 +68,6 @@ public class SearchServiceTest
|
|||
public void quickSearchOnArtifactIdGuest()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( null );
|
||||
|
||||
// START SNIPPET: quick-search
|
||||
|
@ -100,24 +80,12 @@ public class SearchServiceTest
|
|||
assertTrue( " not 6 results for commons-logging search but " + artifacts.size() + ":" + artifacts,
|
||||
artifacts.size() == 6 );
|
||||
log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchArtifactVersions()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
// START SNIPPET: searchservice-artifact-versions
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
|
@ -138,24 +106,12 @@ public class SearchServiceTest
|
|||
|
||||
|
||||
}
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchWithSearchRequestGroupIdAndArtifactIdAndClassifier()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
// START SNIPPET: searchservice-with-classifier
|
||||
|
@ -171,24 +127,12 @@ public class SearchServiceTest
|
|||
assertTrue( " not 2 results for commons-logging search but " + artifacts.size() + ":" + artifacts,
|
||||
artifacts.size() == 2 );
|
||||
log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchWithSearchRequestBundleSymbolicNameOneVersion()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
// START SNIPPET: searchservice-with-osgi
|
||||
|
@ -203,25 +147,15 @@ public class SearchServiceTest
|
|||
" not 1 results for Bundle Symbolic Name org.apache.karaf.features.command but " + artifacts.size() + ":"
|
||||
+ artifacts, artifacts.size() == 1
|
||||
);
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchWithSearchRequestBundleSymbolicNameTwoVersion()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
UiConfiguration uiConfiguration = new UiConfiguration();
|
||||
uiConfiguration.setApplicationUrl( null );
|
||||
getArchivaAdministrationService().setUiConfiguration( uiConfiguration );
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
|
@ -243,29 +177,17 @@ public class SearchServiceTest
|
|||
|
||||
|
||||
}
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchWithSearchRequestExportPackageOneVersion()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, getBasedir() + "/src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.setBundleExportPackage( "org.apache.karaf.features.command.completers" );
|
||||
searchRequest.setRepositories( Arrays.asList( testRepoId ) );
|
||||
searchRequest.setRepositories( Arrays.asList( TEST_REPO ) );
|
||||
|
||||
List<Artifact> artifacts = searchService.searchArtifacts( searchRequest );
|
||||
|
||||
|
@ -274,7 +196,6 @@ public class SearchServiceTest
|
|||
+ artifacts.size() + ":" + artifacts, artifacts.size() == 1 );
|
||||
|
||||
log.info( "artifact url {}", artifacts.get( 0 ).getUrl() );
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -284,16 +205,6 @@ public class SearchServiceTest
|
|||
public void searchWithSearchUnknwownRepoId()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
|
@ -303,10 +214,8 @@ public class SearchServiceTest
|
|||
List<Artifact> artifacts = searchService.searchArtifacts( searchRequest );
|
||||
|
||||
assertNotNull( artifacts );
|
||||
assertTrue( " not 0 results for Bundle ExportPackage org.apache.karaf.features.command.completers but "
|
||||
+ artifacts.size() + ":" + artifacts, artifacts.size() == 0 );
|
||||
|
||||
deleteTestRepo( testRepoId );
|
||||
assertTrue( " not 0 results for Bundle ExportPackage org.apache.karaf.features.command.completers but " +
|
||||
artifacts.size() + ":" + artifacts, artifacts.size() == 0 );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -316,16 +225,6 @@ public class SearchServiceTest
|
|||
public void searchWithSearchNoRepos()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
|
@ -338,31 +237,19 @@ public class SearchServiceTest
|
|||
+ artifacts.size() + ":" + artifacts, artifacts.size() == 1 );
|
||||
|
||||
log.info( "artifact url {}", artifacts.get( 0 ).getUrl() );
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllGroupIds()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-osgi" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
Collection<String> groupIds = searchService.getAllGroupIds( Arrays.asList( testRepoId ) ).getGroupIds();
|
||||
Collection<String> groupIds = searchService.getAllGroupIds( Arrays.asList( TEST_REPO ) ).getGroupIds();
|
||||
log.info( "groupIds {}", groupIds );
|
||||
assertFalse( groupIds.isEmpty() );
|
||||
assertTrue( groupIds.contains( "commons-cli" ) );
|
||||
assertTrue( groupIds.contains( "org.apache.felix" ) );
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -372,25 +259,44 @@ public class SearchServiceTest
|
|||
public void getSearchArtifactsWithOnlyClassifier()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
String testRepoId = "test-repo";
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( testRepoId, "src/test/repo-with-classifier-only" );
|
||||
createAndIndexRepo( TEST_REPO, "src/test/repo-with-classifier-only" );
|
||||
|
||||
SearchService searchService = getSearchService( authorizationHeader );
|
||||
|
||||
SearchRequest searchRequest =
|
||||
new SearchRequest( "org.foo", "studio-all-update-site", null, null, null, Arrays.asList( "test-repo" ) );
|
||||
new SearchRequest( "org.foo", "studio-all-update-site", null, null, null, Arrays.asList( TEST_REPO ) );
|
||||
|
||||
List<Artifact> artifacts = searchService.searchArtifacts( searchRequest );
|
||||
log.info( "artifacts: {}", artifacts );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
deleteTestRepo( testRepoId );
|
||||
}
|
||||
|
||||
@Before
|
||||
public void createRepo()
|
||||
throws Exception
|
||||
{
|
||||
// force guest user creation if not exists
|
||||
if ( getUserService( authorizationHeader ).getGuestUser() == null )
|
||||
{
|
||||
assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
|
||||
}
|
||||
|
||||
createAndIndexRepo( TEST_REPO, "src/test/repo-with-osgi" );
|
||||
|
||||
waitForScanToComplete( TEST_REPO );
|
||||
}
|
||||
|
||||
@After
|
||||
public void deleteRepo()
|
||||
throws Exception
|
||||
{
|
||||
deleteTestRepo( TEST_REPO );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue