Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Fixes for ITs
Browse files Browse the repository at this point in the history
git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus/trunk/nexus@6567 2aa8b3fc-8ebb-4439-a84f-95066eaea8ab
  • Loading branch information
cstamas committed Jun 4, 2010
1 parent c6fba89 commit ceb7968
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Expand Up @@ -33,11 +33,14 @@ public void testAutoBlockNotification()
// make central auto-block itself (point it to bad URL)
pointCentralToRemoteUrl( "http://repo1.maven.org/mavenFooBar/not-here/" );

// we have 3 recipients set
checkMails( 3, 0 );

// make central unblock itself (point it to good URL)
pointCentralToRemoteUrl( "http://repo1.maven.org/maven2/" );

// we have 3 recipients set
checkMails( 3 );
checkMails( 0, 3 );
}

// --
Expand Down Expand Up @@ -105,39 +108,39 @@ protected void pointCentralToRemoteUrl( String remoteUrl )

repoMessageUtil.updateRepo( central );

// to "ping it" (and not wait for thread to check remote availability)
// to "ping it" (and wait for all the thread to check remote availability)
RepositoryStatusResource res = repoMessageUtil.getStatus( "central", true );

while ( RemoteStatus.UNKNOWN.name().equals( res.getRemoteStatus() ) )
{
res = repoMessageUtil.getStatus( "central", false );

Thread.sleep( 1000 );
Thread.sleep( 10000 );
}
}

protected void checkMails( int recipientCount )
protected void checkMails( int expectedBlockedMails, int expectedUnblockedMails )
throws InterruptedException, MessagingException
{
int expectedMailCount = recipientCount * 2;

// expect total 2*count mails: once for auto-block, once for unblock, for admin user, for pipi1 and for pipi2.
// Mail
// should be about "unblocked"
server.waitForIncomingEmail( 10000, expectedMailCount );
// wait for long, since we really _dont_ know when the mail gonna be sent:
// See "fibonacci" calculation above!
server.waitForIncomingEmail( 440000, expectedBlockedMails + expectedUnblockedMails );

MimeMessage[] msgs = server.getReceivedMessages();

Assert.assertNotNull( "Messages array should not be null!", msgs );

Assert.assertEquals( "We expect " + expectedMailCount + " mails, since we have " + recipientCount
+ " recipients!", expectedMailCount, msgs.length );
Assert.assertEquals( "We expect " + ( expectedBlockedMails + expectedUnblockedMails ) + " mails!",
( expectedBlockedMails + expectedUnblockedMails ), msgs.length );

int blockedMails = 0;

int unblockedMails = 0;

for ( int i = 0; i < expectedMailCount; i++ )
for ( int i = 0; i < msgs.length; i++ )
{
MimeMessage msg = msgs[i];

Expand All @@ -151,8 +154,10 @@ else if ( msg.getSubject().toLowerCase().contains( "unblocked" ) )
}
}

Assert.assertEquals( "We should have equally " + recipientCount
+ " for auto-blocked and unblocked mails! We have auto-blocked and unblocked!", blockedMails
+ unblockedMails, expectedMailCount );
Assert.assertEquals( "We should have " + expectedBlockedMails + " auto-blocked mails!", expectedBlockedMails,
blockedMails );

Assert.assertEquals( "We should have " + expectedUnblockedMails + " auto-UNblocked mails!",
expectedUnblockedMails, unblockedMails );
}
}
Expand Up @@ -29,7 +29,6 @@
import org.sonatype.nexus.rest.model.ScheduledServiceBaseResource;
import org.sonatype.nexus.rest.model.ScheduledServiceListResource;
import org.sonatype.nexus.rest.model.ScheduledServiceOnceResource;
import org.sonatype.nexus.test.utils.NexusConfigUtil;
import org.sonatype.nexus.test.utils.TaskScheduleUtil;

public abstract class AbstractNexusTasksIntegrationIT<E extends ScheduledServiceBaseResource>
Expand All @@ -48,7 +47,6 @@ public void scheduleTasks()
assertTasks();
}

@SuppressWarnings( "unchecked" )
protected void assertTasks()
throws IOException
{
Expand Down
Expand Up @@ -81,7 +81,7 @@ public void remote500Error()
{
// skip
}

// clear cache, then download
ScheduledServicePropertyResource prop = new ScheduledServicePropertyResource();
prop.setId( "repositoryOrGroupId" );
Expand Down

0 comments on commit ceb7968

Please sign in to comment.