4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
24 import org.apache.archiva.admin.model.beans.ManagedRepository;
25 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import javax.inject.Inject;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.springframework.test.context.ContextConfiguration;
33 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
34 import junit.framework.TestCase;
37 * <code>SimpleArtifactConsumerTest</code>
39 @RunWith( SpringJUnit4ClassRunner.class )
40 @ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
41 public class SimpleArtifactConsumerTest
45 private SimpleArtifactConsumer consumer;
49 private ManagedRepository testRepository;
51 private Logger log = LoggerFactory.getLogger( SimpleArtifactConsumer.class );
58 String consumerRole = KnownRepositoryContentConsumer.class.getName();
60 setUpMockRepository();
66 private void setUpMockRepository()
68 repoDir = new java.io.File( "target/test-consumer-repo" );
70 repoDir.deleteOnExit();
72 testRepository = new ManagedRepository();
73 testRepository.setName( "Test-Consumer-Repository" );
74 testRepository.setId( "test-consumer-repository" );
75 testRepository.setLocation( repoDir.getAbsolutePath() );
79 public void testBeginScan()
82 log.info( "Beginning scan of repository [test-consumer-repository]" );
84 consumer.beginScan( testRepository );
89 public void testProcessFile()
92 consumer.beginScan( testRepository );
93 consumer.processFile( "org/simple/test/testartifact/testartifact/1.0/testartifact-1.0.pom" );
94 consumer.processFile( "org/simple/test/testartifact/testartifact/1.1/testartifact-1.1.pom" );