Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

test cases for bug 350414 #4

Closed
wants to merge 1 commit into from

2 participants

Andrew Eisenberg Fred Bricon
Fred Bricon
Collaborator

Commit was applied as e3e55f6. Closing.

Fred Bricon fbricon closed this April 09, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 21, 2012
Andrew Eisenberg test cases for bug 350414 22feff4
This page is out of date. Refresh to see the latest.
2  org.eclipse.m2e.tests/src/org/eclipse/m2e/tests/lifecycle/LifecycleMappingMetadataPrioritiesTest.java
@@ -17,6 +17,7 @@
17 17
 
18 18
 
19 19
 public class LifecycleMappingMetadataPrioritiesTest extends AbstractLifecycleMappingTest {
  20
+  
20 21
   // Tests lifecycle mapping declared in default lifecycle mapping metadata
21 22
   public void testDefaultMetadataSource() throws Exception {
22 23
     LifecycleMappingMetadataSource defaultMetadata = loadLifecycleMappingMetadataSource("projects/lifecyclemapping/lifecycleMappingMetadata/LifecycleMappingMetadataPrioritiesTest/defaultMetadata.xml");
@@ -133,4 +134,5 @@ public void testParent() throws Exception {
133 134
     WorkspaceHelpers.assertLifecycleIdErrorMarkerAttributes(marker,
134 135
         "no such lifecycle mapping for test-packaging-a - override");
135 136
   }
  137
+  
136 138
 }
153  org.eclipse.m2e.tests/src/org/eclipse/m2e/tests/lifecycle/PluginExecutionMetadataPrioritiesTest.java
@@ -19,6 +19,12 @@
19 19
 
20 20
 @SuppressWarnings("restriction")
21 21
 public class PluginExecutionMetadataPrioritiesTest extends AbstractLifecycleMappingTest {
  22
+  protected void tearDown() throws Exception {
  23
+    super.tearDown();
  24
+    // ensure there is no workspace lifecycle mapping
  25
+    setWorkspaceLifecycleMappingMetadataSource("");
  26
+  }
  27
+  
22 28
   public void testDefaultMetadataSource() throws Exception {
23 29
     LifecycleMappingMetadataSource defaultMetadata = loadLifecycleMappingMetadataSource("projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest/defaultMetadata.xml");
24 30
     LifecycleMappingFactory.setDefaultLifecycleMappingMetadataSource(defaultMetadata);
@@ -159,4 +165,151 @@ public void testParent() throws Exception {
159 165
     WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, expectedErrorMessage,
160 166
         null /*lineNumber*/, project);
161 167
   }
  168
+  
  169
+  // Workspace mappings override plugin mappings
  170
+  public void testWorkspace() throws Exception {
  171
+    
  172
+    // now set the lifecycle mapping in the workspace.
  173
+    setWorkspaceLifecycleMappingMetadataSource(
  174
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
  175
+        "<lifecycleMappingMetadata>\n" + 
  176
+        "  <pluginExecutions>\n" + 
  177
+        "    <pluginExecution>\n" + 
  178
+        "      <pluginExecutionFilter>\n" + 
  179
+        "        <groupId>org.eclipse.m2e.test.lifecyclemapping</groupId>\n" + 
  180
+        "        <artifactId>test-lifecyclemapping-plugin</artifactId>\n" + 
  181
+        "        <versionRange>[1.0.0,)</versionRange>\n" + 
  182
+        "        <goals>\n" + 
  183
+        "          <goal>test-goal-for-eclipse-extension2</goal>\n" + 
  184
+        "        </goals>\n" + 
  185
+        "      </pluginExecutionFilter>\n" + 
  186
+        "      <action>\n" + 
  187
+        "        <ignore/>\n" + 
  188
+        "      </action>\n" + 
  189
+        "    </pluginExecution>\n" + 
  190
+        "  </pluginExecutions>\n" + 
  191
+        "</lifecycleMappingMetadata>");
  192
+
  193
+    LifecycleMappingMetadataSource defaultMetadata = loadLifecycleMappingMetadataSource("projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest/defaultMetadata.xml");
  194
+    LifecycleMappingFactory.setDefaultLifecycleMappingMetadataSource(defaultMetadata);
  195
+
  196
+    IMavenProjectFacade facade = importMavenProject(
  197
+        "projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest",
  198
+        "testDefaultMetadataSource/pom.xml");
  199
+    assertNotNull("Expected not null MavenProjectFacade", facade);
  200
+    IProject project = facade.getProject();
  201
+    List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
  202
+    assertNotNull(errorMarkers);
  203
+    assertEquals(WorkspaceHelpers.toString(errorMarkers), 2, errorMarkers.size());
  204
+
  205
+    // should still have lifecycle errors
  206
+    String expectedErrorMessage = "Plugin execution not covered by lifecycle configuration: org.eclipse.m2e.test.lifecyclemapping:test-lifecyclemapping-plugin:1.0.0:test-goal-1 (execution: default-test-goal-1, phase: process-resources)";
  207
+    WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, expectedErrorMessage,
  208
+        11 /*lineNumber*/, project);
  209
+
  210
+    // should not have any plugin execution errors
  211
+    expectedErrorMessage = "Project configurator \"missing default project configurator id for test-lifecyclemapping-plugin:test-goal-1\" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.";
  212
+    WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID,
  213
+        expectedErrorMessage, null /*lineNumber*/, project);
  214
+  }
  215
