Author: jjankovi
Date: 2011-08-10 08:07:22 -0400 (Wed, 10 Aug 2011)
New Revision: 33760
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/Rest.java.ws
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.project
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java
Log:
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project 2011-08-10 11:00:15 UTC (rev
33759)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project 2011-08-10 12:07:22 UTC (rev
33760)
@@ -42,4 +42,11 @@
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
<nature>org.jboss.tools.cdi.core.cdinature</nature>
</natures>
+ <linkedResources>
+ <link>
+ <name>lib-src</name>
+ <type>2</type>
+ <location>/home/jjankovi/Dokumenty/Trunk-svn/trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src</location>
+ </link>
+ </linkedResources>
</projectDescription>
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.project
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.project 2011-08-10 11:00:15 UTC (rev
33759)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.project 2011-08-10 12:07:22 UTC (rev
33760)
@@ -43,4 +43,16 @@
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
+ <linkedResources>
+ <link>
+ <name>lib-src</name>
+ <type>2</type>
+ <location>/home/jjankovi/Dokumenty/Trunk-svn/trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src</location>
+ </link>
+ <link>
+ <name>lib-src-1</name>
+ <type>2</type>
+ <location>/home/jjankovi/Dokumenty/Trunk-svn/trunk/tests/plugins/org.jboss.tools.tests/src</location>
+ </link>
+ </linkedResources>
</projectDescription>
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/Rest.java.ws
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/Rest.java.ws
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/Rest.java.ws 2011-08-10
12:07:22 UTC (rev 33760)
@@ -0,0 +1,49 @@
+package rest.sample;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/RESTSample")
+public class Sample {
+
+ @GET()
+ @Produces("text/plain")
+ public String method1() {
+ return "Hello World!";
+ }
+
+
+
+ @GET()
+ @Path("{name}")
+ @Produces("text/plain")
+ public String method2(@PathParam("name")String name) {
+ return "Hello " + name;
+ }
+
+ @POST()
+ @Path("PostMethod")
+ @Produces("text/plain")
+ public void method3() {
+
+ }
+
+ @PUT()
+ @Path("PutMethod")
+ public void method4() {
+
+ }
+
+
+ @DELETE()
+ @Path("DeleteMethod")
+ public void method5() {
+
+ }
+
+}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2011-08-10
11:00:15 UTC (rev 33759)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2011-08-10
12:07:22 UTC (rev 33760)
@@ -36,6 +36,7 @@
* Suite duration: aprox. 13min
*
* @author Lukas Jungmann
+ * @author jjankovi
*/
@SuiteClasses({
SampleWSTest.class,
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java 2011-08-10
11:00:15 UTC (rev 33759)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java 2011-08-10
12:07:22 UTC (rev 33760)
@@ -11,9 +11,11 @@
package org.jboss.tools.ws.ui.bot.test.jbt;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -22,15 +24,13 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
-import org.jboss.tools.ui.bot.ext.entity.JavaProjectEntity;
import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewSampleWSWizardAction;
import org.jboss.tools.ws.ui.bot.test.uiutils.actions.TreeItemAction;
import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard;
@@ -38,6 +38,7 @@
import org.jboss.tools.ws.ui.bot.test.utils.WSClient;
import org.jboss.tools.ws.ui.bot.test.wtp.WSTestBase;
import org.junit.AfterClass;
+import org.junit.Ignore;
import org.junit.Test;
@SWTBotTestRequires(server =
@@ -96,26 +97,13 @@
createDD(project);
}
assertTrue(dd.exists());
- createSampleRESTWS(project, "RESTSample", "rest.sample",
"Sample", "RESTApp");
+ createSampleRESTWS(project, "RESTSample", "rest.sample",
"Sample", "RESTApp");
checkRESTService(project, "RESTSample", "rest.sample",
"Sample", "Hello World!", "RESTApp");
- }
+ }
-
-
- /*
- * Adding Rest support through context menu is available from JBT 3.3.0 M2
- */
- @Test
- public void testImportRestSupport() {
- String projectName = "RestLessProject";
- JavaProjectEntity javaProject = new JavaProjectEntity();
- javaProject.setProjectName(projectName);
- eclipse.createJavaProject(javaProject);
- SWTBotTree tree = projectExplorer.bot().tree();
- assertTrue("Project " + projectName + " was not created
properly",
- SWTEclipseExt.treeContainsItemWithLabel(tree, projectName));
- SWTBotTreeItem ti = tree.expandNode(projectName);
-
+ private void addRestSupport(String project) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem ti = tree.expandNode(project);
new TreeItemAction(ti, "Configure","Add JAX-RS 1.1
support...").run();
bot.sleep(500);
util.waitForNonIgnoredJobs();
@@ -123,8 +111,47 @@
ti.getNode("RESTful Web Services");
}catch (WidgetNotFoundException exc) {
fail("REST support was not configured properly");
+ }
+ }
+
+ private void checkRestSupport(String project, String servName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem ti = tree.expandNode(project,"RESTful Web Services");
+ ArrayList<String> nodes = (ArrayList<String>)ti.getNodes();
+
+
+ assertTrue("Should be 2 GET services instead of " +
+ numberOfService(nodes,"GET"), numberOfService(nodes,"GET") ==
2);
+ assertTrue("Should be 1 DELETE service instead of " +
+ numberOfService(nodes,"DELETE"), numberOfService(nodes,"DELETE")
== 1);
+ assertTrue("Should be 1 POST service instead of " +
+ numberOfService(nodes,"POST"), numberOfService(nodes,"POST") ==
1);
+ assertTrue("Should be 1 PUT service instead of " +
+ numberOfService(nodes,"PUT"), numberOfService(nodes,"PUT") ==
1);
+
+
+ assertTrue("Node's form should be {GET /RESTSample} instead of {" +
+ nodes.get(0) + "}",nodes.get(0).equals("GET /" + servName));
+ assertTrue("Node's form should be {DELETE /RESTSample/DeleteMethod} instead
of {" +
+ nodes.get(1) + "}",nodes.get(1).equals("DELETE /" + servName +
"/DeleteMethod"));
+ assertTrue("Node's form should be {POST /RESTSample/PostMethod} instead of
{" +
+ nodes.get(2) + "}",nodes.get(2).equals("POST /" + servName +
"/PostMethod"));
+ assertTrue("Node's form should be {PUT /RESTSample/PutMethod} instead of
{" +
+ nodes.get(3) + "}",nodes.get(3).equals("PUT /" + servName +
"/PutMethod"));
+ assertTrue("Node's form should be {GET /RESTSample/{name}} instead of
{" +
+ nodes.get(4) + "}",nodes.get(4).equals("GET /" + servName +
"/{name}"));
+
+ }
+
+ private int numberOfService(ArrayList<String> services, String serviceType) {
+ int count = 0;
+ for (String service: services) {
+ if (service.contains(serviceType)) {
+ count++;
+ }
}
- }
+ return count;
+ }
private void createDD(String project) {
SWTBotTree tree = projectExplorer.bot().tree();
@@ -136,31 +163,33 @@
util.waitForNonIgnoredJobs();
bot.sleep(1500);
}
-
- // createSampleSOAPWS(getWsProjectName(), "HelloService",
"sample", "SampleService");
- //createSampleService(Type.SOAP, project, name, pkg, cls, null);
+
private void createSampleSOAPWS(String project, String name, String pkg, String cls)
{
createSampleService(Type.SOAP, project, name, pkg, cls, null);
}
-
- //checkSOAPService(getWsProjectName(), "HelloService", "sample",
"SampleService", "You");
+
private void checkSOAPService(String project, String svcName, String svcPkg, String
svcClass, String msgContent) {
checkService(Type.SOAP, project, svcName, svcPkg, svcClass, msgContent, null);
}
private void checkRESTService(String project, String svcName, String svcPkg, String
svcClass, String msgContent, String appCls) {
checkService(Type.REST, project, svcName, svcPkg, svcClass, msgContent, appCls);
+ addRestSupport(project);
+ checkRestSupport(project,svcName);
}
private void createSampleRESTWS(String project, String name, String pkg, String cls,
String appCls) {
- createSampleService(Type.REST, project, name, pkg, cls, appCls);
+ SWTBotEditor ed = createSampleService(Type.REST, project, name, pkg, cls, appCls);
+ SWTBotEclipseEditor st = ed.toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+ InputStream javasrc =
SampleWSTest.class.getResourceAsStream("/resources/jbossws/Rest.java.ws");
+ String code = readStream(javasrc);
+ st.setText(code);
+ ed.save();
}
-
-
- // createSampleSOAPWS(getWsProjectName(), "HelloService",
"sample", "SampleService");
- //createSampleService(Type.SOAP, project, name, pkg, cls, null);
- private void createSampleService(Type type, String project, String name, String pkg,
String cls, String appCls) {
+
+ private SWTBotEditor createSampleService(Type type, String project, String name,
String pkg, String cls, String appCls) {
SampleWSWizard w = new NewSampleWSWizardAction(type).run();
w.setProjectName(project).setServiceName(name);
w.setPackageName(pkg).setClassName(cls);
@@ -169,6 +198,7 @@
}
w.finish();
util.waitForNonIgnoredJobs();
+ return bot.editorByTitle(cls + ".java");
}
private void checkService(Type type, String project, String svcName, String svcPkg,
String svcClass, String msgContent, String appCls) {