1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.maven.plugin.eclipse.it;
16
17 import java.io.File;
18 import java.io.FileInputStream;
19 import java.util.Properties;
20
21 import org.apache.maven.plugin.eclipse.writers.workspace.EclipseWorkspaceWriter;
22 import org.apache.maven.plugin.ide.IdeUtils;
23 import org.codehaus.plexus.PlexusTestCase;
24 import org.codehaus.plexus.util.FileUtils;
25
26
27
28
29 public class EclipseWorkspaceIT
30 extends AbstractEclipsePluginIT
31 {
32
33 private static final String ECLIPSE_JDT_CORE_PREFS_PATH =
34 EclipseWorkspaceWriter.ECLIPSE_CORE_RUNTIME_SETTINGS_DIR + "/"
35 + EclipseWorkspaceWriter.ECLIPSE_JDT_CORE_PREFS_FILE;
36
37 private static final String ECLIPSE_JDT_UI_PREFS_PATH =
38 EclipseWorkspaceWriter.ECLIPSE_CORE_RUNTIME_SETTINGS_DIR + "/"
39 + EclipseWorkspaceWriter.ECLIPSE_JDT_UI_PREFS_FILE;
40
41 protected void setUp()
42 throws Exception
43 {
44 super.setUp();
45 }
46
47 public void testWorkspace02()
48 throws Exception
49 {
50
51
52
53
54 String projectName = "workspace-02";
55
56 FileUtils.deleteDirectory( this.getTestWorkspaceWorkDirectory( projectName ) );
57 testWorkspace( projectName );
58
59 this.validateM2REPOVar( projectName );
60
61 File eclipseJDTUIPrefsFile = new File( this.getOutputDirectory( projectName ), ECLIPSE_JDT_UI_PREFS_PATH );
62
63 assertTrue( eclipseJDTUIPrefsFile.exists() );
64
65 }
66
67 private void validateM2REPOVar( String projectName )
68 throws Exception
69 {
70 File eclipseJDTCorePrefsFile = new File( this.getOutputDirectory( projectName ), ECLIPSE_JDT_CORE_PREFS_PATH );
71
72 assertTrue( "Test if workspace properties exists", eclipseJDTCorePrefsFile.exists() );
73
74 Properties props = new Properties();
75 props.load( new FileInputStream( eclipseJDTCorePrefsFile ) );
76
77 String M2_REPO = props.getProperty( EclipseWorkspaceWriter.CLASSPATH_VARIABLE_M2_REPO );
78
79 assertNotNull( "Test M2_REPO has a value", M2_REPO );
80
81 String expectectLocalRepo =
82 new File( PlexusTestCase.getBasedir(), "target/test-classes/m2repo" ).getCanonicalPath();
83
84
85 expectectLocalRepo = IdeUtils.fixSeparator( expectectLocalRepo ).toLowerCase();
86 String actualLocalRepo = IdeUtils.fixSeparator( M2_REPO ).toLowerCase();
87 assertEquals( "Test M2_REPO value", expectectLocalRepo, actualLocalRepo );
88
89 }
90
91 }