|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2011 IBM Corporation and others. |
| 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 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.ant.tests.ui.externaltools; |
| 12 |
|
| 13 |
import java.util.HashMap; |
| 14 |
import java.util.Map; |
| 15 |
|
| 16 |
import org.eclipse.ant.internal.launching.AntLaunchingUtil; |
| 17 |
import org.eclipse.ant.launching.IAntLaunchConstants; |
| 18 |
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest; |
| 19 |
import org.eclipse.core.externaltools.internal.IExternalToolConstants; |
| 20 |
import org.eclipse.core.externaltools.internal.model.BuilderCoreUtils; |
| 21 |
import org.eclipse.core.resources.ICommand; |
| 22 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
| 23 |
import org.eclipse.debug.core.ILaunchConfiguration; |
| 24 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
| 25 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 26 |
|
| 27 |
/** |
| 28 |
* Tests for {@link BuilderCoreUtils} |
| 29 |
* |
| 30 |
* @since 3.5.100 org.eclipse.ant.tests.ui |
| 31 |
*/ |
| 32 |
public class BuilderCoreUtilsTests extends AbstractExternalToolTest { |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor |
| 36 |
*/ |
| 37 |
public BuilderCoreUtilsTests() { |
| 38 |
super("BuilderCoreUtils Tests"); |
| 39 |
} |
| 40 |
|
| 41 |
/* (non-Javadoc) |
| 42 |
* @see org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest#setUp() |
| 43 |
*/ |
| 44 |
protected void setUp() throws Exception { |
| 45 |
super.setUp(); |
| 46 |
//create the external tool builder dir |
| 47 |
BuilderCoreUtils.getBuilderFolder(getProject(), true); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 52 |
* method. |
| 53 |
* <br><br> |
| 54 |
* Tests the argument map missing the {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute and all other config arguments |
| 55 |
* @throws Exception |
| 56 |
*/ |
| 57 |
public void testConfigFromBuildCommandArgs1() throws Exception { |
| 58 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), new HashMap(), new String[] {BuilderCoreUtils.VERSION_1_0}); |
| 59 |
assertNull("There should be no configuration returned without the config handle and arguments", config); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 64 |
* method. |
| 65 |
* <br><br> |
| 66 |
* Tests the argument map missing the {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute only |
| 67 |
* @throws Exception |
| 68 |
*/ |
| 69 |
public void testConfigFromBuildCommandArgs2() throws Exception { |
| 70 |
Map args = get20AntArgumentMap(); |
| 71 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 72 |
assertNotNull("There should be a migrated configuration returned", config); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 77 |
* method. |
| 78 |
* <br><br> |
| 79 |
* Tests the argument map with an invalid {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute |
| 80 |
* @throws Exception |
| 81 |
*/ |
| 82 |
public void testConfigFromBuildCommandArgs3() throws Exception { |
| 83 |
Map args = new HashMap(); |
| 84 |
args.put(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE, "foo"); |
| 85 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 86 |
assertNull("There should be no configuration returned", config); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 91 |
* method. |
| 92 |
* <br><br> |
| 93 |
* Tests the argument map with a valid {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute with no project prefix, but does |
| 94 |
* include the .externalToolBuilders dir name - causes a lookup in the launch manager which fails because of the extra path prefix |
| 95 |
* @throws Exception |
| 96 |
*/ |
| 97 |
public void testConfigFromBuildCommandArgs4() throws Exception { |
| 98 |
createExternalToolBuilder(getProject(), "testConfigFromBuildCommandArgs4", null); |
| 99 |
Map args = new HashMap(); |
| 100 |
args.put(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE, "/.externalToolBuilders/testConfigFromBuildCommandArgs4.launch"); |
| 101 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 102 |
assertNull("There should be no configuration returned", config); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 107 |
* method. |
| 108 |
* <br><br> |
| 109 |
* Tests the argument map with a valid {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute with no project prefix - |
| 110 |
* causes a lookup in the launch manager returns the config |
| 111 |
* @throws Exception |
| 112 |
*/ |
| 113 |
public void testConfigFromBuildCommandArgs5() throws Exception { |
| 114 |
createExternalToolBuilder(getProject(), "testConfigFromBuildCommandArgs5", null); |
| 115 |
Map args = new HashMap(); |
| 116 |
args.put(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE, "testConfigFromBuildCommandArgs5.launch"); |
| 117 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 118 |
assertNotNull("There should be a configuration returned", config); |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 123 |
* method. |
| 124 |
* <br><br> |
| 125 |
* Tests the argument map with a valid {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute with the project prefix but |
| 126 |
* not including the .externalToolBuilder path segment |
| 127 |
* @throws Exception |
| 128 |
*/ |
| 129 |
public void testConfigFromBuildCommandArgs6() throws Exception { |
| 130 |
createExternalToolBuilder(getProject(), "testConfigFromBuildCommandArgs6", null); |
| 131 |
Map args = new HashMap(); |
| 132 |
args.put(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE, "<project>/testConfigFromBuildCommandArgs6.launch"); |
| 133 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 134 |
assertNull("There should be no configuration returned", config); |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* Tests the {@link BuilderCoreUtils#configFromBuildCommandArgs(org.eclipse.core.resources.IProject, java.util.Map, String[])} |
| 139 |
* method. |
| 140 |
* <br><br> |
| 141 |
* Tests the argument map with a valid {@link BuilderCoreUtils#LAUNCH_CONFIG_HANDLE} attribute with the project prefix and |
| 142 |
* a valid config path |
| 143 |
* @throws Exception |
| 144 |
*/ |
| 145 |
public void testConfigFromBuildCommandArgs7() throws Exception { |
| 146 |
createExternalToolBuilder(getProject(), "testConfigFromBuildCommandArgs7", null); |
| 147 |
Map args = new HashMap(); |
| 148 |
args.put(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE, "<project>/.externalToolBuilders/testConfigFromBuildCommandArgs7.launch"); |
| 149 |
ILaunchConfiguration config = BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[] {BuilderCoreUtils.VERSION_2_1}); |
| 150 |
assertNotNull("There should be a configuration returned", config); |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 155 |
* method |
| 156 |
* <br><br> |
| 157 |
* Tests that the triggers are configured for a full build of the default target after a clean |
| 158 |
* @throws Exception |
| 159 |
*/ |
| 160 |
public void testConfigureTriggers1() throws Exception { |
| 161 |
Map args = new HashMap(); |
| 162 |
args.put(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, null); |
| 163 |
args.put(IExternalToolConstants.ATTR_LOCATION, getBuildFile(EXT_BUILD_FILE_NAME).getAbsolutePath()); |
| 164 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_FULL); |
| 165 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers1", args); |
| 166 |
assertNotNull("the test builder must not be null", config); |
| 167 |
ICommand command = createBuildCommand(config); |
| 168 |
assertNotNull("the test build command must not be null", command); |
| 169 |
assertTrue("the command must be building FULL builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 170 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 171 |
assertNull("should be no target names resolved from the config - null given for target names", names); |
| 172 |
} |
| 173 |
|
| 174 |
/** |
| 175 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 176 |
* method |
| 177 |
* <br><br> |
| 178 |
* Tests that the triggers are configured for a full build of a specific targets 'def' and 'clean' |
| 179 |
* @throws Exception |
| 180 |
*/ |
| 181 |
public void testConfigureTriggers2() throws Exception { |
| 182 |
Map args = new HashMap(); |
| 183 |
args.put(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, "def,clean"); |
| 184 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_FULL); |
| 185 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers2", args); |
| 186 |
assertNotNull("the test builder must not be null", config); |
| 187 |
ICommand command = createBuildCommand(config); |
| 188 |
assertNotNull("the test build command must not be null", command); |
| 189 |
assertTrue("the command must be building FULL builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 190 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 191 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 196 |
* method |
| 197 |
* <br><br> |
| 198 |
* Tests that the triggers are configured for an incremental AND full build with default targets |
| 199 |
* <br><br> |
| 200 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=114563 |
| 201 |
* @throws Exception |
| 202 |
*/ |
| 203 |
public void testConfigureTriggers3() throws Exception { |
| 204 |
Map args = new HashMap(); |
| 205 |
args.put(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, null); |
| 206 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_INCREMENTAL); |
| 207 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers3", args); |
| 208 |
assertNotNull("the test builder must not be null", config); |
| 209 |
ICommand command = createBuildCommand(config); |
| 210 |
assertNotNull("the test build command must not be null", command); |
| 211 |
assertTrue("the command must be building INCREMENTAL builds", command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD)); |
| 212 |
assertTrue("the command must be building FULL builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 213 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 214 |
assertNull("should be no target names resolved from the config - null given for target names", names); |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 219 |
* method |
| 220 |
* <br><br> |
| 221 |
* Tests that the triggers are configured for an incremental AND full build with the targets 'def' and 'inc' |
| 222 |
* <br><br> |
| 223 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=114563 |
| 224 |
* @throws Exception |
| 225 |
*/ |
| 226 |
public void testConfigureTriggers4() throws Exception { |
| 227 |
Map args = new HashMap(); |
| 228 |
args.put(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, "def,inc"); |
| 229 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_INCREMENTAL); |
| 230 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers4", args); |
| 231 |
assertNotNull("the test builder must not be null", config); |
| 232 |
ICommand command = createBuildCommand(config); |
| 233 |
assertNotNull("the test build command must not be null", command); |
| 234 |
assertTrue("the command must be building INCREMENTAL builds", command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD)); |
| 235 |
assertTrue("the command must be building FULL builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 236 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 237 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 238 |
} |
| 239 |
|
| 240 |
/** |
| 241 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 242 |
* method |
| 243 |
* <br><br> |
| 244 |
* Tests that the triggers are configured for an auto build |
| 245 |
* @throws Exception |
| 246 |
*/ |
| 247 |
public void testConfigureTriggers5() throws Exception { |
| 248 |
Map args = new HashMap(); |
| 249 |
args.put(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS, null); |
| 250 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_AUTO); |
| 251 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers5", args); |
| 252 |
assertNotNull("the test builder must not be null", config); |
| 253 |
ICommand command = createBuildCommand(config); |
| 254 |
assertNotNull("the test build command must not be null", command); |
| 255 |
assertTrue("the command must be building AUTO builds", command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD)); |
| 256 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 257 |
assertNull("should be no target names resolved from the config - null given for target names", names); |
| 258 |
} |
| 259 |
|
| 260 |
/** |
| 261 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 262 |
* method |
| 263 |
* <br><br> |
| 264 |
* Tests that the triggers are configured for an auto build with the targets 'def' and 'auto' |
| 265 |
* @throws Exception |
| 266 |
*/ |
| 267 |
public void testConfigureTriggers6() throws Exception { |
| 268 |
Map args = new HashMap(); |
| 269 |
args.put(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS, "def,auto"); |
| 270 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_AUTO); |
| 271 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers6", args); |
| 272 |
assertNotNull("the test builder must not be null", config); |
| 273 |
ICommand command = createBuildCommand(config); |
| 274 |
assertNotNull("the test build command must not be null", command); |
| 275 |
assertTrue("the command must be building AUTO builds", command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD)); |
| 276 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 277 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 278 |
} |
| 279 |
|
| 280 |
/** |
| 281 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 282 |
* method |
| 283 |
* <br><br> |
| 284 |
* Tests that the triggers are configured for a clean build |
| 285 |
* @throws Exception |
| 286 |
*/ |
| 287 |
public void testConfigureTriggers7() throws Exception { |
| 288 |
Map args = new HashMap(); |
| 289 |
args.put(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS, null); |
| 290 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_CLEAN); |
| 291 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers7", args); |
| 292 |
assertNotNull("the test builder must not be null", config); |
| 293 |
ICommand command = createBuildCommand(config); |
| 294 |
assertNotNull("the test build command must not be null", command); |
| 295 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD)); |
| 296 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 297 |
assertNull("should be no target names resolved from the config - null given for target names", names); |
| 298 |
} |
| 299 |
|
| 300 |
/** |
| 301 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 302 |
* method |
| 303 |
* <br><br> |
| 304 |
* Tests that the triggers are configured for a clean build with the targets 'def' and 'clean' |
| 305 |
* @throws Exception |
| 306 |
*/ |
| 307 |
public void testConfigureTriggers8() throws Exception { |
| 308 |
Map args = new HashMap(); |
| 309 |
args.put(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS, "def,clean"); |
| 310 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_CLEAN); |
| 311 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers6", args); |
| 312 |
assertNotNull("the test builder must not be null", config); |
| 313 |
ICommand command = createBuildCommand(config); |
| 314 |
assertNotNull("the test build command must not be null", command); |
| 315 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD)); |
| 316 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 317 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 318 |
} |
| 319 |
|
| 320 |
/** |
| 321 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 322 |
* method |
| 323 |
* <br><br> |
| 324 |
* Tests that the triggers are configured for a full + incremental build with the targets 'def' and 'inc' specified |
| 325 |
* for after clean targets and manual targets respectively |
| 326 |
* @throws Exception |
| 327 |
*/ |
| 328 |
public void testConfigureTriggers9() throws Exception { |
| 329 |
Map args = new HashMap(); |
| 330 |
args.put(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, "def"); |
| 331 |
args.put(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, "inc"); |
| 332 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, IExternalToolConstants.BUILD_TYPE_CLEAN+","+IExternalToolConstants.BUILD_TYPE_INCREMENTAL); |
| 333 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers9", args); |
| 334 |
assertNotNull("the test builder must not be null", config); |
| 335 |
ICommand command = createBuildCommand(config); |
| 336 |
assertNotNull("the test build command must not be null", command); |
| 337 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 338 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD)); |
| 339 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 340 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 341 |
} |
| 342 |
|
| 343 |
/** |
| 344 |
* Tests the {@link BuilderCoreUtils#configureTriggers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 345 |
* method |
| 346 |
* <br><br> |
| 347 |
* Tests that the triggers are configured for a full + incremental build with the targets 'def' and 'inc' specified |
| 348 |
* for after clean targets and manual targets respectively |
| 349 |
* @throws Exception |
| 350 |
*/ |
| 351 |
public void testConfigureTriggers10() throws Exception { |
| 352 |
Map args = new HashMap(); |
| 353 |
args.put(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, "def"); |
| 354 |
args.put(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, "inc"); |
| 355 |
args.put(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS, "auto"); |
| 356 |
args.put(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS, "clean"); |
| 357 |
String kinds = IExternalToolConstants.BUILD_TYPE_CLEAN+","+ |
| 358 |
IExternalToolConstants.BUILD_TYPE_INCREMENTAL+","+ |
| 359 |
IExternalToolConstants.BUILD_TYPE_AUTO+","+ |
| 360 |
IExternalToolConstants.BUILD_TYPE_FULL; |
| 361 |
args.put(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, kinds); |
| 362 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testConfigureTriggers10", args); |
| 363 |
assertNotNull("the test builder must not be null", config); |
| 364 |
ICommand command = createBuildCommand(config); |
| 365 |
assertNotNull("the test build command must not be null", command); |
| 366 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.FULL_BUILD)); |
| 367 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD)); |
| 368 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD)); |
| 369 |
assertTrue("the command must be building CLEAN builds", command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD)); |
| 370 |
String[] names = AntLaunchingUtil.getTargetNames(config); |
| 371 |
assertNull("should be no target names resolved from the config - only available during a build", names); |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Tests the {@link BuilderCoreUtils#isUnmigratedConfig(org.eclipse.debug.core.ILaunchConfiguration)} method |
| 376 |
* @throws Exception |
| 377 |
*/ |
| 378 |
public void testIsUnmigratedConfig1() throws Exception { |
| 379 |
ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager().getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE); |
| 380 |
if(type != null) { |
| 381 |
ILaunchConfigurationWorkingCopy config = type.newInstance(BuilderCoreUtils.getBuilderFolder(getProject(), true), "testIsUnmigratedConfig1"); |
| 382 |
assertTrue("should be considered 'unmigrated'", BuilderCoreUtils.isUnmigratedConfig(config)); |
| 383 |
} |
| 384 |
else { |
| 385 |
fail("could not find the Ant builder launch configuration type"); |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
/** |
| 390 |
* Tests the {@link BuilderCoreUtils#isUnmigratedConfig(org.eclipse.debug.core.ILaunchConfiguration)} method |
| 391 |
* @throws Exception |
| 392 |
*/ |
| 393 |
public void testIsUnmigratedConfig2() throws Exception { |
| 394 |
ILaunchConfiguration config = createExternalToolBuilder(getProject(), "testIsUnmigratedConfig2", null); |
| 395 |
assertFalse("Shoudl not be considered 'unmigrated'", BuilderCoreUtils.isUnmigratedConfig(config)); |
| 396 |
} |
| 397 |
|
| 398 |
/** |
| 399 |
* Tests the {@link BuilderCoreUtils#toBuildCommand(org.eclipse.core.resources.IProject, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 400 |
* method |
| 401 |
* <br><br> |
| 402 |
* Tests the case of a new un-saved {@link ILaunchConfiguration} |
| 403 |
* @throws Exception |
| 404 |
*/ |
| 405 |
public void testToBuildCommand1() throws Exception { |
| 406 |
ILaunchConfigurationWorkingCopy copy = createExternalToolBuilderWorkingCopy(getProject(), "testToBuildCommand1", null); |
| 407 |
ICommand command = BuilderCoreUtils.toBuildCommand(getProject(), copy, getProject().getDescription().newCommand()); |
| 408 |
assertNotNull("There should have been a new build command created", command); |
| 409 |
} |
| 410 |
|
| 411 |
/** |
| 412 |
* Tests the {@link BuilderCoreUtils#toBuildCommand(org.eclipse.core.resources.IProject, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 413 |
* method |
| 414 |
* <br><br> |
| 415 |
* Tests the case of an existing configuration |
| 416 |
* @throws Exception |
| 417 |
*/ |
| 418 |
public void testToBuildCommand2() throws Exception { |
| 419 |
Map args = new HashMap(); |
| 420 |
ILaunchConfiguration copy = createExternalToolBuilder(getProject(), "testToBuildCommand2", args); |
| 421 |
ICommand command = BuilderCoreUtils.toBuildCommand(getProject(), copy, getProject().getDescription().newCommand()); |
| 422 |
assertNotNull("There should have been a new build command created", command); |
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* Tests the {@link BuilderCoreUtils#toBuildCommand(org.eclipse.core.resources.IProject, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} |
| 427 |
* method |
| 428 |
* <br><br> |
| 429 |
* Tests the case of the working copy of an existing configuration |
| 430 |
* @throws Exception |
| 431 |
*/ |
| 432 |
public void testToBuildCommand3() throws Exception { |
| 433 |
Map args = new HashMap(); |
| 434 |
ILaunchConfiguration copy = createExternalToolBuilder(getProject(), "testToBuildCommand3", args); |
| 435 |
ICommand command = BuilderCoreUtils.toBuildCommand(getProject(), copy.getWorkingCopy(), getProject().getDescription().newCommand()); |
| 436 |
assertNotNull("There should have been a new build command created", command); |
| 437 |
} |
| 438 |
|
| 439 |
/** |
| 440 |
* Tests the {@link BuilderCoreUtils#migrateBuilderConfiguration(org.eclipse.core.resources.IProject, org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)} |
| 441 |
* method |
| 442 |
* @throws Exception |
| 443 |
*/ |
| 444 |
public void testMigrateBuilderConfiguration1() throws Exception { |
| 445 |
ILaunchConfigurationWorkingCopy copy = createExternalToolBuilderWorkingCopy(getProject(), "testMigrateBuilderConfiguration1", null); |
| 446 |
ILaunchConfiguration config = BuilderCoreUtils.migrateBuilderConfiguration(getProject(), copy); |
| 447 |
assertNotNull("The un-saved working copy should have been migrated", config); |
| 448 |
assertTrue("The name of the migrated configuration should be testMigrateBuilderConfiguration1", config.getName().equals("testMigrateBuilderConfiguration1")); |
| 449 |
} |
| 450 |
|
| 451 |
/** |
| 452 |
* Tests the {@link BuilderCoreUtils#migrateBuilderConfiguration(org.eclipse.core.resources.IProject, org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)} |
| 453 |
* method |
| 454 |
* @throws Exception |
| 455 |
*/ |
| 456 |
public void testMigrateBuilderConfiguration2() throws Exception { |
| 457 |
ILaunchConfigurationWorkingCopy copy = createExternalToolBuilderWorkingCopy(getProject(), "testMigra/teBuilderConfi/guration2", null); |
| 458 |
ILaunchConfiguration config = BuilderCoreUtils.migrateBuilderConfiguration(getProject(), copy); |
| 459 |
assertNotNull("The un-saved working copy should have been migrated", config); |
| 460 |
assertTrue("The name of the migrated configuration should be testMigra.teBuilderConfi.guration2", config.getName().equals("testMigra.teBuilderConfi.guration2")); |
| 461 |
} |
| 462 |
|
| 463 |
/** |
| 464 |
* Tests the {@link BuilderCoreUtils#buildTypesToArray(String)} method |
| 465 |
* @throws Exception |
| 466 |
*/ |
| 467 |
public void testBuildTypesToArray1() throws Exception { |
| 468 |
String kinds = IExternalToolConstants.BUILD_TYPE_CLEAN+","+ |
| 469 |
IExternalToolConstants.BUILD_TYPE_INCREMENTAL+","+ |
| 470 |
IExternalToolConstants.BUILD_TYPE_AUTO+","+ |
| 471 |
IExternalToolConstants.BUILD_TYPE_FULL; |
| 472 |
int[] array = BuilderCoreUtils.buildTypesToArray(kinds); |
| 473 |
assertNotNull("The build kinds array cannot be null", array); |
| 474 |
boolean contains = true; |
| 475 |
for (int i = 0; i < array.length; i++) { |
| 476 |
contains &= (array[i] == IncrementalProjectBuilder.AUTO_BUILD) | |
| 477 |
(array[i] == IncrementalProjectBuilder.CLEAN_BUILD) | |
| 478 |
(array[i] == IncrementalProjectBuilder.FULL_BUILD) | |
| 479 |
(array[i] == IncrementalProjectBuilder.INCREMENTAL_BUILD); |
| 480 |
if(!contains) { |
| 481 |
break; |
| 482 |
} |
| 483 |
} |
| 484 |
assertTrue("All of the build kinds should have been found", contains); |
| 485 |
} |
| 486 |
} |