JBoss Tools SVN: r37893 - in trunk/openshift: tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-17 08:35:33 -0500 (Tue, 17 Jan 2012)
New Revision: 37893
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftMavenProfile.java
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftProfile.java
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftProfileTests.java
Modified:
trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java
Log:
[JBIDE-10479] renamed OpenShiftProfile to OpenShiftMavenProfile, added test for complex pom
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftMavenProfile.java (from rev 37851, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftProfile.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftMavenProfile.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftMavenProfile.java 2012-01-17 13:35:33 UTC (rev 37893)
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.wizard.appimport;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author André Dietisheim
+ */
+public class OpenShiftMavenProfile {
+
+ private static final String POM_FILENAME = "pom.xml";
+
+ private static final String ID_OPENSHIFT = "openshift";
+ private static final String ELEMENT_PROJECT = "project";
+ private static final String ELEMENT_PROFILES = "profiles";
+ private static final String ELEMENT_PROFILE = "profile";
+ private static final String ELEMENT_ID = "id";
+
+ private static final String OPENSHIFT_PROFILE =
+ "<profile>\n"
+ + "<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->\n"
+ + "<!-- Use this profile for any OpenShift specific customization your app will need. -->\n"
+ + "<!-- By default that is to put the resulting archive into the 'deployments' folder. -->\n"
+ + "<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environm... -->\n"
+ + "<id>openshift</id>\n"
+ + "<build>\n"
+ + " <finalName>{0}</finalName>\n"
+ + " <plugins>\n"
+ + " <plugin>\n"
+ + " <artifactId>maven-war-plugin</artifactId>\n"
+ + " <version>2.1.1</version>\n"
+ + " <configuration>\n"
+ + " <outputDirectory>deployments</outputDirectory>\n"
+ + " <warName>ROOT</warName>\n"
+ + " </configuration>\n"
+ + " </plugin>\n"
+ + " </plugins>\n"
+ + " </build>\n"
+ + "</profile>\n";
+
+ private IFile pomFile;
+ private String pluginId;
+ private Document document;
+
+ public OpenShiftMavenProfile(IProject project, String pluginId) {
+ this(project.getFile(POM_FILENAME), pluginId);
+ }
+
+ /**
+ * Creates an openshift profile that will allow you to deal with the
+ * openshift profile in a given pom.
+ *
+ * @param pomFile
+ * @param pluginId
+ */
+ public OpenShiftMavenProfile(IFile pomFile, String pluginId) {
+ this.pomFile = pomFile;
+ this.pluginId = pluginId;
+ }
+
+ /**
+ * Checks the pom (that was given at constructin time) for presence of the
+ * OpenShift profile. Returns <code>true</code> if this pom has the
+ * OpenShift profile, <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the pom has the openshift profile.
+ * @throws CoreException
+ */
+ public boolean existsInPom() throws CoreException {
+ if (!exists(pomFile)) {
+ return false;
+ }
+
+ Element openShiftProfileElement = getOpenShiftProfileElement(getDocument());
+ return openShiftProfileElement != null;
+ }
+
+ /**
+ * Adds the openshift profile to the pom this is instance is bound to.
+ * Returns <code>true</code> if it was added, <code>false</code> otherwise.
+ *
+ * @return true if the profile was added to the pom this instance is bound
+ * to.
+ * @throws CoreException
+ */
+ public boolean addToPom(String finalName) throws CoreException {
+ try {
+ if (existsInPom()) {
+ return false;
+ }
+ Document document = getDocument();
+ Element profilesElement = getOrCreateProfilesElement(document);
+ Node profileNode = document.importNode(createOpenShiftProfileElement(finalName), true);
+ profilesElement.appendChild(profileNode);
+ return true;
+ } catch (SAXException e) {
+ throw new CoreException(createStatus(e));
+ } catch (IOException e) {
+ throw new CoreException(createStatus(e));
+ } catch (ParserConfigurationException e) {
+ throw new CoreException(createStatus(e));
+ }
+ }
+
+ private Element createOpenShiftProfileElement(String finalName) throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ String openShiftProfile = MessageFormat.format(OPENSHIFT_PROFILE, finalName);
+ Document document = documentBuilder.parse(new ByteArrayInputStream(openShiftProfile.getBytes()));
+ return document.getDocumentElement();
+ }
+
+ private Element getOrCreateProfilesElement(Document document) throws CoreException {
+ Element profilesElement = getProfilesElement(document);
+ if (profilesElement == null) {
+ profilesElement = createProfilesElement(document);
+ }
+ return profilesElement;
+ }
+
+ private Element createProfilesElement(Document document) throws CoreException {
+ Element profilesElement;
+ profilesElement = document.createElement(ELEMENT_PROFILES);
+ Element projectElement = getProjectElement(document);
+ if (projectElement == null) {
+ throw new CoreException(
+ createStatus(NLS.bind("Could not find <project> tag in pom {0}", pomFile.toString())));
+ }
+ projectElement.appendChild(profilesElement);
+ return profilesElement;
+ }
+
+ private boolean exists(IFile file) {
+ return file != null
+ && file.exists();
+ }
+
+ private Element getProfilesElement(Document document) {
+ return getFirstElement(ELEMENT_PROFILES, document);
+ }
+
+ private Element getProjectElement(Document document) {
+ return getFirstElement(ELEMENT_PROJECT, document);
+ }
+
+ private Element getOpenShiftProfileElement(Document document) {
+ return getOpenShiftProfileElement(getProfilesElement(document));
+ }
+
+ private Element getOpenShiftProfileElement(Element element) {
+ Element openshiftProfile = getFirstElementByMatcher(ELEMENT_PROFILE, new IMatcher() {
+
+ @Override
+ public boolean isMatch(Element element) {
+ if (element == null) {
+ return false;
+ }
+
+ Element idElement = getFirstElement(ELEMENT_ID, element);
+ if (idElement == null) {
+ return false;
+ }
+ if (idElement.hasChildNodes()) {
+ return ID_OPENSHIFT.equals(idElement.getFirstChild().getTextContent());
+ }
+ return false;
+ }
+ }, element);
+ return openshiftProfile;
+ }
+
+ private Element getFirstElement(String elementName, Document document) {
+ NodeList elements = document.getElementsByTagName(elementName);
+ if (elements != null
+ && elements.getLength() > 0) {
+ return (Element) elements.item(0);
+ }
+ return null;
+ }
+
+ protected Element getFirstElement(String elementName, Element element) {
+ NodeList children = element.getElementsByTagName(elementName);
+ if (children == null
+ || children.getLength() == 0) {
+ return null;
+ }
+ return (Element) children.item(0);
+ }
+
+ protected Element getFirstElementByMatcher(String elementName, IMatcher matcher, Element element) {
+ if (element == null) {
+ return null;
+ }
+
+ NodeList children = element.getElementsByTagName(elementName);
+ if (children == null
+ || children.getLength() == 0) {
+ return null;
+ }
+ for (int i = 0; i < children.getLength(); i++) {
+ Element child = (Element) children.item(i);
+ if (matcher.isMatch(child)) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ private Document getDocument() throws CoreException {
+ return getDocument(pomFile);
+ }
+
+ private Document getDocument(IFile file) throws CoreException {
+ return getDocument(file.getContents());
+ }
+
+ private Document getDocument(InputStream inputStream) throws CoreException {
+ try {
+ if (document == null) {
+ DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ this.document = documentBuilder.parse(inputStream);
+ }
+ return document;
+ } catch (ParserConfigurationException e) {
+ throw new CoreException(createStatus(e));
+ } catch (SAXException e) {
+ throw new CoreException(createStatus(e));
+ } catch (IOException e) {
+ throw new CoreException(createStatus(e));
+ }
+ }
+
+ private interface IMatcher {
+ public boolean isMatch(Element element);
+ }
+
+ private IStatus createStatus(Throwable e) {
+ return new Status(IStatus.ERROR, pluginId, e.getMessage(), e);
+ }
+
+ private IStatus createStatus(String message) {
+ return new Status(IStatus.ERROR, pluginId, message);
+ }
+
+ public void savePom() throws CoreException {
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ transformerFactory.setAttribute("indent-number", new Integer(4));
+
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+
+ Result out =
+ new StreamResult(
+ new OutputStreamWriter(new FileOutputStream(pomFile.getLocation().toString()), "UTF-8"));
+ transformer.transform(new DOMSource(getDocument()), out);
+ } catch (TransformerConfigurationException e) {
+ throw new CoreException(createStatus(e));
+ } catch (UnsupportedEncodingException e) {
+ throw new CoreException(createStatus(e));
+ } catch (TransformerException e) {
+ throw new CoreException(createStatus(e));
+ } catch (FileNotFoundException e) {
+ throw new CoreException(createStatus(e));
+ }
+ }
+
+ public static boolean isMavenProject(IProject project) {
+ return project.getFile(POM_FILENAME).exists();
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftMavenProfile.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftProfile.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftProfile.java 2012-01-17 13:08:45 UTC (rev 37892)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/OpenShiftProfile.java 2012-01-17 13:35:33 UTC (rev 37893)
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.openshift.express.internal.ui.wizard.appimport;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.text.MessageFormat;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * @author André Dietisheim
- */
-public class OpenShiftProfile {
-
- private static final String ID_OPENSHIFT = "openshift";
- private static final String ELEMENT_PROJECT = "project";
- private static final String ELEMENT_PROFILES = "profiles";
- private static final String ELEMENT_PROFILE = "profile";
- private static final String ELEMENT_ID = "id";
-
- private static final String OPENSHIFT_PROFILE =
- "<profile>\n"
- + "<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->\n"
- + "<!-- Use this profile for any OpenShift specific customization your app will need. -->\n"
- + "<!-- By default that is to put the resulting archive into the 'deployments' folder. -->\n"
- + "<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environm... -->\n"
- + "<id>openshift</id>\n"
- + "<build>\n"
- + " <finalName>{0}</finalName>\n"
- + " <plugins>\n"
- + " <plugin>\n"
- + " <artifactId>maven-war-plugin</artifactId>\n"
- + " <version>2.1.1</version>\n"
- + " <configuration>\n"
- + " <outputDirectory>deployments</outputDirectory>\n"
- + " <warName>ROOT</warName>\n"
- + " </configuration>\n"
- + " </plugin>\n"
- + " </plugins>\n"
- + " </build>\n"
- + "</profile>\n";
-
- private IFile pomFile;
- private String pluginId;
- private Document document;
-
- /**
- * Creates an openshift profile that will allow you to deal with the
- * openshift profile in a given pom.
- *
- * @param pomFile
- * @param pluginId
- */
- public OpenShiftProfile(IFile pomFile, String pluginId) {
- this.pomFile = pomFile;
- this.pluginId = pluginId;
- }
-
- /**
- * Checks the pom (that was given at constructin time) for presence of the
- * OpenShift profile. Returns <code>true</code> if this pom has the
- * OpenShift profile, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the pom has the openshift profile.
- * @throws CoreException
- */
- public boolean existsInPom() throws CoreException {
- if (!exists(pomFile)) {
- return false;
- }
-
- Element openShiftProfileElement = getOpenShiftProfileElement(getDocument());
- return openShiftProfileElement != null;
- }
-
- /**
- * Adds the openshift profile to the pom this is instance is bound to.
- * Returns <code>true</code> if it was added, <code>false</code> otherwise.
- *
- * @return true if the profile was added to the pom this instance is bound
- * to.
- * @throws CoreException
- */
- public boolean addToPom(String finalName) throws CoreException {
- try {
- if (existsInPom()) {
- return false;
- }
- Document document = getDocument();
- Element profilesElement = getOrCreateProfilesElement(document);
- Node profileNode = document.importNode(createOpenShiftProfileElement(finalName), true);
- profilesElement.appendChild(profileNode);
- return true;
- } catch (SAXException e) {
- throw new CoreException(createStatus(e));
- } catch (IOException e) {
- throw new CoreException(createStatus(e));
- } catch (ParserConfigurationException e) {
- throw new CoreException(createStatus(e));
- }
- }
-
- private Element createOpenShiftProfileElement(String finalName) throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- String openShiftProfile = MessageFormat.format(OPENSHIFT_PROFILE, finalName);
- Document document = documentBuilder.parse(new ByteArrayInputStream(openShiftProfile.getBytes()));
- return document.getDocumentElement();
- }
-
- private Element getOrCreateProfilesElement(Document document) throws CoreException {
- Element profilesElement = getProfilesElement(document);
- if (profilesElement == null) {
- profilesElement = createProfilesElement(document);
- }
- return profilesElement;
- }
-
- private Element createProfilesElement(Document document) throws CoreException {
- Element profilesElement;
- profilesElement = document.createElement(ELEMENT_PROFILES);
- Element projectElement = getProjectElement(document);
- if (projectElement == null) {
- throw new CoreException(
- createStatus(NLS.bind("Could not find <project> tag in pom {0}", pomFile.toString())));
- }
- projectElement.appendChild(profilesElement);
- return profilesElement;
- }
-
- private boolean exists(IFile file) {
- return file != null
- && file.exists();
- }
-
- private Element getProfilesElement(Document document) {
- return getFirstElement(ELEMENT_PROFILES, document);
- }
-
- private Element getProjectElement(Document document) {
- return getFirstElement(ELEMENT_PROJECT, document);
- }
-
- private Element getOpenShiftProfileElement(Document document) {
- return getOpenShiftProfileElement(getProfilesElement(document));
- }
-
- private Element getOpenShiftProfileElement(Element element) {
- Element openshiftProfile = getFirstElementByMatcher(ELEMENT_PROFILE, new IMatcher() {
-
- @Override
- public boolean isMatch(Element element) {
- if (element == null) {
- return false;
- }
-
- Element idElement = getFirstElement(ELEMENT_ID, element);
- if (idElement == null) {
- return false;
- }
- if (idElement.hasChildNodes()) {
- return ID_OPENSHIFT.equals(idElement.getFirstChild().getTextContent());
- }
- return false;
- }
- }, element);
- return openshiftProfile;
- }
-
- private Element getFirstElement(String elementName, Document document) {
- NodeList elements = document.getElementsByTagName(elementName);
- if (elements != null
- && elements.getLength() > 0) {
- return (Element) elements.item(0);
- }
- return null;
- }
-
- protected Element getFirstElement(String elementName, Element element) {
- NodeList children = element.getElementsByTagName(elementName);
- if (children == null
- || children.getLength() == 0) {
- return null;
- }
- return (Element) children.item(0);
- }
-
- protected Element getFirstElementByMatcher(String elementName, IMatcher matcher, Element element) {
- if (element == null) {
- return null;
- }
-
- NodeList children = element.getElementsByTagName(elementName);
- if (children == null
- || children.getLength() == 0) {
- return null;
- }
- for (int i = 0; i < children.getLength(); i++) {
- Element child = (Element) children.item(i);
- if (matcher.isMatch(child)) {
- return child;
- }
- }
- return null;
- }
-
- private Document getDocument() throws CoreException {
- return getDocument(pomFile);
- }
-
- private Document getDocument(IFile file) throws CoreException {
- return getDocument(file.getContents());
- }
-
- private Document getDocument(InputStream inputStream) throws CoreException {
- try {
- if (document == null) {
- DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- this.document = documentBuilder.parse(inputStream);
- }
- return document;
- } catch (ParserConfigurationException e) {
- throw new CoreException(createStatus(e));
- } catch (SAXException e) {
- throw new CoreException(createStatus(e));
- } catch (IOException e) {
- throw new CoreException(createStatus(e));
- }
- }
-
- private interface IMatcher {
- public boolean isMatch(Element element);
- }
-
- private IStatus createStatus(Throwable e) {
- return new Status(IStatus.ERROR, pluginId, e.getMessage(), e);
- }
-
- private IStatus createStatus(String message) {
- return new Status(IStatus.ERROR, pluginId, message);
- }
-
- public void savePom() throws CoreException {
- try {
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- transformerFactory.setAttribute("indent-number", new Integer(4));
-
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-
- Result out =
- new StreamResult(
- new OutputStreamWriter(new FileOutputStream(pomFile.getLocation().toString()), "UTF-8"));
- transformer.transform(new DOMSource(getDocument()), out);
- } catch (TransformerConfigurationException e) {
- throw new CoreException(createStatus(e));
- } catch (UnsupportedEncodingException e) {
- throw new CoreException(createStatus(e));
- } catch (TransformerException e) {
- throw new CoreException(createStatus(e));
- } catch (FileNotFoundException e) {
- throw new CoreException(createStatus(e));
- }
- }
-}
Copied: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java (from rev 37851, trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftProfileTests.java)
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java (rev 0)
+++ trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java 2012-01-17 13:35:33 UTC (rev 37893)
@@ -0,0 +1,407 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.OpenShiftMavenProfile;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class OpenShiftMavenProfileTests {
+
+ private static final String PLUGIN_ID = "org.jboss.tools.openshift.express.test";
+ private static final String POM_FILENAME = "pom.xml";
+
+ private static final String POM_WITHOUT_OPENSHIFT =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n"
+ + " <modelVersion>4.0.0</modelVersion>\n"
+ + " <groupId>org.jboss.tools.openshift.tests</groupId>\n"
+ + " <artifactId>org.jboss.tools.openshift.express.test</artifactId>\n"
+ + " <packaging>eclipse-test-plugin</packaging>\n"
+ + "</project>\n";
+
+ private static final String OPENSHIFT_PROFILE =
+ "<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->\n"
+ + "<!-- Use this profile for any OpenShift specific customization your app will need. -->\n"
+ + "<!-- By default that is to put the resulting archive into the 'deployments' folder. -->\n"
+ + "<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environm... -->\n"
+ + "<id>openshift</id>\n"
+ + "<build>\n"
+ + " <finalName>as22</finalName>\n"
+ + " <plugins>\n"
+ + " <plugin>\n"
+ + " <artifactId>maven-war-plugin</artifactId>\n"
+ + " <version>2.1.1</version>\n"
+ + " <configuration>\n"
+ + " <outputDirectory>deployments</outputDirectory>\n"
+ + " <warName>ROOT</warName>\n"
+ + " </configuration>\n"
+ + " </plugin>\n"
+ + " </plugins>\n"
+ + "</build>\n";
+
+ private static final String POM_WITH_OPENSHIFT =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n"
+ + " <modelVersion>4.0.0</modelVersion>\n"
+ + " <groupId>org.jboss.tools.openshift.tests</groupId>\n"
+ + " <artifactId>org.jboss.tools.openshift.express.test</artifactId>\n"
+ + " <packaging>eclipse-test-plugin</packaging>\n"
+ + " <profiles>\n"
+ + " <profile>\n"
+
+ + OPENSHIFT_PROFILE
+
+ + " </profile>\n"
+ + " </profiles>\n"
+ + "</project>\n";
+
+ private static final String POM_COMPLEX_WITHOUT_OPENSHIFT =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ +"<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ +" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n"
+ +"\n"
+ +" <modelVersion>4.0.0</modelVersion>\n"
+ +"\n"
+ +" <groupId>org.jboss.tools.example.richfaces</groupId>\n"
+ +" <artifactId>richfaces-webapp</artifactId>\n"
+ +" <name>RichFaces 4 Application</name>\n"
+ +" <version>0.0.1-SNAPSHOT</version>\n"
+ +" <packaging>war</packaging>\n"
+ +" <url>http://jboss.org/richfaces</url>\n"
+ +" <repositories>\n"
+ +" <!-- You should seriously consider using a repository manager or declare repositories in your settings.xml.\n"
+ +" See http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-p... -->\n"
+ +" <repository>\n"
+ +" <id>jboss-public-repository-group</id>\n"
+ +" <name>JBoss Public Maven Repository Group</name>\n"
+ +" <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>\n"
+ +" <layout>default</layout>\n"
+ +" <releases>\n"
+ +" <enabled>true</enabled>\n"
+ +" <updatePolicy>never</updatePolicy>\n"
+ +" </releases>\n"
+ +" <snapshots>\n"
+ +" <enabled>true</enabled>\n"
+ +" <updatePolicy>never</updatePolicy>\n"
+ +" </snapshots>\n"
+ +" </repository>\n"
+ +" </repositories>\n"
+ +" <pluginRepositories>\n"
+ +" <pluginRepository>\n"
+ +" <id>jboss-public-repository-group</id>\n"
+ +" <name>JBoss Public Maven Repository Group</name>\n"
+ +" <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>\n"
+ +" <layout>default</layout>\n"
+ +" <releases>\n"
+ +" <enabled>true</enabled>\n"
+ +" <updatePolicy>never</updatePolicy>\n"
+ +" </releases>\n"
+ +" <snapshots>\n"
+ +" <enabled>true</enabled>\n"
+ +" <updatePolicy>never</updatePolicy>\n"
+ +" </snapshots>\n"
+ +" </pluginRepository>\n"
+ +" </pluginRepositories>\n"
+ +"\n"
+ +" <properties>\n"
+ +" <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n"
+ +" <maven.compiler.source>1.6</maven.compiler.source>\n"
+ +" <maven.compiler.target>1.6</maven.compiler.target>\n"
+ +" <!-- Setting this property using archetype-metadata.xml requiredPorperty\n"
+ +" so that generated project uses correct version of richfaces.\n"
+ +" -->\n"
+ +" <org.richfaces.bom.version>4.1.0.Final</org.richfaces.bom.version>\n"
+ +" </properties>\n"
+ +"\n"
+ +" <build>\n"
+ +" <finalName>richfaces-webapp</finalName>\n"
+ +" <plugins>\n"
+ +" <plugin>\n"
+ +" <artifactId>maven-compiler-plugin</artifactId>\n"
+ +" <version>2.3.2</version>\n"
+ +" </plugin>\n"
+ +" <plugin>\n"
+ +" <artifactId>maven-war-plugin</artifactId>\n"
+ +" <version>2.1.1</version>\n"
+ +" </plugin>\n"
+ +" </plugins>\n"
+ +" </build>\n"
+ +"\n"
+ +" <dependencyManagement>\n"
+ +" <dependencies>\n"
+ +" <dependency>\n"
+ +" <groupId>org.richfaces</groupId>\n"
+ +" <artifactId>richfaces-bom</artifactId>\n"
+ +" <version>${org.richfaces.bom.version}</version>\n"
+ +" <scope>import</scope>\n"
+ +" <type>pom</type>\n"
+ +" </dependency>\n"
+ +" </dependencies>\n"
+ +" </dependencyManagement>\n"
+ +"\n"
+ +" <dependencies>\n"
+ +" <dependency>\n"
+ +" <groupId>org.richfaces.ui</groupId>\n"
+ +" <artifactId>richfaces-components-ui</artifactId>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>org.richfaces.core</groupId>\n"
+ +" <artifactId>richfaces-core-impl</artifactId>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.faces</groupId>\n"
+ +" <artifactId>javax.faces-api</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>org.glassfish</groupId>\n"
+ +" <artifactId>javax.faces</artifactId>\n"
+ +" <scope>compile</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.servlet</groupId>\n"
+ +" <artifactId>servlet-api</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.servlet.jsp</groupId>\n"
+ +" <artifactId>jsp-api</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.el</groupId>\n"
+ +" <artifactId>el-api</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.servlet.jsp.jstl</groupId>\n"
+ +" <artifactId>jstl-api</artifactId>\n"
+ +" </dependency>\n"
+ +"\n"
+ +" <dependency>\n"
+ +" <groupId>net.sf.ehcache</groupId>\n"
+ +" <artifactId>ehcache</artifactId>\n"
+ +" </dependency>\n"
+ +" </dependencies>\n"
+ +"\n"
+ +" <profiles>\n"
+ +" <profile>\n"
+ +" <id>jee6</id>\n"
+ +" <build>\n"
+ +" <plugins>\n"
+ +" <plugin>\n"
+ +" <artifactId>maven-war-plugin</artifactId>\n"
+ +" <configuration>\n"
+ +" <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>\n"
+ +" <classifier>jee6</classifier>\n"
+ +" </configuration>\n"
+ +" </plugin>\n"
+ +" </plugins>\n"
+ +" </build>\n"
+ +"\n"
+ +" <dependencies>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.faces</groupId>\n"
+ +" <artifactId>javax.faces-api</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>org.glassfish</groupId>\n"
+ +" <artifactId>javax.faces</artifactId>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" <dependency>\n"
+ +" <groupId>javax.transaction</groupId>\n"
+ +" <artifactId>jta</artifactId>\n"
+ +" <version>1.1</version>\n"
+ +" <scope>provided</scope>\n"
+ +" </dependency>\n"
+ +" </dependencies>\n"
+ +" </profile>\n"
+ +" <profile>\n"
+ +" <id>release</id>\n"
+ +" <build>\n"
+ +" <plugins>\n"
+ +" <plugin>\n"
+ +" <artifactId>maven-war-plugin</artifactId>\n"
+ +" <executions>\n"
+ +" <execution>\n"
+ +" <id>jee6</id>\n"
+ +" <phase>package</phase>\n"
+ +" <goals>\n"
+ +" <goal>war</goal>\n"
+ +" </goals>\n"
+ +" <configuration>\n"
+ +" <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>\n"
+ +" <classifier>jee6</classifier>\n"
+ +" <packagingExcludes>WEB-INF/lib/javax.faces*</packagingExcludes>\n"
+ +" <warSourceExcludes>WEB-INF/lib/javax.faces*</warSourceExcludes>\n"
+ +" </configuration>\n"
+ +" </execution>\n"
+ +" </executions>\n"
+ +" </plugin>\n"
+ +" </plugins>\n"
+ +" </build>\n"
+ +" </profile>\n"
+ +" </profiles>\n"
+ +"</project>\n";
+
+ private IProject nonOpenShiftProject;
+ private IFile pomWithoutOpenShiftProfile;
+ private IProject complexNonOpenShiftProject;
+ private IProject openShiftProject;
+ private IFile pomWithOpenShiftProfile;
+
+ @Test
+ public void canDetectOpenShiftProfileNotPresent() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
+ assertFalse(profile.existsInPom());
+ }
+
+ @Test
+ public void canDetectOpenShiftProfilePresent() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithOpenShiftProfile, PLUGIN_ID);
+ assertTrue(profile.existsInPom());
+ }
+
+ @Test
+ public void canDetectPomInProject() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(openShiftProject, PLUGIN_ID);
+ assertTrue(profile.existsInPom());
+ profile = new OpenShiftMavenProfile(nonOpenShiftProject, PLUGIN_ID);
+ assertFalse(profile.existsInPom());
+ }
+
+ @Test
+ public void canDetectOpenShiftProfileInComplexPom() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(complexNonOpenShiftProject, PLUGIN_ID);
+ assertFalse(profile.existsInPom());
+ }
+
+ @Test
+ public void canAddOpenShiftProfile() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
+ boolean added = profile.addToPom(nonOpenShiftProject.getName());
+ assertTrue(added);
+ }
+
+ @Test
+ public void pomHasOpenShiftProfileAfterAdd() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
+ profile.addToPom(nonOpenShiftProject.getName());
+ profile.savePom();
+ profile = new OpenShiftMavenProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
+ assertTrue(profile.existsInPom());
+ }
+
+ @Test
+ public void canAddOpenShiftProfileToComplexPom() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(complexNonOpenShiftProject, PLUGIN_ID);
+ boolean added = profile.addToPom(complexNonOpenShiftProject.getName());
+ assertTrue(added);
+ profile.savePom();
+ profile = new OpenShiftMavenProfile(complexNonOpenShiftProject, PLUGIN_ID);
+ assertTrue(profile.existsInPom());
+ }
+
+ @Test
+ public void doesNotAddOpenShiftProfileIfAlreadyPresent() throws CoreException {
+ OpenShiftMavenProfile profile = new OpenShiftMavenProfile(pomWithOpenShiftProfile, PLUGIN_ID);
+ boolean added = profile.addToPom(openShiftProject.getName());
+ assertFalse(added);
+ }
+
+ @Before
+ public void setUp() throws CoreException {
+ this.openShiftProject = createTmpProject();
+ this.pomWithOpenShiftProfile = createPomFile(POM_WITH_OPENSHIFT, openShiftProject);
+ this.complexNonOpenShiftProject = createTmpProject();
+ createPomFile(POM_COMPLEX_WITHOUT_OPENSHIFT, complexNonOpenShiftProject);
+ this.nonOpenShiftProject = createTmpProject();
+ this.pomWithoutOpenShiftProfile = createPomFile(POM_WITHOUT_OPENSHIFT, nonOpenShiftProject);
+ }
+
+ @After
+ public void tearDown() throws CoreException {
+ deleteProject(openShiftProject);
+ deleteProject(nonOpenShiftProject);
+ deleteProject(complexNonOpenShiftProject);
+ }
+
+ private void deleteProject(final IProject project) throws CoreException {
+ if (project == null
+ || !project.isAccessible()) {
+ return;
+ }
+ project.getWorkspace().run(new IWorkspaceRunnable() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ project.close(null);
+ project.delete(true, null);
+ }
+ }, null);
+ }
+
+ private IFile createPomFile(final String content, final IProject project) throws CoreException {
+ final IFile pomFile = project.getFile(POM_FILENAME);
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ pomFile.create(
+ new ByteArrayInputStream(content.getBytes())
+ , true
+ , new NullProgressMonitor());
+ pomFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ };
+ project.getWorkspace().run(runnable, new NullProgressMonitor());
+ return pomFile;
+ }
+
+ private IProject createTmpProject() throws CoreException {
+ String name = String.valueOf(System.currentTimeMillis());
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ project.create(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+ }
+ };
+ project.getWorkspace().run(runnable, new NullProgressMonitor());
+ return project;
+ }
+}
Property changes on: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftMavenProfileTests.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftProfileTests.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftProfileTests.java 2012-01-17 13:08:45 UTC (rev 37892)
+++ trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftProfileTests.java 2012-01-17 13:35:33 UTC (rev 37893)
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.openshift.express.test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.jboss.tools.openshift.express.internal.ui.wizard.appimport.OpenShiftProfile;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Andre Dietisheim
- */
-public class OpenShiftProfileTests {
-
- private static final String PLUGIN_ID = "org.jboss.tools.openshift.express.test";
-
- private static final String POM_FILENAME = "pom.xml";
-
- private static final String POM_WITHOUT_OPENSHIFT =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" "
- + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- + "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n"
- + " <modelVersion>4.0.0</modelVersion>\n"
- + " <groupId>org.jboss.tools.openshift.tests</groupId>\n"
- + " <artifactId>org.jboss.tools.openshift.express.test</artifactId>\n"
- + " <packaging>eclipse-test-plugin</packaging>\n"
- + "</project>\n";
-
- private static final String OPENSHIFT_PROFILE =
- "<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->\n"
- + "<!-- Use this profile for any OpenShift specific customization your app will need. -->\n"
- + "<!-- By default that is to put the resulting archive into the 'deployments' folder. -->\n"
- + "<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environm... -->\n"
- + "<id>openshift</id>\n"
- + "<build>\n"
- + " <finalName>as22</finalName>\n"
- + " <plugins>\n"
- + " <plugin>\n"
- + " <artifactId>maven-war-plugin</artifactId>\n"
- + " <version>2.1.1</version>\n"
- + " <configuration>\n"
- + " <outputDirectory>deployments</outputDirectory>\n"
- + " <warName>ROOT</warName>\n"
- + " </configuration>\n"
- + " </plugin>\n"
- + " </plugins>\n"
- + "</build>\n";
-
- private static final String POM_WITH_OPENSHIFT =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" "
- + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- + "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n"
- + " <modelVersion>4.0.0</modelVersion>\n"
- + " <groupId>org.jboss.tools.openshift.tests</groupId>\n"
- + " <artifactId>org.jboss.tools.openshift.express.test</artifactId>\n"
- + " <packaging>eclipse-test-plugin</packaging>\n"
- + " <profiles>\n"
- + " <profile>\n"
-
- + OPENSHIFT_PROFILE
-
- + " </profile>\n"
- + " </profiles>\n"
- + "</project>\n";
-
- private IProject nonOpenShiftProject;
- private IFile pomWithoutOpenShiftProfile;
- private IProject openShiftProject;
- private IFile pomWithOpenShiftProfile;
-
- @Before
- public void setUp() throws CoreException {
- this.openShiftProject = createTmpProject();
- this.pomWithOpenShiftProfile = createPomFile(POM_WITH_OPENSHIFT, openShiftProject);
- this.nonOpenShiftProject = createTmpProject();
- this.pomWithoutOpenShiftProfile = createPomFile(POM_WITHOUT_OPENSHIFT, nonOpenShiftProject);
- }
-
- @After
- public void tearDown() throws CoreException {
- deleteProject(openShiftProject);
- deleteProject(nonOpenShiftProject);
- }
-
- private void deleteProject(final IProject project) throws CoreException {
- if (project == null
- || !project.isAccessible()) {
- return;
- }
- project.getWorkspace().run(new IWorkspaceRunnable() {
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- project.close(null);
- project.delete(true, null);
- }
- }, null);
- }
-
- @Test
- public void canDetectOpenShiftProfileNotPresent() throws CoreException {
- OpenShiftProfile profile = new OpenShiftProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
- assertFalse(profile.existsInPom());
- }
-
- @Test
- public void canDetectOpenShiftProfilePresent() throws CoreException {
- OpenShiftProfile profile = new OpenShiftProfile(pomWithOpenShiftProfile, PLUGIN_ID);
- assertTrue(profile.existsInPom());
- }
-
- @Test
- public void canAddOpenShiftProfile() throws CoreException {
- OpenShiftProfile profile = new OpenShiftProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
- boolean added = profile.addToPom(nonOpenShiftProject.getName());
- assertTrue(added);
- }
-
- @Test
- public void pomHasOpenShiftProfileAfterAdd() throws CoreException {
- OpenShiftProfile profile = new OpenShiftProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
- profile.addToPom(nonOpenShiftProject.getName());
- profile.savePom();
- profile = new OpenShiftProfile(pomWithoutOpenShiftProfile, PLUGIN_ID);
- assertTrue(profile.existsInPom());
- }
-
- @Test
- public void doesNotAddOpenShiftProfileIfAlreadyPresent() throws CoreException {
- OpenShiftProfile profile = new OpenShiftProfile(pomWithOpenShiftProfile, PLUGIN_ID);
- boolean added = profile.addToPom(openShiftProject.getName());
- assertFalse(added);
- }
-
- private IFile createPomFile(final String content, final IProject project) throws CoreException {
- final IFile pomFile = project.getFile(POM_FILENAME);
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- pomFile.create(
- new ByteArrayInputStream(content.getBytes())
- , true
- , new NullProgressMonitor());
- pomFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
- };
- project.getWorkspace().run(runnable, new NullProgressMonitor());
- return pomFile;
- }
-
- private IProject createTmpProject() throws CoreException {
- String name = String.valueOf(System.currentTimeMillis());
- final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- project.create(new NullProgressMonitor());
- project.open(new NullProgressMonitor());
- }
- };
- project.getWorkspace().run(runnable, new NullProgressMonitor());
- return project;
- }
-}
Modified: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java 2012-01-17 13:08:45 UTC (rev 37892)
+++ trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java 2012-01-17 13:35:33 UTC (rev 37893)
@@ -16,7 +16,7 @@
@RunWith(Suite.class)
@SuiteClasses({
- OpenShiftProfileTests.class
+ OpenShiftMavenProfileTests.class
})
/**
* @author Andre Dietisheim
12 years, 12 months
JBoss Tools SVN: r37892 - trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test.
by jbosstools-commits@lists.jboss.org
Author: jpeterka
Date: 2012-01-17 08:08:45 -0500 (Tue, 17 Jan 2012)
New Revision: 37892
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/pom.xml
Log:
[hbbot] pom.xml fix
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/pom.xml
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/pom.xml 2012-01-17 09:59:38 UTC (rev 37891)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/pom.xml 2012-01-17 13:08:45 UTC (rev 37892)
@@ -22,7 +22,7 @@
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<useUIThread>false</useUIThread>
- <skip>${swt.test.skip}</skip>
+ <skip>${swtbot.test.skip}</skip>
<dependencies combine.children="append">
<dependency>
<type>p2-installable-unit</type>
12 years, 12 months
JBoss Tools SVN: r37891 - trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-01-17 04:59:38 -0500 (Tue, 17 Jan 2012)
New Revision: 37891
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsContentProvider.java
Log:
Fixing JBIDE-10655 - Unable to display project content when JAX-RS has been enabled
https://issues.jboss.org/browse/JBIDE-10655
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsContentProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsContentProvider.java 2012-01-17 09:36:24 UTC (rev 37890)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.ui/src/org/jboss/tools/ws/jaxrs/ui/cnf/UriMappingsContentProvider.java 2012-01-17 09:59:38 UTC (rev 37891)
@@ -36,8 +36,6 @@
@SuppressWarnings("restriction")
public class UriMappingsContentProvider implements ITreeContentProvider, Subscriber { // ,
- // IResourceChangeListener
- // {
private TreeViewer viewer;
@@ -64,8 +62,8 @@
buildJob.schedule();
Logger.debug("Displaying a temporary node in the viewer while the metamodel is being built...");
//return new Object[] { new WaitWhileBuildingElement() };
- //}
- //else {
+ }
+ else {
// edge case: if the metamodel was built but no category was initialized yet.
Logger.debug("Adding a UriPathTemplateCategory for project {} (case #2)", project.getName());
UriPathTemplateCategory uriPathTemplateCategory = new UriPathTemplateCategory(this, project);
12 years, 12 months
JBoss Tools SVN: r37890 - in trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate: helper and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: jpeterka
Date: 2012-01-17 04:36:24 -0500 (Tue, 17 Jan 2012)
New Revision: 37890
Added:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/ConsoleHelper.java
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java
Log:
[hbbot] bot tests update, multiple consoles fix
Added: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/ConsoleHelper.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/ConsoleHelper.java (rev 0)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/ConsoleHelper.java 2012-01-17 09:36:24 UTC (rev 37890)
@@ -0,0 +1,27 @@
+package org.jboss.tools.hibernate.helper;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+public class ConsoleHelper {
+
+ static Logger log = Logger.getLogger(ConsoleHelper.class);
+
+ public static boolean consoleExists(String console) {
+ SWTOpenExt open = new SWTOpenExt(new SWTBotExt());
+ SWTBotView view = open.viewOpen(ActionItem.View.HibernateHibernateConfigurations.LABEL);
+
+ SWTBotTreeItem[] items = view.bot().tree().getAllItems();
+
+ for (SWTBotTreeItem item : items) {
+ log.info("Console found:" + item.getText());
+ if (item.getText().equals(console)) return true;
+ }
+ return false;
+ }
+
+}
Property changes on: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/helper/ConsoleHelper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2012-01-17 08:46:57 UTC (rev 37889)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2012-01-17 09:36:24 UTC (rev 37890)
@@ -44,7 +44,9 @@
eclipse.closeView(IDELabel.View.WELCOME);
prepareProject();
- prepareConsole();
+ ConsoleTest consoleTest = new ConsoleTest();
+ consoleTest.createConsole();
+
util.waitForNonIgnoredJobs();
}
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2012-01-17 08:46:57 UTC (rev 37889)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2012-01-17 09:36:24 UTC (rev 37890)
@@ -11,9 +11,9 @@
package org.jboss.tools.hibernate.ui.bot.testcase;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.hibernate.helper.ConsoleHelper;
import org.jboss.tools.hibernate.ui.bot.test.util.DataHolder;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
import org.jboss.tools.hibernate.ui.bot.testsuite.Project;
@@ -52,7 +52,7 @@
*/
@Test
public void createConsole() {
- if (consoleCreated) return;
+ if (ConsoleHelper.consoleExists(Project.PROJECT_NAME)) return;
log.info("HB Console creation STARTED");
@@ -239,4 +239,6 @@
SWTBotTreeItem item = SWTEclipseExt.selectTreeLocation(viewBot, Project.PROJECT_NAME);
item.doubleClick();
}
+
+
}
Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java 2012-01-17 08:46:57 UTC (rev 37889)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingsDiagramTest.java 2012-01-17 09:36:24 UTC (rev 37890)
@@ -34,7 +34,8 @@
eclipse.closeView(IDELabel.View.WELCOME);
prepareProject();
- prepareConsole();
+ ConsoleTest test = new ConsoleTest();
+ test.createConsole();
util.waitForNonIgnoredJobs();
}
12 years, 12 months
JBoss Tools SVN: r37889 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2012-01-17 03:46:57 -0500 (Tue, 17 Jan 2012)
New Revision: 37889
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ExecuteQueryAction.java
Log:
https://issues.jboss.org/browse/JBIDE-10649
Build session factory in HibernateExtension instead of in ConsoleConfiguration
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ExecuteQueryAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ExecuteQueryAction.java 2012-01-17 08:16:44 UTC (rev 37888)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/ExecuteQueryAction.java 2012-01-17 08:46:57 UTC (rev 37889)
@@ -76,7 +76,7 @@
}
}
if (cfg.getHibernateExtension().hasConfiguration()) {
- cfg.buildSessionFactory();
+ cfg.getHibernateExtension().buildSessionFactory();
queryEditor.executeQuery(cfg);
}
}
12 years, 12 months
JBoss Tools SVN: r37888 - trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2012-01-17 03:16:44 -0500 (Tue, 17 Jan 2012)
New Revision: 37888
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/NewProjectPostProcessor.java
Log:
JBIDE-8911: Forge should not swallow errors
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/NewProjectPostProcessor.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/NewProjectPostProcessor.java 2012-01-17 02:55:58 UTC (rev 37887)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/NewProjectPostProcessor.java 2012-01-17 08:16:44 UTC (rev 37888)
@@ -1,8 +1,16 @@
package org.jboss.tools.forge.ui.console;
+import java.io.File;
import java.util.Map;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.jboss.tools.forge.core.process.ForgeRuntime;
import org.jboss.tools.forge.importer.ProjectImporter;
+import org.jboss.tools.forge.ui.part.ForgeView;
+import org.jboss.tools.forge.ui.util.ForgeHelper;
public class NewProjectPostProcessor implements ForgeCommandPostProcessor {
@@ -10,11 +18,56 @@
@Override
public void postProcess(Map<String, String> commandDetails) {
String projectPath = commandDetails.get("cpn");
- int index = projectPath.lastIndexOf('/');
- String projectDirName = projectPath.substring(index + 1);
- String projectBaseDirPath = projectPath.substring(0, index);
- ProjectImporter importer = new ProjectImporter(projectBaseDirPath, projectDirName);
- importer.importProject();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ String workspacePath = workspaceRoot.getLocation().toOSString();
+ if (workspacePath.equals(projectPath)) {
+ if (MessageDialog.open(
+ MessageDialog.QUESTION,
+ null,
+ "Project Import Failed",
+ "The Forge runtime created the project in the workspace root. " +
+ "Such a project cannot be imported.\n" +
+ "Do you want to remove the created artifacts?",
+ SWT.NONE)) {
+ String fileSeparator = System.getProperty("file.separator");
+ String pomPath = projectPath + fileSeparator + "pom.xml";
+ File pomFile = new File(pomPath);
+ if (pomFile.exists()) {
+ delete(pomFile);
+ }
+ String srcPath = projectPath + fileSeparator + "src";
+ File srcDir = new File(srcPath);
+ if (srcDir.exists()) {
+ delete(srcDir);
+ }
+ resetRuntime();
+ }
+ } else {
+ int index = projectPath.lastIndexOf('/');
+ String projectDirName = projectPath.substring(index + 1);
+ String projectBaseDirPath = projectPath.substring(0, index);
+ ProjectImporter importer = new ProjectImporter(projectBaseDirPath, projectDirName);
+ importer.importProject();
+ }
}
+
+ private void delete(File f) {
+ if (f.isDirectory()) {
+ for (String s : f.list()) {
+ delete(new File(f, s));
+ }
+ }
+ f.delete();
+ }
+
+ private void resetRuntime() {
+ ForgeView forgeView = ForgeHelper.getForgeView();
+ if (forgeView != null) {
+ ForgeRuntime runtime = forgeView.getRuntime();
+ if (runtime != null && ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
+ runtime.sendInput("reset\n");
+ }
+ }
+ }
}
12 years, 12 months
JBoss Tools SVN: r37887 - trunk/jbpm/docs/reference.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2012-01-16 21:55:58 -0500 (Mon, 16 Jan 2012)
New Revision: 37887
Modified:
trunk/jbpm/docs/reference/pom.xml
Log:
updated for hudson
Modified: trunk/jbpm/docs/reference/pom.xml
===================================================================
--- trunk/jbpm/docs/reference/pom.xml 2012-01-17 02:08:45 UTC (rev 37886)
+++ trunk/jbpm/docs/reference/pom.xml 2012-01-17 02:55:58 UTC (rev 37887)
@@ -27,7 +27,7 @@
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.3.3</version>
+ <version>2.3.4</version>
<extensions>true</extensions>
<configuration>
<formats>
12 years, 12 months
JBoss Tools SVN: r37886 - in trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test: src/org/jboss/tools/jsf/text/ext/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2012-01-16 21:08:45 -0500 (Mon, 16 Jan 2012)
New Revision: 37886
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java
Log:
test added for converterId attribute openon
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2012-01-17 00:45:13 UTC (rev 37885)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2012-01-17 02:08:45 UTC (rev 37886)
@@ -25,7 +25,8 @@
org.jboss.tools.jsf.ui,
org.eclipse.jst.standard.schemas,
org.jboss.tools.jst.text.ext.test;bundle-version="3.3.0",
- org.eclipse.jdt.ui;bundle-version="3.7.0"
+ org.eclipse.jdt.ui;bundle-version="3.7.0",
+ org.jboss.tools.jsf;bundle-version="3.3.0"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.jsf.text.ext.test
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java 2012-01-17 00:45:13 UTC (rev 37885)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java 2012-01-17 02:08:45 UTC (rev 37886)
@@ -3,6 +3,7 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
@@ -10,6 +11,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
+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;
@@ -19,6 +21,7 @@
import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
import org.jboss.tools.common.model.ui.editors.multipage.DefaultMultipageEditor;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
+import org.jboss.tools.jsf.jsf2.bean.model.JSF2ProjectFactory;
import org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPTagNameHyperlinkDetector;
import org.jboss.tools.jsf.text.ext.hyperlink.TLDTagHyperlink;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
@@ -36,6 +39,11 @@
project = ResourcesPlugin.getWorkspace().getRoot().getProject(
OPENON_TEST_PROJECT);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ try {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ } catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
IWorkbench workbench = PlatformUI.getWorkbench();
}
@@ -639,6 +647,30 @@
assertModelObjectSelection(links[0], "myattr");
}
+
+ public static final String CONVERTER_TEST_FILE = OPENON_TEST_PROJECT + "/WebContent/converterHiperlinkTest.jsp";
+
+ public void testConverterTagOpenOn() throws BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(CONVERTER_TEST_FILE);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+ IDocument document = jspMultyPageEditor.getSourceEditor().getTextViewer().getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ "testConverter", true, true, false, false);
+ JSF2ProjectFactory.getJSF2Project(ResourcesPlugin.getWorkspace().getRoot().getProject(OPENON_TEST_PROJECT),true);
+ JobUtils.waitForIdle();
+ IHyperlink[] links = new HyperlinkDetector().detectHyperlinks(viewer, reg, true);
+ assertNotNull(links);
+ assertTrue(links.length!=0);
+ //assertNotNull(links[0].getHyperlinkText());
+ assertNotNull(links[0].toString());
+ links[0].open();
+
+ editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+
+ // TODO: add assert for opened faces-config.xml editor with converter selected
+ }
void assertModelObjectSelection(IHyperlink link, String name) {
assertTrue(link instanceof TLDTagHyperlink);
12 years, 12 months
JBoss Tools SVN: r37885 - in trunk/cdi/tests: org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-16 19:45:13 -0500 (Mon, 16 Jan 2012)
New Revision: 37885
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleDisposers.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleObservers.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
Log:
Quick fix for "Method has more than one parameter annotated @Disposes/@Observes https://issues.jboss.org/browse/JBIDE-7670
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleDisposers.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleDisposers.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleDisposers.java 2012-01-17 00:45:13 UTC (rev 37885)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.jbt.quickfixes;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+
+public class MultipleDisposers {
+ @Produces
+ public String produce(){
+ return "";
+ }
+
+ public void dispose(@Disposes String param, @Disposes String param2, @Disposes String param3){
+
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleDisposers.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleObservers.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleObservers.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleObservers.java 2012-01-17 00:45:13 UTC (rev 37885)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.jbt.quickfixes;
+
+import javax.enterprise.event.Observes;
+
+
+public class MultipleObservers {
+ public void method(@Observes Boolean param, @Observes Boolean param2, @Observes Boolean param3){
+
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/quickfixes/MultipleObservers.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2012-01-17 00:39:08 UTC (rev 37884)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2012-01-17 00:45:13 UTC (rev 37885)
@@ -37,6 +37,7 @@
import org.jboss.tools.cdi.ui.marker.CreateCDIElementMarkerResolution;
import org.jboss.tools.cdi.ui.marker.DeleteAllDisposerDuplicantMarkerResolution;
import org.jboss.tools.cdi.ui.marker.DeleteAllInjectedConstructorsMarkerResolution;
+import org.jboss.tools.cdi.ui.marker.DeleteAllOtherAnnotationsFromParametersMarkerResolution;
import org.jboss.tools.cdi.ui.marker.DeleteAnnotationMarkerResolution;
import org.jboss.tools.cdi.ui.marker.MakeFieldStaticMarkerResolution;
import org.jboss.tools.cdi.ui.marker.MakeMethodBusinessMarkerResolution;
@@ -1026,4 +1027,26 @@
CDIValidationErrorManager.PARAM_INJECTION_DECLARES_EMPTY_NAME_ID,
AddNameMarkerResolution.class);
}
+
+ public void testDeleteAllOtherDisposerParametersResolution() throws CoreException{
+ checkResolution(tckProject,
+ new String[]{
+ "JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/MultipleDisposers.java"
+ },
+ CDICoreValidator.PROBLEM_TYPE,
+ CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME,
+ CDIValidationErrorManager.MULTIPLE_DISPOSING_PARAMETERS_ID,
+ DeleteAllOtherAnnotationsFromParametersMarkerResolution.class);
+ }
+
+ public void testDeleteAllOtherObserverParametersResolution() throws CoreException{
+ checkResolution(tckProject,
+ new String[]{
+ "JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/MultipleObservers.java"
+ },
+ CDICoreValidator.PROBLEM_TYPE,
+ CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME,
+ CDIValidationErrorManager.MULTIPLE_OBSERVING_PARAMETERS_ID,
+ DeleteAllOtherAnnotationsFromParametersMarkerResolution.class);
+ }
}
\ No newline at end of file
12 years, 12 months
JBoss Tools SVN: r37884 - trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2012-01-16 19:39:08 -0500 (Mon, 16 Jan 2012)
New Revision: 37884
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
Log:
JBIDE-10638 InvocationTargetException while importing Java EE Project from Central
Modified: trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2012-01-16 23:20:03 UTC (rev 37883)
+++ trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/ImportMavenProjectExample.java 2012-01-17 00:39:08 UTC (rev 37884)
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.project.AbstractProjectScanner;
@@ -32,6 +33,7 @@
import org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.maven.ui.Activator;
import org.jboss.tools.project.examples.ProjectExamplesActivator;
import org.jboss.tools.project.examples.model.AbstractImportProjectExample;
import org.jboss.tools.project.examples.model.Project;
@@ -113,8 +115,36 @@
});
return false;
}
-
- List<String> projectNames = importMavenProjects(destination, projectDescription, monitor);
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ boolean configureSeam = store.getBoolean(Activator.CONFIGURE_SEAM);
+ boolean configureJSF = store.getBoolean(Activator.CONFIGURE_JSF);
+ boolean configurePortlet = store.getBoolean(Activator.CONFIGURE_PORTLET);
+ boolean configureJSFPortlet = store.getBoolean(Activator.CONFIGURE_JSFPORTLET);
+ boolean configureSeamPortlet = store.getBoolean(Activator.CONFIGURE_SEAMPORTLET);
+ boolean configureCDI = store.getBoolean(Activator.CONFIGURE_CDI);
+ boolean configureHibernate = store.getBoolean(Activator.CONFIGURE_HIBERNATE);
+ boolean configureJaxRs = store.getBoolean(Activator.CONFIGURE_JAXRS);
+ List<String> projectNames;
+ try {
+ store.setValue(Activator.CONFIGURE_SEAM, false);
+ store.setValue(Activator.CONFIGURE_JSF, false);
+ store.setValue(Activator.CONFIGURE_PORTLET, false);
+ store.setValue(Activator.CONFIGURE_JSFPORTLET, false);
+ store.setValue(Activator.CONFIGURE_SEAMPORTLET, false);
+ store.setValue(Activator.CONFIGURE_CDI, false);
+ store.setValue(Activator.CONFIGURE_HIBERNATE, false);
+ store.setValue(Activator.CONFIGURE_JAXRS, false);
+ projectNames = importMavenProjects(destination, projectDescription, monitor);
+ } finally {
+ store.setValue(Activator.CONFIGURE_SEAM, configureSeam);
+ store.setValue(Activator.CONFIGURE_JSF, configureJSF);
+ store.setValue(Activator.CONFIGURE_PORTLET, configurePortlet);
+ store.setValue(Activator.CONFIGURE_JSFPORTLET, configureJSFPortlet);
+ store.setValue(Activator.CONFIGURE_SEAMPORTLET, configureSeamPortlet);
+ store.setValue(Activator.CONFIGURE_CDI, configureCDI);
+ store.setValue(Activator.CONFIGURE_HIBERNATE, configureHibernate);
+ store.setValue(Activator.CONFIGURE_JAXRS, configureJaxRs);
+ }
new OpenMavenConsoleAction().run();
List<String> includedProjects = projectDescription.getIncludedProjects();
includedProjects.clear();
12 years, 12 months