Permalink
Browse files

mostly mechanical changes to replace testng with junit4

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information...
1 parent 029c2ca commit ab05a2174ec176b39f9608fb4f88563c7fc9a23b @ifedorenko ifedorenko committed Jan 5, 2013
Showing 331 changed files with 2,618 additions and 2,604 deletions.
@@ -49,11 +49,6 @@
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-test-common</artifactId>
<scope>test</scope>
@@ -16,6 +16,9 @@
import java.util.Iterator;
import java.util.List;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.nexus.client.NexusClient;
@@ -31,9 +34,6 @@
import org.sonatype.nexus.rest.model.RepositoryBaseResource;
import org.sonatype.nexus.rest.model.RepositoryListResource;
import org.sonatype.nexus.rest.model.RepositoryResource;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
/**
* Tests the Nexus java/REST client.
@@ -57,7 +57,7 @@ private NexusClient getConnectedNexusClient()
}
@BeforeClass
- public void setSecureTest(){
+ public static void setSecureTest(){
TestContainer.getInstance().getTestContext().setSecureTest( true );
}
@@ -68,7 +68,7 @@ public void getRepoListTest()
NexusClient client = this.getConnectedNexusClient();
List<RepositoryListResource> repos = client.getRepositories();
- Assert.assertTrue( repos.size() > 0, "Expected list of repos to be larger then 0" );
+ Assert.assertTrue( "Expected list of repos to be larger then 0", repos.size() > 0 );
List<String> knownRepos = new ArrayList<String>();
knownRepos.add( "fake-central" );
@@ -82,8 +82,8 @@ public void getRepoListTest()
for ( Iterator<RepositoryListResource> iter = repos.iterator(); iter.hasNext(); )
{
RepositoryListResource repositoryListResource = iter.next();
- Assert.assertTrue( knownRepos.contains( repositoryListResource.getId() ), "Expected to find repo: "
- + repositoryListResource.getId() + " in list: " + knownRepos );
+ Assert.assertTrue( "Expected to find repo: "
+ + repositoryListResource.getId() + " in list: " + knownRepos, knownRepos.contains( repositoryListResource.getId() ) );
}
client.disconnect();
}
@@ -94,11 +94,11 @@ public void isValidRepositoryTest()
{
NexusClient client = this.getConnectedNexusClient();
- Assert.assertTrue( client.isValidRepository( "nexus-test-harness-repo" ),
- "Expected to find 'apache-snapshots' repo:" );
- Assert.assertFalse( client.isValidRepository( "foobar" ), "Expected not to find 'foobar' repo:" );
+ Assert.assertTrue( "Expected to find 'apache-snapshots' repo:",
+ client.isValidRepository( "nexus-test-harness-repo" ) );
+ Assert.assertFalse( "Expected not to find 'foobar' repo:", client.isValidRepository( "foobar" ) );
- Assert.assertFalse( client.isValidRepository( null ), "Expected not to find 'null' repo:" );
+ Assert.assertFalse( "Expected not to find 'null' repo:", client.isValidRepository( null ) );
client.disconnect();
@@ -111,7 +111,7 @@ public void getRepoTest()
NexusClient client = this.getConnectedNexusClient();
RepositoryBaseResource repo = client.getRepository( "nexus-test-harness-repo" );
- Assert.assertEquals( "nexus-test-harness-repo", repo.getId() );
+ Assert.assertEquals( repo.getId(), "nexus-test-harness-repo" );
client.disconnect();
}
@@ -145,14 +145,14 @@ public void repoCrudTest()
RepositoryBaseResource repoResult = client.createRepository( repoResoruce );
RepositoryBaseResource repoExpected = client.getRepository( "testCreate" );
- Assert.assertEquals( repoResult.getId(), repoExpected.getId() );
- Assert.assertEquals( repoResult.getName(), repoExpected.getName() );
- Assert.assertEquals( repoResult.getFormat(), repoExpected.getFormat() );
+ Assert.assertEquals( repoExpected.getId(), repoResult.getId() );
+ Assert.assertEquals( repoExpected.getName(), repoResult.getName() );
+ Assert.assertEquals( repoExpected.getFormat(), repoResult.getFormat() );
// now update it
repoExpected.setName( "Updated Name" );
repoExpected = client.updateRepository( repoExpected );
- Assert.assertEquals( "Updated Name", repoExpected.getName() );
+ Assert.assertEquals( repoExpected.getName(), "Updated Name" );
// now delete it
client.deleteRepository( "testCreate" );
@@ -166,7 +166,7 @@ public void repoCrudTest()
{
// expected
}
- Assert.assertFalse( client.isValidRepository( "testCreate" ), "Expected false, repo should have been deleted." );
+ Assert.assertFalse( "Expected false, repo should have been deleted.", client.isValidRepository( "testCreate" ) );
client.disconnect();
}
@@ -209,12 +209,12 @@ public void searchByGAVTest()
searchParam.setClassifier( null );
List<NexusArtifact> results = client.searchByGAV( searchParam );
- Assert.assertEquals( results.size(), 1, "Search result size" );
+ Assert.assertEquals( "Search result size", results.size(), 1 );
- Assert.assertEquals( results.get( 0 ).getArtifactId(), "nexus725-artifact-1", "Search result artifact id" );
- Assert.assertEquals( results.get( 0 ).getGroupId(), "nexus725", "Search result group id" );
- Assert.assertEquals( results.get( 0 ).getVersion(), "1.0.1", "Search result version" );
- Assert.assertEquals( results.get( 0 ).getPackaging(), "jar", "Search result packaging" );
+ Assert.assertEquals( "Search result artifact id", results.get( 0 ).getArtifactId(), "nexus725-artifact-1" );
+ Assert.assertEquals( "Search result group id", results.get( 0 ).getGroupId(), "nexus725" );
+ Assert.assertEquals( "Search result version", results.get( 0 ).getVersion(), "1.0.1" );
+ Assert.assertEquals( "Search result packaging", results.get( 0 ).getPackaging(), "jar" );
client.disconnect();
@@ -240,11 +240,11 @@ public void checkForErrorsInRepsonse()
catch ( NexusConnectionException e )
{
// make sure we have an error
- Assert.assertTrue( e.getErrors().size() > 0,
- "NexusConnectionException should contain at least 1 NexusError" );
+ Assert.assertTrue( "NexusConnectionException should contain at least 1 NexusError",
+ e.getErrors().size() > 0 );
// make sure the error is in the stacktrace
- Assert.assertTrue( e.getMessage().contains( e.getErrors().get( 0 ).getMsg() ), "Expected message in error" );
+ Assert.assertTrue( "Expected message in error", e.getMessage().contains( e.getErrors().get( 0 ).getMsg() ) );
}
}
@@ -15,13 +15,12 @@
import java.io.File;
import java.net.URL;
+import org.junit.Assert;
+import org.junit.Test;
import org.sonatype.nexus.integrationtests.AbstractNexusIntegrationTest;
import org.sonatype.nexus.maven.tasks.descriptors.RebuildMavenMetadataTaskDescriptor;
import org.sonatype.nexus.rest.model.ScheduledServicePropertyResource;
-import org.sonatype.nexus.scheduling.TaskUtils;
import org.sonatype.nexus.test.utils.TaskScheduleUtil;
-import org.testng.Assert;
-import org.testng.annotations.Test;
public class Nexus1022RebuildRepositoryMavenMetadataTaskIT
extends AbstractNexusIntegrationTest
@@ -49,10 +48,10 @@ public void rebuildMavenMetadata()
File artifactDirMd =
new File( nexusWorkDir, repoPrefix + "nexus1022/foo/bar/artifact/maven-metadata.xml" );
- Assert.assertTrue( artifactDirMd.exists(), "Maven metadata file should be generated after rebuild" );
+ Assert.assertTrue( "Maven metadata file should be generated after rebuild", artifactDirMd.exists() );
File groupPluginMd = new File( nexusWorkDir, repoPrefix + "nexus1022/foo/bar/plugins/maven-metadata.xml" );
- Assert.assertTrue( groupPluginMd.exists(), "Maven metadata file should be generated after rebuild" );
+ Assert.assertTrue( "Maven metadata file should be generated after rebuild", groupPluginMd.exists() );
// just downloading it into dummy, since we are just checking is download possible
// if not, downloadFile() will fail anyway. The content is not we are interested in.
@@ -12,20 +12,21 @@
*/
package org.sonatype.nexus.integrationtests.nexus1071;
-import static org.sonatype.nexus.integrationtests.ITGroups.SECURITY;
-import static org.testng.Assert.assertTrue;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import org.apache.maven.index.artifact.Gav;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.sonatype.nexus.integrationtests.AbstractPrivilegeTest;
+import org.sonatype.nexus.integrationtests.ITGroups.SECURITY;
import org.sonatype.nexus.integrationtests.TestContainer;
import org.sonatype.nexus.test.utils.FileTestingUtils;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
/**
* @author Juven Xu
@@ -34,12 +35,12 @@
extends AbstractPrivilegeTest
{
- @BeforeClass(alwaysRun = true)
- public void setSecureTest(){
+ @BeforeClass
+ public static void setSecureTest(){
TestContainer.getInstance().getTestContext().setSecureTest( true );
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void downloadArtifactFromPublicGroup()
throws Exception
{
@@ -59,7 +60,7 @@ public void downloadArtifactFromPublicGroup()
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void downloadArtifactFromInternalRepo()
throws Exception
{
@@ -12,30 +12,30 @@
*/
package org.sonatype.nexus.integrationtests.nexus1071;
-import static org.sonatype.nexus.integrationtests.ITGroups.SECURITY;
-
import java.io.File;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.sonatype.nexus.integrationtests.AbstractMavenNexusIT;
+import org.sonatype.nexus.integrationtests.ITGroups.SECURITY;
import org.sonatype.nexus.integrationtests.TestContainer;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
/**
* @author Juven Xu
*/
public class Nexus1071DeployToRepoAnonCannotAccessIT
extends AbstractMavenNexusIT
{
- @BeforeClass(alwaysRun = true)
- public void setSecureTest(){
+ @BeforeClass
+ public static void setSecureTest(){
TestContainer.getInstance().getTestContext().setSecureTest( true );
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void deployRepeatly()
throws Exception
{
@@ -73,7 +73,7 @@ public void deployRepeatly()
}
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void deploySnapshot()
throws Exception
{
@@ -98,7 +98,7 @@ public void deploySnapshot()
}
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void deployToAnotherRepo()
throws Exception
{
@@ -122,7 +122,7 @@ public void deployToAnotherRepo()
}
}
- @Test(groups = SECURITY)
+ @Test @Category(SECURITY.class)
public void anonDeploy()
throws Exception
{
@@ -17,6 +17,9 @@
import java.util.List;
import java.util.Set;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Response;
@@ -31,16 +34,13 @@
import org.sonatype.security.rest.model.ClientPermission;
import org.sonatype.security.rest.model.PrivilegeProperty;
import org.sonatype.security.rest.model.PrivilegeStatusResource;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
public class Nexus1170ReducePermissionCheckingIT
extends AbstractNexusIntegrationTest
{
@BeforeClass
- public void setSecureTest(){
+ public static void setSecureTest(){
TestContainer.getInstance().getTestContext().setSecureTest( true );
}
@@ -13,18 +13,19 @@
package org.sonatype.nexus.integrationtests.nexus1197;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
import java.io.FileNotFoundException;
-import static org.hamcrest.Matchers.*;
import org.eclipse.jetty.server.Server;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.sonatype.jettytestsuite.BlockingServer;
import org.sonatype.nexus.integrationtests.AbstractNexusIntegrationTest;
import org.sonatype.nexus.test.utils.TestProperties;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
public class Nexus1197CheckUserAgentIT
extends AbstractNexusIntegrationTest
Oops, something went wrong.

0 comments on commit ab05a21

Please sign in to comment.