mirror of https://github.com/apache/archiva.git
fix unit tests
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0835fd6be4
commit
01b9012562
|
@ -288,8 +288,8 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest
|
||||||
"target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
|
"target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
|
||||||
|
|
||||||
ReadMetadataRequest readMetadataRequest =
|
ReadMetadataRequest readMetadataRequest =
|
||||||
new ReadMetadataRequest().namespace( TEST_SNAP_REPO_ID ).namespace( "com.example.test" ).projectId(
|
new ReadMetadataRequest( TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
|
||||||
"test-snapshot-artifact-module-a" ).projectVersion( "1.1-SNAPSHOT" );
|
"1.1-SNAPSHOT" );
|
||||||
|
|
||||||
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,6 @@ package org.apache.archiva.metadata.repository.storage.maven2;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.archiva.common.utils.FileUtil;
|
import org.apache.archiva.common.utils.FileUtil;
|
||||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||||
|
@ -40,6 +33,7 @@ import org.apache.archiva.metadata.model.MailingList;
|
||||||
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
|
||||||
import org.apache.archiva.metadata.repository.filter.AllFilter;
|
import org.apache.archiva.metadata.repository.filter.AllFilter;
|
||||||
import org.apache.archiva.metadata.repository.filter.Filter;
|
import org.apache.archiva.metadata.repository.filter.Filter;
|
||||||
|
import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
|
||||||
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
|
import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
|
||||||
import org.apache.archiva.proxy.common.WagonFactory;
|
import org.apache.archiva.proxy.common.WagonFactory;
|
||||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||||
|
@ -48,19 +42,28 @@ import org.apache.maven.wagon.Wagon;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
|
||||||
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
|
import javax.inject.Inject;
|
||||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
|
import javax.inject.Named;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith ( ArchivaSpringJUnit4ClassRunner.class )
|
||||||
|
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
|
||||||
public class Maven2RepositoryMetadataResolverMRM1411Test
|
public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
extends TestCase
|
extends TestCase
|
||||||
{
|
{
|
||||||
private static final Filter<String> ALL = new AllFilter<String>();
|
private static final Filter<String> ALL = new AllFilter<String>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named( value = "repositoryStorage#maven2" )
|
@Named ( value = "repositoryStorage#maven2" )
|
||||||
private Maven2RepositoryStorage storage;
|
private Maven2RepositoryStorage storage;
|
||||||
|
|
||||||
private static final String TEST_REPO_ID = "test";
|
private static final String TEST_REPO_ID = "test";
|
||||||
|
@ -107,7 +110,6 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
testRepo.setSnapshots( true );
|
testRepo.setSnapshots( true );
|
||||||
c.addManagedRepository( testRepo );
|
c.addManagedRepository( testRepo );
|
||||||
|
|
||||||
|
|
||||||
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
|
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
|
||||||
testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
|
testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
|
||||||
testRemoteRepo.setLayout( "default" );
|
testRemoteRepo.setLayout( "default" );
|
||||||
|
@ -124,8 +126,8 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
|
|
||||||
configuration.save( c );
|
configuration.save( c );
|
||||||
|
|
||||||
assertTrue ( c.getManagedRepositories().get( 0 ).isSnapshots() );
|
assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
|
||||||
assertTrue ( c.getManagedRepositories().get( 0 ).isReleases() );
|
assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );
|
||||||
|
|
||||||
wagonFactory = mock( WagonFactory.class );
|
wagonFactory = mock( WagonFactory.class );
|
||||||
|
|
||||||
|
@ -143,8 +145,8 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
||||||
"target/test-repository/com/example/test/test-artifact-module-a" );
|
"target/test-repository/com/example/test/test-artifact-module-a" );
|
||||||
|
|
||||||
ProjectVersionMetadata metadata =
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
|
||||||
storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" );
|
new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" ) );
|
||||||
|
|
||||||
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
||||||
assertEquals( "jar", facet.getPackaging() );
|
assertEquals( "jar", facet.getPackaging() );
|
||||||
|
@ -193,8 +195,8 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
||||||
"target/test-repository/com/example/test/test-artifact-module-a" );
|
"target/test-repository/com/example/test/test-artifact-module-a" );
|
||||||
|
|
||||||
ProjectVersionMetadata metadata =
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
|
||||||
storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" );
|
new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" ) );
|
||||||
assertEquals( "1.0", metadata.getId() );
|
assertEquals( "1.0", metadata.getId() );
|
||||||
|
|
||||||
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
||||||
|
@ -218,8 +220,8 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a",
|
||||||
"target/test-repository/com/example/test/test-artifact-module-a" );
|
"target/test-repository/com/example/test/test-artifact-module-a" );
|
||||||
|
|
||||||
ProjectVersionMetadata metadata =
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
|
||||||
storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-parent", "1.1" );
|
new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "missing-parent", "1.1" ) );
|
||||||
|
|
||||||
assertEquals( "1.1", metadata.getId() );
|
assertEquals( "1.1", metadata.getId() );
|
||||||
|
|
||||||
|
@ -244,9 +246,9 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
|
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
|
||||||
"target/test-repository/com/example/test/test-snapshot-artifact-module-a" );
|
"target/test-repository/com/example/test/test-snapshot-artifact-module-a" );
|
||||||
|
|
||||||
ProjectVersionMetadata metadata =
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
|
||||||
storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
|
new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
|
||||||
"1.1-SNAPSHOT" );
|
"1.1-SNAPSHOT" ) );
|
||||||
|
|
||||||
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
|
||||||
assertEquals( "jar", facet.getPackaging() );
|
assertEquals( "jar", facet.getPackaging() );
|
||||||
|
@ -285,15 +287,15 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
{
|
{
|
||||||
testRepo.setSnapshots( false );
|
testRepo.setSnapshots( false );
|
||||||
configuration.save( c );
|
configuration.save( c );
|
||||||
assertFalse ( c.getManagedRepositories().get( 0 ).isSnapshots() );
|
assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() );
|
||||||
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
|
copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
|
||||||
"target/test-repository/com/example/test/test-snapshot-artifact-module-a" );
|
"target/test-repository/com/example/test/test-snapshot-artifact-module-a" );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProjectVersionMetadata metadata =
|
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(
|
||||||
storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
|
new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
|
||||||
"1.1-SNAPSHOT" );
|
"1.1-SNAPSHOT" ) );
|
||||||
fail( "Should not be found" );
|
fail( "Should not be found" );
|
||||||
}
|
}
|
||||||
catch ( RepositoryStorageRuntimeException e )
|
catch ( RepositoryStorageRuntimeException e )
|
||||||
|
@ -308,7 +310,7 @@ public class Maven2RepositoryMetadataResolverMRM1411Test
|
||||||
}
|
}
|
||||||
// Tests for MRM-1411 - END
|
// Tests for MRM-1411 - END
|
||||||
|
|
||||||
private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
|
private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
|
||||||
{
|
{
|
||||||
assertDependency( dependency, groupId, artifactId, version, "compile" );
|
assertDependency( dependency, groupId, artifactId, version, "compile" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue