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

Collapse All | Expand All

(-)src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java (+62 lines)
Lines 11-22 Link Here
11
11
12
package org.eclipse.jdt.apt.pluggable.tests;
12
package org.eclipse.jdt.apt.pluggable.tests;
13
13
14
import java.util.Map;
15
14
import junit.framework.Test;
16
import junit.framework.Test;
15
import junit.framework.TestSuite;
17
import junit.framework.TestSuite;
16
18
19
import org.eclipse.core.resources.IMarker;
17
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
23
import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
24
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
18
import org.eclipse.jdt.apt.core.util.AptConfig;
25
import org.eclipse.jdt.apt.core.util.AptConfig;
19
import org.eclipse.jdt.core.IJavaProject;
26
import org.eclipse.jdt.core.IJavaProject;
27
import org.eclipse.jdt.core.compiler.CategorizedProblem;
28
import org.eclipse.jdt.core.tests.builder.Problem;
20
29
21
/**
30
/**
22
 * Basic tests for the Filer interface in the IDE.
31
 * Basic tests for the Filer interface in the IDE.
Lines 78-81 Link Here
78
		expectingNoFile( proj, ".apt_generated/summary.txt" );
87
		expectingNoFile( proj, ".apt_generated/summary.txt" );
79
	}
88
	}
80
89
90
	/**
91
	 * Test generation of a source file that is referenced by the parent, using the GenClass6 annotation
92
	 * @see javax.annotation.processing.Filer#createSourceFile(CharSequence, javax.lang.model.element.Element...)
93
	 */
94
	public void testCreateSourceFileWithGenReference() throws Throwable
95
	{
96
		// Temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=201931
97
		// Bail out on Linux
98
		String osName = System.getProperty("os.name");
99
		if (null == osName || !osName.contains("Windows")) {
100
			return;
101
		}
102
103
		IJavaProject jproj = createJavaProject(_projectName);
104
		IProject proj = jproj.getProject();
105
		IdeTestUtils.copyResources(proj, "targets/filer02a", "src/targets/filer");
106
		
107
		// Make sure that there are no Java 5 processors on the factory path - see comment below.
108
		FactoryPath fp = (FactoryPath) AptConfig.getFactoryPath(jproj);
109
		for (Map.Entry<FactoryContainer, FactoryPath.Attributes> entry : fp.getAllContainers().entrySet()) {
110
			if (entry.getKey().getType() == FactoryType.PLUGIN) {
111
				String id = entry.getKey().getId();
112
				if (!Apt6TestsPlugin.PLUGIN_ID.equals(id)) {
113
					fp.disablePlugin(id);
114
				}
115
			}
116
		}
117
		AptConfig.setFactoryPath(jproj, fp);
118
		AptConfig.setEnabled(jproj, true);
119
		fullBuild();
120
		expectingNoProblems();
121
		
122
		// Check whether generated sources were generated and compiled
123
		expectingFile(proj, ".apt_generated/gen6/Generated02.java");
124
		final String[] expectedClasses = { "targets.filer.Parent02", "gen6.Generated02" };
125
		expectingUniqueCompiledClasses(expectedClasses);
126
		
127
		// Modify target file to change name of generated file and incrementally rebuild; 
128
		// generated file should be deleted.
129
		IdeTestUtils.copyResources(proj, "targets/filer02b", "src/targets/filer");
130
		incrementalBuild();
131
		
132
		IPath parentPath = proj.getFullPath().append("src/targets/filer/Parent02.java");
133
		expectingOnlySpecificProblemFor(parentPath, new Problem("Parent02", "gen6.Generated02 cannot be resolved to a type", parentPath, 842, 858, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR));
134
		
135
		// This test only works if there are no Java 5 processors (e.g., apt.tests plugin) in the factory path.
136
		// If Java 5 processors are present, then gen6.Generated02 will also be recompiled, before it's deleted.
137
		final String[] expectedClasses2 = { "gen6.XxxGenerated02", "targets.filer.Parent02" };
138
		expectingUniqueCompiledClasses(expectedClasses2);
139
140
		expectingNoFile(proj, ".apt_generated/gen6/Generated02.java");
141
	}
142
81
}
143
}
(-)resources/targets/filer02a/Parent02.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 BEA Systems, 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
 *    wharley@bea.com - initial API and implementation
10
 *******************************************************************************/
11
12
package targets.filer;
13
14
import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
15
16
/**
17
 * Processing this class should result in creation of a source file,
18
 * thereby allowing this class to compile
19
 */
20
@GenClass6(name="Generated02", pkg="gen6")
21
public class Parent02 {
22
	gen6.Generated02 _gen;
23
}
24
25
26
(-)resources/targets/filer02b/Parent02.java (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 BEA Systems, 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
 *    wharley@bea.com - initial API and implementation
10
 *******************************************************************************/
11
12
package targets.filer;
13
14
import org.eclipse.jdt.apt.pluggable.tests.annotations.GenClass6;
15
16
/**
17
 * Processing this class should result in removal of the previously
18
 * generated type and creation of a new one, resulting in a compilation error.
19
 */
20
@GenClass6(name="XxxGenerated02", pkg="gen6")
21
public class Parent02 {
22
	gen6.Generated02 _gen;
23
}
24

Return to bug 203454