1 package org.apache.archiva.consumers.core;
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
22 import junit.framework.TestCase;
23 import org.apache.archiva.common.utils.BaseFile;
24 import org.apache.archiva.configuration.ArchivaConfiguration;
25 import org.apache.archiva.configuration.FileType;
26 import org.apache.archiva.configuration.FileTypes;
27 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
28 import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.springframework.context.ApplicationContext;
33 import org.springframework.test.context.ContextConfiguration;
34 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
36 import javax.inject.Inject;
39 @RunWith( SpringJUnit4ClassRunner.class )
40 @ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
41 public abstract class AbstractArtifactConsumerTest
44 private File repoLocation;
46 protected KnownRepositoryContentConsumer consumer;
49 protected ApplicationContext applicationContext;
52 ArchivaConfiguration archivaConfiguration;
61 (FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
62 assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
63 fileType.addPattern( "**/*.xml" );
65 repoLocation = new File( "target/test-" + getName() + "/test-repo" );
69 public void testConsumption()
72 new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
74 ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
75 BaseFile baseFile = new BaseFile( repoLocation, localFile );
76 predicate.setBasefile( baseFile );
78 assertFalse( predicate.evaluate( consumer ) );
82 public void testConsumptionOfOtherMetadata()
85 new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
87 ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
88 BaseFile baseFile = new BaseFile( repoLocation, localFile );
89 predicate.setBasefile( baseFile );
91 assertFalse( predicate.evaluate( consumer ) );