+  // Embedded metadata should override Workspace mappings
  216
+  public void testPomOverridesWorkspace() throws Exception {
  217
+    
  218
+    // now set the lifecycle mapping in the workspace.
  219
+    setWorkspaceLifecycleMappingMetadataSource(
  220
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
  221
+            "<lifecycleMappingMetadata>\n" + 
  222
+            "  <pluginExecutions>\n" + 
  223
+            "    <pluginExecution>\n" + 
  224
+            "      <pluginExecutionFilter>\n" + 
  225
+            "        <groupId>org.eclipse.m2e.test.lifecyclemapping</groupId>\n" + 
  226
+            "        <artifactId>test-lifecyclemapping-plugin</artifactId>\n" + 
  227
+            "        <versionRange>[1.0.0,)</versionRange>\n" + 
  228
+            "        <goals>\n" + 
  229
+            "          <goal>test-goal-for-eclipse-extension2</goal>\n" + 
  230
+            "        </goals>\n" + 
  231
+            "      </pluginExecutionFilter>\n" + 
  232
+            "      <action>\n" + 
  233
+            "        <configurator>\n" + 
  234
+            "          <id>no such project configurator id for test-lifecyclemapping-plugin:test-goal-for-eclipse-extension2 - embedded from pom</id>\n" + 
  235
+            "        </configurator>\n" + 
  236
+            "      </action>\n" + 
  237
+            "    </pluginExecution>\n" + 
  238
+            "  </pluginExecutions>\n" + 
  239
+        "</lifecycleMappingMetadata>");
  240
+    
  241
+    IMavenProjectFacade parentFacade = importMavenProject(
  242
+        "projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest",
  243
+        "testParent/pom.xml");
  244
+    assertNotNull("Expected not null MavenProjectFacade", parentFacade);
  245
+    IProject project = parentFacade.getProject();
  246
+    WorkspaceHelpers.assertNoErrors(project);
  247
+
  248
+    // parent pom should have no errors even though bad metadata is in the workspace mappings
  249
+    IMavenProjectFacade facade = importMavenProject(
  250
+        "projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest",
  251
+        "testParent/useParent/pom.xml");
  252
+    assertNotNull("Expected not null MavenProjectFacade", facade);
  253
+    project = facade.getProject();
  254
+    List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
  255
+    assertNotNull(errorMarkers);
  256
+    assertEquals(WorkspaceHelpers.toString(errorMarkers), 2, errorMarkers.size());
  257
+    String expectedErrorMessage = "Plugin execution not covered by lifecycle configuration: org.eclipse.m2e.test.lifecyclemapping:test-lifecyclemapping-plugin:1.0.0:test-goal-1 (execution: default-test-goal-1, phase: process-resources)";
  258
+    IMarker marker = WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID,
  259
+        expectedErrorMessage, null /*lineNumber*/, project);
  260
