JBoss Tools SVN: r42691 - trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-07-24 10:02:16 -0400 (Tue, 24 Jul 2012)
New Revision: 42691
Modified:
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java
Log:
updating JUnit API (was using deprecated classes)
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java 2012-07-24 13:39:26 UTC (rev 42690)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AbstractCommonTestCase.java 2012-07-24 14:02:16 UTC (rev 42691)
@@ -29,9 +29,9 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
-import org.junit.rules.MethodRule;
-import org.junit.rules.TestWatchman;
-import org.junit.runners.model.FrameworkMethod;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,18 +67,18 @@
private ProjectSynchronizator synchronizor;
@Rule
- public MethodRule watchman = new TestWatchman() {
+ public TestRule watchman = new TestWatcher() {
@Override
- public void starting(FrameworkMethod method) {
+ public void starting(Description description) {
LOGGER.info("**********************************************************************************");
- LOGGER.info("Starting test '{}'...", method.getName());
+ LOGGER.info("Starting test '{}'...", description.getMethodName());
LOGGER.info("**********************************************************************************");
}
@Override
- public void finished(FrameworkMethod method) {
+ public void finished(Description description) {
LOGGER.info("**********************************************************************************");
- LOGGER.info("Test '{}' finished.", method.getName());
+ LOGGER.info("Test '{}' finished.", description.getMethodName());
LOGGER.info("**********************************************************************************");
}
};
13 years, 5 months
JBoss Tools SVN: r42690 - in trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test: src/org/jboss/tools/vpe/ui/bot/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2012-07-24 09:39:26 -0400 (Tue, 24 Jul 2012)
New Revision: 42690
Removed:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestLinesToggle.xml
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestToggle.xml
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/CommentTestUntoggle.xml
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/ToggleCommentTestToggle.xml
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
Log:
Fix comments within web page comparing for VPE tests.
Deleted: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestLinesToggle.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestLinesToggle.xml 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestLinesToggle.xml 2012-07-24 13:39:26 UTC (rev 42690)
@@ -1,38 +0,0 @@
-<BODY id="__content__area__" >
-<DIV style="-moz-user-modify: read-write;" >
-<DIV style="display: none; -moz-user-modify: read-only;" title="head" >
-</DIV>
-<DIV title="body" >
-<TABLE style="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;" title="f:view" >
-<TR title="f:view" >
-<TD title="f:view" >
-<DIV title="f:view" >
-<H1 style="-moz-user-modify: read-write;" title="h1" >
-<SPAN class="vpe-text" title="h:outputText value: #{Message.header}" >
-Hello Demo Application
-</SPAN>
-</H1>
-<UL style="color: red; -moz-user-modify: read-only;" title="h:messages style: color: red" >
-<LI title="h:messages style: color: red" >
-Error Messages
-</LI>
-</UL>
-<FORM style="border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="h:form id: greetingForm" >
-<SPAN class="vpe-text" title="h:outputText value: #{Message.prompt_message}" >
-Name:
-</SPAN>
-<!--
-<h:inputText value="#{user.name}" required="true">
- <f:validateLength maximum="30" minimum="3"/>
- </h:inputText>
- -->
-<INPUT type="button" title="h:commandButton action: hello value: Say Hello!" value="Say Hello!" style="-moz-user-modify: read-only;" >
-</INPUT>
-</FORM>
-</DIV>
-</TD>
-</TR>
-</TABLE>
-</DIV>
-</DIV>
-</BODY>
\ No newline at end of file
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestToggle.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestToggle.xml 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/BlockCommentTestToggle.xml 2012-07-24 13:39:26 UTC (rev 42690)
@@ -1,9 +1,9 @@
<BODY id="__content__area__" >
-<DIV style="-moz-user-modify: read-write;" >
+<DIV>
<DIV style="display: none; -moz-user-modify: read-only;" title="head" >
</DIV>
<DIV title="body" >
-<TABLE style="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;" title="f:view" >
+<TABLE style="width: 100%; border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="f:view" >
<TR title="f:view" >
<TD title="f:view" >
<DIV title="f:view" >
@@ -27,7 +27,7 @@
<INPUT value="#{user.name}" title="h:inputText value: #{user.name} required: true" >
</INPUT>
</SPAN>
-<!-- <h:commandButton action="hello" value="Say Hello!" /> -->
+<COMMENTPLACEHOLDER></COMMENTPLACEHOLDER>
</FORM>
</DIV>
</TD>
@@ -35,4 +35,4 @@
</TABLE>
</DIV>
</DIV>
-</BODY>
\ No newline at end of file
+</BODY>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/CommentTestUntoggle.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/CommentTestUntoggle.xml 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/CommentTestUntoggle.xml 2012-07-24 13:39:26 UTC (rev 42690)
@@ -1,41 +1,39 @@
-<BODY id="__content__area__" >
-<DIV style="-moz-user-modify: read-write;" >
-<DIV style="display: none; -moz-user-modify: read-only;" title="head" >
-</DIV>
-<DIV title="body" >
-<TABLE style="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;" title="f:view" >
-<TR title="f:view" >
-<TD title="f:view" >
-<DIV title="f:view" >
-<H1 style="-moz-user-modify: read-write;" title="h1" >
-<SPAN class="vpe-text" title="h:outputText value: #{Message.header}" >
-Hello Demo Application
-</SPAN>
-</H1>
-<UL style="color: red; -moz-user-modify: read-only;" title="h:messages style: color: red" >
-<LI title="h:messages style: color: red" >
-Error Messages
-</LI>
-</UL>
-<FORM style="border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="h:form id: greetingForm" >
-<SPAN class="vpe-text" title="h:outputText value: #{Message.prompt_message}" >
-Name:
-</SPAN>
-<SPAN class="vpe-text" title="h:inputText value: #{user.name} required: true" >
-<SPAN class="vpe-text" title="h:inputText value: #{user.name} required: true" >
-</SPAN>
-<INPUT value="#{user.name}" title="h:inputText value: #{user.name} required: true" >
-</INPUT>
-</SPAN>
-<INPUT type="button" title="h:commandButton action: hello value: Say Hello!" value="Say Hello!" style="border: 2px solid rgb(0, 0, 255) ! important; -moz-user-modify: read-only;" oldstyle="-moz-user-modify: read-only;" >
-</INPUT>
-</FORM>
-</DIV>
-</TD>
-</TR>
-</TABLE>
-</DIV>
-</DIV>
-<IMG vpetemporarydndelement="true" id="dragIcon" src="file:////opt/jbdevstudio4.0.0.M2/studio/eclipse/plugins/org.jboss.tools.vpe_3.2.0.v201008232021N-H413-M2/ve/dragIcon.gif" style="position: absolute; cursor: move; left: 260px ! important; top: 119px ! important;" >
-</IMG>
-</BODY>
\ No newline at end of file
+<BODY id="__content__area__" >
+<DIV>
+<DIV style="display: none; -moz-user-modify: read-only;" title="head" >
+</DIV>
+<DIV title="body" >
+<TABLE style="width: 100%; border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="f:view" >
+<TR title="f:view" >
+<TD title="f:view" >
+<DIV title="f:view" >
+<H1 style="-moz-user-modify: read-write;" title="h1" >
+<SPAN class="vpe-text" title="h:outputText value: #{Message.header}" >
+Hello Demo Application
+</SPAN>
+</H1>
+<UL style="color: red; -moz-user-modify: read-only;" title="h:messages style: color: red" >
+<LI title="h:messages style: color: red" >
+Error Messages
+</LI>
+</UL>
+<FORM style="border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="h:form id: greetingForm" >
+<SPAN class="vpe-text" title="h:outputText value: #{Message.prompt_message}" >
+Name:
+</SPAN>
+<SPAN class="vpe-text" title="h:inputText value: #{user.name} required: true" >
+<SPAN class="vpe-text" title="h:inputText value: #{user.name} required: true" >
+</SPAN>
+<INPUT value="#{user.name}" title="h:inputText value: #{user.name} required: true" >
+</INPUT>
+</SPAN>
+<INPUT type="button" title="h:commandButton action: hello value: Say Hello!" value="Say Hello!" style="-moz-user-modify: read-only;" >
+</INPUT>
+</FORM>
+</DIV>
+</TD>
+</TR>
+</TABLE>
+</DIV>
+</DIV>
+</BODY>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/ToggleCommentTestToggle.xml
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/ToggleCommentTestToggle.xml 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/resources/editor/ToggleCommentTestToggle.xml 2012-07-24 13:39:26 UTC (rev 42690)
@@ -1,9 +1,9 @@
<BODY id="__content__area__" >
-<DIV style="-moz-user-modify: read-write;" >
+<DIV>
<DIV style="display: none; -moz-user-modify: read-only;" title="head" >
</DIV>
<DIV title="body" >
-<TABLE style="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;" title="f:view" >
+<TABLE style="width: 100%; border: 1px dotted rgb(255, 102, 0); padding: 5px;" title="f:view" >
<TR title="f:view" >
<TD title="f:view" >
<DIV title="f:view" >
@@ -27,7 +27,7 @@
<INPUT value="#{user.name}" title="h:inputText value: #{user.name} required: true" >
</INPUT>
</SPAN>
-<!-- <h:commandButton action="hello" value="Say Hello!" /> -->
+<COMMENTPLACEHOLDER></COMMENTPLACEHOLDER>
</FORM>
</DIV>
</TD>
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/TestDomUtil.java 2012-07-24 13:39:26 UTC (rev 42690)
@@ -130,33 +130,20 @@
*/
public static void compareNodes(nsIDOMNode vpeNode, Node modelNode)
throws ComparisonException {
-
- if (!modelNode.getNodeName().equalsIgnoreCase(vpeNode.getNodeName())) {
- throw new ComparisonException("name of tag is \"" //$NON-NLS-1$
- + vpeNode.getNodeName() + "\"but must be \"" //$NON-NLS-1$
- + modelNode.getNodeName() + "\""); //$NON-NLS-1$
- }
if ("#comment".equals(vpeNode.getNodeName())){ //$NON-NLS-1$
- String vpeNodeValue = vpeNode.getNodeValue().trim();
- try {
- vpeNodeValue = clearStringFromSpecSymbol("\t",clearStringFromSpecSymbol("\r",vpeNodeValue));
- } catch (Exception e) {
- }
- if (modelNode.getNodeValue() != null){
- String modelNodeValue = modelNode.getNodeValue().trim();
- try {
- modelNodeValue = clearStringFromSpecSymbol("\t",clearStringFromSpecSymbol("\r" , modelNodeValue));
- } catch (Exception e) {
- }
- if (!modelNodeValue.equalsIgnoreCase(vpeNodeValue)) {
- throw new ComparisonException("value of " + vpeNode.getNodeName() //$NON-NLS-1$
- + " is\n\"" + vpeNodeValue //$NON-NLS-1$
- + "\" but must be\n\"" + modelNodeValue //$NON-NLS-1$
- + "\""); //$NON-NLS-1$
- }
- }
- } else {
+ if (!"COMMENTPLACEHOLDER".equalsIgnoreCase(modelNode.getNodeName())){
+ throw new ComparisonException("name of tag is \"" //$NON-NLS-1$
+ + vpeNode.getNodeName() + "\"but must be \"" //$NON-NLS-1$
+ + modelNode.getNodeName() + "\""); //$NON-NLS-1$
+ }
+ }
+ else {
+ if (!modelNode.getNodeName().equalsIgnoreCase(vpeNode.getNodeName())) {
+ throw new ComparisonException("name of tag is \"" //$NON-NLS-1$
+ + vpeNode.getNodeName() + "\"but must be \"" //$NON-NLS-1$
+ + modelNode.getNodeName() + "\""); //$NON-NLS-1$
+ }
if ((modelNode.getNodeValue() != null)
&& (!modelNode.getNodeValue().trim().equalsIgnoreCase(
vpeNode.getNodeValue().trim()))) {
@@ -165,63 +152,61 @@
+ "\" but must be \"" + modelNode.getNodeValue().trim() //$NON-NLS-1$
+ "\""); //$NON-NLS-1$
}
- }
- // compare node's attributes
- if (modelNode.getNodeType() == Node.ELEMENT_NODE) {
- boolean attrVpetemporarydndelementFound = false;
- if (modelNode.getNodeName().equalsIgnoreCase("IMG")){
- NamedNodeMap attrMap = modelNode.getAttributes();
- for (int index = 0 ; (!attrVpetemporarydndelementFound) && (index < attrMap.getLength()) ; index++){
- if (((Attr)attrMap.item(index)).getName().equalsIgnoreCase("vpetemporarydndelement")){
- attrVpetemporarydndelementFound = true;
- }
- }
- }
- if (!attrVpetemporarydndelementFound){
- compareAttributes(modelNode.getAttributes(), vpeNode.getAttributes());
- }
- }
+ // compare node's attributes
+ if (modelNode.getNodeType() == Node.ELEMENT_NODE) {
+ boolean attrVpetemporarydndelementFound = false;
+ if (modelNode.getNodeName().equalsIgnoreCase("IMG")){
+ NamedNodeMap attrMap = modelNode.getAttributes();
+ for (int index = 0 ; (!attrVpetemporarydndelementFound) && (index < attrMap.getLength()) ; index++){
+ if (((Attr)attrMap.item(index)).getName().equalsIgnoreCase("vpetemporarydndelement")){
+ attrVpetemporarydndelementFound = true;
+ }
+ }
+ }
+ if (!attrVpetemporarydndelementFound){
+ compareAttributes(modelNode.getAttributes(), vpeNode.getAttributes());
+ }
+ }
+ // compare children
+ nsIDOMNodeList vpeChildren = vpeNode.getChildNodes();
+ NodeList schemeChildren = modelNode.getChildNodes();
+ int realCount = 0;
+ for (int i = 0; i < schemeChildren.getLength(); i++) {
- // compare children
- nsIDOMNodeList vpeChildren = vpeNode.getChildNodes();
- NodeList schemeChildren = modelNode.getChildNodes();
- int realCount = 0;
- for (int i = 0; i < schemeChildren.getLength(); i++) {
+ Node schemeChild = schemeChildren.item(i);
- Node schemeChild = schemeChildren.item(i);
+ // leave out empty text nodes in test dom model
+ if ((schemeChild.getNodeType() == Node.TEXT_NODE)
+ && ((schemeChild.getNodeValue() == null) || (schemeChild
+ .getNodeValue().trim().length() == 0)))
+ continue;
- // leave out empty text nodes in test dom model
- if ((schemeChild.getNodeType() == Node.TEXT_NODE)
- && ((schemeChild.getNodeValue() == null) || (schemeChild
- .getNodeValue().trim().length() == 0)))
- continue;
+ nsIDOMNode vpeChild = vpeChildren.item(realCount++);
- nsIDOMNode vpeChild = vpeChildren.item(realCount++);
+ if (null == vpeChild) {
+ throw new ComparisonException(
+ "Child of node \"" //$NON-NLS-1$
+ + vpeNode.getNodeName()
+ + "\" is \"null\", but should be \"" + schemeChild.getNodeName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- if (null == vpeChild) {
- throw new ComparisonException(
- "Child of node \"" //$NON-NLS-1$
- + vpeNode.getNodeName()
- + "\" is \"null\", but should be \"" + schemeChild.getNodeName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ // leave out empty text nodes in vpe dom model
+ while (((vpeChild.getNodeType() == Node.TEXT_NODE) && ((vpeChild
+ .getNodeValue() == null) || (vpeChild.getNodeValue().trim().length() == 0)))) {
+ vpeChild = vpeChildren.item(realCount++);
+ if (null == vpeChild) {
+ throw new ComparisonException(
+ "Child of node \"" //$NON-NLS-1$
+ + vpeNode.getNodeName()
+ + "\" is \"null\", but should be \"" + schemeChild.getNodeName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
- // leave out empty text nodes in vpe dom model
- while (((vpeChild.getNodeType() == Node.TEXT_NODE) && ((vpeChild
- .getNodeValue() == null) || (vpeChild.getNodeValue().trim()
- .length() == 0)))) {
- vpeChild = vpeChildren.item(realCount++);
- if (null == vpeChild) {
- throw new ComparisonException(
- "Child of node \"" //$NON-NLS-1$
- + vpeNode.getNodeName()
- + "\" is \"null\", but should be \"" + schemeChild.getNodeName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ compareNodes(vpeChild, schemeChild);
- compareNodes(vpeChild, schemeChild);
-
+ }
}
-
+
}
/**
@@ -315,21 +300,5 @@
}
}
- /**
- * Clear string from special symbol
- * @param symbol
- * @param string
- * @return
- */
- private static String clearStringFromSpecSymbol(String symbol,String string){
- int index = string.indexOf(symbol); //$NON-NLS-1$
- while (index!=-1) {
- String stringAfterSymbol = string.substring(index+1);
- String stringBeforeSymbol = string.substring(0,index);
- string = stringBeforeSymbol.concat(stringAfterSymbol);
- index = string.indexOf(symbol); //$NON-NLS-1$
- }
- return string;
- }
-
+
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java 2012-07-24 13:39:26 UTC (rev 42690)
@@ -28,53 +28,33 @@
//Test add block comment from Source menu
- getEditor().navigateTo(22,22);
+ getEditor().selectLine(22);
bot.menu("Source").menu("Add Block Comment").click(); //$NON-NLS-1$//$NON-NLS-2$
+ getEditor().save();
checkVPE("BlockCommentTestToggle.xml"); //$NON-NLS-1$
//Test remove block comment from Source menu
- getEditor().navigateTo(22,22);
+ getEditor().selectLine(22);
bot.menu("Source").menu("Remove Block Comment").click(); //$NON-NLS-1$//$NON-NLS-2$
+ getEditor().save();
checkVPE("CommentTestUntoggle.xml"); //$NON-NLS-1$
//Test add block comment with CTRL+SHIFT+/ hot keys
- getEditor().navigateTo(22,22);
+ getEditor().selectLine(22);
pressBlockCommentHotKeys();
+ getEditor().save();
checkVPE("BlockCommentTestToggle.xml"); //$NON-NLS-1$
//Test remove block comment with CTRL+SHIFT+\ hot keys
- getEditor().navigateTo(22,22);
+ getEditor().selectLine(22);
pressUnBlockCommentHotKeys();
+ getEditor().save();
checkVPE("CommentTestUntoggle.xml"); //$NON-NLS-1$
- //Test add block comment lines from Source menu
-
- getEditor().navigateTo(18,22);
- bot.menu("Source").menu("Add Block Comment").click(); //$NON-NLS-1$//$NON-NLS-2$
- checkVPE("BlockCommentTestLinesToggle.xml"); //$NON-NLS-1$
-
- //Test remove block comment lines from Source menu
-
- getEditor().navigateTo(18,22);
- bot.menu("Source").menu("Remove Block Comment").click(); //$NON-NLS-1$//$NON-NLS-2$
- checkVPE("BlockCommentTestUntoggle.xml"); //$NON-NLS-1$
-
- //Test add block comment lines with CTRL+SHIFT+/ hot keys
-
- getEditor().navigateTo(18,22);
- bot.menu("Source").menu("Add Block Comment").click(); //$NON-NLS-1$ //$NON-NLS-2$
- checkVPE("BlockCommentTestLinesToggle.xml"); //$NON-NLS-1$
-
- //Test remove block comment lines with CTRL+SHIFT+/ hot keys
-
- getEditor().navigateTo(18,22);
- bot.menu("Source").menu("Remove Block Comment").click(); //$NON-NLS-1$ //$NON-NLS-2$
- checkVPE("BlockCommentTestUntoggle.xml"); //$NON-NLS-1$
-
}
private void pressBlockCommentHotKeys(){
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java 2012-07-24 13:39:26 UTC (rev 42690)
@@ -30,24 +30,28 @@
getEditor().navigateTo(22,22);
bot.menu("Source").menu("Toggle Comment").click(); //$NON-NLS-1$ //$NON-NLS-2$
+ getEditor().save();
checkVPE("ToggleCommentTestToggle.xml"); //$NON-NLS-1$
//Test untoggle comment from Source menu
getEditor().navigateTo(22,22);
bot.menu("Source").menu("Toggle Comment").click(); //$NON-NLS-1$ //$NON-NLS-2$
+ getEditor().save();
checkVPE("CommentTestUntoggle.xml"); //$NON-NLS-1$
//Test toggle comment with CTRL+SHIFT+C hot keys
getEditor().navigateTo(22,22);
pressToggleCommentHotKeys();
+ getEditor().save();
checkVPE("ToggleCommentTestToggle.xml"); //$NON-NLS-1$
//Test untoggle comment with CTRL+SHIFT hot keys
getEditor().navigateTo(22,22);
pressToggleCommentHotKeys();
+ getEditor().save();
checkVPE("CommentTestUntoggle.xml"); //$NON-NLS-1$
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java 2012-07-24 12:10:07 UTC (rev 42689)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VisualEditorContextMenuTest.java 2012-07-24 13:39:26 UTC (rev 42690)
@@ -94,7 +94,9 @@
SWTBotWebBrowser.ZOOM_MENU_LABEL,
"",
SWTBotWebBrowser.PREFERENCES_MENU_LABEL,
- "",
+ "",
+ SWTBotWebBrowser.TEAM_MENU_LABEL,
+ "",
SWTBotWebBrowser.PASTE_MENU_LABEL});
}
@@ -121,6 +123,8 @@
"",
SWTBotWebBrowser.PREFERENCES_MENU_LABEL,
"",
+ SWTBotWebBrowser.TEAM_MENU_LABEL,
+ "",
SWTBotWebBrowser.CUT_MENU_LABEL,
SWTBotWebBrowser.COPY_MENU_LABEL,
SWTBotWebBrowser.PASTE_MENU_LABEL});
@@ -148,6 +152,8 @@
"",
SWTBotWebBrowser.PREFERENCES_MENU_LABEL,
"",
+ SWTBotWebBrowser.TEAM_MENU_LABEL,
+ "",
SWTBotWebBrowser.CUT_MENU_LABEL,
SWTBotWebBrowser.COPY_MENU_LABEL,
SWTBotWebBrowser.PASTE_MENU_LABEL});
13 years, 5 months
JBoss Tools SVN: r42689 - trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot.
by jbosstools-commits@lists.jboss.org
Author: rhopp
Date: 2012-07-24 08:10:07 -0400 (Tue, 24 Jul 2012)
New Revision: 42689
Modified:
trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java
Log:
Modified the way preferences are open.
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java 2012-07-24 06:32:19 UTC (rev 42688)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java 2012-07-24 12:10:07 UTC (rev 42689)
@@ -8,12 +8,14 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.SWTFormsBotExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.condition.NonSystemJobRunsCondition;
import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.Preference;
import org.jboss.tools.ui.bot.ext.parts.SWTBotFormTextExt;
import org.jboss.tools.ui.bot.ext.parts.SWTBotTwistie;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -32,9 +34,11 @@
public static void setup() throws FileNotFoundException{
util.closeAllEditors(false);
util.closeAllViews();
- bot.menu("Window").menu("Preferences").click();
+ SWTOpenExt open = new SWTOpenExt(bot);
+ open.preferenceOpen(Preference.create("Maven"));
+ /*bot.menu("Window").menu("Preferences").click();
bot.waitForShell("Preferences");
- bot.tree().getTreeItem("Maven").select();
+ bot.tree().getTreeItem("Maven").select();*/
bot.checkBox("Download repository index updates on startup").deselect();
bot.clickButton("OK");
bot.menu("Help").menu(IDELabel.JBossCentralEditor.JBOSS_CENTRAL).click();
13 years, 5 months
JBoss Tools SVN: r42688 - trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties.
by jbosstools-commits@lists.jboss.org
Author: rhopp
Date: 2012-07-24 02:32:19 -0400 (Tue, 24 Jul 2012)
New Revision: 42688
Modified:
trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties
Log:
Repaired as7.swtbot.test.properties.
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties 2012-07-24 06:26:14 UTC (rev 42687)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties 2012-07-24 06:32:19 UTC (rev 42688)
@@ -1 +1 @@
-SERVER=AS,7.1,default,/home/rhopp/Runtimes/jboss-as-7.1.1.Final
\ No newline at end of file
+SERVER=AS,7.1,default,${jbosstools.test.jbossas.home}
\ No newline at end of file
13 years, 5 months
JBoss Tools SVN: r42687 - in trunk/central/tests/org.jboss.tools.central.test.ui.bot: resources and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: rhopp
Date: 2012-07-24 02:26:14 -0400 (Tue, 24 Jul 2012)
New Revision: 42687
Removed:
trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/eap6.swtbot.test.properties
Modified:
trunk/central/tests/org.jboss.tools.central.test.ui.bot/pom.xml
trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties
trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/settings.xml
trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CentralAllBotTests.java
trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java
trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/EmptyTestForHudson.java
Log:
=Deleted EAP configuration as there is no on hudson
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/pom.xml
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/pom.xml 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/pom.xml 2012-07-24 06:26:14 UTC (rev 42687)
@@ -85,13 +85,13 @@
<artifactId>org.jboss.tools.community.project.examples.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
-<!-- <dependency> -->
-<!-- <type>p2-installable-unit</type> -->
-<!-- <artifactId>org.jboss.tools.maven.project.examples.feature.feature.group</artifactId> -->
-<!-- <version>0.0.0</version> -->
-<!-- </dependency> -->
<dependency>
<type>p2-installable-unit</type>
+ <artifactId>org.jboss.tools.maven.project.examples.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
<artifactId>org.jboss.tools.openshift.express.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/as7.swtbot.test.properties 2012-07-24 06:26:14 UTC (rev 42687)
@@ -1 +1 @@
-SERVER=AS,7.1,default,${jbosstools.test.jbossas.home}
\ No newline at end of file
+SERVER=AS,7.1,default,/home/rhopp/Runtimes/jboss-as-7.1.1.Final
\ No newline at end of file
Deleted: trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/eap6.swtbot.test.properties
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/eap6.swtbot.test.properties 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/server_properties/eap6.swtbot.test.properties 2012-07-24 06:26:14 UTC (rev 42687)
@@ -1 +0,0 @@
-SERVER=EAP,6.0,default,/home/rhopp/Runtimes/jboss-eap-6.0-ER6/jboss-eap-6.0
\ No newline at end of file
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/settings.xml
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/settings.xml 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/resources/settings.xml 2012-07-24 06:26:14 UTC (rev 42687)
@@ -50,7 +50,7 @@
<repositories>
<repository>
<id>jboss-eap</id>
- <url>http://download.lab.bos.redhat.com/rel-eng/repos/jb-eap-6-rhel-6-build/JB...</url>
+ <url>http://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -62,7 +62,7 @@
<pluginRepositories>
<pluginRepository>
<id>jboss-eap-maven-plugin-repository</id>
- <url>http://download.lab.bos.redhat.com/rel-eng/repos/jb-eap-6-rhel-6-build/JB...</url>
+ <url>http://maven.repository.redhat.com/techpreview/all/</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -78,7 +78,7 @@
<repositories>
<repository>
<id>jboss-eap</id>
- <url>file:///home/rhopp/repositories/jboss-eap-6.0.0.ER5-maven-repository</url>
+ <url>file:///home/rhopp/repositories/jboss-eap-6.0.0-maven-repository</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -90,7 +90,7 @@
<pluginRepositories>
<pluginRepository>
<id>jboss-eap-maven-plugin-repository</id>
- <url>file:///home/rhopp/repositories/jboss-eap-6.0.0.ER5-maven-repository</url>
+ <url>file:///home/rhopp/repositories/jboss-eap-6.0.0.CR1-maven-repository</url>
<releases>
<enabled>true</enabled>
</releases>
@@ -107,7 +107,7 @@
<repository>
<id>jboss-wfk-repository</id>
<name>JBoss WFK Maven Repository</name>
- <url>file:///home/rhopp/repositories/jboss-wfk-2.0.0.ER5-maven-repository</url>
+ <url>file:///home/rhopp/repositories/jboss-wfk-2.0.0-maven-repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
@@ -123,7 +123,7 @@
<pluginRepository>
<id>jboss-wfk-repository-group</id>
<name>JBoss WFK Maven Repository</name>
- <url>file:///home/rhopp/repositories/jboss-wfk-2.0.0.ER5-maven-repository</url>
+ <url>file:///home/rhopp/repositories/jboss-wfk-2.0.0-maven-repository</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CentralAllBotTests.java
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CentralAllBotTests.java 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CentralAllBotTests.java 2012-07-24 06:26:14 UTC (rev 42687)
@@ -16,3 +16,4 @@
public class CentralAllBotTests {
}
+
\ No newline at end of file
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/CreateProjectsWithServerTest.java 2012-07-24 06:26:14 UTC (rev 42687)
@@ -99,11 +99,6 @@
}
@Test
- public void dummyTest(){
-
- }
-
- @Test
public void createProjectsSectionTest(){
//Dynamic web project
bot.hyperlink(IDELabel.JBossCentralEditor.DYNAMIC_WEB_PROJECT).click();
@@ -118,6 +113,7 @@
bot.waitForShell(IDELabel.JBossCentralEditor.OPENSHIFT_APP_WIZARD);
bot.waitWhile(new NonSystemJobRunsCondition());
assertTrue("New OpenShift Express Application window should have appeared", bot.activeShell().getText().equals(IDELabel.JBossCentralEditor.OPENSHIFT_APP_WIZARD));
+ bot.waitWhile(new NonSystemJobRunsCondition());
//assertTrue("New OpenShift Express Application window should have appeared", bot.shell(IDELabel.JBossCentralEditor.OPENSHIFT_APP_WIZARD).isActive());
bot.activeShell().close();
bot.waitWhile(new NonSystemJobRunsCondition());
Modified: trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/EmptyTestForHudson.java
===================================================================
--- trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/EmptyTestForHudson.java 2012-07-24 05:37:25 UTC (rev 42686)
+++ trunk/central/tests/org.jboss.tools.central.test.ui.bot/src/org/jboss/tools/central/test/ui/bot/EmptyTestForHudson.java 2012-07-24 06:26:14 UTC (rev 42687)
@@ -1,17 +1,120 @@
package org.jboss.tools.central.test.ui.bot;
+import java.io.FileNotFoundException;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.SWTFormsBotExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.wizards.SWTBotWizard;
+import org.junit.BeforeClass;
import org.junit.Test;
-@Require(server=(a)org.jboss.tools.ui.bot.ext.config.Annotations.Server(type=ServerType.JbossAS))
+@Require
public class EmptyTestForHudson extends SWTTestExt {
+ @BeforeClass
+ public static void setup() throws FileNotFoundException{
+ util.closeAllEditors(false);
+ util.closeAllViews();
+ bot.menu("Window").menu("Preferences").click();
+ bot.waitForShell("Preferences");
+ bot.tree().getTreeItem("Maven").select();
+ bot.checkBox("Download repository index updates on startup").deselect();
+ bot.clickButton("OK");
+ bot.menu("Help").menu(IDELabel.JBossCentralEditor.JBOSS_CENTRAL).click();
+ util.waitForAll();
+ }
+
@Test
- public void isRuntimeTest(){
- assertTrue(jbt.isServerRuntimeDefined());
+ public void testTest(){
+ checkExample(null, IDELabel.JBossCentralEditor.RICHFACES_PROJECT, true);
+ checkExample(null, IDELabel.JBossCentralEditor.SPRING_MVC_PROJECT, true);
+ SWTFormsBotExt formsBot = SWTBotFactory.getFormsBot();
+ formsBot.formTextWithText("Helloworld").click();
+ bot.sleep(TIME_10S);
}
+
+
+
+ /**
+ *
+ * @param formsBot formBot==null => link is of type HyperLink else it is of type FormText
+ * @param formText
+ * @param readme true if readme should be shown
+ */
+
+ private void checkExample(SWTFormsBotExt formsBot, String formText, boolean readme){
+ checkExample(formsBot, formText, readme, null);
+ }
+
+ /**
+ * Checks example
+ * @param formsBot bot for Forms
+ * @param formText text to be clicked at
+ * @param readme true if readme is supposed to show, false otherwise
+ * @param readmeFileName
+ */
+
+ private void checkExample(SWTFormsBotExt formsBot, String formText, boolean readme, String readmeFileName){
+ problems.show();
+ if (formsBot==null){
+ bot.hyperlink(formText).click();
+ }else{
+ try{
+ formsBot.formTextWithText(formText).click();
+ }catch(WidgetNotFoundException wnfex){
+ throw new WidgetNotFoundException("Could not found widget of type Hyperlink and text " +
+ formText, wnfex);
+ }
+ }
+ bot.waitForShell(IDELabel.JBossCentralEditor.PROJECT_EXAMPLE);
+ /*SWTBotWizard wizard = new SWTBotWizard(bot.shell(IDELabel.JBossCentralEditor.PROJECT_EXAMPLE).widget);
+ wizard.next();
+ if (wizard.canNext()){
+ bot.comboBox(2).setSelection(1);
+ try{
+ bot.link();
+ fail("There is something wrong with maven repo. Message: \n"+bot.link().getText());
+ }catch (WidgetNotFoundException ex){
+ //everything fine
+ }
+ wizard.next();
+ }
+ wizard.finishWithWait();
+ String readmeText = bot.checkBox(1).getText();
+ assertFalse("Quick fix should not be enabled (Everything should be fine)", bot.checkBox(0).isEnabled());
+ if (readme){
+ assertTrue("Show readme checkbox should be enabled", bot.checkBox(1).isEnabled());
+ assertTrue("Show readme checkbox should be checked by default", bot.checkBox(1).isChecked());
+ if (readmeFileName != null){
+ assertTrue(readmeText.toLowerCase().contains(readmeFileName));
+ bot.clickButton("Finish");
+ assertTrue("Cheat Sheets view should be opened right now", bot.activeView().getTitle().equals("Cheat Sheets"));
+ bot.activeView().close();
+ }else if (readmeText.contains("cheatsheet.xml")){
+ bot.clickButton("Finish");
+ assertTrue("Cheat Sheets view should be opened right now", bot.activeView().getTitle().equals("Cheat Sheets"));
+ bot.activeView().close();
+ }else if (readmeText.toLowerCase().contains("readme.md") || readmeText.toLowerCase().contains("readme.txt")){
+ bot.clickButton("Finish");
+ assertTrue("Readme should have opened in Text Editor", bot.activeEditor().getReference().getEditor(false).getClass().getName().contains("org.eclipse.ui.editors.text.TextEditor")); //because readmes are opening in browser now.. It's a bug. Jira is created.
+ bot.activeEditor().close();
+ }else if (readmeText.toLowerCase().contains("readme.htm")){
+ bot.clickButton("Finish");
+ assertTrue("Readme should have opened in Internal Browser", bot.activeEditor().getReference().getEditor(false).getClass().getName().contains("org.eclipse.ui.internal.browser.WebBrowserEditor"));
+ }
+ }else{
+ bot.clickButton("Finish");
+ }*/
+ bot.activeShell().close();
+ }
+
}
13 years, 5 months
JBoss Tools SVN: r42686 - in trunk/as/tests: org.jboss.tools.as.test.core and 20 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-24 01:37:25 -0400 (Tue, 24 Jul 2012)
New Revision: 42686
Added:
trunk/as/tests/org.jboss.tools.as.test.core/
trunk/as/tests/org.jboss.tools.as.test.core/.classpath
trunk/as/tests/org.jboss.tools.as.test.core/.project
trunk/as/tests/org.jboss.tools.as.test.core/.settings/
trunk/as/tests/org.jboss.tools.as.test.core/.settings/org.eclipse.jdt.core.prefs
trunk/as/tests/org.jboss.tools.as.test.core/META-INF/
trunk/as/tests/org.jboss.tools.as.test.core/META-INF/MANIFEST.MF
trunk/as/tests/org.jboss.tools.as.test.core/bin/
trunk/as/tests/org.jboss.tools.as.test.core/build.properties
trunk/as/tests/org.jboss.tools.as.test.core/plugin.properties
trunk/as/tests/org.jboss.tools.as.test.core/plugin.xml
trunk/as/tests/org.jboss.tools.as.test.core/pom.xml
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/3.2.8.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.0.5.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.2.3.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.0.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.1.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.1.0.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/6.0.0.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.0.0.mf.jboss-as-server.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.1.0.mf.jboss-as-server.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap4.3.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap5.0.mf.twiddle.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap6.0.0.mf.jboss-as-server.jar
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/jboss-service.xml
trunk/as/tests/org.jboss.tools.as.test.core/serverMock/run.jar
trunk/as/tests/org.jboss.tools.as.test.core/src/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/ASMatrixTests.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/TestConstants.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/classpath/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/classpath/JEEClasspathContainerTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/MockPublishMethod4.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/BundleUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ComponentReferenceUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/IOUtil.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/MatrixUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/PathUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ProjectRuntimeUtil.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ResourceUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/CreateProjectOperationsUtility.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/JavaEEFacetConstants.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/OperationTestCase.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/PostBuildListener.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/ProjectUtility.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/TaskViewUtility.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/launch/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/launch/MockArgsTests.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/Ear50CreationTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ProjectRuntimeClasspathTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerBeanLoader3Test.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerHomeTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerParameterUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerTypeDefaultClasspathEntriesTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/WebDeployableArtifactUtilDefectTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractPublishingTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarNestedWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyFilesetReferenceTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFileTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFolderTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/defect/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/defect/RepublishDefectTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
Log:
JBIDE-12363 initial test commit, NOT adding to parent pom.xml yet
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core
___________________________________________________________________
Added: svn:ignore
+ bin
target
build
Added: trunk/as/tests/org.jboss.tools.as.test.core/.classpath
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/.classpath
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: trunk/as/tests/org.jboss.tools.as.test.core/.project
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/.project
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: trunk/as/tests/org.jboss.tools.as.test.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/.settings/org.eclipse.jdt.core.prefs 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,7 @@
+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.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/as/tests/org.jboss.tools.as.test.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/META-INF/MANIFEST.MF (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/META-INF/MANIFEST.MF 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,62 @@
+hManifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundlehugs-Name.0
+Bundle-SymbolicName: org.jboss.tools.as.test.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.as.test.core.ASMatrixTests
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.junit4;bundle-version="4.8.1",
+ org.jboss.ide.eclipse.archives.core;bundle-version="3.2.1",
+ org.jboss.ide.eclipse.archives.jdt.integration;bundle-version="3.2.1",
+ org.jboss.ide.eclipse.archives.ui;bundle-version="3.2.1",
+ org.jboss.ide.eclipse.archives.webtools;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.classpath.core;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.classpath.ui;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.core;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.dmr;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.doc.user;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.jmx.integration;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.management.as71;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.management.core;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.rse.core;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.rse.ui;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.ui;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.ui.mbeans;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0",
+ org.jboss.ide.eclipse.as.wtp.ui;bundle-version="2.3.0",
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.core.manipulation,
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.debug.core,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jee,
+ org.eclipse.jst.server.core,
+ org.eclipse.ui.navigator,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.j2ee.ejb,
+ org.eclipse.jst.j2ee.jca,
+ org.eclipse.jst.jee.ejb,
+ org.eclipse.jst.jee.web,
+ org.eclipse.wst.common.emf,
+ org.eclipse.wst.common.emfworkbench.integration,
+ org.eclipse.wst.common.core,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.validation,
+ org.eclipse.jem.util,
+ org.eclipse.jst.j2ee.web,
+ org.jboss.tools.jmx.core.test,
+ org.jboss.tools.tests,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jpt.jpa.core,
+ org.jboss.ide.eclipse.as.management.core;bundle-version="1.0.0",
+ org.eclipse.equinox.security;bundle-version="1.1.1"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: trunk/as/tests/org.jboss.tools.as.test.core/build.properties
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/build.properties (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/build.properties 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ build.properties,\
+ plugin.properties,\
+ serverMock/
Added: trunk/as/tests/org.jboss.tools.as.test.core/plugin.properties
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/plugin.properties (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/plugin.properties 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,10 @@
+#Properties file for org.jboss.ide.eclipse.as.server.test
+Bundle-Vendor.0 = JBoss by Red Hat
+Bundle-Name.0 = AS Adapter Matrix Test Plug-in
+
+AllJBossRuntimeTypes=org.jboss.ide.eclipse.as.runtime.32,org.jboss.ide.eclipse.as.runtime.40,org.jboss.ide.eclipse.as.runtime.42,org.jboss.ide.eclipse.as.runtime.50,org.jboss.ide.eclipse.as.runtime.51,org.jboss.ide.eclipse.as.runtime.60,org.jboss.ide.eclipse.as.runtime.70,org.jboss.ide.eclipse.as.runtime.eap.43,org.jboss.ide.eclipse.as.runtime.eap.50,org.jboss.ide.eclipse.as.runtime.eap.60
+AllJBossServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50,org.jboss.ide.eclipse.as.eap.60,
+AllJBTServerTypes=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50,org.jboss.ide.eclipse.as.eap.60,org.jboss.ide.eclipse.as.systemCopyServer
+ServerTypesJBoss6OrHigher=org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.60
+ServerTypesJBoss6OrLower=org.jboss.ide.eclipse.as.32,org.jboss.ide.eclipse.as.40,org.jboss.ide.eclipse.as.42,org.jboss.ide.eclipse.as.50,org.jboss.ide.eclipse.as.51,org.jboss.ide.eclipse.as.60,org.jboss.ide.eclipse.as.eap.43,org.jboss.ide.eclipse.as.eap.50
+ServerTypesJBoss7=org.jboss.ide.eclipse.as.70,org.jboss.ide.eclipse.as.eap.60
\ No newline at end of file
Added: trunk/as/tests/org.jboss.tools.as.test.core/plugin.xml
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: trunk/as/tests/org.jboss.tools.as.test.core/pom.xml
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/3.2.8.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/3.2.8.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.0.5.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.0.5.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.2.3.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/4.2.3.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.0.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.0.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.1.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.0.1.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.1.0.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/5.1.0.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/6.0.0.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/6.0.0.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.0.0.mf.jboss-as-server.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.0.0.mf.jboss-as-server.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.1.0.mf.jboss-as-server.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/7.1.0.mf.jboss-as-server.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap4.3.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap4.3.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap5.0.mf.twiddle.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap5.0.mf.twiddle.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap6.0.0.mf.jboss-as-server.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/eap6.0.0.mf.jboss-as-server.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/jboss-service.xml
===================================================================
Added: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/run.jar
===================================================================
(Binary files differ)
Property changes on: trunk/as/tests/org.jboss.tools.as.test.core/serverMock/run.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/ASMatrixTests.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/ASMatrixTests.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/ASMatrixTests.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,73 @@
+package org.jboss.tools.as.test.core;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.ProjectUtility;
+import org.jboss.tools.test.util.JobUtils;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ASMatrixTests extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.as.test.core"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ASMatrixTests plugin;
+
+ /**
+ * The constructor
+ */
+ public ASMatrixTests() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ASMatrixTests getDefault() {
+ return plugin;
+ }
+
+ public static void clearStateLocation() {
+ IPath state = ASMatrixTests.getDefault().getStateLocation();
+ if( state.toFile().exists()) {
+ File[] children = state.toFile().listFiles();
+ for( int i = 0; i < children.length; i++ ) {
+ FileUtil.safeDelete(children[i]);
+ }
+ }
+ }
+ public static void cleanup() throws Exception {
+ JobUtils.waitForIdle();
+ ServerCreationTestUtils.deleteAllServersAndRuntimes();
+ ProjectUtility.deleteAllProjects();
+ ASMatrixTests.clearStateLocation();
+ JobUtils.waitForIdle();
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,13 @@
+package org.jboss.tools.as.test.core;
+
+import org.jboss.tools.as.test.core.parametized.server.ParametizedSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+(a)RunWith(Suite.class)
+@SuiteClasses({
+ ParametizedSuite.class
+})
+public class MySuite {
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/TestConstants.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/TestConstants.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/TestConstants.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,38 @@
+package org.jboss.tools.as.test.core;
+
+import java.util.HashMap;
+
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+
+public class TestConstants {
+ public static final String TOMCAT_RUNTIME_55 = "org.eclipse.jst.server.tomcat.runtime.55";
+ public static final String JBOSS_AS_32_HOME = System.getProperty("jbosstools.test.jboss.home.3.2", "C:\\apps\\jboss\\jboss-3.2.8.SP1\\");
+ public static final String JBOSS_AS_40_HOME = System.getProperty("jbosstools.test.jboss.home.4.0", "C:\\apps\\jboss\\jboss-4.0.5.GA\\");
+ public static final String JBOSS_AS_42_HOME = System.getProperty("jbosstools.test.jboss.home.4.2", "C:\\apps\\jboss\\jboss-4.2.1.GA\\");
+ public static final String JBOSS_AS_50_HOME = System.getProperty("jbosstools.test.jboss.home.5.0", "C:\\apps\\jboss\\jboss-5.0.0.GA\\");
+ public static final String JBOSS_AS_51_HOME = System.getProperty("jbosstools.test.jboss.home.5.1", "C:\\apps\\jboss\\jboss-5.1.0.GA\\");
+ public static final String JBOSS_AS_52_HOME = System.getProperty("jbosstools.test.jboss.home.5.2", "C:\\apps\\jboss\\jboss-5.2.0.GA\\");
+ public static final String JBOSS_AS_60_HOME = System.getProperty("jbosstools.test.jboss.home.6.0", "C:\\apps\\jboss\\jboss-6.0.0.GA\\");
+ public static final String JBOSS_AS_70_HOME = System.getProperty("jbosstools.test.jboss.home.7.0", "C:\\apps\\jboss\\jboss-7.0.0.GA\\");
+ public static final String JRE_14_HOME = System.getProperty("jbosstools.test.jre.1.4", "C:\\apps\\jboss\\jboss-5.2.0.GA\\");
+ public static final String JRE_5_HOME = System.getProperty("jbosstools.test.jre.5", "C:\\apps\\jboss\\jboss-5.2.0.GA\\");
+ public static final String JRE_6_HOME = System.getProperty("jbosstools.test.jre.6", "C:\\apps\\jboss\\jboss-5.2.0.GA\\");
+
+ public static final String JBOSS_AS_HOME = System.getProperty("jbosstools.test.jboss.home", JBOSS_AS_42_HOME);
+
+ public static final HashMap<String, String> serverTypeToHome = new HashMap<String, String>();
+ static {
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_32, JBOSS_AS_32_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_40, JBOSS_AS_40_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_42, JBOSS_AS_42_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_50, JBOSS_AS_50_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_51, JBOSS_AS_51_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_60, JBOSS_AS_60_HOME);
+ serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_70, JBOSS_AS_70_HOME);
+ //serverTypeToHome.put(IJBossToolingConstants.SERVER_AS_71, JBOSS_AS_32_HOME);
+ }
+
+ public static String getServerHome(String serverTypeId) {
+ return serverTypeToHome.get(serverTypeId);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/classpath/JEEClasspathContainerTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/classpath/JEEClasspathContainerTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/classpath/JEEClasspathContainerTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,137 @@
+/**
+ * JBoss by Red Hat
+ * Copyright 2006-2009, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tools.as.test.core.classpath;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.jmx.core.test.util.TestProjectProvider;
+
+/**
+ * This class tests the jee classpath containers
+ * to make sure they're returning live jars that exist.
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ */
+public class JEEClasspathContainerTest extends TestCase {
+
+ private static final int ORIGINAL_ENTRIES = 2;
+
+ private TestProjectProvider provider;
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null, "basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ }
+
+ public void testJEE13ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.3", 7);
+ }
+
+ public void testJEE14ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.4", 8);
+ }
+
+ public void testJEE50ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.javaee-5.0", 3);
+ }
+
+
+ protected void testGenericClasspathContainer(String containerPath, int expectedEntries) {
+ try {
+ IJavaProject jproject = JavaCore.create(project);
+ IPath path = new Path(containerPath);
+ verifyContainerEntries(path, jproject, expectedEntries);
+ verifyRawClasspathCount(jproject, ORIGINAL_ENTRIES);
+ verifyNotIncludedEntry(jproject, path);
+ int beforeRawCount = jproject.getRawClasspath().length;
+ int beforeResolvedCount = jproject.getResolvedClasspath(true).length;
+ addContainer(jproject, path);
+ assertEquals(beforeRawCount+1, jproject.getRawClasspath().length);
+ assertEquals(beforeResolvedCount+expectedEntries, jproject.getResolvedClasspath(true).length);
+ beforeRawCount = jproject.getRawClasspath().length;
+ beforeResolvedCount = jproject.getResolvedClasspath(true).length;
+ removeContainer(jproject, path);
+ assertEquals(beforeRawCount-1, jproject.getRawClasspath().length);
+ assertEquals(beforeResolvedCount-expectedEntries, jproject.getResolvedClasspath(true).length);
+
+ } catch( JavaModelException jme ) {
+ fail("Exception: " + jme.getMessage());
+ } catch( CoreException ce ) {
+ fail("Exception: " + ce.getMessage());
+ }
+
+ }
+
+ protected void verifyContainerEntries(IPath path, IJavaProject jproject, int expected) throws JavaModelException {
+ IClasspathContainer cpc = JavaCore.getClasspathContainer(path, jproject);
+ IClasspathEntry[] entries = cpc.getClasspathEntries();
+ assertEquals("Received unexpected number of entries", expected, entries.length );
+ }
+
+ protected void verifyRawClasspathCount(IJavaProject jproject, int count) throws JavaModelException {
+ IClasspathEntry[] projectEntry = jproject.getRawClasspath();
+ assertEquals("Project should start with only " + count + " classpath entries", count, projectEntry.length);
+ }
+
+ protected void verifyNotIncludedEntry(IJavaProject jproject, IPath path) throws JavaModelException {
+ IClasspathEntry[] projectEntry = jproject.getRawClasspath();
+ for( int i = 0; i < projectEntry.length; i++ ) {
+ if( projectEntry[i].getPath().toOSString().startsWith(path.toOSString())) {
+ assertFalse("Project prematurely includes classpath", true);
+ }
+ }
+ }
+
+ protected void addContainer(IJavaProject jproject, IPath path) throws JavaModelException {
+ ArrayList tmp = new ArrayList();
+ tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
+ tmp.add(JavaCore.newContainerEntry(path));
+ jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new IClasspathEntry[tmp.size()]), null);
+ }
+
+ protected void removeContainer(IJavaProject jproject, IPath path) throws JavaModelException {
+ ArrayList tmp = new ArrayList();
+ tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
+ tmp.remove(JavaCore.newContainerEntry(path));
+ jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new IClasspathEntry[tmp.size()]), null);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/MockPublishMethod4.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/MockPublishMethod4.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/MockPublishMethod4.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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.as.test.core.internal;
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.ide.eclipse.as.core.publishers.AbstractPublishMethod;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IPublishCopyCallbackHandler;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+
+public class MockPublishMethod4 extends AbstractPublishMethod {
+
+ public static final String PUBLISH_METHOD_ID = "mock4";
+ public static ArrayList<IPath> changed = new ArrayList<IPath>();
+ public static ArrayList<IPath> removed = new ArrayList<IPath>();
+ public static ArrayList<IPath> tempFiles = new ArrayList<IPath>();
+ public static ArrayList<IModuleFile> copiedFiles = new ArrayList<IModuleFile>();
+
+
+ protected static String expectedRoot = null;
+ protected static String expectedTempRoot = null;
+
+ protected static RuntimeException error = null;
+
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath path,
+ IServer server) {
+ return new MockCopyCallbackHandler(path, null);
+ }
+
+ public IPublishCopyCallbackHandler getCallbackHandler(IPath deployPath,
+ IPath tmpFolder, IServer server) {
+ return new MockCopyCallbackHandler(deployPath, tmpFolder);
+ }
+
+
+ public String getPublishDefaultRootFolder(IServer server) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds.getDeployFolder();
+ }
+
+ public String getPublishDefaultRootTempFolder(IServer server) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds.getTempDeployFolder();
+ }
+
+ public String getPublishMethodId() {
+ return PUBLISH_METHOD_ID;
+ }
+ public static void resetPublish() {
+ changed.clear();
+ removed.clear();
+ tempFiles.clear();
+ copiedFiles.clear();
+ error = null;
+ }
+
+ /* Reset Everything */
+ public static void reset() {
+ changed.clear();
+ removed.clear();
+ tempFiles.clear();
+ copiedFiles.clear();
+ expectedRoot = null;
+ expectedTempRoot = null;
+ error = null;
+ }
+
+ public static void setExpectedRoot(String s) {
+ expectedRoot = s;
+ }
+
+ public static void setExpectedTempRoot(String s) {
+ expectedTempRoot = s;
+ }
+
+ public static IPath[] getRemoved() {
+ return (IPath[]) removed.toArray(new IPath[removed.size()]);
+ }
+ public static IModuleFile[] getChangedFiles() {
+ return copiedFiles.toArray(new IModuleFile[copiedFiles.size()]);
+ }
+
+ public static IPath[] getChanged() {
+ return (IPath[]) changed.toArray(new IPath[changed.size()]);
+ }
+ public static IPath[] getTempPaths() {
+ return (IPath[]) tempFiles.toArray(new IPath[tempFiles.size()]);
+ }
+ public static Exception getError() {
+ return error;
+ }
+
+
+ public class MockCopyCallbackHandler implements IPublishCopyCallbackHandler {
+ private IPath root, tempRoot;
+ public MockCopyCallbackHandler(IPath root, IPath tempRoot) {
+ if( !(new Path(expectedRoot).isPrefixOf(root))) {
+ String e = "Expected " + new Path(expectedRoot) + " but got: " + root.toString();
+ System.out.println(e);
+ System.out.println(expectedRoot);
+ error = new RuntimeException("Unacceptable use of callback handler: " + e);
+ throw error;
+ }
+ if( tempRoot != null && !(new Path(expectedTempRoot).isPrefixOf(tempRoot))) {
+ String e = "Expected " + new Path(expectedTempRoot) + " but got: " + root.toString();
+ System.out.println(e);
+ error = new RuntimeException("Unacceptable use of callback handler: " + e);
+ throw error;
+ }
+ this.root = root;
+ this.tempRoot = tempRoot;
+ }
+
+ public IStatus[] deleteResource(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+// System.out.println("deleting " + root.append(path));
+ IPath path2 = root.append(path);
+ if( !removed.contains(path2.makeRelative()))
+ removed.add(path2.makeRelative());
+ return new IStatus[]{};
+ }
+
+ public IStatus[] makeDirectoryIfRequired(IPath dir,
+ IProgressMonitor monitor) throws CoreException {
+// System.out.println("mkdir to " + root.append(dir));
+
+ IPath path2 = root.append(dir);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
+ return new IStatus[]{};
+ }
+
+ private boolean shouldRestartModule = false;
+ public boolean shouldRestartModule() {
+ return shouldRestartModule;
+ }
+ public IStatus[] copyFile(IModuleFile mf, IPath path,
+ IProgressMonitor monitor) throws CoreException {
+// System.out.println("copying to " + root.append(path));
+ File file = PublishUtil.getFile(mf);
+ shouldRestartModule |= checkRestartModule(file);
+ IPath path2 = root.append(path);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
+ IPath tmpFile = (tempRoot == null ? root : tempRoot).append(path);
+ if( !tempFiles.contains(tmpFile.makeRelative()))
+ tempFiles.add(tmpFile.makeRelative());
+ copiedFiles.add(mf);
+ return new IStatus[]{};
+ }
+
+ public IStatus[] touchResource(IPath path, IProgressMonitor monitor) {
+// System.out.println("touching " + root.append(path));
+ IPath path2 = root.append(path);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
+ return new IStatus[]{};
+ }
+
+ public boolean isFile(IPath path, IProgressMonitor monitor)
+ throws CoreException {
+ IPath path2 = root.append(path);
+ return path2.toFile().exists() && path2.toFile().isFile();
+ }
+ public boolean checkRestartModule(File file) {
+ if( file.getName().toLowerCase().endsWith(".jar")) //$NON-NLS-1$
+ return true;
+ return false;
+ }
+
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/BundleUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/BundleUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/BundleUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,46 @@
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.osgi.framework.Bundle;
+
+public class BundleUtils {
+ /**
+ * Find a file inside this test bundle
+ * @param path
+ * @return
+ * @throws CoreException
+ */
+ public static File getFileLocation(String path) throws CoreException {
+ return getFileLocation(ASMatrixTests.PLUGIN_ID, path);
+ }
+
+ /**
+ * Find a file inside any bundle
+ * @param bundleId
+ * @param path
+ * @return
+ */
+ public static File getFileLocation(String bundleId, String path) throws CoreException {
+ Bundle bundle = Platform.getBundle(bundleId);
+ URL url = null;
+ try {
+ url = FileLocator.resolve(bundle.getEntry(path));
+ } catch (IOException e) {
+ String msg = "Cannot find file " + path + " in " + ASMatrixTests.PLUGIN_ID;
+ IStatus status = new Status(IStatus.ERROR, ASMatrixTests.PLUGIN_ID, msg, e);
+ throw new CoreException(status);
+ }
+ String location = url.getFile();
+ return new File(location);
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ComponentReferenceUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ComponentReferenceUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ComponentReferenceUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,112 @@
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.application.internal.operations.AddReferenceToEnterpriseApplicationDataModelProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IAddReferenceDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.DependencyType;
+import org.eclipse.wst.common.componentcore.internal.operation.AddReferenceDataModelProvider;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualReference;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.jboss.ide.eclipse.archives.webtools.filesets.vcf.WorkspaceFilesetVirtualComponent;
+
+/* Add .component file references */
+public class ComponentReferenceUtils {
+
+ public static void addPathArchiveComponent(IVirtualComponent component,
+ IPath variablePath, String folder, String name, boolean isEar)
+ throws CoreException {
+ IDataModelProvider p = isEar ? new AddReferenceToEnterpriseApplicationDataModelProvider() : new AddReferenceDataModelProvider();
+ IVirtualReference ref = createPathArchiveReference(component, variablePath, folder, name);
+ addReferenceToComponent(component, ref, p);
+ }
+
+ public static IVirtualReference createPathArchiveReference (IVirtualComponent component,
+ IPath variablePath, String folder, String name) throws CoreException {
+ IPath resolvedPath = JavaCore.getResolvedVariablePath(variablePath);
+ java.io.File file = new java.io.File(resolvedPath.toOSString());
+ if (file.isFile() && file.exists()) {
+ String type = VirtualArchiveComponent.VARARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore.createArchiveComponent(
+ component.getProject(), type + variablePath.toString());
+ VirtualReference ref = new VirtualReference(component, archive);
+ ref.setArchiveName(name);
+ ref.setRuntimePath(new Path(folder));
+ return ref;
+ }
+ return null;
+ }
+
+
+ public static void addReferenceToComponent(IVirtualComponent component,
+ IVirtualReference ref, IDataModelProvider provider) throws CoreException {
+ if( ref == null )
+ return;
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+ dm.setProperty(IAddReferenceDataModelProperties.SOURCE_COMPONENT, component);
+ dm.setProperty(IAddReferenceDataModelProperties.TARGET_REFERENCE_LIST, Arrays.asList(ref));
+ IStatus stat = dm.validate();
+ if (!stat.isOK())
+ throw new CoreException(stat);
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ throw new CoreException(new Status(IStatus.ERROR, "test",
+ e.getMessage()));
+ }
+ }
+
+ public static VirtualReference createExternalJarReference(IVirtualComponent rootComponent, IPath path, String runtimeLoc, String name) {
+ return createJarReference(rootComponent, path, runtimeLoc, name, false);
+ }
+
+ public static VirtualReference createWorkspaceJarReference(IVirtualComponent rootComponent, IPath path, String runtimeLoc, String name) {
+ return createJarReference(rootComponent, path, runtimeLoc, name, false);
+ }
+
+ public static VirtualReference createJarReference(IVirtualComponent rootComponent, IPath path,
+ String runtimeLoc, String name, boolean makeRelative ) {
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR;
+ String path2 = (makeRelative ? path.makeRelative() : path).toString();
+ IVirtualComponent archive = ComponentCore.createArchiveComponent(
+ rootComponent.getProject(), type + path2);
+ VirtualReference ref = new VirtualReference(rootComponent, archive);
+ ref.setArchiveName(name);
+ if (runtimeLoc != null) {
+ ref.setRuntimePath(new Path(runtimeLoc).makeAbsolute());
+ }
+ return ref;
+ }
+
+ public static VirtualReference createFilesetComponentReference(IVirtualComponent root, String workspaceRelativeFolder, String includes, String excludes, String runtimePath) {
+
+ WorkspaceFilesetVirtualComponent vc = new WorkspaceFilesetVirtualComponent(
+ root.getProject(), root, new Path(workspaceRelativeFolder).makeAbsolute().toString());
+ vc.setIncludes(includes);
+ vc.setExcludes(excludes);
+ VirtualReference ref = new VirtualReference(root, vc);
+ ref.setDependencyType(DependencyType.CONSUMES);
+ ref.setRuntimePath(new Path(runtimePath)); //$NON-NLS-1$
+ return ref;
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/IOUtil.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/IOUtil.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/IOUtil.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2010 - 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.as.test.core.internal.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.tools.test.util.JobUtils;
+
+public class IOUtil {
+ public static byte[] getBytesFromInputStream(InputStream is) {
+ if( is == null )
+ return null;
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ try {
+ int nRead;
+ byte[] data = new byte[16384];
+
+ while ((nRead = is.read(data, 0, data.length)) != -1) {
+ buffer.write(data, 0, nRead);
+ }
+
+ buffer.flush();
+ return buffer.toByteArray();
+ } catch(IOException ioe) {
+ return null;
+ }
+ }
+
+ public static void setContents(File file, String contents) throws IOException, CoreException {
+ byte[] buffer = new byte[65536];
+ InputStream in = new ByteArrayInputStream(contents.getBytes());
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ int avail = in.read(buffer);
+ while (avail > 0) {
+ out.write(buffer, 0, avail);
+ avail = in.read(buffer);
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ public static String getContents(File aFile) throws IOException {
+ return new String(getBytesFromFile(aFile));
+ }
+
+ public static byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+ byte[] bytes = new byte[(int)file.length()];
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+ offset += numRead;
+ }
+ is.close();
+ return bytes;
+ }
+
+ public static int countFiles(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countFiles(children[i]);
+ return count;
+ }
+
+ public static int countAllResources(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countAllResources(children[i]);
+ return 1 + count;
+ }
+
+ public static void unzipFile(IPath zipped, IPath toLoc) {
+ toLoc.toFile().mkdirs();
+ final int BUFFER = 2048;
+ try {
+ BufferedOutputStream dest = null;
+ FileInputStream fis = new
+ FileInputStream(zipped.toFile());
+ ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
+ ZipEntry entry;
+ while((entry = zis.getNextEntry()) != null) {
+ int count;
+ byte data[] = new byte[BUFFER];
+ // write the files to the disk
+ if( entry.isDirectory() ) {
+ toLoc.append(entry.getName()).toFile().mkdirs();
+ } else {
+ toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
+ if( !toLoc.append(entry.getName()).toFile().exists()) {
+ String out = toLoc.append(entry.getName()).toOSString();
+ FileOutputStream fos = new FileOutputStream(out);
+ dest = new BufferedOutputStream(fos, BUFFER);
+ while ((count = zis.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+ dest.flush();
+ dest.close();
+ }
+ }
+ }
+ zis.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public static boolean isZip(File file) {
+ if(file.isDirectory()) {
+ return false;
+ }
+ if(!file.canRead()) {
+ return false;
+ }
+ if(file.length() < 4) {
+ return false;
+ }
+ try {
+ DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+ int test = in.readInt();
+ in.close();
+ return test == 0x504b0304;
+ }catch( IOException ioe) {
+ return false;
+ }
+ }
+
+ public static IModuleFile findFile(IModuleFile[] files, String needle) {
+ if( files != null ) {
+ for( int i = 0; i < files.length; i++ ) {
+ if( files[i].getName().equals(needle))
+ return files[i];
+ }
+ }
+ return null;
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/MatrixUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/MatrixUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/MatrixUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,56 @@
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.util.ArrayList;
+
+public class MatrixUtils {
+ public static Object[] createPath(Object[][] blocks, int[] vals) {
+ Object[] ret = new Object[blocks.length];
+ for( int i = 0; i < blocks.length; i++ ) {
+ ret[i] = blocks[i][vals[i]];
+ }
+ return ret;
+ }
+
+
+ /**
+ * Accept an array of the following style:
+ * Object[][] {
+ * new Object[] { "server1, server2"},
+ * new Object[] { "zipped", "unzipped"}
+ * };
+ * and return values of:
+ * Object[][] {
+ * new Object[] {"server1", "zipped"},
+ * new Object[] {"server1", "unzipped"},
+ * new Object[] {"server2", "zipped"},
+ * new Object[] {"server2", "unzipped"}
+ * }
+ * @param params
+ * @return
+ */
+ public static ArrayList<Object[]> toMatrix(Object[][] blocks) {
+ ArrayList<Object[]> paths = new ArrayList<Object[]>();
+ int depth = blocks.length;
+ int[] depthCount = new int[depth];
+ for( int i = 0; i < depth; i++ ) {
+ depthCount[i] = 0;
+ }
+ boolean done = false;
+ while(!done ) {
+ paths.add(createPath(blocks, depthCount));
+ depthCount[depth-1]++;
+ for( int i = depth-1; i > 0; i-- ) {
+ if(depthCount[i] == blocks[i].length) {
+ depthCount[i] = 0;
+ depthCount[i-1]++;
+ }
+ }
+ if( depthCount[0] == blocks[0].length)
+ done = true;
+ }
+ return paths;
+ }
+
+
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/PathUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/PathUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/PathUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 - 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.as.test.core.internal.utils;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author André Dietisheim
+ */
+public class PathUtils {
+
+ /**
+ * Returns <code>true</code> if the given path (string) is contained in the
+ * given array of paths
+ *
+ * @param pathString
+ * the path (string) to check
+ * @param pathArray
+ * the array of paths to check
+ * @return true if the path was found in the array
+ */
+ public static boolean containsPath(String pathString, IPath[] pathArray) {
+ if (pathArray == null
+ || pathString == null) {
+ return false;
+ }
+ for (IPath path : pathArray) {
+ if (pathString.equals(path.toString())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ProjectRuntimeUtil.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ProjectRuntimeUtil.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ProjectRuntimeUtil.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,57 @@
+/**
+ * JBoss by Red Hat
+ * Copyright 2006-2009, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.util.Collections;
+import java.util.HashSet;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IRuntime;
+
+public class ProjectRuntimeUtil extends Assert {
+
+ public static org.eclipse.wst.common.project.facet.core.runtime.IRuntime getRuntime(IProject theProject) throws CoreException {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ return facetedProject.getPrimaryRuntime();
+ }
+
+ public static void clearRuntime(IProject theProject) throws CoreException {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ facetedProject.setTargetedRuntimes(new HashSet<org.eclipse.wst.common.project.facet.core.runtime.IRuntime>(), null);
+ facetedProject.setTargetedRuntimes(Collections.EMPTY_SET, new NullProgressMonitor());
+ }
+
+ public static void setTargetRuntime(IRuntime runtime, IProject theProject) throws CoreException {
+ final org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime = RuntimeManager.getRuntime(runtime.getId());
+ assertNotNull("bridged facet runtime not found", facetRuntime);
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ facetedProject.setTargetedRuntimes(new HashSet<org.eclipse.wst.common.project.facet.core.runtime.IRuntime>() { { this.add(facetRuntime);}}, null);
+ facetedProject.setPrimaryRuntime(facetRuntime, null);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ResourceUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ResourceUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ResourceUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,139 @@
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.jboss.tools.test.util.JobUtils;
+
+public class ResourceUtils {
+ public static IFile createFile(IProject p, String filename, String contents) throws CoreException, IOException {
+ IFile resource = p.getFile(filename);
+ setContents(resource, contents);
+ return resource;
+ }
+
+ public static String getContents(IFile file) throws IOException, CoreException {
+ byte[] b = IOUtil.getBytesFromInputStream(file.getContents());
+ return new String(b);
+ }
+ public static String getContents(IModuleFile file) throws IOException, CoreException {
+ File f1 = (File)file.getAdapter(File.class);
+ IFile f2 = (IFile)file.getAdapter((IFile.class));
+ InputStream is = f2 != null ? f2.getContents() : f1 != null ? new FileInputStream(f1) : null;
+ byte[] b = IOUtil.getBytesFromInputStream(is);
+ return b == null ? null : new String(b);
+ }
+
+ public static void setContents(IFile file, int val) throws IOException , CoreException{
+ setContents(file, "" + val);
+ }
+
+ public static void setContents(IFile file, String val) throws IOException , CoreException{
+ if( !file.exists())
+ file.create(new ByteArrayInputStream((val).getBytes()), false, null);
+ else
+ file.setContents(new ByteArrayInputStream((val).getBytes()), false, false, new NullProgressMonitor());
+ try {
+ Thread.sleep(600);
+ } catch( InterruptedException ie) {}
+ JobUtils.waitForIdle();
+ }
+
+ public static void setContents(IProject project, IPath path, String val) throws IOException , CoreException{
+ if( project.exists() ) {
+ IResource member = project.findMember(path);
+ if( member.exists() && member instanceof IFile ) {
+ setContents((IFile)member, val);
+ }
+ }
+ }
+
+ public static IProject findProject(String name) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ }
+
+ public static void deleteProject(String name) {
+ final IProject projectA = findProject("d1");
+ Job deleteJob = new Job("delete d1") {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ projectA.delete(true, new NullProgressMonitor());
+ } catch(CoreException ce) {
+ return ce.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ deleteJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ deleteJob.schedule();
+ JobUtils.delay(1000);
+ JobUtils.waitForIdle();
+ }
+
+
+ public static IFile createJavaType(IProject p, IPath projectRelativePath, String packageName, String className) throws CoreException {
+ IFolder folder = p.getFolder(projectRelativePath);
+ createFolder(folder);
+ IFile f = folder.getFile(className + ".java");
+ String s = "package " + packageName + ";\n\npublic class " + className + "{\n\n}";
+ f.create(new ByteArrayInputStream(s.getBytes()), true, new NullProgressMonitor());
+ return f;
+ }
+
+ public static boolean createFolder(IFolder c) throws CoreException {
+ if( c.exists())
+ return true;
+ if( !c.getParent().exists()) {
+ createFolder((IFolder)c.getParent());
+ }
+ c.create(true, true, null);
+ return true;
+ }
+
+
+ public static IModuleFile[] findAllIModuleFiles(IModule module) throws CoreException {
+ ModuleDelegate md = (ModuleDelegate) module.loadAdapter(
+ ModuleDelegate.class, new NullProgressMonitor());
+ ArrayList<IModuleFile> list = new ArrayList<IModuleFile>();
+ IModuleResource[] all = md.members();
+ for(int i = 0; i < all.length; i++ ) {
+ if( all[i] instanceof IModuleFile ) {
+ list.add((IModuleFile)all[i]);
+ } else if( all[i] instanceof IModuleFolder) {
+ findAllIModuleFiles(list, (IModuleFolder) all[i]);
+ }
+ }
+ return (IModuleFile[]) list.toArray(new IModuleFile[list.size()]);
+ }
+ public static void findAllIModuleFiles(ArrayList<IModuleFile> collector, IModuleFolder folder) {
+ IModuleResource[] all = folder.members();
+ for(int i = 0; i < all.length; i++ ) {
+ if( all[i] instanceof IModuleFile ) {
+ collector.add((IModuleFile)all[i]);
+ } else if( all[i] instanceof IModuleFolder) {
+ findAllIModuleFiles(collector, (IModuleFolder) all[i]);
+ }
+ }
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,268 @@
+package org.jboss.tools.as.test.core.internal.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.Server;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerCreationUtils;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.TestConstants;
+
+/**
+ * This class is intended to assist in the creation ONLY
+ * for servers and runtimes. It's scope includes:
+ *
+ * 1) Creating mock folders for each server type
+ * 2) Creating IServer objects out of either mock folders or legitimate installations
+ *
+ */
+public class ServerCreationTestUtils {
+
+ private static final IPath mockedServers = ASMatrixTests.getDefault().getStateLocation().append("mockedServers");
+ private static HashMap<String, String> asSystemJar = new HashMap<String, String>();
+ private static HashMap<String, String> serverRuntimeMap = new HashMap<String, String>();
+ private static final String twiddle_suffix = ".mf.twiddle.jar";
+ private static final String twiddle_3_2_8 = "3.2.8" + twiddle_suffix;
+ private static final String twiddle_4_0_5 = "4.0.5" + twiddle_suffix;
+ private static final String twiddle_4_2_3 = "4.2.3" + twiddle_suffix;
+ private static final String twiddle_5_0_0 = "5.0.0" + twiddle_suffix;
+ private static final String twiddle_5_0_1 = "5.0.1" + twiddle_suffix;
+ private static final String twiddle_5_1_0 = "5.1.0" + twiddle_suffix;
+ private static final String twiddle_6_0_0 = "6.0.0" + twiddle_suffix;
+ private static final String as_server_7_0_jar = "7.0.0.mf.jboss-as-server.jar";
+ private static final String as_server_7_1_jar = "7.1.0.mf.jboss-as-server.jar";
+ private static final String twiddle_eap_4_3 = "eap4.3" + twiddle_suffix;
+ private static final String twiddle_eap_5_0 = "eap5.0" + twiddle_suffix;
+ private static final String eap_server_6_0_jar = "eap6.0.0.mf.jboss-as-server.jar";
+ private static final String run_jar = "run.jar";
+ private static final String service_xml = "service.xml";
+ static {
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_32, twiddle_3_2_8);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_40, twiddle_4_0_5);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_42, twiddle_4_2_3);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_50, twiddle_5_0_0);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_51, twiddle_5_1_0);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_60, twiddle_6_0_0);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_70, as_server_7_0_jar);
+ asSystemJar.put(IJBossToolingConstants.SERVER_AS_71, as_server_7_1_jar);
+ asSystemJar.put(IJBossToolingConstants.SERVER_EAP_43, twiddle_eap_4_3);
+ asSystemJar.put(IJBossToolingConstants.SERVER_EAP_50, twiddle_eap_5_0);
+ asSystemJar.put(IJBossToolingConstants.SERVER_EAP_60, eap_server_6_0_jar);
+
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_32, IJBossToolingConstants.AS_32);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_40, IJBossToolingConstants.AS_40);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_42, IJBossToolingConstants.AS_42);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_50, IJBossToolingConstants.AS_50);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_51, IJBossToolingConstants.AS_51);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_60, IJBossToolingConstants.AS_60);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_70, IJBossToolingConstants.AS_70);
+ //serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_71, IJBossToolingConstants.AS_71);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_43, IJBossToolingConstants.EAP_43);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_50, IJBossToolingConstants.EAP_50);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_60, IJBossToolingConstants.EAP_60);
+ }
+
+ private static IServer createDeployOnlyServer() throws CoreException {
+ return createDeployOnlyServer(getDeployFolder(), getTmpDeployFolder());
+ }
+
+ /*
+ * Only for use with JBoss servers, since deploy-only has no custom layout
+ */
+ public static File createMockServerLayout(String serverType) {
+ boolean isEap = false;
+ if(serverType.startsWith(IJBossToolingConstants.EAP_SERVER_PREFIX))
+ isEap = true;
+ String name = serverType + (isEap ? "/jbossas" : "");
+ IPath serverDir = null;
+ if( IJBossToolingConstants.SERVER_AS_32.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_40.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_42.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_50.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_51.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_60.equals(serverType) ||
+ IJBossToolingConstants.SERVER_EAP_43.equals(serverType) ||
+ IJBossToolingConstants.SERVER_EAP_50.equals(serverType)) {
+ serverDir = createAS6AndBelowMockServerDirectory(serverType + getRandomString(),
+ asSystemJar.get(serverType), "default");
+ } else if( IJBossToolingConstants.SERVER_AS_70.equals(serverType) ||
+ IJBossToolingConstants.SERVER_AS_71.equals(serverType)) {
+ serverDir = createAS7StyleMockServerDirectory(name, serverType, asSystemJar.get(serverType));
+ } else if( IJBossToolingConstants.SERVER_EAP_60.equals(serverType)) {
+ serverDir = createEAP6StyleMockServerDirectory(name, serverType, asSystemJar.get(serverType));
+ }
+ return serverDir == null ? null : serverDir.toFile();
+ }
+
+
+ /* Creates a mock file structure first, then creates an IServer out of it */
+ public static IServer createMockServerWithRuntime(String serverType, String name) {
+ try {
+ if( serverType.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER))
+ return createDeployOnlyServer();
+ File f = createMockServerLayout(serverType);
+ return createServerWithRuntime(serverType, name, f);
+ } catch(CoreException ce) {
+ // Since we're in tests, I can throw a runtime exception here
+ throw new RuntimeException("Unable to create IServer " + name + " of type " + serverType, ce);
+ }
+ }
+
+ public static IServer createServerWithRuntime(String serverType, String name) throws CoreException {
+ String loc = TestConstants.getServerHome(serverType);
+ File locFile = new Path(loc).toFile();
+ return createServerWithRuntime(serverType, name, locFile);
+ }
+
+ private static IServer createServerWithRuntime(String serverType, String name, File f) throws CoreException {
+ if( f != null ) {
+ IServerType type = ServerCore.findServerType(serverType);
+ if( ServerUtil.isJBoss7(type)) {
+ return createJBoss7IServer(f.getAbsolutePath(), name);
+ }
+ return createServer(serverType, f.getAbsolutePath(), "default", name);
+ }
+ return null;
+ }
+
+ private static IPath createAS6AndBelowMockServerDirectory(String name, String twiddleJar, String configurationName ) {
+ IPath loc = mockedServers.append(name);
+ try {
+ loc.toFile().mkdirs();
+ loc.append("bin").toFile().mkdirs();
+ loc.append("server").toFile().mkdirs();
+ loc.append("server").append(configurationName).toFile().mkdirs();
+ IPath configConf = loc.append("server").append(configurationName).append("conf");
+ configConf.toFile().mkdirs();
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/" + twiddleJar);
+ FileUtil.fileSafeCopy(twiddleLoc, loc.append("bin").append("twiddle.jar").toFile());
+ File runJar = BundleUtils.getFileLocation("serverMock/run.jar");
+ FileUtil.fileSafeCopy(runJar, loc.append("bin").append("run.jar").toFile());
+ File serviceXml = BundleUtils.getFileLocation("serverMock/jboss-service.xml");
+ FileUtil.fileSafeCopy(serviceXml, configConf.append("jboss-service.xml").toFile());
+ return loc;
+ } catch( CoreException ce ) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ }
+ }
+
+ private static IPath createAS7StyleMockServerDirectory(String name, String serverTypeId, String serverJar) {
+ IPath loc = mockedServers.append(name);
+ try {
+ loc.toFile().mkdirs();
+ IPath serverJarBelongs = loc.append("modules/org/jboss/as/server/main");
+ serverJarBelongs.toFile().mkdirs();
+ File serverJarLoc = BundleUtils.getFileLocation("serverMock/" + serverJar);
+ FileUtil.fileSafeCopy(serverJarLoc, serverJarBelongs.append("anything.jar").toFile());
+ } catch(CoreException ce) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ }
+ return loc;
+ }
+
+ private static IPath createEAP6StyleMockServerDirectory(String name, String serverTypeId, String serverJar) {
+ IPath loc = mockedServers.append(name);
+ try {
+ loc.toFile().mkdirs();
+ IPath productConf = loc.append("bin/product.conf");
+ loc.append("bin").toFile().mkdirs();
+ IOUtil.setContents(productConf.toFile(), "slot=eap");
+ loc.append("modules/org/jboss/as/product/eap/dir/META-INF").toFile().mkdirs();
+ IPath manifest = loc.append("modules/org/jboss/as/product/eap/dir/META-INF/MANIFEST.MF");
+ String manString = "JBoss-Product-Release-Name: EAP\nJBoss-Product-Release-Version: 6.0.0.Alpha\nJBoss-Product-Console-Slot: eap";
+ IOUtil.setContents(manifest.toFile(), manString);
+ } catch(CoreException ce) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ } catch(IOException ioe) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ }
+ return loc;
+ }
+
+ private static IServer createServer(String serverType,
+ String location, String configuration, String name) throws CoreException {
+ IRuntime runtime = RuntimeUtils.createRuntime(serverRuntimeMap.get(serverType), location, configuration);
+ IServer s = ServerCreationUtils.createServer2(runtime, serverType, name);
+ IServerWorkingCopy wc = s.createWorkingCopy();
+ wc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
+ return wc.save(true, new NullProgressMonitor());
+ }
+
+ private static IServer createDeployOnlyServer(String deployLocation, String tempDeployLocation) throws CoreException {
+ return createDeployOnlyServer(deployLocation, tempDeployLocation, "testRuntime", "testServer");
+ }
+ private static IServer createDeployOnlyServer(String deployLocation, String tempDeployLocation,
+ String rtName, String serverName) throws CoreException {
+ IServer s = ServerCreationUtils.createDeployOnlyServer(deployLocation, tempDeployLocation, rtName, serverName);
+ IServerWorkingCopy wc = s.createWorkingCopy();
+ wc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
+ return wc.save(true, new NullProgressMonitor());
+ }
+ private static IServer createJBoss7IServer(String rtLoc, String name) throws CoreException {
+ IRuntime runtime = RuntimeUtils.createRuntime(IJBossToolingConstants.AS_70, rtLoc, null);
+ IServer s = ServerCreationUtils.createServer2(runtime, IJBossToolingConstants.SERVER_AS_70, name);
+ IServerWorkingCopy swc = s.createWorkingCopy();
+ swc.setServerConfiguration(null);
+ swc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+ public static IPath getRandomAbsoluteFolder() {
+ return getBaseDir().append(getRandomString());
+ }
+ private static String getDeployFolder() {
+ return getRandomAbsoluteFolder().append("deploy").toOSString();
+ }
+
+ private static String getTmpDeployFolder() {
+ return getRandomAbsoluteFolder().append("tmpDeploy").toOSString();
+ }
+ private static String getRandomString() {
+ return String.valueOf(System.currentTimeMillis());
+ }
+ private static IPath getBaseDir() {
+ return ASMatrixTests.getDefault().getStateLocation().append("testDeployments");
+ }
+
+
+
+
+ public static void deleteAllServersAndRuntimes() throws Exception {
+ deleteAllServers();
+ deleteAllRuntimes();
+ }
+
+ public static void deleteAllServers() throws CoreException {
+ IServer[] servers = ServerCore.getServers();
+ for( int i = 0; i < servers.length; i++ ) {
+ servers[i].delete();
+ }
+ }
+
+ public static void deleteAllRuntimes() throws CoreException {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for( int i = 0; i < runtimes.length; i++ ) {
+ runtimes[i].delete();
+ }
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/CreateProjectOperationsUtility.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/CreateProjectOperationsUtility.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/CreateProjectOperationsUtility.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,639 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Oct 27, 2003
+ *
+ * To change the template for this generated file go to Window>Preferences>Java>Code Generation>Code and
+ * Comments
+ */
+package org.jboss.tools.as.test.core.internal.utils.wtp;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.earcreation.IEarFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.ejb.project.operations.IEjbFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.internal.ejb.project.operations.EjbFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.internal.project.facet.EARFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.jca.project.facet.ConnectorFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.jca.project.facet.IConnectorFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.jst.j2ee.project.facet.IAppClientFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJavaUtilityProjectCreationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaUtilityProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetInstallDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+
+/**
+ * @author jsholl
+ * @author Ian Tewksbury (ictewksb(a)us.ibm.com)
+ *
+ * To change the template for this generated type comment go to Window>Preferences>Java>Code
+ * Generation>Code and Comments
+ */
+public class CreateProjectOperationsUtility {
+ private static final String APP_CLIENT_PROJ_12 = "myAppClient_12";
+ private static final String APP_CLIENT_PROJ_13 = "myAppClient_13";
+ private static final String APP_CLIENT_PROJ_14 = "myAppClient_14";
+ private static final String APP_CLIENT_PROJ_5 = "myAppClient_5";
+ private static final String APP_CLIENT_PROJ_6 = "myAppClient_6";
+
+ private static final String EJB_PROJ_11 = "myEJB_11";
+ private static final String EJB_PROJ_2 = "myEJB_2";
+ private static final String EJB_PROJ_21 = "myEJB_21";
+ private static final String EJB_PROJ_3 = "myEJB_3";
+ private static final String EJB_PROJ_31 = "myEJB_31";
+
+ private static final String WEB_PROJ_22 = "myWeb_22";
+ private static final String WEB_PROJ_23 = "myWeb_23";
+ private static final String WEB_PROJ_24 = "myWeb_24";
+ private static final String WEB_PROJ_25 = "myWeb_25";
+ private static final String WEB_PROJ_30 = "myWeb_30";
+
+ private static final String CONNECTOR_PROJ_1 = "myConnector_1";
+ private static final String CONNECTOR_PROJ_15 = "myConnector_15";
+
+ /**
+ * Creates and returns a utility project DM provider with the given name and of the given version.
+ * If earName is not null then util project will be added to the EAR with earName
+ *
+ * @param projName name of the project to create
+ * @param earName name of the ear to add the project too, if NULL then don't add to an EAR
+ * @param version version of Application Client to use
+ * @return a Utility Project Data Model with the appropriate properties set
+ */
+ public static IDataModel getUtilityProjectCreationDataModel(String projName, String earName){
+ IDataModel dm = DataModelFactory.createDataModel(new JavaUtilityProjectCreationDataModelProvider());
+ dm.setProperty(IJavaUtilityProjectCreationDataModelProperties.PROJECT_NAME, projName);
+ dm.setProperty(IJavaUtilityProjectCreationDataModelProperties.SOURCE_FOLDER, "src");
+ if(earName != null) {
+ dm.setProperty(IJavaUtilityProjectCreationDataModelProperties.EAR_PROJECT_NAME, earName);
+ }
+ return dm;
+ }
+
+ public void testEAR12_Defaults() throws Exception{
+ IDataModel dm = getEARDataModel("aEAR", null, null, null, JavaEEFacetConstants.EAR_12, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR13_Defaults() throws Exception{
+ IDataModel dm = getEARDataModel("bEAR", null, null, null, JavaEEFacetConstants.EAR_13, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR14_Defaults() throws Exception{
+ IDataModel dm = getEARDataModel("cEAR", null, null, null, JavaEEFacetConstants.EAR_14, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR50_Defaults() throws Exception{
+ IDataModel dm = getEARDataModel("dEAR", null, null, null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_Defaults() throws Exception{
+// IDataModel dm = getEARDataModel("eeEAR", null, null, null, JavaEEFacetConstants.EAR_6, false);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+
+ public void testEAR12_ChangedContentDir() throws Exception{
+ IDataModel dm = getEARDataModel("eEAR", "whosContent", null, null, JavaEEFacetConstants.EAR_12, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR13_ChangedContentDir() throws Exception{
+ IDataModel dm = getEARDataModel("fEAR", "myContent", null, null, JavaEEFacetConstants.EAR_13, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR14_ChangedContentDir() throws Exception{
+ IDataModel dm = getEARDataModel("gEAR", "yourContent", null, null, JavaEEFacetConstants.EAR_14, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR50_ChangedContentDir() throws Exception{
+ IDataModel dm = getEARDataModel("hEAR", "ourContent", null, null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_ChangedContentDir() throws Exception{
+// IDataModel dm = getEARDataModel("iEAR", "herContent", null, null, JavaEEFacetConstants.EAR_6, false);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+
+ public void testEAR12_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("zEAR", null, getJ2EEDependencyList_12(), getJavaDependencyList_12(), JavaEEFacetConstants.EAR_12, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR13_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("yEAR", null, getJ2EEDependencyList_13(), getJavaDependencyList_13(), JavaEEFacetConstants.EAR_13, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR14_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("xEAR", null, getJ2EEDependencyList_14(), getJavaDependencyList_14(), JavaEEFacetConstants.EAR_14, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR50_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("wEAR", null, getJ2EEDependencyList_5(), getJavaDependencyList_5(), JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_WithDependencies() throws Exception{
+// IDataModel dm = getEARDataModel("whyEAR", null, getJ2EEDependencyList_6(), getJavaDependencyList_6(), JavaEEFacetConstants.EAR_6, false);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+
+ public void testEAR12_ChangedContentDir_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("zEAR", "myContent", getJ2EEDependencyList_12(), getJavaDependencyList_12(), JavaEEFacetConstants.EAR_12, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR13_ChangedContentDir_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("yEAR", "ourContent", getJ2EEDependencyList_13(), getJavaDependencyList_13(), JavaEEFacetConstants.EAR_13, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR14_ChangedContentDir_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("xEAR", "theirContent", getJ2EEDependencyList_14(), getJavaDependencyList_14(), JavaEEFacetConstants.EAR_14, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR50_ChangedContentDir_WithDependencies() throws Exception{
+ IDataModel dm = getEARDataModel("wEAR", "yourContent", getJ2EEDependencyList_5(), getJavaDependencyList_5(), JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_ChangedContentDir_WithDependencies() throws Exception{
+// IDataModel dm = getEARDataModel("xyzEAR", "hisContent", getJ2EEDependencyList_6(), getJavaDependencyList_6(), JavaEEFacetConstants.EAR_6, false);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+
+ public void testEAR50_Defaults_WithDD() throws Exception{
+ IDataModel dm = getEARDataModel("myEAR", null, null, null, JavaEEFacetConstants.EAR_5, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_Defaults_WithDD() throws Exception{
+// IDataModel dm = getEARDataModel("mineEAR", null, null, null, JavaEEFacetConstants.EAR_6, true);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+
+ public void testEAR50_ChangedContentDir_WithDD() throws Exception{
+ IDataModel dm = getEARDataModel("yourEAR", "ourContent", null, null, JavaEEFacetConstants.EAR_5, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+// public void testEAR60_ChangedContentDir_WithDD() throws Exception{
+// IDataModel dm = getEARDataModel("thatEAR", "thatContent", null, null, JavaEEFacetConstants.EAR_6, true);
+// OperationTestCase.runAndVerify(dm);
+// }
+
+/*
+ public void testEAR50_WithDependencies_WithDD() throws Exception{
+ IDataModel dm = getEARDataModel("anEAR", null, getJ2EEDependencyList_5(), getJavaDependencyList_5(), JavaEEFacetConstants.EAR_5, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+
+ public void testEAR50_ChangedContentDir_WithDependencies_WithDD() throws Exception{
+ IDataModel dm = getEARDataModel("theirEAR", "gotContent", getJ2EEDependencyList_5(), getJavaDependencyList_5(), JavaEEFacetConstants.EAR_5, true);
+ OperationTestCase.runAndVerify(dm);
+ }
+*/
+
+
+
+
+ public static List getJ2EEDependencyList_12() throws Exception {
+ List dependencies = new ArrayList();
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_12, null, JavaEEFacetConstants.APP_CLIENT_12, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_11, null, null, null, JavaEEFacetConstants.EJB_11, true));
+
+ models.add(getWebDataModel(WEB_PROJ_22, null, null, null, null, JavaEEFacetConstants.WEB_22, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_12() {
+ return Collections.emptyList();
+ }
+
+
+ public static List getJ2EEDependencyList_13() throws Exception {
+ getJ2EEDependencyList_12();
+ List dependencies = new ArrayList();
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_13, null, JavaEEFacetConstants.APP_CLIENT_13, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_2, null, null, null, JavaEEFacetConstants.EJB_2, true));
+
+ models.add(getWebDataModel(WEB_PROJ_23, null, null, null, null, JavaEEFacetConstants.WEB_23, true));
+
+ models.add(getConnectorDataModel(CONNECTOR_PROJ_1, null, null, JavaEEFacetConstants.CONNECTOR_1));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_13() {
+ return Collections.emptyList();
+ }
+
+
+ public static List getJ2EEDependencyList_14() throws Exception {
+ getJ2EEDependencyList_13();
+ List dependencies = new ArrayList();
+
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_14, null, JavaEEFacetConstants.APP_CLIENT_14, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_21, null, null, null, JavaEEFacetConstants.EJB_21, true));
+
+ models.add(getWebDataModel(WEB_PROJ_24, null, null, null, null, JavaEEFacetConstants.WEB_24, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_14() {
+ return Collections.emptyList();
+ }
+
+ public static List getJ2EEDependencyList_5() throws Exception {
+ getJ2EEDependencyList_14();
+ List dependencies = new ArrayList();
+
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_5, null, JavaEEFacetConstants.APP_CLIENT_5, true, false));
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_5 + "_WithDD", null, JavaEEFacetConstants.APP_CLIENT_5, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_3, null, null, null, JavaEEFacetConstants.EJB_3, false));
+ models.add(getEJBDataModel(EJB_PROJ_3 + "_WithDD", null, null, null, JavaEEFacetConstants.EJB_3, true));
+
+ models.add(getWebDataModel(WEB_PROJ_25, null, null, null, null, JavaEEFacetConstants.WEB_25, false));
+ models.add(getWebDataModel(WEB_PROJ_25 + "_WithDD", null, null, null, null, JavaEEFacetConstants.WEB_25, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ /**
+ * Creates and returns an EJB Data Model with the given name and of the given version.
+ * Can also set the clientName to be different then the default.
+ * If earName is not null then AppClient will be added to the EAR with earName, and if appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param clientName name of client jar to create, if NULL or earName is NULL then don't create one
+ * @param clientSourceFolder source folder for client, use default if value is NULL, ignored if clientName is NULL
+ * @param earName name of the EAR to add the project too, if NULL then don't add to an EAR
+ * @param version version of EJB to use
+ * @param createDD only used if version is JEE5, if true then create DD else don't
+ * @return an EJB Model with the appropriate properties set
+ */
+ public static IDataModel getEJBDataModel(String projName, String clientName, String clientSourceFolder, String earName, IProjectFacetVersion version, boolean createDD) {
+ IDataModel dm = DataModelFactory.createDataModel(new EjbFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projName);
+
+ FacetDataModelMap facetMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.EJB);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, earName);
+
+ //only create client if given a client name, and is added to EAR
+ if(clientName != null) {
+ facetModel.setBooleanProperty(IEjbFacetInstallDataModelProperties.CREATE_CLIENT, true);
+ facetModel.setStringProperty(IEjbFacetInstallDataModelProperties.CLIENT_NAME, clientName);
+
+ //use default source folder unless different name is given
+ if(clientSourceFolder != null) {
+ facetModel.setStringProperty(IEjbFacetInstallDataModelProperties.CLIENT_SOURCE_FOLDER, clientSourceFolder);
+ }
+ }
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, createDD);
+
+// if(version.equals(JavaEEFacetConstants.EJB_31))
+// {
+// IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+// javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_6);
+// }
+// else{
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_5);
+// }
+
+
+ return dm;
+ }
+
+
+ /**
+ * Creates and returns an EJB Data Model with the given name and of the given version.
+ * Can also set the clientName to be different then the default, or choose not to have a client.
+ * If earName is not null then AppClient will be added to the EAR with earName, and if appropriate
+ * with or without a deployment descriptor.
+ *
+ * Created so EJB's could be created without clients.
+ *
+ * @param projName name of the project to create
+ * @param clientName name of client jar to create, if NULL or earName is NULL then don't create one
+ * @param clientSourceFolder source folder for client, use default if value is NULL, ignored if clientName is NULL
+ * @param earName name of the EAR to add the project too, if NULL then don't add to an EAR
+ * @param version version of EJB to use
+ * @param createClient if True and earName not NULL then create with client, else dont
+ * @param createDD only used if version is JEE5, if true then create DD else don't
+ * @return an EJB Model with the appropriate properties set
+ */
+ public static IDataModel getEJBDataModel(String projName, String clientName, String clientSourceFolder, String earName, IProjectFacetVersion version, boolean createCleint, boolean createDD) {
+ IDataModel dm = getEJBDataModel(projName, clientName, clientSourceFolder, earName, version, createDD);
+
+ FacetDataModelMap facetMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.EJB);
+ facetModel.setBooleanProperty(IEjbFacetInstallDataModelProperties.CREATE_CLIENT, createCleint);
+
+ return dm;
+ }
+ public static List getJavaDependencyList_5() {
+ return Collections.emptyList();
+ }
+
+// public static List getJ2EEDependencyList_6() throws Exception {
+// getJ2EEDependencyList_5();
+// List dependencies = new ArrayList();
+//
+// List<IDataModel> models = new ArrayList<IDataModel>();
+//
+// models.add(AppClientProjectCreationOperationTest.getAppClientCreationDataModel(APP_CLIENT_PROJ_6, null, JavaEEFacetConstants.APP_CLIENT_6, true, false));
+// models.add(AppClientProjectCreationOperationTest.getAppClientCreationDataModel(APP_CLIENT_PROJ_6 + "_WithDD", null, JavaEEFacetConstants.APP_CLIENT_6, true, true));
+//
+// models.add(EJBProjectCreationOperationTest.getEJBDataModel(EJB_PROJ_31, null, null, null, JavaEEFacetConstants.EJB_31, false));
+// models.add(EJBProjectCreationOperationTest.getEJBDataModel(EJB_PROJ_31 + "_WithDD", null, null, null, JavaEEFacetConstants.EJB_31, true));
+//
+// models.add(WebProjectCreationOperationTest.getWebDataModel(WEB_PROJ_30, null, null, null, null, JavaEEFacetConstants.WEB_30, false));
+// models.add(WebProjectCreationOperationTest.getWebDataModel(WEB_PROJ_30 + "_WithDD", null, null, null, null, JavaEEFacetConstants.WEB_30, true));
+//
+// for(int i = 0; i < models.size(); i++) {
+// OperationTestCase.runDataModel(models.get(i));
+// }
+//
+// dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+//
+// return dependencies;
+// }
+
+ public static List getJavaDependencyList_6() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Creates and returns an EAR Data Model with the given name and of the given version
+ *
+ * @param projName name of the project to create
+ * @param version version of EAR to use
+ * @param contentDir directory to store the content in, if NULL use default
+ * @param dependenciesJ2EE list of J2EE IProjects that this EAR depends on, ignored if NULL
+ * @param dependenciesJava list of Java IProjects that this EAR depends on, ignored if NULL
+ * @param createDD only used if version is JEE5, if true then create DD else don't
+ * @return an EAR Data Model with the appropriate properties set
+ */
+ public static IDataModel getEARDataModel(String projName, String contentDir, List dependenciesJ2EE, List dependenciesJava, IProjectFacetVersion version, boolean createDD) {
+ IDataModel dm = DataModelFactory.createDataModel(new EARFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projName);
+
+ FacetDataModelMap factMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = (IDataModel) factMap.get(IEarFacetInstallDataModelProperties.ENTERPRISE_APPLICATION);
+ facetModel.setProperty(IFacetInstallDataModelProperties.FACET_VERSION, version);
+
+
+ if(contentDir != null) {
+ facetModel.setStringProperty(IEarFacetInstallDataModelProperties.CONTENT_DIR,contentDir);
+ }
+
+ if(dependenciesJ2EE != null) {
+ facetModel.setProperty(IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST, dependenciesJ2EE);
+ }
+
+ if(dependenciesJava != null) {
+ facetModel.setProperty(IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST, dependenciesJava);
+ }
+
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, createDD);
+
+
+ return dm;
+ }
+
+
+ /**
+ * Creates and returns an Application Client Data Model with the given name and of the given version.
+ * If earName is not null then AppClient will be added to the EAR with earName, and if appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param earName name of the ear to add the project too, if NULL then don't add to an EAR
+ * @param version version of Application Client to use
+ * @param createDefaultMainClass if true then create default main class, else don't
+ * @param createDD only used if version is JEE5, if true then create DD else don't
+ * @return an Application Data Model with the appropriate properties set
+ */
+ public static IDataModel getAppClientCreationDataModel(String projName, String earName, IProjectFacetVersion version, boolean createDefaultMainClass, boolean createDD){
+ IDataModel dm = DataModelFactory.createDataModel(new AppClientFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.APPLICATION_CLIENT);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+ facetModel.setProperty(IAppClientFacetInstallDataModelProperties.CREATE_DEFAULT_MAIN_CLASS, createDefaultMainClass);
+
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, createDD);
+
+// if(version.equals(JavaEEFacetConstants.APP_CLIENT_6))
+// {
+// IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+// javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_6);
+// }
+// else{
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_5);
+// }
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns a Web Data Model with the given name and of the given version.
+ * Can also be used to specify none default context root, content directory, and/or
+ * the java source directory.
+ * If earName is not null then Web will be added to the EAR with earName, and if appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param earName name of the ear to add the project too, if NULL then don't add to an EAR
+ * @param contextRoot the context root to use for this project, use default if NULL
+ * @param contentDir the content directory to use for this project, use default if NULL
+ * @param javaSrcDir the java source directory to use for this project, use default if NULL
+ * @param version version of Web to use
+ * @param createDD only used if version is JEE5, if true then create DD else don't
+ * @return a Web Data Model with the appropriate properties set
+ */
+ public static IDataModel getWebDataModel(String projName, String earName, String contextRoot, String contentDir, String javaSrcDir, IProjectFacetVersion version, boolean createDD){
+ IDataModel dm = DataModelFactory.createDataModel(new WebFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.DYNAMIC_WEB);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ //if no contextRoot provided use default, contextRoot only matters if adding to EAR
+ if(contextRoot != null && earName != null) {
+ facetModel.setStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, contextRoot);
+ }
+
+ //if no contentDir provided use default
+ if(contentDir != null) {
+ facetModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER, contentDir);
+ }
+
+ //if no javaSrcDir provided use default
+ if(javaSrcDir != null) {
+ facetModel.setStringProperty(IWebFacetInstallDataModelProperties.SOURCE_FOLDER, javaSrcDir);
+ }
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD, createDD);
+
+// if(version.equals(JavaEEFacetConstants.WEB_30)) {
+// IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+// javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_6);
+// }
+// else{
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_5);
+// }
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns an Connector Data Model with the given name and of the given version.
+ * If earName is not null then Connector will be added to the EAR with earName.
+ * Can also specify none default source folder
+ *
+ * @param projName name of the project to create
+ * @param earName name of the EAR to add the project too, if NULL then don't add to an EAR
+ * @param sourceFolder name of the source folder to use, if NULL then use default
+ * @param version version of Application Client to use
+ * @return a Connector Model with the appropriate properties set
+ */
+ public static IDataModel getConnectorDataModel(String projName, String earName, String sourceFolder, IProjectFacetVersion version){
+ IDataModel dm = DataModelFactory.createDataModel(new ConnectorFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME, projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME, earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap) dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JCA);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ if(sourceFolder != null) {
+ facetModel.setProperty(IConnectorFacetInstallDataModelProperties.CONFIG_FOLDER, sourceFolder);
+ }
+
+ //be sure to use Java5 with JEE5
+ if(version == JavaEEFacetConstants.CONNECTOR_15){
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_5);
+ }
+// else if(version == JavaEEFacetConstants.CONNECTOR_16) {
+// IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+// javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, JavaEEFacetConstants.JAVA_6);
+// }
+
+ return dm;
+ }
+}
\ No newline at end of file
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/JavaEEFacetConstants.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/JavaEEFacetConstants.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/JavaEEFacetConstants.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.as.test.core.internal.utils.wtp;
+
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+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;
+
+public class JavaEEFacetConstants {
+
+ public static final IProjectFacet APP_CLIENT_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_APPCLIENT_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_12 = APP_CLIENT_FACET.getVersion("1.2"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_13 = APP_CLIENT_FACET.getVersion("1.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_14 = APP_CLIENT_FACET.getVersion("1.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_5 = APP_CLIENT_FACET.getVersion("5.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion APP_CLIENT_6 = APP_CLIENT_FACET.getVersion("6.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet EJB_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EJB_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_11 = EJB_FACET.getVersion("1.1"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_2 = EJB_FACET.getVersion("2.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_3 = EJB_FACET.getVersion("3.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion EJB_31 = EJB_FACET.getVersion("3.1"); //$NON-NLS-1$
+
+ public static final IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_22 = WEB_FACET.getVersion("2.2"); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_23 = WEB_FACET.getVersion("2.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_24 = WEB_FACET.getVersion("2.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_25 = WEB_FACET.getVersion("2.5"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion WEB_30 = WEB_FACET.getVersion("3.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet CONNECTOR_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_CONNECTOR_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion CONNECTOR_1 = CONNECTOR_FACET.getVersion("1.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion CONNECTOR_15 = CONNECTOR_FACET.getVersion("1.5"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion CONNECTOR_16 = CONNECTOR_FACET.getVersion("1.6"); //$NON-NLS-1$
+
+ public static final IProjectFacet EAR_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_12 = EAR_FACET.getVersion("1.2"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_13 = EAR_FACET.getVersion("1.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_14 = EAR_FACET.getVersion("1.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_5 = EAR_FACET.getVersion("5.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion EAR_6 = EAR_FACET.getVersion("6.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_JAVA); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_13 = JAVA_FACET.getVersion("1.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_14 = JAVA_FACET.getVersion("1.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_5 = JAVA_FACET.getVersion("5.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion JAVA_6 = JAVA_FACET.getVersion("6.0"); //$NON-NLS-1$
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/OperationTestCase.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/OperationTestCase.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/OperationTestCase.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.as.test.core.internal.utils.wtp;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.IWorkspaceRunnableWithStatus;
+import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
+import org.eclipse.wst.validation.internal.operations.ValidationBuilder;
+
+
+/**
+ * @author jsholl
+ * @author itewk
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public abstract class OperationTestCase extends TestCase {
+
+ public static final String VALIDATOR_JOB_FAMILY = "validators";
+ public static String fileSep = System.getProperty("file.separator"); //$NON-NLS-1$
+ public static IStatus OK_STATUS = new Status(IStatus.OK, "org.eclipse.jem.util", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ try{
+ deleteAllProjects();
+ } finally {
+ RendererFactory.getDefaultRendererFactory().setValidating(false);
+ }
+ }
+
+ public static void deleteAllProjects() {
+ try {
+ waitOnJobs();
+ } catch (InterruptedException e1) {
+
+ }
+ IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(null) {
+ public void run(IProgressMonitor pm) throws CoreException {
+ try {
+ ProjectUtility.deleteAllProjects();
+ } catch (Exception e) {
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(workspaceRunnable, null);
+ } catch (CoreException e) {
+
+ }
+ }
+
+ public OperationTestCase() {
+ super("OperationsTestCase"); //$NON-NLS-1$
+ }
+
+ public OperationTestCase(String name) {
+ super(name);
+ }
+
+ public static void runAndVerify(IDataModel dataModel) throws Exception {
+ OperationTestCase.runAndVerify(dataModel, true, true);
+ }
+ public static void runDataModel(IDataModel dataModel) throws Exception {
+ OperationTestCase.runDataModel(dataModel, true, true);
+ }
+
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean checkLog) throws Exception {
+ OperationTestCase.runDataModel(dataModel, checkTasks, checkLog, null, true, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean checkLog) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, null, true, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean checkLog, boolean waitForBuildToComplete) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, null, true, waitForBuildToComplete);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, errorOKList, reportIfExpectedErrorNotFound, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean waitForBuildToComplete) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, errorOKList, reportIfExpectedErrorNotFound, waitForBuildToComplete, false);
+ }
+
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean waitForBuildToComplete) throws Exception {
+ runDataModel(dataModel, checkTasks, checkLog, errorOKList, reportIfExpectedErrorNotFound, waitForBuildToComplete, false);
+ }
+
+ /**
+ * Guaranteed to close the dataModel
+ *
+ * @param dataModel
+ * @throws Exception
+ */
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean waitForBuildToComplete, boolean removeAllSameTypesOfErrors) throws Exception {
+ PostBuildListener listener = null;
+ IWorkspaceDescription desc = null;
+ try {
+ if (waitForBuildToComplete) {
+ listener = new PostBuildListener();
+ desc = ResourcesPlugin.getWorkspace().getDescription();
+ desc.setAutoBuilding(false);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_BUILD);
+ }
+
+ //deal with weather to fail on logged statuses or not
+ //BaseTestCase.failOnLoggedStatus(checkLog);
+
+ IStatus operationStatus = dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+ if (waitForBuildToComplete) {
+ desc.setAutoBuilding(true);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ while (!listener.isBuildComplete()) {
+ Thread.sleep(3000);// do nothing till all the jobs are completed
+ }
+ }
+
+ // bug 173933 - runAndVerify() fails to check return IStatus
+ if (operationStatus.getSeverity() == IStatus.ERROR) {
+ Throwable throwable = operationStatus.getException();
+ String throwableStr = null;
+ if(throwable != null){
+ throwable.printStackTrace();
+ throwableStr = getStackTrace(throwable);
+ }
+ if(throwableStr == null){
+ throwableStr = "no message";
+ }
+ Assert.fail(operationStatus.getMessage()+"\n caused by: "+throwableStr);
+ }
+
+ /*//Verifiers don't exist
+ //run data model verifications
+ DataModelVerifierFactory verifierFactory = DataModelVerifierFactory.getInstance();
+ DataModelVerifier verifier = verifierFactory.createVerifier(dataModel);
+ verifier.verify(dataModel);
+
+ if (checkTasks && (errorOKList == null || errorOKList.isEmpty())) {
+ checkTasksList();
+ } else if (checkTasks && errorOKList != null && !errorOKList.isEmpty()) {
+ TaskViewUtility.verifyErrors(errorOKList, reportIfExpectedErrorNotFound, removeAllSameTypesOfErrors);
+ }
+ */
+ } finally {
+ if (listener != null)
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
+ dataModel.dispose();
+ }
+ }
+
+ public static String getStackTrace(Throwable throwable){
+ StringBuffer buffer = new StringBuffer(throwable.toString()+"\n");
+ StackTraceElement[] stack = throwable.getStackTrace();
+ for (int i=0; i<stack.length; i++)
+ buffer.append("\tat " + stack[i]+"\n");
+
+ StackTraceElement[] parentStack = stack;
+ throwable = throwable.getCause();
+ while (throwable != null) {
+ buffer.append("Caused by: ");
+ buffer.append(throwable);
+ buffer.append("\n");
+ StackTraceElement[] currentStack = throwable.getStackTrace();
+ parentStack = currentStack;
+ throwable = throwable.getCause();
+ }
+ return buffer.toString();
+ }
+ /**
+ * Guaranteed to close the dataModel
+ *
+ * @param dataModel
+ * @throws Exception
+ */
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean waitForBuildToComplete, boolean removeAllSameTypesOfErrors) throws Exception {
+ PostBuildListener listener = null;
+ IWorkspaceDescription desc = null;
+ try {
+ if (waitForBuildToComplete) {
+ listener = new PostBuildListener();
+ desc = ResourcesPlugin.getWorkspace().getDescription();
+ desc.setAutoBuilding(false);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_BUILD);
+ }
+
+ //deal with weather to fail on logged statuses or not
+ //BaseTestCase.failOnLoggedStatus(checkLog);
+
+ dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+ if (waitForBuildToComplete) {
+ desc.setAutoBuilding(true);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ while (!listener.isBuildComplete()) {
+ Thread.sleep(3000);// do nothing till all the jobs are completeled
+ }
+ }
+ if (checkTasks && (errorOKList == null || errorOKList.isEmpty())) {
+ checkTasksList();
+ } else if (checkTasks && errorOKList != null && !errorOKList.isEmpty()) {
+ TaskViewUtility.verifyErrors(errorOKList, reportIfExpectedErrorNotFound, removeAllSameTypesOfErrors);
+ }
+
+ } finally {
+ if (listener != null)
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
+ dataModel.dispose();
+ }
+ }
+
+
+ protected static void checkTasksList() {
+ //TaskViewUtility.verifyNoErrors();
+ }
+
+ public static void verifyValidDataModel(IDataModel dataModel) {
+ IStatus status = dataModel.validate();
+
+ if (!status.isOK() && status.getSeverity() == IStatus.ERROR) {
+ Assert.assertTrue("DataModel is invalid operation will not run:" + status.toString(), false); //$NON-NLS-1$
+ }
+ }
+
+ public static void verifyInvalidDataModel(IDataModel dataModel) {
+ IStatus status = dataModel.validate();
+ if (status.isOK()) {
+ Assert.assertTrue("DataModel should be invalid:" + status.getMessage(), false); //$NON-NLS-1$
+ }
+ }
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ // Wait for all validation jobs to end before ending test....
+ waitOnJobs();
+
+ }
+
+ public static void waitOnJobs() throws InterruptedException {
+ IProject[] projects = ProjectUtility.getAllProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ Job.getJobManager().join(project.getName() + VALIDATOR_JOB_FAMILY,null);
+ }
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD,null);
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD,null);
+ Job.getJobManager().join(ValidationBuilder.FAMILY_VALIDATION_JOB,null);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/PostBuildListener.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/PostBuildListener.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/PostBuildListener.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.as.test.core.internal.utils.wtp;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+
+public class PostBuildListener implements IResourceChangeListener {
+ private boolean buildComplete = false;
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (event.getType() == IResourceChangeEvent.POST_BUILD){
+ buildComplete = true;
+ }
+ }
+
+ public boolean isBuildComplete() {
+ return buildComplete;
+ }
+
+ public void testComplete() {
+ buildComplete = false;
+ }
+}
\ No newline at end of file
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/ProjectUtility.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/ProjectUtility.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/ProjectUtility.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.as.test.core.internal.utils.wtp;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.AssertionFailedException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+/**
+ * @author jsholl
+ *
+ * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To
+ * enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
+ */
+public class ProjectUtility {
+ public static IProject[] getAllProjects() {
+ IProject[] projects = new IProject[0];
+ try {
+ projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ } catch (AssertionFailedException ex) {
+ // Catch Malformed tree exception that occurs from time to time...
+ }
+ return projects;
+ }
+ public static boolean projectExists(String projectName) {
+ return getProject(projectName) != null;
+ }
+ public static IProject verifyAndReturnProject(String projectName, boolean exists) {
+ IProject project = getProject(projectName);
+ if (exists) {
+ Assert.assertTrue("Project Does Not Exist:" + projectName, project.exists());
+ } else {
+ Assert.assertTrue("Project Exists:" + projectName, !project.exists());
+ }
+ return project;
+ }
+ public static void verifyProject(String projectName, boolean exists) {
+ IProject project = getProject(projectName);
+ if (exists) {
+ Assert.assertTrue("Project Does Not Exist:" + projectName, project.exists());
+ } else {
+ Assert.assertTrue("Project Exists:" + projectName, !project.exists());
+ }
+ }
+ public static IProject getProject(String projectName) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ String pathString = projectName;
+ if (!(workspace.getRoot().getProject(pathString) == null))
+ return workspace.getRoot().getProject(pathString);
+ else
+ return null;
+ }
+ public static void verifyNoProjects() {
+ IProject[] projects = getAllProjects();
+ String projectNames = "";
+ for (int i = 0; i < projects.length; i++) {
+ projectNames += " " + projects[i].getName();
+ }
+ Assert.assertTrue("All projects not deleted" + projectNames, projects.length == 0);
+ }
+ public static void deleteProjectIfExists(String projectName) {
+ if (projectName == null)
+ return;
+ IProject project = getProject(projectName);
+ if (project != null && project.isAccessible()) {
+ try {
+ project.close(null);
+ project.delete(true, true, null);
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+ }
+ public static void deleteAllProjects() throws Exception {
+ //closing projects and tread work in here is a hack because of a BeanInfo bug holding
+ //onto jars loaded in another VM
+
+// for (int i = 0; i < projects.length; i++) {
+// if (projects[i].exists()) {
+// projects[i].close(null); // This should signal the extra VM to kill itself
+// }
+// }
+ // Thread.yield(); // give the VM a chance to die
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) {
+ IProject[] projects = getAllProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ boolean success = false;
+ Exception lastException = null;
+ // Don't make 2^12 is about 4 seconds which is the max we
+ // will wait for the VM to die
+ for (int j = 0; j < 13 && !success; j++) {
+ try {
+ if (project.exists()) {
+ project.delete(true, true, null);
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ success = true;
+ } catch (Exception e) {
+ lastException = e;
+ if (project.exists()) {
+ try {
+ project.close(null);
+ project.open(null);
+ } catch (Exception e2) {
+ }
+ }
+ try {
+ Thread.sleep((int) Math.pow(2, j));
+ } catch (InterruptedException e1) {
+ } // if the VM
+ // isn't dead,
+ // try sleeping
+ }
+ }
+ if (!success && lastException != null) {
+ // TODO Log
+ // Assert.fail("Caught Exception=" +
+ // lastException.getMessage() + " when deleting
+ // project=" + project.getName());
+ }
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+ } catch (CoreException ce) {
+ }
+ //verifyNoProjects();
+ }
+ /**
+ * Return the absolute path Strings to the files based on the fileSuffix and
+ * path within the plugin.
+ *
+ * @param path
+ * @param fileSuffix
+ * the file ending with the "." if required (the suffix will be
+ * used as is)
+ * @return
+ */
+ public static List getSpecificFilesInDirectory(Plugin plugin, String path, final String fileSuffix) {
+ URL entry = null;
+ entry = plugin.getBundle().getEntry(path);
+ List result = null;
+ File folder = null;
+ if (entry != null) {
+ try {
+ entry = Platform.asLocalURL(entry);
+ folder = new File(new URI(entry.toString()));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ return Collections.EMPTY_LIST;
+ }
+ List files = Arrays.asList(folder.list());
+ if (!files.isEmpty()) {
+ String folderPath = folder.getAbsolutePath() + File.separator;
+ result = new ArrayList();
+ for (int i = 0; i < files.size(); i++) {
+ String fileName = (String) files.get(i);
+ if (!fileName.endsWith(fileSuffix))
+ continue;
+ result.add(folderPath + fileName);
+ }
+ }
+ }
+ if (result == null)
+ result = Collections.EMPTY_LIST;
+ return result;
+ }
+ public static List getJarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".jar");
+ }
+ public static List getRarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".rar");
+ }
+ public static List getEarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".ear");
+ }
+ public static List getWarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".war");
+ }
+ public static String getFullFileName(Plugin plugin, String pluginRelativeFileName) throws IOException {
+ IPath path = new Path(pluginRelativeFileName);
+ if (path.getDevice() != null)
+ return pluginRelativeFileName;
+ URL url = plugin.getBundle().getEntry(pluginRelativeFileName);
+ if (url != null) {
+ url = Platform.asLocalURL(url);
+ IPath iPath = new Path(url.getPath());
+ return iPath.toOSString();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/TaskViewUtility.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/TaskViewUtility.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/wtp/TaskViewUtility.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.as.test.core.internal.utils.wtp;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author jsholl
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class TaskViewUtility {
+
+ public static IResource getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public static void verifyNoNewTasks(HashSet hashSet) {
+ verifyNoNewTasks(null, hashSet);
+ }
+
+ public static void verifyNoNewTasks(IResource resource, HashSet hashSet) {
+ verifyNoNewTasksImpl(resource, hashSet, true);
+ }
+
+ private static void verifyNoNewTasksImpl(IResource resource, HashSet hashSet, boolean failOnFailure) {
+ IResource markerSource = resource == null ? getWorkspaceRoot() : resource;
+ IMarker[] markers = null;
+ try {
+ markers = markerSource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ Assert.fail();
+ }
+ for (int j = 0; markers != null && j < markers.length; j++) {
+ String message = markers[j].toString();
+ try {
+ message = (String) markers[j].getAttribute(IMarker.MESSAGE);
+ } catch (Exception e) {
+ }
+
+ if (null == hashSet) {
+ String failMsg = "Task in Tasks List: " + message;
+ if (failOnFailure) {
+ Assert.fail(failMsg);
+ } else {
+ System.out.println(failMsg);
+ }
+ } else if (!hashSet.contains(markers[j])) {
+ String failMsg = "New Task in Tasks List: " + message;
+ if (failOnFailure) {
+ Assert.fail(failMsg);
+ } else {
+ System.out.println(failMsg);
+ }
+
+ }
+ }
+ }
+
+ public static void verifyNoErrors() {
+ verifyNoErrors(null);
+ }
+
+ public static void verifyNoErrors(IResource resource) {
+ List markers = getErrors(resource);
+ if (null != markers && markers.size() > 0) {
+ int size = markers.size();
+ String message = "" + size + " errors in tasks view:";
+ IMarker marker;
+ for (int i = 0; i < size; i++) {
+ marker = (IMarker) markers.get(i);
+ try {
+ message += "\n" + i + " " + (String) marker.getAttribute(IMarker.MESSAGE);
+ } catch (Exception e) {
+ }
+ }
+ Assert.fail(message);
+ }
+ }
+
+ /**
+ * @param resource
+ * @return
+ */
+ public static List getErrors(IResource resource) {
+ IResource markerSource = resource == null ? getWorkspaceRoot() : resource;
+ List markers = null;
+ try {
+ markers = findSeverityMarkers(markerSource, IMarker.SEVERITY_ERROR);
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ return markers;
+ }
+
+ private static List findSeverityMarkers(IResource markerSource, int severityLevel) throws CoreException {
+ IMarker[] markers = markerSource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ List results = null;
+ Integer severity;
+ for (int i = 0; i < markers.length; i++) {
+ severity = (Integer) markers[i].getAttribute(IMarker.SEVERITY);
+ if (severity.intValue() == severityLevel) {
+ if (results == null)
+ results = new ArrayList();
+ results.add(markers[i]);
+ }
+ }
+ if (results == null)
+ results = Collections.EMPTY_LIST;
+ return results;
+ }
+
+ public static void verifyNoWarnings() {
+
+ }
+
+ public static void verifyNoTasks() {
+ verifyNoTasks(null);
+ }
+
+ public static void verifyNoTasks(IResource resource) {
+ verifyNoNewTasksImpl(resource, null, true);
+ }
+
+ public static void verifyNoTasks(boolean failOnFailure) {
+ verifyNoTasks(null, failOnFailure);
+ }
+
+ public static void verifyNoTasks(IResource resource, boolean failOnFailure) {
+ verifyNoNewTasksImpl(resource, null, failOnFailure);
+ }
+ public static void verifyErrors(List markerDescriptionsExpected) {
+ verifyErrors(markerDescriptionsExpected,true,false);
+ }
+
+
+ public static void verifyErrors(List markerDescriptionsExpected, boolean reportIfExpectedErrorNotFound, boolean removeAllSameTypesOfError) {
+ List markerDescriptionsFound = null;
+ try {
+ List markersFound = findSeverityMarkers(getWorkspaceRoot(), IMarker.SEVERITY_ERROR);
+ markerDescriptionsFound = new ArrayList(markersFound.size());
+ for (int i = 0; i < markersFound.size(); i++) {
+ markerDescriptionsFound.add(((IMarker) markersFound.get(i)).getAttribute("message"));
+ }
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ Assert.fail();
+ }
+
+ ArrayList markerDescriptionsNotFound = new ArrayList();
+ List markersDescriptionsToRemove = new ArrayList();
+ for (int i = 0; i < markerDescriptionsExpected.size(); i++) {
+ String messageToFind = (String)markerDescriptionsExpected.get(i);
+ boolean found = false;
+ for(int j=0;j<markerDescriptionsFound.size() &&(!found || removeAllSameTypesOfError);j++){
+ if(messageToFind.equals(markerDescriptionsFound.get(j))){
+ found = true;
+ markersDescriptionsToRemove.add(markerDescriptionsFound.get(j));
+ }
+ }
+ if (!found) {
+ markerDescriptionsNotFound.add(messageToFind);
+ }
+ }
+ markerDescriptionsFound.removeAll(markersDescriptionsToRemove);
+ if (markerDescriptionsNotFound.size() > 0 || markerDescriptionsFound.size() > 0) {
+ String messages = "";
+ if (reportIfExpectedErrorNotFound){
+ for (int i = 0; i < markerDescriptionsNotFound.size(); i++) {
+ messages += "\nError not found:\"" + markerDescriptionsNotFound.get(i)+"\"";
+ }
+ }
+ for (int i = 0; i < markerDescriptionsFound.size(); i++) {
+ messages += "\nUnexpected error found:\"" + markerDescriptionsFound.get(i)+"\"";
+ }
+ if (!messages.equals(""))
+ Assert.fail(messages);
+ }
+
+ }
+}
\ No newline at end of file
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/launch/MockArgsTests.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/launch/MockArgsTests.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/launch/MockArgsTests.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.launch;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IProcessProvider;
+import org.jboss.ide.eclipse.as.core.server.internal.DelegatingServerBehavior;
+import org.jboss.ide.eclipse.as.core.server.internal.LocalJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.as.test.core.parametized.server.ServerParameterUtils;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class MockArgsTests extends TestCase {
+ private String serverType;
+ private IServer server;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getAllJBossServerTypeParamterers());
+ }
+ public MockArgsTests(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ASMatrixTests.cleanup();
+ }
+
+ @Test
+ protected IServer runAndVerifyArgs() {
+ IServer server = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType);
+ IServer fixed = setMockDetails(server);
+ String command = runAndGetCommand(fixed);
+ assertFalse("No args found from process", command == null || command.trim().length() == 0);
+
+ LocalJBossServerRuntime rt = (LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class, new NullProgressMonitor());
+ String defaultArgs = rt.getDefaultRunArgs().replace("\"", "");
+ String defaultVMArgs = rt.getDefaultRunVMArgs().replace("\"", "");
+ assertTrue(command.replace("\"", "").contains(defaultArgs.trim()));
+ assertTrue(command.replace("\"", "").contains(defaultVMArgs.trim()));
+ return fixed;
+ }
+
+ public void testRemoveCriticalVMArgs() {
+ IServer server = runAndVerifyArgs();
+ try {
+ ILaunchConfiguration config = server.getLaunchConfiguration(true, new NullProgressMonitor());
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "hello");
+ wc.doSave();
+
+ // re-get it and check the changes
+ ILaunchConfiguration launchConfig = server.getLaunchConfiguration(false, null);
+ String vmArgs = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
+ LocalJBossServerRuntime rt = (LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class, new NullProgressMonitor());
+ String defaultVMArgs = rt.getDefaultRunVMArgs();
+ assertFalse(vmArgs == null);
+ assertFalse(vmArgs.equals(rt.getDefaultRunVMArgs()));
+ assertFalse(vmArgs.equals(defaultVMArgs));
+ assertTrue(vmArgs.startsWith("hello -Djava.endorsed.dirs=\""));
+ assertTrue(vmArgs.endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.test/mockedServers/server1/lib/endorsed\""));
+ } catch(CoreException ce) {
+ fail(ce.getMessage());
+ }
+ }
+
+ public void testChangeArgs() {
+ // should still match the defaults since the defaults are extremely all required
+ IServer server = runAndVerifyArgs();
+ try {
+ ILaunchConfiguration config = server.getLaunchConfiguration(true, new NullProgressMonitor());
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
+ wc.doSave();
+ String command = runAndGetCommand(server);
+ assertFalse("No args found from process", command == null || command.trim().length() == 0);
+ LocalJBossServerRuntime rt = (LocalJBossServerRuntime)server.getRuntime().loadAdapter(LocalJBossServerRuntime.class, new NullProgressMonitor());
+ String defaultArgs = rt.getDefaultRunArgs().replace("\"", "");
+ assertTrue(command.replace("\"", "").contains(defaultArgs));
+ } catch(CoreException ce) {
+ fail(ce.getMessage());
+ }
+ }
+
+
+ protected IProcess runAndGetProcess(final IServer server) {
+ try {
+ server.start("run", new NullProgressMonitor());
+ } catch( CoreException ce) {}
+
+ int loops = 0;
+ DelegatingServerBehavior behavior = (DelegatingServerBehavior)server.loadAdapter(DelegatingServerBehavior.class, null);
+
+ while(loops < 50) {
+ if( ((IProcessProvider)behavior.getDelegate()).getProcess() != null ) {
+ return ((IProcessProvider)behavior.getDelegate()).getProcess();
+ }
+ try {
+ loops++;
+ Thread.sleep(1000);
+ } catch(Exception e){}
+ }
+ return null;
+ }
+
+ protected String runAndGetCommand(final IServer server) {
+ return runAndGetProcess(server).getAttribute(IProcess.ATTR_CMDLINE);
+ }
+
+ private IServer setMockDetails(IServer server) {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ ServerAttributeHelper helper = new ServerAttributeHelper(server, copy);
+ helper.setAttribute("start-timeout", "2");
+ helper.setAttribute("org.jboss.ide.eclipse.as.core.server.attributes.startupPollerKey",
+ "org.jboss.ide.eclipse.as.core.runtime.server.timeoutpoller");
+ try {
+ return copy.save(true, new NullProgressMonitor());
+ } catch( CoreException ce ) {
+ }
+ return null;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,69 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This class will test properties of a default created server and runtime
+ * for properties that should never be null.
+ *
+ * @author rob
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class CreateRuntimeTwiceTest extends TestCase {
+ private String serverType;
+ private IServer server;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getAllJBossServerTypeParamterers());
+ }
+
+ public CreateRuntimeTwiceTest(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @Before
+ public void setUp() {
+ server = ServerCreationTestUtils.createMockServerWithRuntime(serverType, getClass().getName() + serverType);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ServerCreationTestUtils.deleteAllServersAndRuntimes();
+ }
+
+ @Test
+ private void createRuntimes(String serverTypeId) throws CoreException {
+ IServerType type = ServerCore.findServerType(serverTypeId);
+ IRuntimeType runtimeType = type.getRuntimeType();
+
+ IRuntimeWorkingCopy firstRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
+ IRuntime savedRuntime = firstRuntime.save(true, new NullProgressMonitor());
+
+ IRuntimeWorkingCopy secondRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
+ IRuntime secondSavedRuntime = secondRuntime.save(true, new NullProgressMonitor());
+
+ assertEquals(savedRuntime.getName(), secondSavedRuntime.getName());
+ assertNotSame(savedRuntime, secondSavedRuntime);
+ assertFalse("Why are two different runtimes " + runtimeType.getId() + " created with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,104 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.io.File;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.archives.webtools.filesets.Fileset;
+import org.jboss.ide.eclipse.archives.webtools.filesets.FilesetUtil;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This class will test properties of a default created server and runtime
+ * for properties that should never be null.
+ *
+ * @author rob
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class CreateServerCheckDefaultsTest extends TestCase {
+ private String serverType;
+ private IServer server;
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getAllJBossServerTypeParamterers());
+ }
+
+ public CreateServerCheckDefaultsTest(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @Before
+ public void setUp() {
+ server = ServerCreationTestUtils.createMockServerWithRuntime(serverType, getClass().getName() + serverType);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ServerCreationTestUtils.deleteAllServersAndRuntimes();
+ }
+
+ @Test
+ public void testServerDefaults() {
+ assertNotNull("Test setup failed to create a server", server);
+ assertNotNull("Created server of type " + server.getServerType().getId() + " has no runtime", server.getRuntime());
+ assertFalse("Server name should not be empty", server.getName() == null || "".equals(server.getName()));
+ assertFalse("Runtime name should not be empty", server.getRuntime().getName() == null || "".equals(server.getRuntime().getName()));
+
+ IJBossServerRuntime rt = getJBossRuntime(server);
+ assertNotNull("Created server does not adapt to IJBossServerRuntime", rt);
+ assertNotNull(rt.getVM());
+ assertNotNull(rt.getExecutionEnvironment());
+
+ LocalJBoss7ServerRuntime jb7rt = (LocalJBoss7ServerRuntime)server.getRuntime().loadAdapter(LocalJBoss7ServerRuntime.class, null);
+ if( jb7rt != null ) {
+ assertEquals("standalone.xml", jb7rt.getConfigurationFile());
+ } else {
+ assertEquals("default", rt.getJBossConfiguration());
+ }
+ }
+
+ @Test
+ public void testXPathsAdded() {
+ JobUtils.waitForIdle();
+ IServer s = server;
+ XPathCategory[] cats = XPathModel.getDefault().getCategories(s);
+ assertFalse("Server has no xpath categories automatically added", cats == null || cats.length == 0);
+ assertNotNull("Server has no 'ports' xpath category. ", XPathModel.getDefault().getCategory(s, "Ports"));
+ File xpathFile = JBossServerCorePlugin.getServerStateLocation(s).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
+ try {
+ assertTrue("The XPath File has not been created. Xpaths will be lost on workspace restart. " + xpathFile.getAbsolutePath(), xpathFile.exists());
+ } catch( Error t) {
+ t.printStackTrace();
+ throw t;
+ }
+ }
+
+ @Test
+ public void testDefaultFilesetsAdded() {
+ Fileset[] fs = FilesetUtil.loadFilesets(server);
+ assertNotNull("No filesets created", fs);
+ assertTrue("0 filesets added for server " + server.getName(), fs.length > 0);
+ }
+
+ private IJBossServerRuntime getJBossRuntime(IServer s) {
+ IRuntime rt = s.getRuntime();
+ return (IJBossServerRuntime) rt.loadAdapter(IJBossServerRuntime.class, null);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/Ear50CreationTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/Ear50CreationTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/Ear50CreationTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,74 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.internal.utils.ProjectRuntimeUtil;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class Ear50CreationTest extends Assert {
+ private static String PROJECT_PREFIX = "a1Ear";
+ private static int PROJECT_ID = 1;
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getJBossServerTypeParamterers());
+ }
+
+ private String serverType;
+ public Ear50CreationTest(String serverType) {
+ this.serverType = serverType;
+ }
+ /* Verify all servers > 42 do NOT create the application.xml file */
+ @Test
+ public void testApplicationXML() throws Exception {
+ String projectName = PROJECT_PREFIX + PROJECT_ID;
+ IServer server = ServerCreationTestUtils.createMockServerWithRuntime(serverType, "server" + PROJECT_ID);
+ PROJECT_ID++;
+
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(projectName, "contentDirS", null, null, JavaEEFacetConstants.EAR_5, false);
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, RuntimeManager.getRuntime(server.getRuntime().getId()));
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("newModule");
+ assertTrue(p.exists());
+ assertNotNull(ProjectRuntimeUtil.getRuntime(p));
+ IFile f = p.getFile(new Path("contentDirS").append("META-INF").append("application.xml"));
+ assertEquals(shouldExist(server), f.exists());
+ }
+
+ private boolean shouldExist(IServer server) {
+ String typeId = server.getServerType().getId();
+ if( IJBossToolingConstants.SERVER_AS_32.equals(typeId))
+ return true;
+ if( IJBossToolingConstants.SERVER_AS_40.equals(typeId))
+ return true;
+ if( IJBossToolingConstants.SERVER_AS_42.equals(typeId))
+ return true;
+
+ return false;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ASMatrixTests.cleanup();
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,18 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import org.jboss.tools.as.test.core.parametized.server.publishing.PublishingSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+(a)RunWith(Suite.class)
+@SuiteClasses({
+// ServerHomeTest.class,
+// ServerBeanLoader3Test.class,
+// CreateServerCheckDefaultsTest.class,
+// ProjectRuntimeClasspathTest.class,
+// CreateRuntimeTwiceTest.class,
+ PublishingSuite.class
+})
+public class ParametizedSuite {
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ProjectRuntimeClasspathTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ProjectRuntimeClasspathTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ProjectRuntimeClasspathTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,181 @@
+/**
+ * JBoss by Red Hat
+ * Copyright 2006-2009, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.tools.as.test.core.internal.utils.ProjectRuntimeUtil;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.jmx.core.test.util.TestProjectProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class ProjectRuntimeClasspathTest extends TestCase {
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getJBossServerTypeParamterers());
+ }
+ private TestProjectProvider provider;
+ private IProject project;
+ private IServer server;
+ private String serverType;
+
+ public ProjectRuntimeClasspathTest(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null, "basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ server = ServerCreationTestUtils.createServerWithRuntime(serverType, getClass().getName() + serverType);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ provider.dispose();
+ ServerCreationTestUtils.deleteAllServersAndRuntimes();
+ }
+
+ @Test
+ public void testProjectRuntime() {
+ assertNotNull(server);
+ assertNotNull(server.getRuntime());
+
+ try {
+ IJavaProject jp = JavaCore.create(project);
+ verifyInitialClasspathEntries(jp);
+
+ ProjectRuntimeUtil.setTargetRuntime(server.getRuntime(), project);
+ verifyPostRuntimeCPE(jp);
+
+ ProjectRuntimeUtil.clearRuntime(project);
+ verifyInitialClasspathEntries(jp);
+
+ } catch( JavaModelException jme ) {
+ jme.printStackTrace();
+ fail(jme.getMessage());
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+
+ @Test
+ public void testJBIDE1657EquivilentEntries() {
+ try {
+ IJavaProject jp = JavaCore.create(project);
+
+ // lets try a runtime
+ IRuntime createdRuntime = server.getRuntime();
+ ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
+ IClasspathEntry[] raw1 = jp.getRawClasspath();
+ IClasspathEntry[] resolved1 = jp.getResolvedClasspath(false);
+
+ IClasspathEntry[] raw2 = cloneAndReplace(raw1, createdRuntime.getName());
+ jp.setRawClasspath(raw2, new NullProgressMonitor());
+ IClasspathEntry[] resolved2 = jp.getResolvedClasspath(false);
+ assertEquals("New classpath container path should return the same classpath entries as the old. ",
+ resolved1.length , resolved2.length);
+ assertTrue("Should be more than one classpath entry", resolved1.length > 0);
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+
+ /* Replace the jst.server.core.container entry with one from jbt. They should be 100% equivilent */
+ private IClasspathEntry[] cloneAndReplace(IClasspathEntry[] raw1, String rtName) {
+ IClasspathEntry[] raw2 = new IClasspathEntry[raw1.length];
+ for( int i = 0; i < raw1.length; i++ ) {
+ if( !raw1[i].getPath().segment(0).equals("org.eclipse.jst.server.core.container")) {
+ raw2[i]=raw1[i];
+ } else {
+ IPath containerPath = new Path("org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer");
+ containerPath = containerPath.append(rtName);
+ raw2[i] = JavaCore.newContainerEntry(containerPath);
+ }
+ }
+ return raw2;
+ }
+
+ protected void verifyPostRuntimeCPE(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ assertEquals(4, entries.length);
+ jp.getResolvedClasspath(false); // make sure it can resolve all
+ String[] required = new String[] {
+ "org.eclipse.jst.server.core.container",
+ "basicwebproject",
+ "org.eclipse.jst.j2ee.internal.web.container",
+ "org.eclipse.jdt.launching.JRE_CONTAINER"};
+ verifyClasspathEntries(entries, required);
+ }
+
+ protected void verifyInitialClasspathEntries(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ jp.getResolvedClasspath(false); // make sure it can resolve all
+ String[] required = new String[] {
+ "org.eclipse.jst.j2ee.internal.web.container", "basicwebproject"};
+ verifyClasspathEntries(entries, required);
+ }
+
+ protected void verifyClasspathEntries(IClasspathEntry[] entries, String[] required) {
+ List<String> list = new ArrayList<String>();
+ for (int i = 0; i < required.length; i++) {
+ list.add(required[i]);
+ }
+ for( int i = 0; i < entries.length; i++ ) {
+ if( list.contains(entries[i].getPath().segment(0)))
+ list.remove(entries[i].getPath().segment(0));
+ }
+
+ if( list.size() > 0 ) {
+ String tmp = "Required enties not found: ";
+ for( int i = 0; i < list.size(); i++ ) {
+ tmp += list.get(i) + ", ";
+ }
+ fail(tmp.substring(0, tmp.length() - 2));
+ }
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerBeanLoader3Test.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerBeanLoader3Test.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerBeanLoader3Test.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,102 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
+import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.tools.as.test.core.TestConstants;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+/**
+ *
+ * @author rob
+ *
+ */
+@RunWith(value = Parameterized.class)
+public class ServerBeanLoader3Test extends TestCase {
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getJBossServerTypeParamterers());
+ }
+
+ private HashMap<String, Pair> expected = new HashMap<String, Pair>();
+ private class Pair {
+ private JBossServerType type;
+ private String version;
+ public Pair(JBossServerType type, String version) {
+ this.type = type;
+ this.version = version;
+ }
+ }
+
+
+ private String serverType;
+ public ServerBeanLoader3Test(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @Before
+ public void setUp() {
+ expected.put(IJBossToolingConstants.SERVER_AS_32, new Pair(JBossServerType.AS, IJBossToolingConstants.V3_2));
+ expected.put(IJBossToolingConstants.SERVER_AS_40, new Pair(JBossServerType.AS, IJBossToolingConstants.V4_0));
+ expected.put(IJBossToolingConstants.SERVER_AS_42, new Pair(JBossServerType.AS, IJBossToolingConstants.V4_2));
+ expected.put(IJBossToolingConstants.SERVER_AS_50, new Pair(JBossServerType.AS, IJBossToolingConstants.V5_0));
+ expected.put(IJBossToolingConstants.SERVER_AS_51, new Pair(JBossServerType.AS, IJBossToolingConstants.V5_1));
+ expected.put(IJBossToolingConstants.SERVER_AS_60, new Pair(JBossServerType.AS, IJBossToolingConstants.V6_0));
+ expected.put(IJBossToolingConstants.SERVER_AS_70, new Pair(JBossServerType.AS7, IJBossToolingConstants.V7_0));
+ expected.put(IJBossToolingConstants.SERVER_AS_71, new Pair(JBossServerType.AS7, IJBossToolingConstants.V7_1));
+ expected.put(IJBossToolingConstants.SERVER_EAP_43, new Pair(JBossServerType.EAP_STD, IJBossToolingConstants.V4_3));
+ expected.put(IJBossToolingConstants.SERVER_EAP_50, new Pair(JBossServerType.EAP_STD, IJBossToolingConstants.V5_0));
+ expected.put(IJBossToolingConstants.SERVER_EAP_60, new Pair(JBossServerType.EAP6, IJBossToolingConstants.V6_0));
+ }
+
+ /*
+ * Test the server bean loader using runtime home flags passed in to the build
+ */
+ @Test
+ public void testServerBeanLoaderFromRuntimes() {
+ String fLoc = TestConstants.getServerHome(serverType);
+ if( fLoc == null )
+ fail("Test Suite has no server home for server type " + serverType);
+ inner_testServerBeanLoaderForFolder(new File(fLoc));
+ }
+
+ /*
+ * Create a mock folder and verify the mock folder matches also
+ */
+ @Test
+ public void testServerBeanLoaderForMocks() {
+ File serverDir = (ServerCreationTestUtils.createMockServerLayout(serverType));
+ if( serverDir == null || !serverDir.exists())
+ fail("Creation of mock server type " + serverType + " has failed.");
+ inner_testServerBeanLoaderForFolder(serverDir);
+ }
+
+ private void inner_testServerBeanLoaderForFolder(File serverDir) {
+ assertNotNull(serverType);
+ IServerType itype = ServerCore.findServerType(serverType);
+ if( itype == null )
+ fail("Server type " + itype + " not found in the build");
+ if( expected.get(serverType) == null )
+ fail("Test Case needs to be updated for new adapter");
+
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir);
+ JBossServerType type = loader.getServerType();
+ assertTrue(type.equals(expected.get(serverType).type));
+ String fullVersion = loader.getFullServerVersion();
+ assertTrue(fullVersion + " does not begin with " + expected.get(serverType).version,
+ fullVersion.startsWith(expected.get(serverType).version));
+ assertEquals(loader.getServerAdapterId(), serverType);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerHomeTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerHomeTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerHomeTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,42 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.tools.as.test.core.TestConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class ServerHomeTest extends Assert {
+
+
+ private String serverType;
+ public ServerHomeTest(String serverType) {
+ this.serverType = serverType;
+ }
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getJBossServerTypeParamterers());
+ }
+ @Test
+ public void testServerHomeSet() {
+ assertNotNull(serverType);
+ IServerType type = ServerCore.findServerType(serverType);
+ if( type == null )
+ fail("Server type " + type + " not found in the build");
+ if( type.getRuntimeType() == null )
+ fail("Server type " + serverType + " does not have an associated runtime");
+ String loc = TestConstants.getServerHome(serverType);
+ if( loc == null )
+ fail( "Test Runtime for " + serverType + " is not set properly in the build" );
+ if (!new File(loc).exists())
+ fail(serverType + " (" + loc + ") does not exist.");
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerParameterUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerParameterUtils.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerParameterUtils.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,72 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+
+public class ServerParameterUtils {
+
+ public static final String ZIPPED = "zipped";
+ public static final String UNZIPPED = "unzipped";
+ public static final String DEPLOY_META = "metadata";
+ public static final String DEPLOY_SERVER = "server";
+ public static final String DEPLOY_CUSTOM_REL = "customRelative";
+ public static final String DEPLOY_CUSTOM_ABS = "customAbsolute";
+ public static final String DEPLOY_CUSTOM_NULL = "customNull";
+ public static final String DEPLOY_PERMOD_DEFAULT = "permod_default";
+ public static final String DEPLOY_PERMOD_ABS = "permod_absolute";
+ public static final String DEPLOY_PERMOD_REL = "permod_relative";
+
+
+ // Turn an array [item1, item2, item3] into a collection of 1-length items
+ // ie new Collection<Object[]>() { new Object[]{item1}, new Object[]{item2}, new Object[]{item3}};
+
+ public static Collection<Object[]> asCollection(Object[] items) {
+ ArrayList<Object[]> ret = new ArrayList<Object[]>();
+ for( int i = 0; i < items.length; i++ ) {
+ ret.add(new Object[]{items[i]});
+ }
+ return ret;
+ }
+ public static Object[] getJBossServerTypeParamterers() {
+ return IJBossToolingConstants.ALL_JBOSS_SERVERS;
+ }
+ public static Object[] getAllJBossServerTypeParamterers() {
+ Object[] ret = new Object[IJBossToolingConstants.ALL_JBOSS_SERVERS.length + 1];
+ ret[0] = IJBossToolingConstants.DEPLOY_ONLY_SERVER;
+ System.arraycopy(IJBossToolingConstants.ALL_JBOSS_SERVERS, 0, ret, 1, IJBossToolingConstants.ALL_JBOSS_SERVERS.length);
+ return ret;
+ }
+
+ /*
+ * Return the most common DIFFERENT server types where impl may matter
+ */
+ public static Object[] getPublishServerTypes() {
+ return new Object[] {
+ IJBossToolingConstants.DEPLOY_ONLY_SERVER,
+ IJBossToolingConstants.SERVER_AS_60, IJBossToolingConstants.SERVER_AS_71
+ };
+ }
+
+ public static Object[] getServerZipOptions() {
+ return new String[] {
+ ZIPPED, UNZIPPED
+ };
+ }
+
+ public static Object[] getDefaultDeployOptions() {
+ return new String[] {
+ DEPLOY_META, DEPLOY_SERVER, DEPLOY_CUSTOM_NULL, DEPLOY_CUSTOM_ABS, DEPLOY_CUSTOM_REL
+ };
+ }
+
+ /* TODO add changing the deploy name (ex: from project.ear to project1.jar */
+ public static Object[] getPerModuleOverrideOptions() {
+ return new String[] {
+ DEPLOY_PERMOD_DEFAULT, DEPLOY_PERMOD_ABS, DEPLOY_PERMOD_REL
+ };
+ }
+
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerTypeDefaultClasspathEntriesTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerTypeDefaultClasspathEntriesTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ServerTypeDefaultClasspathEntriesTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,50 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel;
+import org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel.IDefaultPathProvider;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class ServerTypeDefaultClasspathEntriesTest extends Assert {
+
+
+ private String serverType;
+ public ServerTypeDefaultClasspathEntriesTest(String serverType) {
+ this.serverType = serverType;
+ }
+ @Parameters
+ public static Collection<Object[]> data() {
+ return ServerParameterUtils.asCollection(ServerParameterUtils.getJBossServerTypeParamterers());
+ }
+ @Test
+ public void testDefaultClasspathEntriesAdded() {
+ assertNotNull(serverType);
+ IServerType type = ServerCore.findServerType(serverType);
+ if( type == null )
+ fail("Server type " + type + " not found in the build");
+ if( type.getRuntimeType() == null )
+ fail("Server type " + serverType + " does not have an associated runtime");
+ IRuntimeType rtType = type.getRuntimeType();
+ IDefaultPathProvider[] providers = CustomRuntimeClasspathModel.getInstance().getDefaultEntries(rtType);
+ assertNotNull("Null returned for default classpath entries", providers);
+ assertFalse("0 classpath entr yproviders returned", providers.length == 0);
+ ArrayList<IPath> paths = new ArrayList<IPath>();
+ for( int i = 0; i < providers.length; i++ ) {
+ paths.addAll(Arrays.asList(providers[i].getAbsolutePaths()));
+ }
+ assertFalse("0 classpath entries returned", paths.size() == 0);
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/WebDeployableArtifactUtilDefectTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/WebDeployableArtifactUtilDefectTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/WebDeployableArtifactUtilDefectTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,108 @@
+package org.jboss.tools.as.test.core.parametized.server;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+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.IncrementalProjectBuilder;
+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.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactUtil;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.WebResource;
+import org.jboss.ide.eclipse.as.core.server.internal.JBossLaunchAdapter;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class WebDeployableArtifactUtilDefectTest extends TestCase {
+ @Parameters
+ public static Collection<Object[]> data() {
+ ArrayList<Object[]> options = new ArrayList<Object[]>();
+ Collection<Object[]> all = ServerParameterUtils.asCollection(ServerParameterUtils.getAllJBossServerTypeParamterers());
+ options.addAll(all);
+ // add a null option for no server
+ options.add(new Object[]{null});
+ return options;
+ }
+
+ private String serverType;
+ public WebDeployableArtifactUtilDefectTest(String serverType) {
+ this.serverType = serverType;
+ }
+
+ @Test
+ public void testWebDeployableDefectWorkaround() throws Exception {
+ IFile f = createProjectAndGetJavaIFile();
+ if( serverType == null ) {
+ testWebDeployableDefect(f);
+ } else {
+ webDeployableDefectWorkaroundForServer(f);
+ }
+ }
+
+ private void testWebDeployableDefect(IResource f) throws Exception {
+ IModuleArtifact artifact = new WebDeployableArtifactUtil().getModuleObject(f);
+ if( artifact != null && artifact instanceof WebResource ) {
+ // should be fixed by now
+ assertFalse(((WebResource)artifact).getPath().lastSegment().endsWith(".java"));
+ }
+ }
+
+ private void webDeployableDefectWorkaroundForServer(IResource f) throws Exception {
+ IServer server = ServerCreationTestUtils.createServerWithRuntime(serverType, serverType);
+ JBossLaunchAdapter adapter = new JBossLaunchAdapter();
+ IModuleArtifact artifact = new WebDeployableArtifactUtil().getModuleObject(f);
+ if( artifact != null ) {
+ Object o = adapter.getLaunchable(server, artifact);
+ assertTrue(o instanceof JBossLaunchAdapter.JBTCustomHttpLaunchable);
+ URL url = ((JBossLaunchAdapter.JBTCustomHttpLaunchable)o).getURL();
+ assertTrue(url != null );
+ String u2 = url.toString();
+ assertFalse(u2.endsWith(".java"));
+ }
+ }
+
+
+ private IFile createProjectAndGetJavaIFile() throws Exception {
+ IDataModel dm = CreateProjectOperationsUtility.getWebDataModel("TestWeb", null, null, null, null, JavaEEFacetConstants.WEB_25, true);
+ OperationTestCase.runAndVerify(dm);
+ final IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("TestWeb");
+ assertTrue(p.exists());
+ final IFile[] file = new IFile[1];
+ file[0] = null;
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ file[0] = ResourceUtils.createJavaType(p, new Path("src/my/pack"), "my.pack", "Tiger");
+ assertTrue(file[0].exists());
+ p.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
+ }, new NullProgressMonitor());
+ return file[0];
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ASMatrixTests.cleanup();
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,65 @@
+package org.jboss.tools.as.test.core.parametized.server.publishing;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.tools.as.test.core.internal.utils.MatrixUtils;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.parametized.server.ServerParameterUtils;
+
+public class AbstractComponentPublishingTest extends AbstractPublishingTest {
+ public static Collection<Object[]> componentJarData() {
+ Object[] servers = ServerParameterUtils.getPublishServerTypes();
+ Object[] zipOption = ServerParameterUtils.getServerZipOptions();
+ Object[] defaultDeployLoc = ServerParameterUtils.getDefaultDeployOptions();
+ Object[] perModOverrides = ServerParameterUtils.getPerModuleOverrideOptions();
+ Object[] junitName = new String[] { "junit.jar", "otherOut.jar"};
+ Object[] outFolder = new String[] { "lib", "otherFolder", "deep/nested", ""};
+ Object[][] allOptions = new Object[][] {
+ servers, zipOption, defaultDeployLoc, perModOverrides,
+ junitName, outFolder
+ };
+ return MatrixUtils.toMatrix(allOptions);
+ }
+ protected String jarFolder;
+ protected String jarName;
+
+ public AbstractComponentPublishingTest(String serverType,
+ String zip, String deployLoc, String perMod,
+ String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod);
+ jarName = refName;
+ jarFolder = refFolder;
+ }
+
+ protected void completeSetUp() {
+ // Keep it local for REAL publishes
+ wc.setAttribute(IDeployableServer.SERVER_MODE, "local");
+ }
+
+ protected void verifyFileFoundInModule(String folder, String name, int expectedFileCount) throws Exception {
+ verifyFileFoundInModule(folder, name, expectedFileCount, primaryModule);
+ }
+
+ protected void verifyFileFoundInModule(String folder, String name, int expectedFileCount, IModule module) throws Exception {
+ // now verify
+ IModuleFile[] allFiles = ResourceUtils.findAllIModuleFiles(module);
+ assertEquals(allFiles.length,expectedFileCount);
+ IModuleFile selected = null;
+ for( int i = 0; i < allFiles.length; i++ ) {
+ if( allFiles[i].getName().equals(name)) {
+ selected = allFiles[i];
+ break;
+ }
+ }
+ IModuleFile mf = selected;
+ assertNotNull(mf);
+ assertEquals(mf.getName(), name);
+ assertEquals(mf.getModuleRelativePath().makeRelative(), new Path(folder).makeRelative());
+ }
+
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractPublishingTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractPublishingTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractPublishingTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,332 @@
+package org.jboss.tools.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerPreferences;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
+import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.DeploymentMarkerUtils;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentModulePrefs;
+import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader.DeploymentPreferences;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.util.ServerUtil;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.internal.MockPublishMethod4;
+import org.jboss.tools.as.test.core.internal.utils.IOUtil;
+import org.jboss.tools.as.test.core.internal.utils.MatrixUtils;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
+import org.jboss.tools.as.test.core.parametized.server.ServerParameterUtils;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import de.schlichtherle.io.ArchiveDetector;
+
+@RunWith(value = Parameterized.class)
+public abstract class AbstractPublishingTest extends TestCase {
+ public static ArrayList<Object[]> defaultData() {
+ Object[] servers = ServerParameterUtils.getPublishServerTypes();
+ Object[] zipOption = ServerParameterUtils.getServerZipOptions();
+ Object[] defaultDeployLoc = ServerParameterUtils.getDefaultDeployOptions();
+ Object[] perModOverrides = ServerParameterUtils.getPerModuleOverrideOptions();
+ Object[][] allOptions = new Object[][] {
+ servers, zipOption, defaultDeployLoc, perModOverrides
+ };
+ return MatrixUtils.toMatrix(allOptions);
+ }
+
+ protected String param_serverType;
+ protected String param_zip;
+ protected String param_deployLoc;
+ protected String param_perModOverride;
+ protected IServer server;
+ protected IServerWorkingCopy wc;
+ protected String serverDeployPath;
+ protected String serverTempDeployPath;
+ protected IModule primaryModule;
+
+ public AbstractPublishingTest(String serverType, String zip, String deployLoc, String perMod) {
+ System.out.println(serverType + ", " + zip + ", " + deployLoc + ", " + perMod);
+ this.param_serverType = serverType;
+ this.param_zip = zip;
+ this.param_deployLoc = deployLoc;
+ this.param_perModOverride = perMod;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ ServerPreferences.getInstance().setAutoPublishing(false);
+ JobUtils.waitForIdle();
+ server = ServerCreationTestUtils.createMockServerWithRuntime(param_serverType, getClass().getName() + param_serverType);
+ wc = server.createWorkingCopy();
+ setMockPublishMethod4(wc);
+ setupZipParam(wc);
+ setupDeployTypeParam(wc);
+ createProjects();
+ completeSetUp();
+ server = wc.save(false, new NullProgressMonitor());
+ }
+
+ protected void completeSetUp() {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ ASMatrixTests.cleanup();
+ }
+
+ protected void setMockPublishMethod4(IServerWorkingCopy wc) {
+ MockPublishMethod4.reset();
+ wc.setAttribute(IDeployableServer.SERVER_MODE, "mock4");
+ }
+
+ protected void createProjects() throws Exception {}
+
+ public void addModuleToServer(IModule module) throws CoreException {
+ assertNotNull(module);
+ primaryModule = module;
+ wc.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
+ setCustomDeployOverride(module);
+ }
+
+ protected void setCustomDeployOverride(IModule module) {
+ if( param_perModOverride.equals(ServerParameterUtils.DEPLOY_PERMOD_DEFAULT))
+ return;
+ String overrideFolder = null;
+ String overrideTemp = null;
+
+ if( param_perModOverride.equals(ServerParameterUtils.DEPLOY_PERMOD_ABS)) {
+ overrideFolder = getAbsoluteOverrideFolder();
+ overrideTemp = getAbsoluteTempOverrideFolder();
+ } else if( param_perModOverride.equals(ServerParameterUtils.DEPLOY_PERMOD_REL)) {
+ overrideFolder = getRelativeOverrideFolder();
+ overrideTemp = getRelativeTempOverrideFolder();
+ }
+ setCustomDeployOverride(module, null, overrideFolder, overrideTemp);
+ MockPublishMethod4.setExpectedRoot(overrideFolder);
+ MockPublishMethod4.setExpectedTempRoot(overrideTemp);
+ }
+
+ protected void setCustomDeployOverride(IModule rootModule, String outputName, String outputDir, String temporaryDir) {
+ DeploymentPreferences prefs = DeploymentPreferenceLoader.loadPreferencesFromServer(wc);
+ DeploymentModulePrefs modPrefs = prefs.getOrCreatePreferences().getOrCreateModulePrefs(rootModule);
+ modPrefs.setProperty(IJBossToolingConstants.LOCAL_DEPLOYMENT_TEMP_LOC, temporaryDir);
+ modPrefs.setProperty(IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC, outputDir);
+ modPrefs.setProperty(IJBossToolingConstants.LOCAL_DEPLOYMENT_OUTPUT_NAME, outputName);
+ DeploymentPreferenceLoader.savePreferencesToServerWorkingCopy(wc, prefs);
+ }
+
+ protected void setupZipParam(IServerWorkingCopy wc) {
+ if( isZipped())
+ ServerConverter.getDeployableServer(wc).setZipWTPDeployments(true);
+ }
+
+ protected boolean isZipped() {
+ return param_zip.equals(ServerParameterUtils.ZIPPED);
+ }
+
+ protected void setupDeployTypeParam(IServerWorkingCopy wc) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(wc);
+ if( !server.getServerType().getId().equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ if( param_deployLoc.equals(ServerParameterUtils.DEPLOY_META))
+ ds.setDeployLocationType(IDeployableServer.DEPLOY_METADATA);
+ if( param_deployLoc.equals(ServerParameterUtils.DEPLOY_SERVER))
+ ds.setDeployLocationType(IDeployableServer.DEPLOY_SERVER);
+ if( param_deployLoc.equals(ServerParameterUtils.DEPLOY_CUSTOM_NULL) ||
+ param_deployLoc.equals(ServerParameterUtils.DEPLOY_CUSTOM_ABS) ||
+ param_deployLoc.equals(ServerParameterUtils.DEPLOY_CUSTOM_REL)) {
+ ds.setDeployLocationType(IDeployableServer.DEPLOY_SERVER);
+ }
+ if( param_deployLoc.equals(ServerParameterUtils.DEPLOY_CUSTOM_ABS)) {
+ String f = getCustomAbsoluteFolder();
+ new File(f).mkdirs();
+ ds.setDeployFolder(f);
+ String f2 = getCustomAbsoluteTempFolder();
+ new File(f2).mkdirs();
+ ds.setTempDeployFolder(f2);
+ } else if(param_deployLoc.equals(ServerParameterUtils.DEPLOY_CUSTOM_REL) ) {
+ String f = getCustomRelativeFolder();
+ server.getRuntime().getLocation().append(f).toFile().mkdirs();
+ ds.setDeployFolder(f);
+ String f2 = getCustomRelativeTempFolder();
+ server.getRuntime().getLocation().append(f2).toFile().mkdirs();
+ ds.setTempDeployFolder(f2);
+ }
+ }
+ serverDeployPath = ds.getDeployFolder();
+ serverTempDeployPath = ds.getTempDeployFolder();
+ MockPublishMethod4.setExpectedRoot(serverDeployPath);
+ MockPublishMethod4.setExpectedTempRoot(serverTempDeployPath);
+
+ }
+
+ private String getCustomAbsoluteFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("final").toOSString();
+ }
+ private String getCustomAbsoluteTempFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("tmp").toOSString();
+ }
+
+ private String getAbsoluteOverrideFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("finalOverride").toOSString();
+ }
+ private String getAbsoluteTempOverrideFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("tmpOverride").toOSString();
+ }
+
+ private String getRelativeOverrideFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("finalOverride").toOSString();
+ }
+ private String getRelativeTempOverrideFolder(){
+ return ServerCreationTestUtils.getRandomAbsoluteFolder().append("tmpOverride").toOSString();
+ }
+
+ private String getCustomRelativeFolder(){
+ if( ServerUtil.isJBoss7(server)) {
+ return "myDeploy/final";
+ }
+ return "server/myDeploy/final";
+ }
+ private String getCustomRelativeTempFolder(){
+ if( ServerUtil.isJBoss7(server)) {
+ return "myDeploy/temp";
+ }
+ return "server/myDeploy/temp";
+ }
+
+
+
+ /* Utilities */
+ /* Should add a .deploy marker */
+ protected int getFullPublishChangedResourceCountModifier() {
+ if( DeploymentMarkerUtils.supportsJBoss7MarkerDeployment(server))
+ return 1;
+ return 0;
+ }
+
+ /* Should remove a .failed marker */
+ protected int getFullPublishRemovedResourceCountModifier() {
+ if( DeploymentMarkerUtils.supportsJBoss7MarkerDeployment(server))
+ return 1;
+ return 0;
+ }
+
+
+ /* Util methods to do the checking */
+ protected static void publishAndCheckError(IServer server, int pubType) {
+ MockPublishMethod4.resetPublish();
+ server.publish(pubType, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ if( MockPublishMethod4.getError() != null ) {
+ Throwable t = MockPublishMethod4.getError();
+ System.out.println(" " + t.getMessage());
+ fail("Error when publishing: " + t.getMessage());
+ }
+ }
+ protected void verifyPublishMethodResults(int changed, int removed, int temp) {
+ IPath[] changed2 = MockPublishMethod4.getChanged();
+ IPath[] removed2 = MockPublishMethod4.getRemoved();
+ IPath[] temp2 = MockPublishMethod4.getTempPaths();
+ System.out.println(" " + changed2.length + ", " + removed2.length + ", " + temp2.length);
+ assertEquals(changed2.length, changed);
+ assertEquals(removed2.length, removed);
+ assertEquals(temp2.length, temp);
+ }
+
+ protected IModuleFile findModuleFile(IModuleFile[] files, IPath path) {
+ for( int j = 0; j < files.length; j++ ) {
+ IPath p1 = files[j].getModuleRelativePath().append(files[j].getName());
+ if( p1.makeRelative().equals(path.makeRelative()))
+ return files[j];
+ }
+ return null;
+ }
+
+ protected void verifyZipContents(IModuleFile[] files, IPath[] paths, String[] contents) throws CoreException, IOException {
+ File foundZip = findZip(files);
+
+ for( int i = 0; i < paths.length; i++ ) {
+ IPath relative = paths[i].removeFirstSegments(1);
+ de.schlichtherle.io.File zipRoot = new de.schlichtherle.io.File(foundZip, new TrueZipUtil.JarArchiveDetector());
+ de.schlichtherle.io.File truezipFile = new de.schlichtherle.io.File(zipRoot, relative.toString(), ArchiveDetector.ALL);
+ de.schlichtherle.io.FileInputStream fis = new de.schlichtherle.io.FileInputStream(truezipFile);
+ byte[] b = IOUtil.getBytesFromInputStream(fis);
+ String b2 = new String(b);
+ assertEquals(b2, contents[i]);
+ }
+ }
+ protected void verifyWorkspaceContents(IModuleFile[] files, IPath[] paths, String[] contents) throws CoreException, IOException {
+ for( int i = 0; i < paths.length; i++ ) {
+ IModuleFile mf = findModuleFile(files, paths[i].removeFirstSegments(1));
+ assertNotNull("File not found: " + paths[i], mf);
+ String s = ResourceUtils.getContents(mf);
+ assertNotNull("File contents are null", s);
+ assertEquals("File contents does not match expected contents", s, contents[i]);
+ }
+ }
+
+ protected File findZip(IModuleFile[] files) {
+ File foundZip = null;
+ for( int i = 0; i < files.length; i++ ) {
+ File f = (File)files[i].getAdapter(File.class);
+ assertNotNull(f);
+ boolean isZip = IOUtil.isZip(f);
+ if( isZip && foundZip == null ) {
+ foundZip = f;
+ } else if( isZip ) {
+ fail("Multiple top level zips found in zipped deployment");
+ }
+ }
+ assertNotNull("Could not find a zipped file in the deployment", foundZip);
+ return foundZip;
+ }
+
+
+
+ protected IModule[] getModule(IProject p) {
+ return new IModule[]{org.eclipse.wst.server.core.ServerUtil.getModule(p)};
+ }
+ protected IProject findProject(String name) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ }
+ protected IPath getLocalPublishMethodDeployRoot() {
+ DeployableServer ds = (DeployableServer)server.loadAdapter(DeployableServer.class, new NullProgressMonitor());
+ IPath path = PublishUtil.getDeployPath(new LocalPublishMethod(), new IModule[]{primaryModule}, ds);
+ return path;
+ }
+
+ protected void verifyList(IPath root, ArrayList<IPath> list, boolean exists) {
+ Iterator<IPath> iterator = list.iterator();
+ ArchiveDetector detector = isZipped() ? new TrueZipUtil.JarArchiveDetector() : ArchiveDetector.DEFAULT;
+ while(iterator.hasNext()) {
+ de.schlichtherle.io.File f = new de.schlichtherle.io.File(root.toFile(), detector);
+ IPath next = iterator.next();
+ IPath nextTrimmed = next.removeFirstSegments(root.segmentCount());
+ de.schlichtherle.io.File toCheck = new de.schlichtherle.io.File(f, nextTrimmed.toString(), ArchiveDetector.DEFAULT);
+ assertEquals(toCheck.exists(), exists);
+ }
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.common.componentcore.internal.operation.AddReferenceDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyArchivePathVarNestedWarTest extends DeploymentAssemblyArchivePathVarTest {
+ private static String PROJECT_PREFIX = "qEar";
+ private static String PROJECT_NESTED_PREFIX = "qWar";
+ private static int PROJECT_ID = 1;
+ public DeploymentAssemblyArchivePathVarNestedWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected String MY_NESTED_PROJECT_NAME;
+ protected void createProjects() throws Exception {
+ setProjectName();
+ IProject p = projectCreation();
+ addReferences(ResourceUtils.findProject(MY_NESTED_PROJECT_NAME));
+ addModuleToServer(p);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ MY_NESTED_PROJECT_NAME = PROJECT_NESTED_PREFIX + PROJECT_ID;
+ }
+
+ /* Return the project which will have the component added */
+ protected IProject projectCreation() throws Exception {
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(MY_PROJECT_NAME, "earContent", null, null, JavaEEFacetConstants.EAR_5, false);
+ IDataModel dm2 = CreateProjectOperationsUtility.getWebDataModel(MY_NESTED_PROJECT_NAME, MY_PROJECT_NAME, null, "webContent", null, JavaEEFacetConstants.WEB_25, true);
+ IProject ep = createSingleProject(dm, MY_PROJECT_NAME);
+ /* IProject nested = */ createSingleProject(dm2, MY_NESTED_PROJECT_NAME);
+ return ep;
+ }
+
+ protected void verifyFileFoundInModule(String folder, String name, int expectedFileCount) throws Exception {
+ IModule secondModule = ServerUtil.getModule(ResourceUtils.findProject(MY_NESTED_PROJECT_NAME));
+ verifyFileFoundInModule(folder, name, expectedFileCount, secondModule);
+ }
+
+ @Test
+ public void testVariableReference() throws Exception {
+ verifyFileFoundInModule(jarFolder, jarName, getExpectedFileCount());
+ server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ IPath earPath = getLocalPublishMethodDeployRoot();
+ ArrayList<IPath> toFind = new ArrayList<IPath>();
+ toFind.add(earPath.append(MY_NESTED_PROJECT_NAME + ".war").append(jarFolder).append(jarName));
+ verifyList(earPath, toFind, true);
+ }
+
+ protected IDataModelProvider getDefaultAddReferenceProvider() {
+ return new AddReferenceDataModelProvider();
+ }
+
+
+ protected int getExpectedFileCount() {
+ // manifest.mf, web.xml, and the junit jar
+ return 3;
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.application.internal.operations.AddReferenceToEnterpriseApplicationDataModelProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyArchivePathVarTest extends AbstractComponentPublishingTest {
+
+ private static String PROJECT_PREFIX = "pEar";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyArchivePathVarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected String MY_PROJECT_NAME;
+ protected void createProjects() throws Exception {
+ setProjectName();
+ IProject p = projectCreation();
+ addReferences(p);
+ addModuleToServer(p);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+
+ /* Return the project which will have the component added */
+ protected IProject projectCreation() throws Exception {
+ return createSingleProject(getSingleProjectCreationDataModel(), MY_PROJECT_NAME);
+ }
+
+ protected IProject createSingleProject(IDataModel dm, String name) throws Exception {
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourceUtils.findProject(name);
+ if( p == null || !p.exists())
+ fail();
+ return p;
+ }
+
+ protected IDataModel getSingleProjectCreationDataModel() {
+ return CreateProjectOperationsUtility.getEARDataModel(MY_PROJECT_NAME, "ourContent",
+ null, null, JavaEEFacetConstants.EAR_5, false);
+ }
+
+ protected void addReferences(IProject p) throws Exception {
+ IVirtualComponent vc = ComponentCore.createComponent(p);
+ IVirtualReference ref = createArchiveReference(vc);
+ ComponentReferenceUtils.addReferenceToComponent(vc, ref, getDefaultAddReferenceProvider());
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent vc) throws Exception {
+ IPath path = new Path("JUNIT_HOME/junit.jar"); //$NON-NLS-1$
+ IVirtualReference ref = ComponentReferenceUtils.createPathArchiveReference(vc, path, jarFolder, jarName);
+ return ref;
+ }
+
+ protected IDataModelProvider getDefaultAddReferenceProvider() {
+ return new AddReferenceToEnterpriseApplicationDataModelProvider();
+ }
+
+
+ protected void addModuleToServer(IProject p) throws CoreException {
+ IModule module = ServerUtil.getModule(p);
+ addModuleToServer(module);
+ }
+
+ //wtp305306_patchBuildTest
+ @Test
+ public void testVariableReference() throws Exception {
+ verifyFileFoundInModule(jarFolder, jarName, getExpectedFileCount());
+ server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ IPath earPath = getLocalPublishMethodDeployRoot();
+ ArrayList<IPath> toFind = new ArrayList<IPath>();
+ toFind.add(earPath.append(jarFolder).append(jarName));
+ verifyList(earPath, toFind, true);
+ }
+
+ protected int getExpectedFileCount() {
+ return 1;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import org.eclipse.wst.common.componentcore.internal.operation.AddReferenceDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyArchivePathVarWarTest extends DeploymentAssemblyArchivePathVarTest {
+ private static String PROJECT_PREFIX = "pWar";
+ private static int PROJECT_ID = 1;
+ public DeploymentAssemblyArchivePathVarWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+ protected IDataModel getSingleProjectCreationDataModel() {
+ return CreateProjectOperationsUtility.getWebDataModel(MY_PROJECT_NAME,
+ null, null, null, null, JavaEEFacetConstants.WEB_24, false);
+ }
+ protected IDataModelProvider getDefaultAddReferenceProvider() {
+ return new AddReferenceDataModelProvider();
+ }
+
+ protected int getExpectedFileCount() {
+ // manifest.mf, web.xml, and the junit jar
+ return 3;
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarNestedWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarNestedWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarNestedWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyExternalArchiveVarNestedWarTest extends DeploymentAssemblyArchivePathVarNestedWarTest {
+ private static String PROJECT_NESTED_PREFIX = "rWar";
+ private static String PROJECT_PREFIX = "rEar";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyExternalArchiveVarNestedWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ MY_NESTED_PROJECT_NAME = PROJECT_NESTED_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws CoreException {
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IPath path = new Path(twiddleLoc.getAbsolutePath());
+ IVirtualReference ref = ComponentReferenceUtils.createExternalJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyExternalArchiveVarTest extends DeploymentAssemblyArchivePathVarTest {
+
+ private static String PROJECT_PREFIX = "qEar";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyExternalArchiveVarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws CoreException {
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IPath path = new Path(twiddleLoc.getAbsolutePath());
+ IVirtualReference ref = ComponentReferenceUtils.createExternalJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+
+ protected int getExpectedFileCount() {
+ return 1;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyExternalArchiveVarWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyExternalArchiveVarWarTest extends DeploymentAssemblyArchivePathVarWarTest {
+
+ private static String PROJECT_PREFIX = "qWar";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyExternalArchiveVarWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws CoreException {
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IPath path = new Path(twiddleLoc.getAbsolutePath());
+ IVirtualReference ref = ComponentReferenceUtils.createExternalJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyFilesetReferenceTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyFilesetReferenceTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyFilesetReferenceTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jst.j2ee.application.internal.operations.AddReferenceToEnterpriseApplicationDataModelProvider;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualReference;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.tools.as.test.core.ASMatrixTests;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DeploymentAssemblyFilesetReferenceTest extends TestCase {
+
+ private static String PROJECT_PREFIX = "q40Ear";
+ private static int PROJECT_ID = 1;
+
+ private String MY_PROJECT_NAME;
+
+ @After
+ public void tearDown() throws Exception {
+ ASMatrixTests.cleanup();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(MY_PROJECT_NAME, "ourContent",
+ null, null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourceUtils.findProject(MY_PROJECT_NAME);
+ if( p == null || !p.exists())
+ fail();
+
+ p.getFolder("folder1").create(true, true, new NullProgressMonitor());
+ p.getFolder("folder2").create(true, true, new NullProgressMonitor());
+ p.getFolder("folder3").create(true, true, new NullProgressMonitor());
+
+ createFile(p, "folder1", "a", "contents1" );
+ createFile(p, "folder1", "b", "contents1" );
+ createFile(p, "folder1", "z", "contents1" );
+
+ createFile(p, "folder2", "c", "contents1" );
+ createFile(p, "folder2", "d", "contents1" );
+ createFile(p, "folder2", "z", "contents1" );
+
+ createFile(p, "folder3", "d", "contents1" );
+ createFile(p, "folder3", "e", "contents1" );
+ createFile(p, "folder3", "z", "contents1" );
+ }
+
+ private void createFile(IProject project, String folder, String filename, String contents) throws CoreException {
+ IFolder f = project.getFolder(folder);
+ IFile f2 = f.getFile(filename);
+ ByteArrayInputStream is = new ByteArrayInputStream(contents.getBytes());
+ f2.create(is, true, new NullProgressMonitor());
+ }
+
+ @Test
+ public void testRootFolder() throws Exception {
+ runTest(MY_PROJECT_NAME, "**", "", "/", 12);
+ }
+
+ @Test
+ public void testRootFolderExcludeZ() throws Exception {
+ runTest(MY_PROJECT_NAME, "**", "**/z*", "/", 9);
+ }
+
+ @Test
+ public void testFolderOneOnly() throws Exception {
+ runTest(MY_PROJECT_NAME, "folder1/**", "", "/", 3);
+ }
+
+ @Test
+ public void testFolderTwoOnly() throws Exception {
+ runTest(MY_PROJECT_NAME, "folder2/**", "", "/", 3);
+ }
+
+ @Test
+ public void testFolderThreeOnly() throws Exception {
+ runTest(MY_PROJECT_NAME, "folder3/**", "", "/", 3);
+ }
+
+ @Test
+ public void testZsOnly() throws Exception {
+ runTest(MY_PROJECT_NAME, "**/z", "", "/", 3);
+ }
+
+ private void runTest(String rootFolder, String inc, String exc, String runtimePath, int expectedCount) throws CoreException {
+ IProject p = ResourceUtils.findProject(MY_PROJECT_NAME);
+ System.out.println(p.getLocation());
+ IVirtualComponent root = ComponentCore.createComponent(p);
+ VirtualReference ref = ComponentReferenceUtils.createFilesetComponentReference(root,
+ rootFolder, inc, exc, runtimePath);
+ ComponentReferenceUtils.addReferenceToComponent(root, ref, new AddReferenceToEnterpriseApplicationDataModelProvider());
+ IModule module = ServerUtil.getModule(p);
+ IModuleFile[] allFiles = ResourceUtils.findAllIModuleFiles(module);
+ assertEquals(allFiles.length, expectedCount);
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyWorkspaceArchiveVarNestedWarTest extends DeploymentAssemblyArchivePathVarNestedWarTest {
+ private static String PROJECT_NESTED_PREFIX = "q35War";
+ private static String PROJECT_PREFIX = "q35Ear";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyWorkspaceArchiveVarNestedWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ MY_NESTED_PROJECT_NAME = PROJECT_NESTED_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws Exception {
+ String tmpName = PROJECT_PREFIX + "tmp" + PROJECT_ID;
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(tmpName, "ourContent",
+ null, null, JavaEEFacetConstants.EAR_5, false);
+ IProject p = createSingleProject(dm, tmpName);
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IFile f = p.getFile("inner.jar");
+ f.create(new FileInputStream(twiddleLoc), true, new NullProgressMonitor());
+ JobUtils.waitForIdle(300);
+ IPath path = new Path(f.getProject().getName()).append(f.getProjectRelativePath());
+ IVirtualReference ref = ComponentReferenceUtils.createWorkspaceJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyWorkspaceArchiveVarTest extends DeploymentAssemblyArchivePathVarTest {
+
+ private static String PROJECT_PREFIX = "q33Ear";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyWorkspaceArchiveVarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws Exception {
+ String tmpName = PROJECT_PREFIX + "tmp" + PROJECT_ID;
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(tmpName, "ourContent",
+ null, null, JavaEEFacetConstants.EAR_5, false);
+ IProject p = createSingleProject(dm, tmpName);
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IFile f = p.getFile("inner.jar");
+ f.create(new FileInputStream(twiddleLoc), true, new NullProgressMonitor());
+ JobUtils.waitForIdle(300);
+ IPath path = new Path(f.getProject().getName()).append(f.getProjectRelativePath());
+ IVirtualReference ref = ComponentReferenceUtils.createWorkspaceJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+
+ protected int getExpectedFileCount() {
+ return 1;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarWarTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyWorkspaceArchiveVarWarTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.as.test.core.internal.utils.BundleUtils;
+import org.jboss.tools.as.test.core.internal.utils.ComponentReferenceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class DeploymentAssemblyWorkspaceArchiveVarWarTest extends DeploymentAssemblyArchivePathVarWarTest {
+
+ private static String PROJECT_PREFIX = "q34War";
+ private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+ public DeploymentAssemblyWorkspaceArchiveVarWarTest(String serverType, String zip,
+ String deployLoc, String perMod, String refName, String refFolder) {
+ super(serverType, zip, deployLoc, perMod, refName, refFolder);
+ }
+
+ protected void setProjectName() {
+ PROJECT_ID++;
+ MY_PROJECT_NAME = PROJECT_PREFIX + PROJECT_ID;
+ }
+
+ protected IVirtualReference createArchiveReference(IVirtualComponent root) throws Exception {
+ String tmpName = PROJECT_PREFIX + "tmp" + PROJECT_ID;
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel(tmpName, "ourContent",
+ null, null, JavaEEFacetConstants.EAR_5, false);
+ IProject p = createSingleProject(dm, tmpName);
+ File twiddleLoc = BundleUtils.getFileLocation("serverMock/3.2.8.mf.twiddle.jar");
+ IFile f = p.getFile("inner.jar");
+ f.create(new FileInputStream(twiddleLoc), true, new NullProgressMonitor());
+ JobUtils.waitForIdle(300);
+ IPath path = new Path(f.getProject().getName()).append(f.getProjectRelativePath());
+ IVirtualReference ref = ComponentReferenceUtils.createWorkspaceJarReference(root, path, "/" + jarFolder, jarName);
+ return ref;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,24 @@
+package org.jboss.tools.as.test.core.parametized.server.publishing;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+(a)RunWith(Suite.class)
+@SuiteClasses({
+// DeploymentAssemblyArchivePathVarTest.class,
+// DeploymentAssemblyArchivePathVarWarTest.class,
+// DeploymentAssemblyArchivePathVarNestedWarTest.class,
+// DeploymentAssemblyExternalArchiveVarTest.class,
+// DeploymentAssemblyExternalArchiveVarWarTest.class,
+// DeploymentAssemblyExternalArchiveVarNestedWarTest.class,
+// DeploymentAssemblyWorkspaceArchiveVarTest.class,
+// DeploymentAssemblyWorkspaceArchiveVarWarTest.class,
+// DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.class,
+ DeploymentAssemblyFilesetReferenceTest.class,
+// RepublishDefectTest.class,
+// SingleDeployableFileTest.class,
+// SingleDeployableFolderTest.class
+})
+public class PublishingSuite {
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFileTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFileTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFileTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,101 @@
+package org.jboss.tools.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.tools.as.test.core.internal.MockPublishMethod4;
+import org.jboss.tools.as.test.core.internal.utils.IOUtil;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class SingleDeployableFileTest extends AbstractPublishingTest {
+ @Parameters
+ public static Collection<Object[]> params() {
+ ArrayList<Object[]> ret = defaultData();
+ return ret;
+ }
+
+ public SingleDeployableFileTest(String serverType, String zip,
+ String deployLoc, String perMod) {
+ super(serverType, zip, deployLoc, perMod);
+ }
+
+ @Override
+ protected void createProjects() throws Exception {
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel("ear1", "earContent", null, null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("ear1");
+ assertTrue(p.exists());
+ final String filename = "test.xml";
+ IResource file = ResourceUtils.createFile(p, filename, "<test>done</test>");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+ SingleDeployableFactory.makeDeployable(file);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ addModuleToServer(mods[0]);
+ }
+
+ @Test
+ public void testSingleDeployableFullPublish() throws IOException, CoreException {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("ear1");
+
+ // Initial
+ fullPublishAndVerify(IServer.PUBLISH_FULL, "<test>done</test>");
+
+ /* Add incremental */
+ ResourceUtils.setContents(p, new Path("test.xml"), "2");
+ JobUtils.waitForIdle();
+ fullPublishAndVerify(IServer.PUBLISH_INCREMENTAL, "2");
+ ResourceUtils.setContents(p, new Path("test.xml"), "3");
+ JobUtils.waitForIdle();
+ fullPublishAndVerify(IServer.PUBLISH_INCREMENTAL, "3");
+ }
+
+ private void fullPublishAndVerify(int publishType, String expectedContents) throws CoreException, IOException {
+ publishAndCheckError(server,publishType);
+ boolean isFullPublish = publishType == IServer.PUBLISH_FULL;
+ int[] vals = isFullPublish ? new int[] { 1,1,1} : new int[] {1,0,1};
+ vals[0] += isFullPublish ? getFullPublishChangedResourceCountModifier() : 0;
+ vals[1] += getFullPublishRemovedResourceCountModifier();
+ vals[2] += isFullPublish ? getFullPublishChangedResourceCountModifier() : 0;
+ verifyPublishMethodResults(vals[0], vals[1], vals[2]);
+
+ IModuleFile[] f = MockPublishMethod4.getChangedFiles();
+ IModuleFile f2 = findBinaryModuleFile(f, "test.xml");
+ File asFile = (File)f2.getAdapter(File.class);
+ assertNotNull(asFile);
+ assertTrue(asFile.exists());
+ assertTrue(asFile.isFile());
+ assertFalse(IOUtil.isZip(asFile));
+ assertEquals(expectedContents, ResourceUtils.getContents(f2));
+ }
+
+ private IModuleFile findBinaryModuleFile(IModuleFile[] files, String name) {
+ for( int i = 0; i < files.length; i++ ) {
+ if( files[i].getName().equals(name))
+ return files[i];
+ }
+ return null;
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFolderTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFolderTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/SingleDeployableFolderTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,159 @@
+package org.jboss.tools.as.test.core.parametized.server.publishing;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.tools.as.test.core.internal.MockPublishMethod4;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.jboss.tools.test.util.JobUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class SingleDeployableFolderTest extends AbstractPublishingTest {
+ @Parameters
+ public static Collection<Object[]> params() {
+ ArrayList<Object[]> ret = defaultData();
+ return ret;
+ }
+
+ public SingleDeployableFolderTest(String serverType, String zip,
+ String deployLoc, String perMod) {
+ super(serverType, zip, deployLoc, perMod);
+ }
+
+ @Override
+ protected void createProjects() throws Exception {
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel("ear2", "earContent", null, null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("ear2");
+ assertTrue(p.exists());
+ IFolder folder1 = p.getFolder("folder1");
+ folder1.create(false, true, new NullProgressMonitor());
+ ResourceUtils.createFile(p, "folder1/file1.txt", "file1 edit1");
+ ResourceUtils.createFile(p, "folder1/file2.txt", "file2 edit1");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+ SingleDeployableFactory.makeDeployable(folder1);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ addModuleToServer(mods[0]);
+ }
+
+ @Test
+ public void testSingleDeployableFolder() throws IOException, CoreException {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("ear2");
+ String file1Path = "folder1/file1.txt";
+ String file2Path = "folder1/file2.txt";
+ IPath f1Path = new Path(file1Path);
+ IPath f2Path = new Path(file2Path);
+
+ // Initial
+ fullPublishAndVerify1("file1 edit1", "file2 edit1");
+
+
+ /* Add incremental */
+ ResourceUtils.setContents(p, f1Path, "file1 edit2");
+ JobUtils.waitForIdle();
+ incrementalOneFileChangedPublishAndVerify1(f1Path, "file1 edit2");
+
+
+ ResourceUtils.setContents(p, f2Path, "file2 edit2");
+ JobUtils.waitForIdle();
+ incrementalOneFileChangedPublishAndVerify1(f2Path, "file2 edit2");
+
+ // Change 2 files
+ String f1e3Cont = "file1 edit3";
+ String f2e3Cont = "file2 edit3";
+ ResourceUtils.setContents(p, f1Path, f1e3Cont);
+ ResourceUtils.setContents(p, f2Path, f2e3Cont);
+ incrementalFilesChangedPublishAndVerify1(new IPath[] { f1Path, f2Path}, new String[] { f1e3Cont, f2e3Cont});
+
+
+ // Incremental Addition
+ String f3Loc = "folder1/file3.txt";
+ IPath f3Path = new Path(f3Loc);
+ ResourceUtils.createFile(p, f3Loc, "file3 added");
+ incrementalFilesChangedPublishAndVerify1(new IPath[] { f3Path}, new String[] { "file3 added"});
+
+ // Incremental Removal
+ ResourceUtils.createFile(p, f3Loc, "file3 added");
+ incrementalFilesChangedPublishAndVerify1(new IPath[] { f3Path}, new String[] { "file3 added"});
+
+ IFile f3 = p.getFile(f3Path);
+ f3.delete(false, null);
+ incrementalFilesRemovedPublishAndVerify1(f3Path);
+ }
+
+ private void incrementalOneFileChangedPublishAndVerify1(IPath filePath, String fileContents) throws CoreException, IOException {
+ incrementalFilesChangedPublishAndVerify1(new IPath[] { filePath }, new String[] { fileContents });
+ }
+
+ private void fullPublishAndVerify1(String file1Contents, String file2Contents) throws CoreException, IOException {
+ publishAndCheckError(server,IServer.PUBLISH_FULL);
+ // initial full publish should be 3 changes, 1 remove, , and 2 temp files (or 1,0,1 for zip)
+ int[] vals = isZipped() ? new int[] { 1,0,1} : new int[] {3,1,2};
+ vals[0] += getFullPublishChangedResourceCountModifier();
+ vals[1] += getFullPublishRemovedResourceCountModifier();
+ vals[2] += getFullPublishChangedResourceCountModifier();
+ verifyPublishMethodResults(vals[0], vals[1], vals[2]);
+ }
+
+ private void incrementalFilesChangedPublishAndVerify1(IPath[] filePath, String[] fileContents) throws CoreException, IOException {
+ publishAndCheckError(server, IServer.PUBLISH_INCREMENTAL);
+ int[] vals = isZipped() ? new int[] { 1,0,1} : new int[] {filePath.length,0,filePath.length};
+ vals[0] += isZipped() ? getFullPublishChangedResourceCountModifier() : 1;
+ vals[1] += getFullPublishRemovedResourceCountModifier();
+ vals[2] += isZipped() ? getFullPublishChangedResourceCountModifier() : 0;
+ verifyPublishMethodResults(vals[0], vals[1], vals[2]);
+
+ IModuleFile[] mf = MockPublishMethod4.getChangedFiles();
+ if (isZipped()) {
+ verifyZipContents(mf, filePath, fileContents);
+ } else {
+ verifyWorkspaceContents(mf, filePath, fileContents);
+ }
+ }
+ private void incrementalFilesRemovedPublishAndVerify1(IPath filePath) throws CoreException, IOException {
+ publishAndCheckError(server, IServer.PUBLISH_INCREMENTAL);
+ IPath[] changed = MockPublishMethod4.getChanged();
+ IPath[] removed = MockPublishMethod4.getRemoved();
+ IPath[] temp = MockPublishMethod4.getTempPaths();
+ System.out.println(" " + changed.length + ", " + removed.length + ", " + temp.length);
+ if( !isZipped() ) {
+ boolean foundRemoved = false;
+ for( int i = 0; i < removed.length; i++ ) {
+ if( removed[i].lastSegment().equals(filePath.lastSegment()))
+ foundRemoved = true;
+ }
+ assertTrue("Incremental removal has failed", foundRemoved);
+ } else {
+ File foundZip = findZip(MockPublishMethod4.getChangedFiles());
+ de.schlichtherle.io.File zipRoot = new de.schlichtherle.io.File(foundZip, new TrueZipUtil.JarArchiveDetector());
+ de.schlichtherle.io.File removed2 = new de.schlichtherle.io.File(zipRoot, filePath.removeFirstSegments(1).toString());
+ assertFalse(removed2.exists());
+ }
+ }
+
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/defect/RepublishDefectTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/defect/RepublishDefectTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/defect/RepublishDefectTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.as.test.core.parametized.server.publishing.defect;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.tools.as.test.core.internal.utils.ResourceUtils;
+import org.jboss.tools.as.test.core.internal.utils.wtp.CreateProjectOperationsUtility;
+import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
+import org.jboss.tools.as.test.core.internal.utils.wtp.OperationTestCase;
+import org.jboss.tools.as.test.core.parametized.server.publishing.AbstractPublishingTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class RepublishDefectTest extends AbstractPublishingTest {
+ @Parameters
+ public static Collection<Object[]> params() {
+ return defaultData();
+ }
+
+ public RepublishDefectTest(String serverType, String zip,
+ String deployLoc, String perMod) {
+ super(serverType, zip, deployLoc, perMod);
+ }
+
+ protected void createProjects() throws Exception {
+ IDataModel dm = CreateProjectOperationsUtility.getEARDataModel("ear", "thatContent", null, null, JavaEEFacetConstants.EAR_5, true);
+ OperationTestCase.runAndVerify(dm);
+ IDataModel dyn1Model = CreateProjectOperationsUtility.getWebDataModel("d1", "ear", null, null, null, JavaEEFacetConstants.WEB_23, true);
+ OperationTestCase.runAndVerify(dyn1Model);
+ IDataModel dyn2Model = CreateProjectOperationsUtility.getWebDataModel("d2", "ear", null, null, null, JavaEEFacetConstants.WEB_23, true);
+ OperationTestCase.runAndVerify(dyn2Model);
+ addModuleToServer(ServerUtil.getModule(findProject("ear")));
+ }
+
+ protected void completeSetUp() {
+ // Keep it local for REAL publishes
+ wc.setAttribute(IDeployableServer.SERVER_MODE, "local");
+ }
+
+ private void addOrRemoveModuleWithPublish(IModule[] module, boolean add) throws CoreException {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ if( add )
+ wc.modifyModules(module, new IModule[]{}, new NullProgressMonitor());
+ else
+ wc.modifyModules(new IModule[]{}, module, new NullProgressMonitor());
+ server = wc.save(true, new NullProgressMonitor());
+ server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ }
+
+
+ @Test
+ public void testJBIDE6184_Odd_Republish_Error() throws Exception {
+ IModule[] ear = getModule(findProject("ear"));
+
+ // Create a temp server
+ addOrRemoveModuleWithPublish(ear, true);
+
+ // verify
+ IPath earPath = getLocalPublishMethodDeployRoot();
+ System.out.println(earPath);
+ JBIDE6184EarHasDynProjs(earPath, true);
+
+ // undeploy
+ addOrRemoveModuleWithPublish(ear, false);
+ assertFalse(earPath.toFile().exists());
+
+ ResourceUtils.deleteProject("d1");
+
+ // republish the ear
+ addOrRemoveModuleWithPublish(ear, true);
+ JBIDE6184EarHasDynProjs(earPath, false);
+
+ // recreate the war
+ IDataModel dyn1Model = CreateProjectOperationsUtility.getWebDataModel("d1", "ear", null, null, null, JavaEEFacetConstants.WEB_23, true);
+ OperationTestCase.runAndVerify(dyn1Model);
+ server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ JBIDE6184EarHasDynProjs(earPath, true);
+ }
+
+ protected void JBIDE6184EarHasDynProjs(IPath earPath, boolean d1Present ) {
+ ArrayList<IPath> mustBePresent = new ArrayList<IPath>();
+ ArrayList<IPath> mustBeMissing = new ArrayList<IPath>();
+
+ mustBePresent.add(earPath);
+ mustBePresent.add(earPath.append("META-INF"));
+ mustBePresent.add(earPath.append("META-INF").append("application.xml"));
+
+ ArrayList<IPath> tmp = d1Present ? mustBePresent : mustBeMissing;
+ tmp.add(earPath.append("d1.war"));
+ tmp.add(earPath.append("d1.war").append("WEB-INF"));
+ tmp.add(earPath.append("d1.war").append("META-INF"));
+ tmp.add(earPath.append("d1.war").append("META-INF").append("MANIFEST.MF"));
+ tmp.add(earPath.append("d1.war").append("WEB-INF").append("web.xml"));
+
+ mustBePresent.add(earPath.append("d2.war"));
+ mustBePresent.add(earPath.append("d2.war").append("WEB-INF"));
+ mustBePresent.add(earPath.append("d2.war").append("META-INF"));
+ mustBePresent.add(earPath.append("d2.war").append("META-INF").append("MANIFEST.MF"));
+ mustBePresent.add(earPath.append("d2.war").append("WEB-INF").append("web.xml"));
+
+ verifyList(earPath, mustBePresent, true);
+ verifyList(earPath, mustBeMissing, false);
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ArgsUtilTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * 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.as.test.core.utiltests;
+
+import junit.framework.TestCase;
+
+import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
+
+public class ArgsUtilTest extends TestCase {
+ private static String QUOTE = "\"";
+ private static String EQ = "=";
+
+ public void testParse() {
+ assertEquals(1, ArgsUtil.parse("").length);
+ assertEquals(1, ArgsUtil.parse("a").length);
+ assertEquals(1, ArgsUtil.parse("abc ").length);
+ assertEquals(1, ArgsUtil.parse(" abcde ").length);
+ assertEquals(1, ArgsUtil.parse(" abcde ").length);
+ assertEquals(1, ArgsUtil.parse(" abcde ").length);
+ assertEquals(2, ArgsUtil.parse("a b").length);
+ assertEquals(2, ArgsUtil.parse("a b").length);
+ assertEquals(2, ArgsUtil.parse(" a b").length);
+ assertEquals(2, ArgsUtil.parse(" a b ").length);
+ assertEquals(2, ArgsUtil.parse("-b test ").length);
+ assertEquals(2, ArgsUtil.parse("-b --host=someval ").length);
+ assertEquals(2, ArgsUtil.parse("-b \"--host=some val\"").length);
+ assertEquals(3, ArgsUtil.parse("-b val --host=someval").length);
+ assertEquals(2, ArgsUtil.parse("-b --host=\"some val\"").length);
+ assertEquals(2, ArgsUtil.parse("-b \"--host=some val\"").length);
+ }
+
+ public void testShortArgMatch() {
+ assertTrue(ArgsUtil.matchesShortArg("-b", split("-b -c -d -f")));
+ assertFalse(ArgsUtil.matchesShortArg("-b", split("-c opt d two -f")));
+ assertFalse(ArgsUtil.matchesShortArg("-b", split("b")));
+ assertFalse(ArgsUtil.matchesShortArg("-b", split("b opt")));
+ assertTrue(ArgsUtil.matchesShortArg("-b", split("-b opt")));
+
+ assertTrue(ArgsUtil.matchesShortArg("-host", split("-host -c -d -f")));
+ assertFalse(ArgsUtil.matchesShortArg("-host", split("-c val d two -f")));
+ assertFalse(ArgsUtil.matchesShortArg("-host", split("host")));
+ assertFalse(ArgsUtil.matchesShortArg("-host", split("host val")));
+ assertTrue(ArgsUtil.matchesShortArg("-host", split("-host val")));
+ }
+
+ public void testLongArgMatch() {
+ assertTrue(ArgsUtil.matchesLongArg("--host=localhost", split("--host --longopt1 -longopt2 -f")));
+ assertFalse(ArgsUtil.matchesLongArg("-host=localhost", split("--host --longopt1 -longopt2 -f")));
+ assertTrue(ArgsUtil.matchesLongArg("-longopt2=v1", split("--host --longopt1 -longopt2 -f")));
+ assertFalse(ArgsUtil.matchesLongArg("-longopt2 v1", split("--host --longopt1 -longopt2 -f")));
+ }
+
+ public void testReplace() {
+ String allArgs = "";
+ allArgs = ArgsUtil.setArg(allArgs, "-h", null, "new");
+ assertTrue(ArgsUtil.parse(allArgs).length == 2);
+ assertTrue(ArgsUtil.getValue(allArgs, "-h", null).equals("new"));
+ allArgs = ArgsUtil.setArg(allArgs, "-h", null, "correct");
+ assertTrue(ArgsUtil.parse(allArgs).length == 2);
+ assertTrue(ArgsUtil.getValue(allArgs, "-h", null).equals("correct"));
+
+ allArgs = ArgsUtil.setArg(allArgs, null, "--two", "newtwo");
+ assertTrue(ArgsUtil.parse(allArgs).length == 3);
+
+ // opt was set as long opt, --two=newtwo. Search for short opt fails
+ assertTrue(ArgsUtil.getValue(allArgs, "--two", null) == null);
+
+ // clear long opt
+ allArgs = ArgsUtil.setArg(allArgs, null, "--two", null);
+ assertTrue(ArgsUtil.parse(allArgs).length == 2);
+
+
+ // test replacement of short args
+ allArgs = ArgsUtil.setArg(allArgs, new String[]{"-h", "-o"}, new String[]{}, "twoOpt", false);
+ assertTrue(ArgsUtil.parse(allArgs).length == 2); // no change
+
+ assertTrue(ArgsUtil.getValue(allArgs, "-h", null).equals("twoOpt"));
+ assertTrue(ArgsUtil.getValue(allArgs, new String[]{"-h", "-o"}, null).equals("twoOpt"));
+ assertTrue(ArgsUtil.getValue(allArgs, new String[]{"-o", "-h"}, null).equals("twoOpt"));
+
+ // test clear of short arg
+ allArgs = ArgsUtil.setArg(allArgs, new String[]{"-h", "-o"}, new String[]{}, null, false);
+ assertTrue(ArgsUtil.parse(allArgs).length == 1); // no change
+
+ allArgs = ArgsUtil.setArg(allArgs, null, "--three", "three");
+ assertTrue(ArgsUtil.getValue(allArgs, null, "--three").equals("three"));
+
+ allArgs = ArgsUtil.setArg(allArgs, null, "--three", "threea");
+ assertTrue(ArgsUtil.getValue(allArgs, null, "--three").equals("threea"));
+
+ // already has --three, test replace, ensure --four is the new arg
+ // since it is the first of the two acceptable replacements
+ assertTrue(allArgs.contains("--three"));
+ allArgs = ArgsUtil.setArg(allArgs, null, new String[]{"--four", "--three"}, "three_b", false);
+ assertTrue(allArgs.contains("--four"));
+ assertTrue(ArgsUtil.getValue(allArgs, null, "--three") == null);
+ assertTrue(ArgsUtil.getValue(allArgs, null, "--four").equals("three_b"));
+ assertTrue(ArgsUtil.getValue(allArgs, null, new String[]{"--three", "--four"}).equals("three_b"));
+
+ }
+
+
+ public void testOuterQuoteMultipleSet() {
+ String argId = "-Dtest";
+ String folder = "my folder";
+ String args = QUOTE + argId + EQ + folder + QUOTE;
+ String args2 = ArgsUtil.setArg(args, null, argId, folder);
+ assertTrue(args2.trim().equals(args));
+
+ String args3 = ArgsUtil.setArg(args2, null, argId, folder + "2");
+ assertTrue(args3.trim().equals(QUOTE + argId + EQ + folder + "2" + QUOTE));
+ }
+
+ public void testInnerQuotesMultipleSet() {
+ String argId = "-Dtest";
+ String folder = "my folder";
+ String args = argId + EQ + QUOTE + folder + QUOTE;
+ String args2 = ArgsUtil.setArg(args, null, argId, folder + "2");
+ assertTrue(args2.trim().equals(argId + EQ + QUOTE + folder + "2" + QUOTE));
+ args2 = ArgsUtil.setArg(args2, null, argId, folder + "3");
+ assertTrue(args2.trim().equals(argId + EQ + QUOTE + folder + "3" + QUOTE));
+ }
+
+ public void testSetToNulLWithQuotes() {
+ String argId = "-Dtest";
+ String folder = "my folder";
+
+ String args = QUOTE + argId + EQ + folder + QUOTE;
+ String args2 = ArgsUtil.setArg(args, null, argId, null, true);
+ assertTrue(args2.trim().equals(""));
+ }
+
+ // Just for testing, simply split this string into a bunch of options.
+ // So I don't need to make new arrays all the time...
+ public String[] split(String val) {
+ return val.split(" ");
+ }
+}
Added: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java (rev 0)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java 2012-07-24 05:37:25 UTC (rev 42686)
@@ -0,0 +1,20 @@
+package org.jboss.tools.as.test.core.utiltests;
+
+import org.jboss.ide.eclipse.as.core.util.ExpressionResolverUtil;
+
+import junit.framework.TestCase;
+
+public class ExpressionResolverUtilTest extends TestCase {
+ public void testExpressionResolver() {
+ assertEquals("aaa", ExpressionResolverUtil.safeReplaceProperties("aaa"));
+ assertEquals("t9", ExpressionResolverUtil.safeReplaceProperties("t${something:9}"));
+ assertEquals("t9a", ExpressionResolverUtil.safeReplaceProperties("t${something:9}a"));
+
+ // NO recursive checking
+ assertEquals("5:notfound}", ExpressionResolverUtil.safeReplaceProperties("${twoPoint${someNumber:5}:notfound}"));
+
+ // unresolvable, so no change
+ assertEquals("t${something}", ExpressionResolverUtil.safeReplaceProperties("t${something}"));
+ assertEquals("t${something}a", ExpressionResolverUtil.safeReplaceProperties("t${something}a"));
+ }
+}
13 years, 5 months
JBoss Tools SVN: r42685 - trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-24 00:43:16 -0400 (Tue, 24 Jul 2012)
New Revision: 42685
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
Log:
JBIDE-12361 part 2 to trunk
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2012-07-24 04:30:08 UTC (rev 42684)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2012-07-24 04:43:16 UTC (rev 42685)
@@ -84,6 +84,9 @@
protected ScannableFileSet fs;
protected ArrayList<FileWrapper> matches;
protected HashMap<String, ArrayList<FileWrapper>> matchesMap;
+
+ /* Folders that are required to be created due to a descendent, but are not fully included */
+ protected HashMap<String, ArrayList<FileWrapper>> requiredFolders;
public DirectoryScannerExtension(ScannableFileSet fs) {
this.fs = fs;
String includes = fs.includes == null ? "" : fs.includes; //$NON-NLS-1$
@@ -95,6 +98,7 @@
workspaceRelative = fs.inWorkspace;
matches = new ArrayList<FileWrapper>();
matchesMap = new HashMap<String, ArrayList<FileWrapper>>();
+ requiredFolders = new HashMap<String, ArrayList<FileWrapper>>();
setBasedir2(fs.rawPath);
}
@@ -139,8 +143,10 @@
.getVFS().getWorkspaceChildren(workspaceRelative);
IPath[] childrenAbsolute = globalize(childrenWorkspace);
File[] files = new File[childrenAbsolute.length];
+ IPath parentRootFSRelative = ((FileWrapper)file).getRootArchiveRelative();
for( int i = 0; i < files.length; i++ ) {
- files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i], fs.rootArchiveRelativePath);
+ files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i],
+ parentRootFSRelative.append(childrenWorkspace[i].lastSegment()));
}
return files;
}
@@ -171,15 +177,29 @@
f2.setFilesetRelative(relative);
if( f.isFile() ) {
matches.add(f2);
- ArrayList<FileWrapper> l = matchesMap.get(f2);
- if( l == null ) {
- l = new ArrayList<FileWrapper>();
- matchesMap.put(((FileWrapper)f).getAbsolutePath(), l);
- }
- l.add(f2);
+ addMatchToMap(f2, matchesMap);
+ if( fs.inWorkspace )
+ ensureRequiredFoldersIncluded(f2);
}
}
}
+ protected void addMatchToMap(FileWrapper f2, HashMap<String, ArrayList<FileWrapper>> map) {
+ ArrayList<FileWrapper> l = map.get(f2);
+ if( l == null ) {
+ l = new ArrayList<FileWrapper>();
+ map.put(f2.getAbsolutePath(), l);
+ }
+ l.add(f2);
+ }
+ protected void ensureRequiredFoldersIncluded(FileWrapper includedFile) {
+ FileWrapper tmpParentWrapper = includedFile.getParentFile();
+ while(tmpParentWrapper != null ) {
+ includedFile = tmpParentWrapper;
+ if( requiredFolders.get(includedFile.getAbsolutePath()) != null )
+ return; // all done
+ addMatchToMap(includedFile, requiredFolders);
+ }
+ }
protected boolean isSelected(String name, File file) {
return super.isSelected(name, file) && file.isFile();
@@ -195,6 +215,10 @@
return matchesMap;
}
+ public HashMap<String, ArrayList<FileWrapper>> getRequiredFolderMap() {
+ return requiredFolders;
+ }
+
public static class FileWrapper extends File {
// The actual source file
File f;
@@ -232,8 +256,11 @@
}
public IPath getRootArchiveRelative() {
- if( rootArchiveRelativePath != null )
+ if( rootArchiveRelativePath != null ) {
+ if( fsRelative == null )
+ return rootArchiveRelativePath;
return rootArchiveRelativePath.append(fsRelative);
+ }
return null;
}
@@ -244,6 +271,23 @@
}
return false;
}
+ @Override
+ public FileWrapper getParentFile() {
+ if( f.getParentFile() == null )
+ return null;
+ if( path.segmentCount() == 0 )
+ return null;
+ if( rootArchiveRelativePath.segmentCount() == 0 )
+ return null;
+ IPath p = new Path(fsRelative);
+ if( p.segmentCount() == 0 )
+ return null;
+
+ FileWrapper ret = new FileWrapper(f.getParentFile(),
+ path.removeLastSegments(1), rootArchiveRelativePath.removeLastSegments(1));
+ ret.setFilesetRelative(p.removeLastSegments(1).toString());
+ return ret;
+ }
}
public boolean couldBeIncluded(String path, boolean inWorkspace) {
13 years, 5 months
JBoss Tools SVN: r42684 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-24 00:30:08 -0400 (Tue, 24 Jul 2012)
New Revision: 42684
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
Log:
JBIDE-12360 uncommit a bad change
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2012-07-24 04:09:04 UTC (rev 42683)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2012-07-24 04:30:08 UTC (rev 42684)
@@ -43,7 +43,6 @@
swc.setRuntime(runtime);
swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
- swc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
IServer server = swc.save(true, null);
return server;
}
13 years, 5 months
JBoss Tools SVN: r42683 - in trunk/as/plugins: org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-24 00:09:04 -0400 (Tue, 24 Jul 2012)
New Revision: 42683
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/WorkspaceFilesetVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
Log:
trivial change to liberalize parameter from IServer to superinterface IServerAttributes
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/WorkspaceFilesetVirtualComponent.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/WorkspaceFilesetVirtualComponent.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/filesets/vcf/WorkspaceFilesetVirtualComponent.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.ide.eclipse.archives.webtools.filesets.vcf;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -19,8 +23,8 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.as.wtp.core.util.ResourceFilter;
import org.jboss.ide.eclipse.as.wtp.core.util.ResourceListVirtualFolder;
import org.jboss.ide.eclipse.as.wtp.core.vcf.AbstractFilesetVirtualComponent;
@@ -96,12 +100,33 @@
scanner = DirectoryScannerFactory.createDirectoryScanner(
rootFolderPath, new Path(""), //$NON-NLS-1$
includes, excludes, getProject().getName(), true,
- IArchiveModelRootNode.DESCRIPTOR_VERSION_1_3, false);
+ IArchiveModelRootNode.DESCRIPTOR_VERSION_1_3, true);
}
public boolean accepts(IResource resource) {
- boolean b = scanner.couldBeIncluded(resource.getFullPath().toString(), true);
- return b;
+ String absolutePath = resource.getLocation().toFile().getAbsolutePath();
+ ArrayList<DirectoryScannerExtension.FileWrapper> sum = getAllMatches(absolutePath);
+ if( sum.size() > 0 ) {
+ DirectoryScannerExtension.FileWrapper tmp;
+ Iterator<DirectoryScannerExtension.FileWrapper> i = sum.iterator();
+ while(i.hasNext()) {
+ tmp = i.next();
+ if( tmp.getWrapperPath().equals(resource.getFullPath()))
+ return true;
+ }
+ }
+ return false;
}
+ private ArrayList<DirectoryScannerExtension.FileWrapper> getAllMatches(String absolutePath) {
+ HashMap<String, ArrayList<DirectoryScannerExtension.FileWrapper>> matchedFiles = scanner.getMatchedMap();
+ HashMap<String, ArrayList<DirectoryScannerExtension.FileWrapper>> requiredFolders = scanner.getRequiredFolderMap();
+ ArrayList<DirectoryScannerExtension.FileWrapper> sum = new ArrayList<DirectoryScannerExtension.FileWrapper>();
+
+ if( matchedFiles.get(absolutePath) != null )
+ sum.addAll(matchedFiles.get(absolutePath));
+ if( requiredFolders.get(absolutePath) != null )
+ sum.addAll(requiredFolders.get(absolutePath));
+ return sum;
+ }
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/AltMethodZippedJSTPublisher.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -86,7 +86,8 @@
String name = sourcePath.lastSegment();
IStatus result = null;
- DeploymentMarkerUtils.removeDeployFailedMarker(method, server, destination, monitor);
+ if( DeploymentMarkerUtils.supportsJBoss7MarkerDeployment(server) )
+ DeploymentMarkerUtils.removeDeployFailedMarker(method, server, destination, monitor);
if(publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
result = removeRemoteDeployment(sourcePath, destination.removeLastSegments(1), name, monitor);
@@ -127,7 +128,7 @@
// Locally zip it up into the remote tmp folder
IStatus result = super.publishModule(method, server, module, publishType, delta, monitor);
- if( result.isOK() ) {
+ if( result.isOK() && requiresTransfer()) { // It seems the superclass already transfers it upstream for as7 :|
result = remoteFullPublish(sourcePath, destination.removeLastSegments(1), name,
AbstractServerToolsPublisher.getSubMon(monitor, 150));
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -36,6 +36,7 @@
public class WTPZippedPublisher implements IJBossServerPublisher {
private int moduleState = IServer.PUBLISH_STATE_NONE;
+ private boolean requiresTransfer = true;
public boolean accepts(String method, IServer server, IModule[] module) {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
@@ -45,6 +46,9 @@
public int getPublishState() {
return moduleState;
}
+ public boolean requiresTransfer() {
+ return requiresTransfer;
+ }
protected String getDeployRoot(IModule[] module, IDeployableServer ds) {
return PublishUtil.getDeployRootFolder(
@@ -65,9 +69,11 @@
return null;
if( DeploymentMarkerUtils.supportsJBoss7MarkerDeployment(server)) {
+ requiresTransfer = false;
status = handleJBoss7Deployment(method, server, module, publishType, delta, monitor);
} else {
Trace.trace(Trace.STRING_FINER, "Using as<=6 publishModule logic in WTPZippedPublisher for module " + module[module.length-1].getName() ); //$NON-NLS-1$
+ requiresTransfer = true;
IDeployableServer ds = ServerConverter.getDeployableServer(server);
String deployRoot = getDeployRoot(module, ds);
LocalZippedPublisherUtil util = new LocalZippedPublisherUtil();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/DeploymentPreferenceLoader.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -79,7 +79,7 @@
return null;
}
- public static DeploymentPreferences loadPreferencesFromServer(IServer server) {
+ public static DeploymentPreferences loadPreferencesFromServer(IServerAttributes server) {
String xml = ((Server)server).getAttribute(DEPLOYMENT_PREFERENCES_KEY, (String)null);
ByteArrayInputStream bis = null;
if( xml != null ) {
@@ -188,17 +188,23 @@
}
public DeploymentModulePrefs getModulePrefs(IModule module) {
- return children.get(module.getId());
+ return getModulePrefs(module.getId());
}
+ public DeploymentModulePrefs getModulePrefs(String id) {
+ return children.get(id);
+ }
public DeploymentModulePrefs getOrCreateModulePrefs(IModule module) {
- if( children.get(module.getId()) == null ) {
+ return getOrCreateModulePrefs(module.getId());
+ }
+ public DeploymentModulePrefs getOrCreateModulePrefs(String id) {
+ if( children.get(id) == null ) {
IMemento childMemento = memento.createChild("module"); //$NON-NLS-1$
- childMemento.putString("id", module.getId()); //$NON-NLS-1$
- children.put(module.getId(),
- new DeploymentModulePrefs(module.getId(),
+ childMemento.putString("id", id); //$NON-NLS-1$
+ children.put(id,
+ new DeploymentModulePrefs(id,
childMemento));
}
- return children.get(module.getId());
+ return children.get(id);
}
public String getProperty(String key) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerConverter.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -104,7 +104,7 @@
return jbServer;
}
- public static IDeployableServer getDeployableServer(IServer server) {
+ public static IDeployableServer getDeployableServer(IServerAttributes server) {
if (server == null) {
return null;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2012-07-24 04:04:40 UTC (rev 42682)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerCreationUtils.java 2012-07-24 04:09:04 UTC (rev 42683)
@@ -23,6 +23,7 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.Server;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
@@ -42,6 +43,7 @@
swc.setRuntime(runtime);
swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ swc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
IServer server = swc.save(true, null);
return server;
}
13 years, 5 months
JBoss Tools SVN: r42682 - branches/jbosstools-3.3.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-24 00:04:40 -0400 (Tue, 24 Jul 2012)
New Revision: 42682
Modified:
branches/jbosstools-3.3.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
Log:
JBIDE_12216 missed file to branch
Modified: branches/jbosstools-3.3.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java
===================================================================
--- branches/jbosstools-3.3.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2012-07-24 04:03:57 UTC (rev 42681)
+++ branches/jbosstools-3.3.x/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ManagerServicePoller.java 2012-07-24 04:04:40 UTC (rev 42682)
@@ -99,15 +99,17 @@
}
private String[] handleAsynchCallbacks(String[] prompts) {
- List<String> tmp = new ArrayList<String>();
- tmp.addAll(Arrays.asList(prompts));
- setRequiredProperties(tmp);
- RequiresInfoException e2 = new RequiresInfoException("Requires proper credentials"); //$NON-NLS-1$
- setRequiredInfoException(e2);
- while( !getDone() && !getCanceled() && getRequiredPropertiesReturned() == null ) {
- try {
- Thread.sleep(500);
- } catch(InterruptedException ie) {/* Do nothing */}
+ if( getRequiredPropertiesReturned() == null ) {
+ List<String> tmp = new ArrayList<String>();
+ tmp.addAll(Arrays.asList(prompts));
+ setRequiredProperties(tmp);
+ RequiresInfoException e2 = new RequiresInfoException("Requires proper credentials"); //$NON-NLS-1$
+ setRequiredInfoException(e2);
+ while( !getDone() && !getCanceled() && getRequiredPropertiesReturned() == null ) {
+ try {
+ Thread.sleep(500);
+ } catch(InterruptedException ie) {/* Do nothing */}
+ }
}
if( getDone() || getCanceled() )
@@ -119,6 +121,7 @@
// If not cleared then it will keep asking for username/password
setRequiredInfoException(null);
+ setRequiredProperties(null);
return retPrompts;
}
@@ -184,9 +187,21 @@
serverState = service.getServerState(managementDetails);
return serverState == JBoss7ServerState.RUNNING;
} catch (Exception e) {
+ Throwable root = getRootException(e);
+ // If the exception is one that autnentication failed, re-prompt.
+ if(root != null && root.getMessage() != null && root.getMessage().startsWith("Authentication failed:")) //$NON-NLS-1$
+ provideCredentials(null);
+ // Otherwise, keep trying.
return false;
}
}
+
+ private Throwable getRootException(Throwable e) {
+ Throwable cause = e.getCause();
+ if( cause != e && cause != null )
+ return getRootException(cause);
+ return cause == null ? e : cause;
+ }
private boolean checkShutdown(IJBoss7ManagerService service) {
try {
13 years, 5 months