01: package org.apache.maven.project;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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.model.Build;
23: import org.apache.maven.model.Resource;
24:
25: import java.io.File;
26:
27: public class ProjectBaseDirectoryAlignmentTest extends
28: AbstractMavenProjectTestCase {
29: private String dir = "src/test/resources/projects/base-directory-alignment/";
30:
31: public void testProjectDirectoryBaseDirectoryAlignment()
32: throws Exception {
33: File f = getTestFile(dir
34: + "project-which-needs-directory-alignment.xml");
35:
36: MavenProject project = getProject(f);
37:
38: assertNotNull("Test project can't be null!", project);
39:
40: File basedirFile = new File(getBasedir());
41: File sourceDirectoryFile = new File(project.getBuild()
42: .getSourceDirectory());
43: File testSourceDirectoryFile = new File(project.getBuild()
44: .getTestSourceDirectory());
45:
46: assertEquals(basedirFile.getCanonicalPath(),
47: sourceDirectoryFile.getCanonicalPath().substring(0,
48: getBasedir().length()));
49:
50: assertEquals(basedirFile.getCanonicalPath(),
51: testSourceDirectoryFile.getCanonicalPath().substring(0,
52: getBasedir().length()));
53:
54: Build build = project.getBuild();
55:
56: Resource resource = (Resource) build.getResources().get(0);
57:
58: assertTrue(resource.getDirectory().startsWith(getBasedir()));
59: }
60: }
|