Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cdi/plugins/org.jboss.tools.cdi.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
class="org.jboss.tools.cdi.internal.core.project.facet.CDIFacetUninstallDelegate">
</delegate>
</action>

<action facet="jst.cdi" type="version-change">
<delegate class="org.jboss.tools.cdi.internal.core.project.facet.CDIFacetVersionChangeDelegate"/>
</action>

</extension>

<extension
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2013 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.internal.core.project.facet;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;

/**
* @author Alexey Kazakov
*/
public class CDIFacetVersionChangeDelegate implements IDelegate {

/* (non-Javadoc)
* @see org.eclipse.wst.common.project.facet.core.IDelegate#execute(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacetVersion, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
// Do nothing special. It's enough just to change the facet version for CDI projects.
}
}
6 changes: 5 additions & 1 deletion cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Require-Bundle: org.jboss.tools.tests,
org.eclipse.wst.common.frameworks;bundle-version="1.2.0",
org.jboss.tools.common.validation,
org.jboss.tools.common.base.test,
org.apache.ant;bundle-version="1.8.4"
org.apache.ant;bundle-version="1.8.4",
org.eclipse.wst.common.project.facet.core,
org.eclipse.jst.j2ee,
org.eclipse.jst.jsf.core,
org.eclipse.jst.common.project.facet.core
Export-Package: org.jboss.tools.cdi.core.test,
org.jboss.tools.cdi.core.test.extension,
org.jboss.tools.cdi.core.test.tck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jboss.tools.cdi.core.test.extension.ExtensionManagerTest;
import org.jboss.tools.cdi.core.test.extension.ExtensionsInSrsAndUsedProjectTest;
import org.jboss.tools.cdi.core.test.extension.SystemExtensionTest;
import org.jboss.tools.cdi.core.test.project.CDIFacetTest;
import org.jboss.tools.cdi.core.test.project.EnableCDISupportForJarTest;
import org.jboss.tools.cdi.core.test.project.EnableCDISupportForWarTest;
import org.jboss.tools.cdi.core.test.tck.AssignabilityOfRawAndParameterizedTypesTest;
Expand Down Expand Up @@ -235,6 +236,7 @@ public static Test suite() {
suiteAll.addTest(dependent);
suiteAll.addTestSuite(EnableCDISupportForWarTest.class);
suiteAll.addTestSuite(EnableCDISupportForJarTest.class);
suiteAll.addTestSuite(CDIFacetTest.class);
suiteAll.addTestSuite(DependentProjectValidationTest.class);
TestSuite weldSuite = new TestSuite("Weld Tests");
weldSuite.addTestSuite(BuiltInContextBeanInjectionWeldTest.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2013 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.core.test.project;

import java.util.HashSet;
import java.util.Set;

import junit.framework.TestCase;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jst.common.project.facet.core.JavaFacet;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.jst.jsf.core.IJSFCoreConstants;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.cdi.internal.core.project.facet.CDIFacetInstallDelegate;

/**
* @author Alexey Kazakov
*/
public class CDIFacetTest extends TestCase {

public void testCDI10Actions() {
assertActions(CDIFacetInstallDelegate.CDI_10);
}

public void testCDI11Actions() {
assertActions(CDIFacetInstallDelegate.CDI_11);
}

private void assertActions(IProjectFacetVersion cdiVersion) {
IProjectFacet jsfFacet = ProjectFacetsManager.getProjectFacet(IJSFCoreConstants.JSF_CORE_FACET_ID);
IProjectFacetVersion jsfVersion = jsfFacet.getVersion(IJSFCoreConstants.FACET_VERSION_2_0);

Set<IProjectFacetVersion> vs = new HashSet<IProjectFacetVersion>();
vs.add(JavaFacet.VERSION_1_7);
vs.add(IJ2EEFacetConstants.DYNAMIC_WEB_30);
vs.add(jsfVersion);

Set<IFacetedProject.Action> actions = new HashSet<Action>();
actions.add(new Action(IFacetedProject.Action.Type.INSTALL, cdiVersion, null));

IStatus status = ProjectFacetsManager.check(vs, actions);
assertTrue(status.getMessage(), status.isOK());

vs.add(cdiVersion);
actions.clear();
actions.add(new Action(IFacetedProject.Action.Type.UNINSTALL, cdiVersion, null));

status = ProjectFacetsManager.check(vs, actions);
assertTrue(status.getMessage(), status.isOK());

actions.clear();
actions.add(new Action(IFacetedProject.Action.Type.VERSION_CHANGE, cdiVersion, null));
status = ProjectFacetsManager.check(vs, actions);
assertTrue(status.getMessage(), status.isOK());
}
}