+    SourceLocation causeLocation = new SourceLocation(parentFacade.getMavenProject().getFile().getAbsolutePath(),
  261
+        WorkspaceHelpers.getModelId(parentFacade.getMavenProject()), 11, 7, 14);
  262
+    WorkspaceHelpers.assertMarkerLocation(new SourceLocation(5, 3, 10, causeLocation), marker);
  263
+    expectedErrorMessage = "Project configurator \"no such project configurator id for test-lifecyclemapping-plugin:test-goal-1 - parent\" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.";
  264
+    marker = WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, expectedErrorMessage,
  265
+        null /*lineNumber*/, project);
  266
+    WorkspaceHelpers.assertMarkerLocation(new SourceLocation(5, 3, 10, causeLocation), marker);
  267
+  }
  268
+  
  269
+  // metadata from workspace should override eclipse extension metadata
  270
+  public void testWorkspaceOverridesEclipseExtensions() throws Exception {
  271
+    // now set the lifecycle mapping in the workspace.
  272
+    setWorkspaceLifecycleMappingMetadataSource(
  273
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
  274
+            "<lifecycleMappingMetadata>\n" + 
  275
+            "  <pluginExecutions>\n" + 
  276
+            "    <pluginExecution>\n" + 
  277
+            "      <pluginExecutionFilter>\n" + 
  278
+            "        <groupId>org.eclipse.m2e.test.lifecyclemapping</groupId>\n" + 
  279
+            "        <artifactId>test-lifecyclemapping-plugin</artifactId>\n" + 
  280
+            "        <versionRange>[1.0.0,)</versionRange>\n" + 
  281
+            "        <goals>\n" + 
  282
+            "          <goal>test-goal-for-eclipse-extension2</goal>\n" + 
  283
+            "        </goals>\n" + 
  284
+            "      </pluginExecutionFilter>\n" + 
  285
+            "      <action>\n" + 
  286
+            "        <configurator>\n" + 
  287
+            "          <id>no such project configurator id for test-lifecyclemapping-plugin:test-goal-for-eclipse-extension2 - workspace</id>\n" + 
  288
+            "        </configurator>\n" + 
  289
+            "      </action>\n" + 
  290
+            "    </pluginExecution>\n" + 
  291
+            "  </pluginExecutions>\n" + 
  292
+        "</lifecycleMappingMetadata>");
  293
+    LifecycleMappingMetadataSource defaultMetadata = loadLifecycleMappingMetadataSource("projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest/defaultMetadata.xml");
  294
+    LifecycleMappingFactory.setDefaultLifecycleMappingMetadataSource(defaultMetadata);
  295
+
  296
+    IMavenProjectFacade facade = importMavenProject(
  297
+        "projects/lifecyclemapping/lifecycleMappingMetadata/PluginExecutionMetadataPrioritiesTest",
  298
+        "testEclipseExtension/pom.xml");
  299
+    assertNotNull("Expected not null MavenProjectFacade", facade);
  300
+    IProject project = facade.getProject();
  301
+    
  302
+    // should have an error since workspace overrides with bad lifecycle data
  303
+    String expectedErrorMessage = "Plugin execution not covered by lifecycle configuration: org.eclipse.m2e.test.lifecyclemapping:test-lifecyclemapping-plugin:1.0.0:test-goal-for-eclipse-extension2 (execution: default-test-goal-for-eclipse-extension2, phase: compile)";
  304
+    WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID, expectedErrorMessage,
  305
+        11 /*lineNumber*/, project);
  306
