]> source.dussan.org Git - archiva.git/blob
ee3cee1ca9676e2c79fcce21b46deaf39bf5805b
[archiva.git] /
1 package org.apache.maven.archiva.proxy;
2
3 /*
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
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.maven.archiva.model.ArtifactReference;
23 import org.apache.maven.archiva.policies.CachedFailuresPolicy;
24 import org.apache.maven.archiva.policies.ChecksumPolicy;
25 import org.apache.maven.archiva.policies.ReleasesPolicy;
26 import org.apache.maven.archiva.policies.SnapshotsPolicy;
27
28 import java.io.File;
29
30 /**
31  * ManagedLegacyTransferTest 
32  *
33  * @author Brett Porter
34  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
35  * @version $Id$
36  */
37 public class ManagedLegacyTransferTest
38     extends AbstractProxyTestCase
39 {
40     public void testLegacyManagedRepoGetNotPresent()
41         throws Exception
42     {
43         String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
44         File expectedFile = new File( managedLegacyDir, path );
45         ArtifactReference artifact = createArtifactReference( "legacy", path );
46
47         expectedFile.delete();
48         assertFalse( expectedFile.exists() );
49
50         // Configure Connector (usually done within archiva.xml configuration)
51         saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
52                        SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
53
54         File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
55
56         File proxied2File = new File( REPOPATH_PROXIED1,
57                                       "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar" );
58         assertFileEquals( expectedFile, downloadedFile, proxied2File );
59         assertNoTempFiles( expectedFile );
60
61         // TODO: timestamp preservation requires support for that in wagon
62         //    assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
63     }
64
65     public void testLegacyManagedRepoGetAlreadyPresent()
66         throws Exception
67     {
68         String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
69         File expectedFile = new File( managedLegacyDir, path );
70         ArtifactReference artifact = createArtifactReference( "legacy", path );
71
72         assertTrue( expectedFile.exists() );
73
74         // Configure Connector (usually done within archiva.xml configuration)
75         saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
76                        SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
77
78         File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
79
80         File proxied2File = new File( REPOPATH_PROXIED1,
81                                       "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar" );
82         assertFileEquals( expectedFile, downloadedFile, proxied2File );
83         assertNoTempFiles( expectedFile );
84     }
85
86     public void testLegacyManagedAndProxyRepoGetNotPresent()
87         throws Exception
88     {
89         String path = "org.apache.maven.test/jars/get-default-layout-1.0.jar";
90         File expectedFile = new File( managedLegacyDir, path );
91         ArtifactReference artifact = createArtifactReference( "legacy", path );
92
93         assertFalse( expectedFile.exists() );
94
95         // Configure Connector (usually done within archiva.xml configuration)
96         saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
97                        SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
98
99         File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
100
101         File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
102         assertFileEquals( expectedFile, downloadedFile, proxiedFile );
103         assertNoTempFiles( expectedFile );
104
105         // TODO: timestamp preservation requires support for that in wagon
106         //    assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
107     }
108
109     public void testLegacyManagedAndProxyRepoGetAlreadyPresent()
110         throws Exception
111     {
112         String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
113         File expectedFile = new File( managedLegacyDir, path );
114         ArtifactReference artifact = createArtifactReference( "legacy", path );
115
116         assertTrue( expectedFile.exists() );
117
118         // Configure Connector (usually done within archiva.xml configuration)
119         saveConnector( ID_LEGACY_MANAGED, ID_LEGACY_PROXIED, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
120                        SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
121
122         File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
123
124         File proxiedFile = new File( REPOPATH_PROXIED_LEGACY, path );
125         assertFileEquals( expectedFile, downloadedFile, proxiedFile );
126         assertNoTempFiles( expectedFile );
127     }
128
129     public void testDefaultRequestConvertedToLegacyPathInManagedRepo()
130         throws Exception
131     {
132         // Check that a Maven2 default request is translated to a legacy path in
133         // the managed repository.
134
135         String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
136         String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
137         File expectedFile = new File( managedLegacyDir, legacyPath );
138         ArtifactReference artifact = createArtifactReference( "legacy", legacyPath );
139
140         expectedFile.delete();
141         assertFalse( expectedFile.exists() );
142
143         // Configure Connector (usually done within archiva.xml configuration)
144         saveConnector( ID_LEGACY_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
145                        SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
146
147         File downloadedFile = proxyHandler.fetchFromProxies( managedLegacyRepository, artifact );
148
149         File proxiedFile = new File( REPOPATH_PROXIED1, path );
150         assertFileEquals( expectedFile, downloadedFile, proxiedFile );
151         assertNoTempFiles( expectedFile );
152     }
153 }