View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.internal.impl;
20  
21  import org.eclipse.aether.artifact.Artifact;
22  import org.eclipse.aether.artifact.DefaultArtifact;
23  import org.eclipse.aether.repository.RemoteRepository;
24  import org.junit.Test;
25  
26  import static org.junit.Assert.assertEquals;
27  
28  public class EnhancedSplitLocalRepositoryManagerTest extends EnhancedLocalRepositoryManagerTest {
29  
30      @Override
31      protected EnhancedLocalRepositoryManager getManager() {
32          session.setConfigProperty("aether.enhancedLocalRepository.split", Boolean.TRUE.toString());
33          return new EnhancedLocalRepositoryManager(
34                  basedir,
35                  new DefaultLocalPathComposer(),
36                  "_remote.repositories",
37                  trackingFileManager,
38                  new DefaultLocalPathPrefixComposerFactory().createComposer(session));
39      }
40  
41      @Test
42      @Override
43      public void testGetPathForLocalArtifact() {
44          Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
45          assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
46          assertEquals(
47                  "installed/g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
48  
49          artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
50          assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
51          assertEquals(
52                  "installed/g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
53      }
54  
55      @Test
56      @Override
57      public void testGetPathForRemoteArtifact() {
58          RemoteRepository remoteRepo = new RemoteRepository.Builder("repo", "default", "ram:/void").build();
59  
60          Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
61          assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
62          assertEquals(
63                  "cached/g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar",
64                  manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
65  
66          artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
67          assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
68          assertEquals(
69                  "cached/g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-20110329.221805-4.jar",
70                  manager.getPathForRemoteArtifact(artifact, remoteRepo, ""));
71      }
72  }