View | Details | Raw Unified | Return to bug 101425 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-3 / +151 lines)
Lines 75-82 Link Here
75
// All specified tests which do not belong to the class are skipped...
75
// All specified tests which do not belong to the class are skipped...
76
static {
76
static {
77
	// Names of tests to run: can be "testBugXXXX" or "BugXXXX")
77
	// Names of tests to run: can be "testBugXXXX" or "BugXXXX")
78
//	TESTS_PREFIX = "testClasspathDuplicateExtraAttribute";
78
//	TESTS_PREFIX = "testUnknownElements";
79
//	TESTS_NAMES = new String[] {"testExportContainer"};
79
//	TESTS_NAMES = new String[] {"testUnknownElements2"};
80
//	TESTS_NUMBERS = new int[] { 23, 28, 38 };
80
//	TESTS_NUMBERS = new int[] { 23, 28, 38 };
81
//	TESTS_RANGE = new int[] { 21, 38 };
81
//	TESTS_RANGE = new int[] { 21, 38 };
82
}
82
}
Lines 3166-3172 Link Here
3166
		}, 
3166
		}, 
3167
		null);
3167
		null);
3168
		time[0] += System.currentTimeMillis()-start[0];
3168
		time[0] += System.currentTimeMillis()-start[0];
3169
		System.out.println("No cycle check ("+numberOfParticipants+" participants) : "+ time[0]+" ms, "+ (useForwardReferences ? "forward references" : "backward references") + ", " + (createProjectsFirst ? "two steps (projects created first, then classpaths are set)" : "one step (projects created and classpaths set in one batch)"));
3169
		//System.out.println("No cycle check ("+numberOfParticipants+" participants) : "+ time[0]+" ms, "+ (useForwardReferences ? "forward references" : "backward references") + ", " + (createProjectsFirst ? "two steps (projects created first, then classpaths are set)" : "one step (projects created and classpaths set in one batch)"));
3170
		
3170
		
3171
		for (int i = 0; i < numberOfParticipants; i++){
3171
		for (int i = 0; i < numberOfParticipants; i++){
3172
			// check cycle markers
3172
			// check cycle markers
Lines 3322-3327 Link Here
3322
	}
3322
	}
3323
}
3323
}
3324
3324
3325
/*
3326
 * Ensures that unknown classpath attributes in a .classpath file are not lost when read and rewritten.
3327
 * (regression test for bug 101425 Classpath persistence should be resilient with unknown attributes)
3328
 */
3329
public void testUnknownAttributes() throws CoreException {
3330
	try {
3331
		IJavaProject project = createJavaProject("P");
3332
		editFile(
3333
			"/P/.classpath",
3334
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3335
			"<classpath>\n" + 
3336
			"	<classpathentry unknown=\"test\" kind=\"src\" path=\"src1\"/>\n" + 
3337
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3338
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3339
			"</classpath>\n"
3340
		);
3341
		IClasspathEntry[] classpath = project.getRawClasspath();
3342
		
3343
		// swap 2 entries
3344
		IClasspathEntry src1 = classpath[0];
3345
		classpath[0] = classpath[1];
3346
		classpath[1] = src1;
3347
		project.setRawClasspath(classpath, null);
3348
		
3349
		// check that .classpath has correct content
3350
		String contents = new String (org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(getFile("/P/.classpath")));
3351
		assertSourceEquals(
3352
			"Unexpected content", 
3353
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3354
			"<classpath>\n" + 
3355
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3356
			"	<classpathentry unknown=\"test\" kind=\"src\" path=\"src1\"/>\n" + 
3357
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3358
			"</classpath>\n",			
3359
			contents);		
3360
	} finally {
3361
		deleteProject("P");
3362
	}
3363
}
3364
3365
/*
3366
 * Ensures that unknown classpath elements in a .classpath file are not lost when read and rewritten.
3367
 * (regression test for bug 101425 Classpath persistence should be resilient with unknown attributes)
3368
 */
3369
public void testUnknownElements1() throws CoreException {
3370
	try {
3371
		IJavaProject project = createJavaProject("P");
3372
		editFile(
3373
			"/P/.classpath",
3374
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3375
			"<classpath>\n" + 
3376
			"	<classpathentry kind=\"src\" path=\"src1\">\n" + 
3377
			"		<unknown>\n" +
3378
			"			<test kind=\"\"/>\n" +
3379
			"		</unknown>\n" +
3380
			"	</classpathentry>\n" +
3381
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3382
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3383
			"</classpath>\n"
3384
		);
3385
		IClasspathEntry[] classpath = project.getRawClasspath();
3386
		
3387
		// swap 2 entries
3388
		IClasspathEntry src1 = classpath[0];
3389
		classpath[0] = classpath[1];
3390
		classpath[1] = src1;
3391
		project.setRawClasspath(classpath, null);
3392
		
3393
		// check that .classpath has correct content
3394
		String contents = new String (org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(getFile("/P/.classpath")));
3395
		assertSourceEquals(
3396
			"Unexpected content", 
3397
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3398
			"<classpath>\n" + 
3399
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3400
			"	<classpathentry kind=\"src\" path=\"src1\">\n" + 
3401
			"		<unknown>\n" +
3402
			"			<test kind=\"\"/>\n" +
3403
			"		</unknown>\n" +
3404
			"	</classpathentry>\n" +
3405
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3406
			"</classpath>\n",			
3407
			contents);		
3408
	} finally {
3409
		deleteProject("P");
3410
	}
3411
}
3412
3413
/*
3414
 * Ensures that unknown classpath elements in a .classpath file are not lost when read and rewritten.
3415
 * (regression test for bug 101425 Classpath persistence should be resilient with unknown attributes)
3416
 */
3417
public void testUnknownElements2() throws CoreException {
3418
	try {
3419
		IJavaProject project = createJavaProject("P");
3420
		editFile(
3421
			"/P/.classpath",
3422
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3423
			"<classpath>\n" + 
3424
			"	<classpathentry kind=\"src\" unknownattribute=\"abcde\" path=\"src1\">\n" + 
3425
			"		<unknown1>\n" +
3426
			"			<test kind=\"1\"/>\n" +
3427
			"			<test kind=\"2\"/>\n" +
3428
			"		</unknown1>\n" +
3429
			"		<unknown2 attribute2=\"\">\n" +
3430
			"			<test>\n" +
3431
			"				<other a=\"b\"/>\n" +
3432
			"			</test>\n" +
3433
			"		</unknown2>\n" +
3434
			"	</classpathentry>\n" +
3435
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3436
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3437
			"</classpath>\n"
3438
		);
3439
		IClasspathEntry[] classpath = project.getRawClasspath();
3440
		
3441
		// swap 2 entries
3442
		IClasspathEntry src1 = classpath[0];
3443
		classpath[0] = classpath[1];
3444
		classpath[1] = src1;
3445
		project.setRawClasspath(classpath, null);
3446
		
3447
		// check that .classpath has correct content
3448
		String contents = new String (org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(getFile("/P/.classpath")));
3449
		assertSourceEquals(
3450
			"Unexpected content", 
3451
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
3452
			"<classpath>\n" + 
3453
			"	<classpathentry kind=\"src\" path=\"src2\"/>\n" + 
3454
			"	<classpathentry kind=\"src\" unknownattribute=\"abcde\" path=\"src1\">\n" + 
3455
			"		<unknown1>\n" +
3456
			"			<test kind=\"1\"/>\n" +
3457
			"			<test kind=\"2\"/>\n" +
3458
			"		</unknown1>\n" +
3459
			"		<unknown2 attribute2=\"\">\n" +
3460
			"			<test>\n" +
3461
			"				<other a=\"b\"/>\n" +
3462
			"			</test>\n" +
3463
			"		</unknown2>\n" +
3464
			"	</classpathentry>\n" +
3465
			"	<classpathentry kind=\"output\" path=\"bin\"/>\n" + 
3466
			"</classpath>\n",
3467
			contents);		
3468
	} finally {
3469
		deleteProject("P");
3470
	}
3471
}
3472
3325
/**
3473
/**
3326
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
3474
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
3327
 * Check that Assert.AssertionFailedException exception is well catched
3475
 * Check that Assert.AssertionFailedException exception is well catched

Return to bug 101425