https://wiki.eclipse.org/api.php?action=feedcontributions&user=Nicolas.marchildon.net&feedformat=atomEclipsepedia - User contributions [en]2024-03-28T18:55:57ZUser contributionsMediaWiki 1.26.4https://wiki.eclipse.org/index.php?title=Jetty&diff=163778Jetty2009-07-13T18:22:20Z<p>Nicolas.marchildon.net: Contributor -> Contributing</p>
<hr />
<div>{{Jetty}}<br />
<br />
Welcome to the Jetty Documentation Wiki. Jetty is an an open-source project providing an HTTP server, HTTP client, and [http://java.sun.com/javaee/5/docs/api/javax/servlet/package-summary.html javax.servlet] container. The Jetty Wiki provides information about getting started with Jetty, tutorials, feature guides, FAQs, help with troubleshooting, and more. <br />
<br />
For short and to the point answers on many topics check the [[Jetty/Howto|How Tos]] section. For more details read the [[Jetty/Feature|Feature Guides]], [[Jetty/Tutorial|Tutorials]], and [[Jetty/Reference|Reference]] guides.<br />
<br />
Simply click on a tab to find the information you are interested in. The information in each tab is:<br />
<br />
<div class="wide-list"><br />
; {{JettyLink|Starting|Getting Started}}<br />
: Downloading, installing, and starting Jetty. <br />
; {{JettyLink|Feature|Feature Guides}}<br />
: Feature guides discuss different ways to use Jetty, how to use debuggers, how to use build tools and the Eclipse platform with Jetty. These documents also discuss a variety of modules that have been put into Jetty. <br />
; {{JettyLink|Tutorial|Tutorials}}<br />
: Longer examples to teach various concepts.<br />
; {{JettyLink|Howto|How Tos}}<br />
: Concise answers to specific technical questions are found in the How To documents.<br />
; {{JettyLink|Reference|References}}<br />
: Information about Jetty architecture, Jetty XML syntax, javadoc, etc. <br />
; {{JettyLink|FAQ}}<br />
: The FAQs answer general questions such as how to access the mail lists, IRC, and the blogs, discusses known bugs, and so on.<br />
; {{JettyLink|Troubleshooting}}<br />
:These documents provide help with issues you may encounter using Jetty.<br />
; {{JettyLink|Contributor|Contributing}}<br />
:These documents are geared for developers who are contributing code to the Jetty project. Topics such as Jetty coding standards, how to access Jetty source code, how to build from source, etc., are covered here.<br />
</div></div>Nicolas.marchildon.nethttps://wiki.eclipse.org/index.php?title=SWTBot/UsersGuide&diff=161486SWTBot/UsersGuide2009-06-30T20:14:00Z<p>Nicolas.marchildon.net: imports net.sf --> org.eclipse</p>
<hr />
<div>=SWTBot Users Guide=<br />
==Introduction==<br />
<br />
SWTBot is an open-source Java based functional testing tool for testing SWT and Eclipse based applications.<br />
<br />
SWTBot provides APIs that are simple to read and write. The APIs also hide the complexities involved with SWT and Eclipse. This makes it suitable for functional testing by everyone. SWTBot also provides its own set of assertions that are useful for SWT. You can also use your own assertion framework with SWTBot.<br />
<br />
SWTBot can record and playback tests and integrates with Eclipse, and also provides for ant tasks so that you can run your builds from within CruiseControl or any other CI tool that you use.<br />
<br />
SWTBot can run on all platforms that SWT runs on. Very few other testing tools provide such a wide variety of platforms.<br />
==Quick Start==<br />
===Configuration===<br />
<br />
SWTBot comes with a releng project and things generally work out of the box. The build instructions are available in the readme in the releng project.<br />
<br />
There are dependencies on org.hamcrest and com.thoughtworks. These are not checked into the SWTBot repository and nor are they in orbit yet.<br />
<br />
You can download the dependencies from https://swtbot.svn.sourceforge.net/svnroot/swtbot/branches/java-1.5-api-spike/org.eclipse.swtbot.releng/externals/plugins/ for now (and put them in .releng/externals/plugins)<br />
<br />
A patched version of the eclipse test framework is available at https://swtbot.svn.sourceforge.net/svnroot/swtbot/branches/java-1.5-api-spike/org.eclipse.swtbot.releng/test-sandbox/eclipse-test-framework-3.3.zip (you'll need to put this into .releng/externals)<br />
<br />
<br />
* Add the following to your classpath:<br />
org.eclipse.swtbot.finder<br />
org.apache.commons.collections<br />
org.apache.log4j<br />
* These are useful if you are using SWTBot to test Eclipse plugins<br />
org.eclipse.swtbot.eclipse.finder<br />
<br />
===Installation from the GIT Repository===<br />
<br />
If you expect to be making changes to the SWTBot source code then the you should consider using GIT. The SWTBot Subversion repository is mirrored to a GIT repository. Although GIT has a higher learning curve than Subversion, you will find it easier to manage your changes and it will be easier for others to pull your changes.<br />
<br />
The GIT repository is at git://github.com/ketan/swtbot.git.<br />
<br />
If you clone this repository and import the projects into Eclipse, you will find a few errors. These can be fixed as follows:<br />
<br />
org.eclipse.swtbot.eclipse.ui contains two versions of the .classpath file. These are named _classpath.eclipse_3.4 and _classpath.eclipse_3.5. Copy one of these to .classpath, depending on which version of Eclipse is being used in your runtime environment. The build errors for this plug-in should go away. There are also two versions of the build.properties file. You will need to copy one of these too if you are going to do PDE builds or create your own update site.<br />
<br />
org.eclipse.swtbot.junit4_x contains two versions each of .classpath and MANIFEST.MF in the META-INF directory. Depending on the version of JUnit you are using, copy one of _classpath.junit4_3 or _classpath.junit4_5 to .classpath and in the META-INF directory copy one of MANIFEST.MF_junit4_3 or MANIFEST.MF_junit4_5 to MANIFEST.MF. The build errors for this plug-in should go away.<br />
<br />
Note that the org.hamcrest and com.thoughtworks bundles are checked into the SWTBot GIT repository and can be found in the org.eclipse.swtbot.releng project in externals/plugins. So you don't have to fetch these separately as you would if using the Subversion repository at eclipse.org.<br />
<br />
===Building an SWTBot Update Site===<br />
<br />
If you are using SWTBot in a project with many developers, and you want those other developers to run and maintain test, and you have made modifications to SWTBot then you will want to make those modifications easily available to the other developers. The easiest way to do this is to set up an update site that contains SWTBot with your modifications.<br />
<br />
To create an update site, follow the instructions in MakingARelease.HOWTO in the org.eclipse.swtbot.releng bundle. Do not use the org.eclipse.swtbot.updatesite bundle. That is old stuff that creates an old-style update site (it predates Equinox p2). You should ensure unique versions, generally done by including your company name or project name in the version string.<br />
<br />
The build.xml file contains the script for building the update site. However you must first ensure you have all the dependencies. A separate script is provided to install the dependencies. This script requires eclipse.sdk.url and eclipse.sdk.archive properties to be set to the location and name of the Eclipse SDK archive file. The best way to be sure you have all the properties set is to copy build.developer.properties.sample to build.developer.properties and edit as appropriate.<br />
<br />
Once those are set, you can install the dependencies by running:<br />
<br />
<code>ant -file download-dependencies.xml download-dependencies</code><br />
<br />
or just run the build.xml script which will run tasks in this script if necessary.<br />
<br />
You will need 'unzip' on the command path. If you are running Windows then you can download a compatible unzip implementation from http://gnuwin32.sourceforge.net/packages/unzip.htm.<br />
<br />
===Getting started with SWTBot===<br />
<br />
SWTBot requires that tests run on a non-UI thread. If you run tests on the UI thread, they will eventually block the UI at some point in time. More info on this behavior available in the [[SWTBot/FAQ|FAQ]].<br />
<br />
===Getting started with SWTBot for SWT applications===<br />
<br />
Because SWTBot tests need to [[SWTBot/FAQ#Why_do_tests_run_on_a_non-UI_thread.3F|run in a non-UI thread]], it is essential that the application starts off in another thread. The example below uses a simple mechanism to start the tests in another thread. You could use any other mechanism to do this instead.<br />
<br />
<source lang="java"><br />
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;<br />
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;<br />
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;<br />
<br />
import org.eclipse.swt.widgets.Display;<br />
<br />
public class FooBarTest extends SWTBotTestCase {<br />
<br />
// pull this up into your own superclass that extends SWTBotTestCase and extend from your superclass instead<br />
static { <br />
startApplicationInAnotherThread();<br />
}<br />
<br />
protected void setUp() throws Exception {<br />
super.setUp();<br />
waitForDisplayToAppear(5000); // wait for the display to appear before you do anything<br />
}<br />
<br />
public void testClicksOnAButton() throws Exception {<br />
bot.button("click me").click();<br />
bot.button("you just clicked me!").click();<br />
}<br />
<br />
public void testThisFails() throws Exception {<br />
bot.button("this does not exist").click();<br />
}<br />
<br />
private void waitForDisplayToAppear(long timeOut) throws TimeoutException, InterruptedException {<br />
long endTime = System.currentTimeMillis() + timeOut;<br />
while (System.currentTimeMillis() < endTime) { // wait until timeout<br />
try {<br />
Display display = SWTUtils.display();<br />
if (display != null)<br />
return;<br />
} catch (Exception e) {<br />
// did not find a display? no problems, try again<br />
}<br />
Thread.sleep(100); // sleep for a while and try again<br />
}<br />
throw new TimeoutException("timed out");<br />
}<br />
<br />
private static void startApplicationInAnotherThread() {<br />
new Thread(new Runnable() {<br />
public void run() {<br />
new MyApplication().main(new String[] { "some", "command", "line", "arguments for your application" });<br />
}<br />
}).start();<br />
}<br />
<br />
}<br />
</source><br />
<br />
===Getting started with SWTBot for Eclipse Plugins===<br />
<br />
To use SWTBot along with your eclipse plugin application you have to add the below plugins to your dependencies.<br />
<br />
org.eclipse.swtbot.swt.finder<br />
org.eclipse.swtbot.eclipse.finder<br />
org.junit4<br />
<br />
Now you can start using SWTBot. Below you can find a sample SWTBot testcase:<br />
<br />
<source lang="java"><br />
import junit.framework.TestCase;<br />
<br />
import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;<br />
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;<br />
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;<br />
<br />
/**<br />
* <br />
* This is a sample swtbot testcase for an eclipse application.<br />
* <br />
*/<br />
public class TestSampleDialog extends TestCase {<br />
<br />
/**<br />
* In future you will not need to create this instance. <br />
* You need to extend SWTBotEclipseTestCase which holds an instance of <br />
* SWTEclipseBot.<br />
*/<br />
protected SWTEclipseBot bot = new SWTEclipseBot();<br />
<br />
/**<br />
* This testcase will create a new java project in <br />
* your workspace.<br />
*/<br />
public void testCreateJavaProject() {<br />
<br />
try {<br />
bot.view("Welcome").close() ;<br />
} catch (WidgetNotFoundException e) {<br />
fail("Welcome window not found.");<br />
}<br />
<br />
//This will open the the menu File > New > Project wizard<br />
bot.menu("File").menu("New").menu("Project...").click();<br />
bot.sleep(1000);<br />
<br />
//Select the java project from the wizard tree.<br />
SWTBotTree projectSelectionTree = bot.tree();<br />
projectSelectionTree.select("Java Project");<br />
bot.sleep(1000);<br />
<br />
//Click Next button<br />
bot.button("Next >").click();<br />
bot.sleep(1000);<br />
<br />
//'com.swtbot.test.project' is the java project name to create<br />
bot.textWithLabel("Project name:").setText("com.swtbot.test.project");<br />
bot.sleep(1000);<br />
<br />
//Click the Finish button<br />
bot.button("Finish").click();<br />
bot.sleep(1000);<br />
<br />
//Now the project is created in your workspace.<br />
}<br />
<br />
/**<br />
* This testcase will set the focus on a view.<br />
*/<br />
public void testFocusView() {<br />
try {<br />
bot.view("Welcome").close() ;<br />
} catch (WidgetNotFoundException e) {<br />
fail("Welcome window not found.");<br />
}<br />
<br />
//This will set focus on the Problems view<br />
//The view is identified using the title of the view.<br />
bot.view("Problems").setFocus();<br />
<br />
//The sleep command can be used to slow down the testcase <br />
//execution so that you can see it or you can wait for a<br />
//background process to complete.<br />
bot.sleep(2000);<br />
}<br />
}<br />
</source><br />
<br />
You can find one more SWTBot Testcase snippet below,<br />
<br />
<source lang="java"><br />
// subclassing SWTBotTestCase gives you an instance of<br />
// SWTBot that offers a lot of convinience api<br />
// this class also has a lot of assertions that are suited for ui operations<br />
public class FooTest extends SWTBotEclipseTestCase {<br />
<br />
// stuff you can do with Eclipse<br />
public void testDoSomethingInterestingWithEclipse() throws Exception {<br />
bot.view("Package Explorer").close();<br />
bot.editor("HelloWorld.java").save();<br />
bot.editor("FooBar.java").close();<br />
<br />
bot.activeEditor().typeText("public static void main ()...");<br />
bot.activeEditor().quickfix("Rename in file");<br />
<br />
// will insert "System.out.println();" in the currently open editor<br />
bot.activeEditor().autoCompleteProposal("sys", "sysout - print to standard out");<br />
}<br />
<br />
// stuff you can do with SWT<br />
public void testDoSomethingInterestingWithSWT() throws Exception {<br />
<br />
// there are two parts to SWTBot:<br />
// one to find a control (the subject)<br />
// and the action to be performed on the control (the verb)<br />
bot.shell("Address Book - Untitled").activate();<br />
bot.button("Hello World").click();<br />
bot.menu("File").menu("New").click();<br />
bot.captureScreenshot("myscreenshot.png");<br />
<br />
bot.listWithLabel("My Items").select(new String[] { "foo", "bar", "baz" });<br />
<br />
// there are a lot of assertions that are very useful<br />
assertEnabled(bot.button("Foo Bar"));<br />
assertVisible(bot.checkBox("This should not visible"));<br />
assertTextContains("I just love this!", bot.textWithLabel("Comments"));<br />
}<br />
}<br />
</source><br />
<br />
===Executing SWTBot Tests for Eclipse Plugins===<br />
<br />
Now that you've written the great test that you'd always wanted to, lets now see it run. In order to run the test, right click on the test and select Run As > Run Configurations...<br />
<br />
[[Image:run-as-option.jpg]]<br />
<br />
<br />
Create a new test under SWTBot Test. Ensure that you're using JUnit 3<br />
<br />
[[Image:run-as-config-create.jpg]]<br />
<br />
<br />
Select the application that you want to test<br />
<br />
[[Image:run-as-config-options.jpg]]<br />
<br />
[[Category:SWTBot]]</div>Nicolas.marchildon.net