]> source.dussan.org Git - archiva.git/commitdiff
fix unit test if metadataFacet not available on update
authorOlivier Lamy <olamy@apache.org>
Tue, 12 Jun 2012 08:12:02 +0000 (08:12 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 12 Jun 2012 08:12:02 +0000 (08:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349179 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java

index da9099aaa430f1bed6eadb2ce4926d73c794fefe..2fc5c977ea286b644cc65cfd0bfcee2625f34f15 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.Scm;
 import org.fest.assertions.Assertions;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -1045,40 +1046,6 @@ public abstract class AbstractMetadataRepositoryTest
         assertEquals( Collections.<ArtifactMetadata>emptyList(), artifactsByChecksum );
     }
 
-    @Test
-    public void testDeleteArtifact()
-        throws Exception
-    {
-        ArtifactMetadata artifact = createArtifact();
-        artifact.addFacet( new TestMetadataFacet( "value" ) );
-
-        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
-
-        assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
-            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
-
-        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact );
-
-        Collection<String> versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
-
-        log.info( "versions {}", versions );
-
-        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "1.0", "2.0" );
-
-        repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() );
-
-        versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
-
-        log.info( "versions {}", versions );
-
-        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "2.0" );
-
-        assertTrue(
-            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
-
-        Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
-                                                        TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty().hasSize( 1 );
-    }
 
     @Test
     public void testDeleteRepository()
@@ -1119,6 +1086,41 @@ public abstract class AbstractMetadataRepositoryTest
     }
 
 
+    @Test
+    public void testDeleteArtifact()
+        throws Exception
+    {
+        ArtifactMetadata artifact = createArtifact();
+        artifact.addFacet( new TestMetadataFacet( "value" ) );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+
+        assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
+            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact );
+
+        Collection<String> versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+
+        log.info( "versions {}", versions );
+
+        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 2 ).contains( "1.0", "2.0" );
+
+        repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() );
+
+        versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+
+        log.info( "versions {}", versions );
+
+        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "2.0" );
+
+        assertTrue(
+            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
+
+        Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
+                                                        TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty().hasSize( 1 );
+    }
+
     @Test
     public void deleteVersion()
         throws Exception
index ab1b1cbd640b2d9ab64b814bf9855f2b2dd2c000..3b5a9e2bdbf67966f3cf181d9f62c2a5a67d8160 100644 (file)
@@ -198,6 +198,10 @@ public class JcrMetadataRepository
             for ( String facetId : metadataFacetFactories.keySet() )
             {
                 MetadataFacet metadataFacet = artifactMeta.getFacet( facetId );
+                if ( metadataFacet == null )
+                {
+                    continue;
+                }
                 if ( node.hasNode( facetId ) )
                 {
                     node.getNode( facetId ).remove();