Author: dazarov
Date: 2010-05-24 08:46:25 -0400 (Mon, 24 May 2010)
New Revision: 22278
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointInProducerMethodHyperlinkDetectorTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java
Log:
https://jira.jboss.org/browse/JBIDE-6311
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java 2010-05-24
12:46:25 UTC (rev 22278)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation.producer.method;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+
+
+/**
+ * @author pmuir
+ *
+ */
+public class CustomProducerImpl implements Producer
+{
+
+ private static boolean disposedCorrectly = false;
+
+ /**
+ * @param log the log to set
+ */
+ public static void reset()
+ {
+ disposedCorrectly = false;
+ }
+
+ @Produces
+ public Foo produce()
+ {
+ return new Foo("foo!");
+ }
+
+ @Produces
+ public Foo produce2((a)New(Foo.class) Foo order)
+ {
+ return new Foo("foo!");
+ }
+
+ public void dispose(@Disposes Foo foo)
+ {
+ disposedCorrectly = foo.getFoo().equals("decorated");
+ }
+
+ /**
+ * @return the disposedCorrectly
+ */
+ public static boolean isDisposedCorrectly()
+ {
+ return disposedCorrectly;
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java 2010-05-24
12:39:33 UTC (rev 22277)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java 2010-05-24
12:46:25 UTC (rev 22278)
@@ -9,6 +9,7 @@
TestSuite suite = new TestSuite(CdiTextExtAllTests.class.getName());
suite.addTest(InjectedPointHyperlinkDetectorTest.suite());
suite.addTest(ProducerDisposerHyperlinkDetectorTest.suite());
+ suite.addTest(InjectedPointInProducerMethodHyperlinkDetectorTest.suite());
return suite;
}
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointInProducerMethodHyperlinkDetectorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointInProducerMethodHyperlinkDetectorTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointInProducerMethodHyperlinkDetectorTest.java 2010-05-24
12:46:25 UTC (rev 22278)
@@ -0,0 +1,110 @@
+package org.jboss.tools.cdi.text.ext.test;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlinkDetector;
+
+public class InjectedPointInProducerMethodHyperlinkDetectorTest extends
HyperlinkDetectorTest{
+ private static final String PROJECT_NAME =
"/tests/decorators/invocation/producer/method";
+ private static final String FILE_NAME =
"JavaSource/org/jboss/jsr299/tck/tests/decorators/invocation/producer/method/CustomProducerImpl.java";
+
+ public static Test suite() {
+ return new TestSuite(InjectedPointInProducerMethodHyperlinkDetectorTest.class);
+ }
+
+ public void testProducerDisposerHyperlinkDetector() throws Exception {
+ IProject project = TCKTest.importPreparedProject(PROJECT_NAME);
+ doTest(project);
+ TCKTest.cleanProject(PROJECT_NAME);
+ }
+
+ private void doTest(IProject project) throws Exception {
+ IFile javaFile = project.getFile(FILE_NAME);
+
+ TCKTest.assertTrue("The file \"" + FILE_NAME + "\" is not
found", (javaFile != null));
+ TCKTest.assertTrue("The file \"" + FILE_NAME + "\" is not
found", (javaFile.exists()));
+
+ FileEditorInput editorInput = new FileEditorInput(javaFile);
+
+ IDocumentProvider documentProvider = null;
+ Throwable exception = null;
+ try {
+ documentProvider =
DocumentProviderRegistry.getDefault().getDocumentProvider(editorInput);
+ } catch (Exception x) {
+ exception = x;
+ x.printStackTrace();
+ }
+ assertNull("An exception caught: " + (exception != null?
exception.getMessage() : ""), exception);
+
+ assertNotNull("The document provider for the file \"" + FILE_NAME +
"\" is not loaded", documentProvider);
+
+ try {
+ documentProvider.connect(editorInput);
+ } catch (Exception x) {
+ exception = x;
+ x.printStackTrace();
+ assertTrue("The document provider is not able to be initialized with the editor
input", false);
+ }
+ assertNull("An exception caught: " + (exception != null?
exception.getMessage() : ""), exception);
+
+ IDocument document = documentProvider.getDocument(editorInput);
+
+ assertNotNull("The document for the file \"" + FILE_NAME + "\"
is not loaded", document);
+
+ InjectedPointHyperlinkDetector elPartitioner = new InjectedPointHyperlinkDetector();
+
+ ArrayList<Region> regionList = new ArrayList<Region>();
+ regionList.add(new Region(1374, 5)); // order
+ regionList.add(new Region(1462, 3));
+ regionList.add(new Region(1498, 3));
+
+ IEditorPart part = openFileInEditor(javaFile);
+ ISourceViewer viewer = null;
+ if(part instanceof JavaEditor){
+ viewer = ((JavaEditor)part).getViewer();
+ }
+
+ elPartitioner.setContext(new TestContext((ITextEditor)part));
+
+ int counter = 0;
+ for (int i = 0; i < document.getLength(); i++) {
+ TestData testData = new TestData(document, i);
+ IHyperlink[] links = elPartitioner.detectHyperlinks(viewer,
testData.getHyperlinkRegion(), true);
+
+ boolean recognized = links != null;
+
+ if (recognized) {
+ counter++;
+ if(!findOffsetInRegions(i, regionList)){
+ fail("Wrong detection for offset - "+i);
+ }
+ } else {
+ for(Region region : regionList){
+ if(i >= region.getOffset() && i <=
region.getOffset()+region.getLength())
+ fail("Wrong detection for region - "+region.getOffset()+" :
"+region.getLength()+" region - "+i);
+ }
+ }
+ }
+
+ assertEquals("Wrong recognized region count: ", 14, counter);
+
+ documentProvider.disconnect(editorInput);
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointInProducerMethodHyperlinkDetectorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain