2 * Copyright 2008 jdumay.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 package org.apache.archiva.consumers;
21 import java.util.Date;
22 import junit.framework.TestCase;
23 import org.apache.commons.io.FileUtils;
24 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
30 public class OBRRepositoryConsumerTest extends TestCase
32 private OBRRepositoryConsumer consumer;
34 private File testRepo;
36 private ManagedRepositoryConfiguration configuration;
39 protected void setUp() throws Exception {
42 File testRepoData = new File("src/test/resources/repository");
43 testRepo = new File("target/obrtestrepo").getAbsoluteFile();
45 consumer = new OBRRepositoryConsumer();
46 FileUtils.copyDirectory(testRepoData, testRepo);
47 configuration = new ManagedRepositoryConfiguration();
48 configuration.setName("My Test OSGi repository");
49 configuration.setId("test-obr-osgi-repo");
50 configuration.setLocation(testRepo.getAbsolutePath());
51 consumer.beginScan(configuration, new Date());
55 protected void tearDown()
59 //FileUtils.deleteDirectory(testRepo);
62 public void testCreatesRepositoryXml() throws Exception
64 File repositoryXml = new File(configuration.getLocation(), "repository.xml");
65 assertFalse("repository.xml should not exist", repositoryXml.exists());
66 consumer.processFile(new File(testRepo, "./commons-codec/commons-codec/1.3.0/commons-codec-1.3.0.jar").getAbsolutePath());
68 assertTrue(".repository.xml iterim file should exist", new File(testRepo, "commons-codec/commons-codec/1.3.0/.repository.xml").exists());
69 assertTrue("repository.xml should exist", repositoryXml.exists());