add some snippet for using it in documentation

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-16 14:09:12 +00:00
parent 35ec0651a4
commit f44fe02ef2
2 changed files with 8 additions and 0 deletions

View File

@ -42,8 +42,11 @@ import java.io.File;
public abstract class AbstractArchivaRestTest public abstract class AbstractArchivaRestTest
extends AbstractRestServicesTest extends AbstractRestServicesTest
{ {
// START SNIPPET: authz-header
public String guestAuthzHeader = public String guestAuthzHeader =
"Basic " + org.apache.cxf.common.util.Base64Utility.encode( ( "guest" + ":" ).getBytes() ); "Basic " + org.apache.cxf.common.util.Base64Utility.encode( ( "guest" + ":" ).getBytes() );
// END SNIPPET: authz-header
@Override @Override
protected String getSpringConfigLocation() protected String getSpringConfigLocation()
@ -149,6 +152,7 @@ public abstract class AbstractArchivaRestTest
protected SearchService getSearchService( String authzHeader ) protected SearchService getSearchService( String authzHeader )
{ {
// START SNIPPET: cxf-searchservice-creation
SearchService service = SearchService service =
JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/", JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
SearchService.class ); SearchService.class );
@ -159,6 +163,7 @@ public abstract class AbstractArchivaRestTest
} }
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
return service; return service;
// END SNIPPET: cxf-searchservice-creation
} }

View File

@ -77,10 +77,13 @@ public class SearchServiceTest
File targetRepo = createAndIndexRepo( testRepoId ); File targetRepo = createAndIndexRepo( testRepoId );
// START SNIPPET: searchservice-artifact-versions
SearchService searchService = getSearchService( authorizationHeader ); SearchService searchService = getSearchService( authorizationHeader );
List<Artifact> artifacts = searchService.getArtifactVersions( "commons-logging", "commons-logging", "jar" ); List<Artifact> artifacts = searchService.getArtifactVersions( "commons-logging", "commons-logging", "jar" );
// END SNIPPET: searchservice-artifact-versions
assertNotNull( artifacts ); assertNotNull( artifacts );
assertTrue( " not 3 results for commons-logging search but " + artifacts.size() + ":" + artifacts, assertTrue( " not 3 results for commons-logging search but " + artifacts.size() + ":" + artifacts,
artifacts.size() == 13 ); artifacts.size() == 13 );