This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPEN - issue NEXUS-2196: Check repository summary
https://issues.sonatype.org/browse/NEXUS-2196 git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus/trunk/nexus/nexus-test-harness/nexus-test-harness-selenium@4541 2aa8b3fc-8ebb-4439-a84f-95066eaea8ab
- Loading branch information
velo
committed
Jul 8, 2009
1 parent
eba5dbe
commit 0b46735
Showing
7 changed files
with
216 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/sonatype/nexus/mock/pages/RepositorySummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.sonatype.nexus.mock.pages; | ||
|
||
import org.sonatype.nexus.mock.components.Component; | ||
import org.sonatype.nexus.mock.components.TextArea; | ||
|
||
import com.thoughtworks.selenium.Selenium; | ||
|
||
public class RepositorySummary | ||
extends Component | ||
{ | ||
|
||
private TextArea distributionManagement; | ||
|
||
private TextArea repositoryInformation; | ||
|
||
public RepositorySummary( Selenium selenium, String expression ) | ||
{ | ||
super( selenium, expression ); | ||
|
||
this.repositoryInformation = new TextArea( selenium, expression + ".find('name', 'informationField')[0]" ); | ||
this.distributionManagement = new TextArea( selenium, expression + ".find('name', 'distMgmtField')[0]" ); | ||
} | ||
|
||
public final TextArea getDistributionManagement() | ||
{ | ||
return distributionManagement; | ||
} | ||
|
||
public final TextArea getRepositoryInformation() | ||
{ | ||
return repositoryInformation; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
src/test/java/org/sonatype/nexus/selenium/nexus2196/Nexus2196RepositorySummaryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package org.sonatype.nexus.selenium.nexus2196; | ||
|
||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.junit.internal.matchers.StringContains.containsString; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.restlet.data.Status; | ||
import org.sonatype.nexus.mock.MockListener; | ||
import org.sonatype.nexus.mock.MockResponse; | ||
import org.sonatype.nexus.mock.NexusTestCase; | ||
import org.sonatype.nexus.mock.SeleniumTest; | ||
import org.sonatype.nexus.mock.pages.RepositorySummary; | ||
import org.sonatype.nexus.mock.pages.RepositoriesEditTabs.RepoKind; | ||
import org.sonatype.nexus.mock.rest.MockHelper; | ||
import org.sonatype.nexus.rest.model.RepositoryMetaResource; | ||
import org.sonatype.nexus.rest.model.RepositoryMetaResourceResponse; | ||
import org.sonatype.nexus.selenium.nexus1815.LoginTest; | ||
|
||
public class Nexus2196RepositorySummaryTest | ||
extends SeleniumTest | ||
{ | ||
|
||
@Test | ||
public void summaryHosted() | ||
throws InterruptedException | ||
{ | ||
MockListener ml = listenResult(); | ||
|
||
RepositorySummary repo = openSummary( "thirdparty", RepoKind.HOSTED ); | ||
|
||
RepositoryMetaResource meta = ( (RepositoryMetaResourceResponse) ml.getResult() ).getData(); | ||
|
||
validateRepoInfo( repo, meta ); | ||
validateDistMngt( repo, meta ); | ||
} | ||
|
||
@Test | ||
public void summaryProxy() | ||
throws InterruptedException | ||
{ | ||
MockListener ml = listenResult(); | ||
|
||
RepositorySummary repo = openSummary( "central", RepoKind.PROXY ); | ||
|
||
RepositoryMetaResource meta = ( (RepositoryMetaResourceResponse) ml.getResult() ).getData(); | ||
|
||
validateRepoInfo( repo, meta ); | ||
} | ||
|
||
@Test | ||
public void summaryShadow() | ||
throws InterruptedException | ||
{ | ||
MockListener ml = listenResult(); | ||
|
||
RepositorySummary repo = openSummary( "central-m1", RepoKind.VIRTUAL ); | ||
|
||
RepositoryMetaResource meta = ( (RepositoryMetaResourceResponse) ml.getResult() ).getData(); | ||
|
||
validateRepoInfo( repo, meta ); | ||
} | ||
|
||
@Test | ||
public void byteSize() | ||
throws InterruptedException | ||
{ | ||
RepositorySummary repo = mockSize( 512 ); | ||
Assert.assertThat( repo.getRepositoryInformation().getValue(), containsString( "512 Bytes" ) ); | ||
} | ||
|
||
@Test | ||
public void kilobyteSize() | ||
throws InterruptedException | ||
{ | ||
RepositorySummary repo = mockSize( 524288 ); | ||
Assert.assertThat( repo.getRepositoryInformation().getValue(), containsString( "512 KB" ) ); | ||
} | ||
|
||
@Test | ||
public void megabyteSize() | ||
throws InterruptedException | ||
{ | ||
RepositorySummary repo = mockSize( 536870912 ); | ||
Assert.assertThat( repo.getRepositoryInformation().getValue(), containsString( "512 MB" ) ); | ||
} | ||
|
||
@Test | ||
public void gigabyteSize() | ||
throws InterruptedException | ||
{ | ||
RepositorySummary repo = mockSize( 549755813888L ); | ||
Assert.assertThat( repo.getRepositoryInformation().getValue(), containsString( "512 GB" ) ); | ||
} | ||
|
||
private RepositorySummary mockSize( long size ) | ||
{ | ||
RepositoryMetaResourceResponse result = new RepositoryMetaResourceResponse(); | ||
RepositoryMetaResource data = new RepositoryMetaResource(); | ||
data.setId( "thridparty" ); | ||
data.setFormat( "maven2" ); | ||
data.setRepoType( "hosted" ); | ||
data.setSizeOnDisk( size ); | ||
result.setData( data ); | ||
|
||
MockHelper.expect( "/repositories/{repositoryId}/meta", new MockResponse( Status.SUCCESS_OK, result ) ); | ||
|
||
RepositorySummary repo = openSummary( "thirdparty", RepoKind.HOSTED ); | ||
return repo; | ||
} | ||
|
||
private MockListener listenResult() | ||
{ | ||
MockListener ml = new MockListener() | ||
{ | ||
}; | ||
MockHelper.listen( "/repositories/{repositoryId}/meta", ml ); | ||
return ml; | ||
} | ||
|
||
private RepositorySummary openSummary( String repoId, RepoKind kind ) | ||
{ | ||
LoginTest.doLogin( main ); | ||
RepositorySummary repo = main.openRepositories().select( repoId, kind ).selectSummary(); | ||
repo.getRepositoryInformation().waitToLoad(); | ||
return repo; | ||
} | ||
|
||
private void validateDistMngt( RepositorySummary repo, RepositoryMetaResource meta ) | ||
{ | ||
String distMgmt = repo.getDistributionManagement().getValue(); | ||
Assert.assertThat( distMgmt, notNullValue() ); | ||
Assert.assertThat( distMgmt, containsString( NexusTestCase.nexusBaseURL + "content/repositories/" | ||
+ meta.getId() ) ); | ||
} | ||
|
||
private void validateRepoInfo( RepositorySummary repo, RepositoryMetaResource meta ) | ||
{ | ||
String summary = repo.getRepositoryInformation().getValue(); | ||
Assert.assertThat( summary, notNullValue() ); | ||
Assert.assertThat( summary, containsString( meta.getId() ) ); | ||
Assert.assertThat( summary, containsString( meta.getRepoType() ) ); | ||
Assert.assertThat( summary, containsString( meta.getFormat() ) ); | ||
} | ||
} |