diff options
author | Harry Terkelsen | 2014-08-15 17:48:22 +0000 |
---|---|---|
committer | Harry Terkelsen | 2014-08-21 23:10:23 +0000 |
commit | a16b4bac72f18b88e0ee337c3ee2d4cf28bfb8b4 (patch) | |
tree | 384b76098b502d643606980f8c2376fcf252471d /org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java | |
parent | 65f5152e309a08bb91b2b35f96e93b2fa93bae4f (diff) | |
download | eclipse.jdt.core-a16b4bac72f18b88e0ee337c3ee2d4cf28bfb8b4.tar.gz eclipse.jdt.core-a16b4bac72f18b88e0ee337c3ee2d4cf28bfb8b4.tar.xz eclipse.jdt.core-a16b4bac72f18b88e0ee337c3ee2d4cf28bfb8b4.zip |
Bug 441790 - AnnotationValue.toString is creating incorrect and
truncated text that cannot be used in source code
Change-Id: Icdbccc0d0ca80a862f8b4b17c67c999492333478
Signed-off-by: Harry Terkelsen <het@google.com>
Diffstat (limited to 'org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java')
-rw-r--r-- | org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java new file mode 100644 index 0000000000..92989fc471 --- /dev/null +++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AnnotationValueTests.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2014 BEA Systems, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * het@google.com - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.apt.tests; + +import java.io.File; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.apt.tests.annotations.ProcessorTestStatus; +import org.eclipse.jdt.apt.tests.annotations.annotationvalue.CodeExample; +import org.eclipse.jdt.apt.tests.plugin.AptTestsPlugin; +import org.eclipse.jdt.core.IJavaProject; + +public class AnnotationValueTests extends APTTestBase { + public AnnotationValueTests(final String name) { + super(name); + } + + public static Test suite() { + return new TestSuite(AnnotationValueTests.class); + } + + private IProject setupTest() throws Exception { + // This should not be necessary, but see + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=99638 + IJavaProject jproj = getCurrentJavaProject(); + jproj.setOption("org.eclipse.jdt.core.compiler.problem.deprecation", "ignore"); + return jproj.getProject(); + } + + private void addTriggerSource() { + IPath srcRoot = getSourcePath(); + // MyTrigger.java + env.addClass(srcRoot, CodeExample.PACKAGE_TRIGGER, + CodeExample.MYTRIGGER_CLASS, + CodeExample.MYTRIGGER_CODE); + + // Trigger.java + env.addClass(srcRoot, CodeExample.PACKAGE_TRIGGER, + CodeExample.TRIGGER_CLASS, CodeExample.TRIGGER_CODE); + } + + /** + * Runs the AnnotationValueProcessor, which contains + * the actual tests + */ + public void testAnnotationValueProcessor() throws Exception { + IProject project = setupTest(); + final File jar = + TestUtil.getFileInPlugin(AptTestsPlugin.getDefault(), + new Path("/resources/question.jar")); //$NON-NLS-1$ + final String path = jar.getAbsolutePath(); + env.addExternalJar(project.getFullPath(), path); + + addTriggerSource(); + + fullBuild(project.getFullPath()); + expectingNoProblems(); + + assertTrue(ProcessorTestStatus.processorRan()); + assertEquals(ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors()); + } +} |