Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 411822e66f9889af8ad2ee51a0dd315a005b5c73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 *  Copyright (c) 2009 Cloudsmith 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:
 *      Cloudsmith - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.tests.testserver.helper;

import junit.framework.TestCase;

/**
 * Testsuite that manages the start and stop of the testserver for a suite of tests.
 * 
 * A derived class should implement the following:<br/><br/>
 * <code>
 *	public static Test suite() throws Exception { <br/>
 *		&nbsp;&nbsp;&nbsp;&nbsp;final TestSuite suite = new TestSuite("...name of suite..."); <br/>
 *		&nbsp;&nbsp;&nbsp;&nbsp;suite.addTest(new AbstractTestServerSuite("startServer"));<br/>
 * <br/>
 *		&nbsp;&nbsp;&nbsp;&nbsp;// Add tests in the suite - here is an example:<br/>
 *		&nbsp;&nbsp;&nbsp;&nbsp;suite.addTestSuite(ExampleTest.class);<br/>
 * <br/>
 *		&nbsp;&nbsp;&nbsp;&nbsp;suite.addTest(new AbstractTestServerSuite("startServer"));<br/>
 *      &nbsp;&nbsp;&nbsp;&nbsp;return suite;<br/>
 *  }<br/>
 * </code>
 * The tests in the suite should call {@link TestServerController} to make sure the server is
 * running either started by this suite, or directly when test is run individually. This is
 * handled by the class {@link AbstractTestServerClientCase} which serves as the base for
 * tests requiring access to a running server.
 */
public class AbstractTestServerSuite extends TestCase {

	// TEMPLATE CODE: do not remove - it is useful to copy this when creating a new class.
	//	public static Test suite() throws Exception {
	//		final TestSuite suite = new TestSuite("AllServerBasedTestSuite");
	//		addToSuite(suite);
	//		return suite;
	//	}
	//
	//	public static void addToSuite(TestSuite suite) {
	//		suite.addTest(new AbstractTestServerSuite("startServer"));
	//		// AuthTest *should* run twice to make sure that second attempt produces the same result.
	//		suite.addTestSuite(AuthTest.class);
	//		suite.addTestSuite(AuthTest.class);
	//		suite.addTestSuite(HttpStatusTest.class);
	//		suite.addTestSuite(TimeoutTest.class);
	//		suite.addTest(new AbstractTestServerSuite("stopServer"));
	//	}

	public void startServer() throws Exception {
		TestServerController.oneTimeSetUp();
	}

	public void stopServer() throws Exception {
		TestServerController.oneTimeTearDown();
	}

	public AbstractTestServerSuite(String testName) {
		super(testName);
	}

}

Back to the top