View | Details | Raw Unified | Return to bug 71761
Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ImportRewriteTest.java (+42 lines)
Lines 1539-1542 Link Here
1539
		compilationUnit.getBuffer().setContents(document.get());
1539
		compilationUnit.getBuffer().setContents(document.get());
1540
	}
1540
	}
1541
1541
1542
	public void testBug71761() throws Exception {
1543
1544
		IPackageFragment pack1= this.sourceFolder.createPackageFragment("pack1", false, null);
1545
		StringBuffer buf= new StringBuffer();
1546
		buf.append("package pack1;\n");
1547
		buf.append("\n");
1548
		buf.append("import pack2.*;\n");
1549
		buf.append("public class C {\n");
1550
		buf.append("}\n");
1551
		ICompilationUnit cu= pack1.createCompilationUnit("C.java", buf.toString(), false, null);
1552
		
1553
		buf= new StringBuffer();
1554
		buf.append("package pack1;\n");
1555
		buf.append("\n");
1556
		buf.append("public class A {\n");
1557
		buf.append("}\n");
1558
		pack1.createCompilationUnit("A.java", buf.toString(), false, null);
1559
		
1560
		IPackageFragment pack2= this.sourceFolder.createPackageFragment("pack2", false, null);
1561
		buf= new StringBuffer();
1562
		buf.append("package pack2;\n");
1563
		buf.append("public class A {\n");
1564
		buf.append("}\n");
1565
		pack2.createCompilationUnit("A.java", buf.toString(), false, null);
1566
1567
		String[] order= new String[] { "pack2" };
1568
1569
		ImportRewrite imports= newImportsRewrite(cu, order, 99, 99, true);
1570
		imports.addImport("pack2.A");
1571
1572
		apply(imports);
1573
1574
		buf= new StringBuffer();
1575
		buf.append("package pack1;\n");
1576
		buf.append("\n");
1577
		buf.append("import pack2.*;\n");
1578
		buf.append("import pack2.A;\n");
1579
		buf.append("public class C {\n");
1580
		buf.append("}\n");
1581
		assertEqualString(cu.getSource(), buf.toString());
1582
	}
1583
1542
}
1584
}

Return to bug 71761