From 7b483799f48e05c48ff272cf7ac5e481b2f45597 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 27 May 2013 12:13:47 +0000 Subject: [PATCH] to ease debug git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1486588 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractMetadataRepositoryTest.java | 73 ++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java index 285548d4e..2cd0fcf13 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java @@ -53,8 +53,8 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) +@RunWith(ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" }) public abstract class AbstractMetadataRepositoryTest extends TestCase { @@ -164,8 +164,9 @@ public abstract class AbstractMetadataRepositoryTest // test that namespace is also constructed - Assertions.assertThat( repository.getRootNamespaces( TEST_REPO_ID ) ).isNotNull().isNotEmpty().contains( - TEST_NAMESPACE ).hasSize( 1 ); + Collection namespaces = repository.getRootNamespaces( TEST_REPO_ID ); + + Assertions.assertThat( namespaces ).isNotNull().isNotEmpty().contains( TEST_NAMESPACE ).hasSize( 1 ); } @Test @@ -348,9 +349,10 @@ public abstract class AbstractMetadataRepositoryTest repository.updateNamespace( TEST_REPO_ID, "namespace" ); repository.updateNamespace( OTHER_REPO_ID, "namespace" ); - assertEquals( "repository.getRepositories() -> " + repository.getRepositories(), - Arrays.asList( TEST_REPO_ID, OTHER_REPO_ID ), - new ArrayList( repository.getRepositories() ) ); + Collection repositories = repository.getRepositories(); + + assertEquals( "repository.getRepositories() -> " + repositories, Arrays.asList( TEST_REPO_ID, OTHER_REPO_ID ), + new ArrayList( repositories ) ); } @Test @@ -573,8 +575,10 @@ public abstract class AbstractMetadataRepositoryTest { repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) ); - assertEquals( new TestMetadataFacet( TEST_VALUE ), - repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ); + TestMetadataFacet test = + (TestMetadataFacet) repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ); + + assertEquals( new TestMetadataFacet( TEST_VALUE ), test ); } @Test @@ -806,9 +810,10 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 ); repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2 ); - assertEquals( Collections.singleton( TEST_PROJECT_VERSION ), - repository.getArtifactVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, - TEST_PROJECT_VERSION ) ); + Collection versions = + repository.getArtifactVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); + + assertEquals( Collections.singleton( TEST_PROJECT_VERSION ), versions ); } @Test @@ -819,8 +824,9 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); repository.save(); - assertEquals( Collections.singletonList( artifact ), - repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ); + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test @@ -833,8 +839,9 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); repository.save(); - assertEquals( Collections.singletonList( artifact ), - repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ); + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test @@ -846,8 +853,10 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); Date date = new Date( artifact.getWhenGathered().getTime() - 10000 ); - assertEquals( Collections.singletonList( artifact ), - repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ) ); + + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test @@ -858,7 +867,10 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); Date date = new Date( artifact.getWhenGathered().getTime() + 10000 ); - assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ).isEmpty() ); + + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ); + + Assertions.assertThat( artifacts ).isNotNull().isEmpty(); } @Test @@ -871,8 +883,10 @@ public abstract class AbstractMetadataRepositoryTest Date lower = new Date( artifact.getWhenGathered().getTime() - 10000 ); Date upper = new Date( artifact.getWhenGathered().getTime() + 10000 ); - assertEquals( Collections.singletonList( artifact ), - repository.getArtifactsByDateRange( TEST_REPO_ID, lower, upper ) ); + + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, lower, upper ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test @@ -884,8 +898,10 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); Date upper = new Date( artifact.getWhenGathered().getTime() + 10000 ); - assertEquals( Collections.singletonList( artifact ), - repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ) ); + + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test @@ -897,7 +913,12 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); Date upper = new Date( artifact.getWhenGathered().getTime() - 10000 ); - assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ).isEmpty() ); + + List artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ); + + //assertTrue( .isEmpty() ); + + Assertions.assertThat( artifacts ).isNotNull().isEmpty(); } @Test @@ -908,7 +929,9 @@ public abstract class AbstractMetadataRepositoryTest repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); repository.save(); - assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) ); + List artifacts = repository.getArtifacts( TEST_REPO_ID ); + + assertEquals( Collections.singletonList( artifact ), artifacts ); } @Test -- 2.39.5