+
  307
+    expectedErrorMessage = "Project configurator \"no such project configurator id for test-lifecyclemapping-plugin:test-goal-for-eclipse-extension2 - workspace\" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.";
  308
+    IMarker marker = WorkspaceHelpers.assertErrorMarker(IMavenConstants.MARKER_LIFECYCLEMAPPING_ID,
  309
+        expectedErrorMessage, 11 /*lineNumber*/, project);
  310
+    WorkspaceHelpers
  311
+        .assertConfiguratorErrorMarkerAttributes(
  312
+            marker,
  313
+            "no such project configurator id for test-lifecyclemapping-plugin:test-goal-for-eclipse-extension2 - workspace");
  314
+  }
162 315
 }
57  org.eclipse.m2e.tests/src/org/eclipse/m2e/tests/lifecycle/WorkspaceMappingsFileTest.java
... ...
@@ -0,0 +1,57 @@
  1
+/*******************************************************************************
  2
+ * Copyright (c) 2012 VMware, Inc
  3
+ * All rights reserved. This program and the accompanying materials
  4
+ * are made available under the terms of the Eclipse Public License v1.0
  5
+ * which accompanies this distribution, and is available at
  6
+ * http://www.eclipse.org/legal/epl-v10.html
  7
+ *
  8
+ * Contributors:
  9
+ *      Andrew Eisenberg - Work on Bug 350414
  10
+ *******************************************************************************/
  11
+
  12
+package org.eclipse.m2e.tests.lifecycle;
  13
+
  14
+import org.eclipse.m2e.tests.common.AbstractLifecycleMappingTest;
  15
+
  16
+
  17
+/**
  18
+ * Tests for changing the workspace lifecycle mappings file
  19
+ * WorkspaceMappingsFileTest
  20
+ *
  21
+ * @author andrew
  22
+ */
  23
+public class WorkspaceMappingsFileTest extends AbstractLifecycleMappingTest {
  24
+
  25
+  protected void tearDown() throws Exception {
  26
+    mavenConfiguration.setWorkspaceMappingsFile(null);
  27
+    super.tearDown();
  28
+  }
  29
+  
  30
+  public void testIsDefault() throws Exception {
  31
+    assertEquals(mavenConfiguration.getDefaultWorkspaceMappingsFile(), 
  32
+        mavenConfiguration.getWorkspaceMappingsFile());
  33
+  }
  34
+  
  35
+  public void testChangeFromDefault() throws Exception {
  36
+    String newFile = "foo";
  37
+    mavenConfiguration.setWorkspaceMappingsFile(newFile);
  38
+    assertEquals(newFile, 
  39
+        mavenConfiguration.getWorkspaceMappingsFile());
  40
+  }
  41
+  public void testChangeToDefault() throws Exception {
  42
+    String newFile = "foo";
  43
+    mavenConfiguration.setWorkspaceMappingsFile(newFile);
  44
+    mavenConfiguration.setWorkspaceMappingsFile(null);
  45
+    assertEquals(mavenConfiguration.getDefaultWorkspaceMappingsFile(), 
  46
+        mavenConfiguration.getWorkspaceMappingsFile());
  47
+  }
  48
+
  49
+  public void testChangeText() throws Exception {
  50
+    String origText =  mavenConfiguration.getWorkspaceMappings();
  51
+    String newText = "blah!";
  52
+    mavenConfiguration.setWorkspaceMappings(newText);
  53
+    assertEquals(newText, mavenConfiguration.getWorkspaceMappings());
  54
+    mavenConfiguration.setWorkspaceMappings(origText);
  55
+    assertEquals(origText, mavenConfiguration.getWorkspaceMappings());
  56
+  }
  57
+}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.