Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBIDE-23862 Enable CDI support when beans xml is created and cdi lib …
…is in build path Signed-off-by: Rastislav Wagner <rawagner@redhat.com>
- Loading branch information
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITestCDISupportNotEnabled/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="lib/cdi-api-1.0.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
22 changes: 22 additions & 0 deletions
22
cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITestCDISupportNotEnabled/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>CDITestCDISupportNotEnabled</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.wst.validation.validationbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
12 changes: 12 additions & 0 deletions
12
...s.cdi.core.test/projects/CDITestCDISupportNotEnabled/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Thu Sep 02 19:40:42 MSD 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
Binary file added
BIN
+43.9 KB
...ts/org.jboss.tools.cdi.core.test/projects/CDITestCDISupportNotEnabled/lib/cdi-api-1.0.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...ols.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewBeansXMLCreationWizardTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is 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: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.cdi.ui.test.wizard; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.jface.viewers.StructuredSelection; | ||
import org.eclipse.jface.wizard.WizardDialog; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.jboss.tools.cdi.core.CDICoreNature; | ||
import org.jboss.tools.cdi.core.CDIVersion; | ||
import org.jboss.tools.cdi.ui.wizard.NewBeansXMLCreationWizard; | ||
import org.jboss.tools.test.util.JobUtils; | ||
import org.jboss.tools.test.util.ResourcesUtils; | ||
import org.jboss.tools.test.util.WorkbenchUtils; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class NewBeansXMLCreationWizardTest extends TestCase{ | ||
|
||
static NewBeansXMLCreationWizard wizard; | ||
static WizardDialog dialog; | ||
static IProject project; | ||
static IProject projectWithoutCDI; | ||
|
||
protected void setUp() throws Exception { | ||
project = ResourcesUtils.importProject("org.jboss.tools.cdi.core.test", "/projects/CDITestCDISupportNotEnabled"); | ||
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); | ||
|
||
projectWithoutCDI = ResourcesUtils.importProject("org.jboss.tools.cdi.core.test", "/projects/FacetedProject"); | ||
projectWithoutCDI.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); | ||
JobUtils.waitForIdle(); | ||
} | ||
|
||
protected void tearDown() throws CoreException { | ||
if(project != null) { | ||
project.delete(true, true, new NullProgressMonitor()); | ||
} | ||
if(projectWithoutCDI != null) { | ||
projectWithoutCDI.delete(true, true, new NullProgressMonitor()); | ||
} | ||
if(dialog != null) { | ||
dialog.close(); | ||
} | ||
} | ||
|
||
private static void cleanDefferedEvents() { | ||
while (Display.getCurrent().readAndDispatch()); | ||
} | ||
|
||
public void testCreateBeansXMLAndEnableCDI() throws CoreException { | ||
assertNull(project.getNature(CDICoreNature.NATURE_ID)); | ||
openWizard(project); | ||
wizard.setVersion(CDIVersion.CDI_1_0); | ||
wizard.performFinish(); | ||
assertNotNull(project.getNature(CDICoreNature.NATURE_ID)); | ||
} | ||
|
||
//CDI support should not be enabled | ||
public void testCreateBeansXMLNoCDIDependency() throws CoreException { | ||
assertNull(projectWithoutCDI.getNature(CDICoreNature.NATURE_ID)); | ||
openWizard(projectWithoutCDI); | ||
wizard.setVersion(CDIVersion.CDI_1_0); | ||
wizard.performFinish(); | ||
assertNull(projectWithoutCDI.getNature(CDICoreNature.NATURE_ID)); | ||
} | ||
|
||
private void openWizard(IProject project) { | ||
wizard= (NewBeansXMLCreationWizard)WorkbenchUtils.findWizardByDefId(NewBeansXMLCreationWizard.WIZARD_ID); | ||
wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(project)); | ||
|
||
dialog = new WizardDialog( | ||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), | ||
wizard); | ||
dialog.create(); | ||
dialog.setBlockOnOpen(false); | ||
dialog.open(); | ||
cleanDefferedEvents(); | ||
} | ||
|
||
} |