Search in sources :

Example 6 with TestSetup

use of junit.extensions.TestSetup in project gradle by gradle.

the class SomeSuite method suite.

public static Test suite() {
    final TestSuite suite = new TestSuite();
    suite.addTestSuite(SomeTest1.class);
    suite.addTestSuite(SomeTest2.class);
    TestSetup wrappedSuite = new junit.extensions.TestSetup(suite) {

        protected void setUp() {
            System.out.println("stdout in TestSetup#setup");
            System.err.println("stderr in TestSetup#setup");
        }

        protected void tearDown() {
            System.out.println("stdout in TestSetup#teardown");
            System.err.println("stderr in TestSetup#teardown");
        }
    };
    return wrappedSuite;
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite)

Example 7 with TestSetup

use of junit.extensions.TestSetup in project jmeter by apache.

the class TestHTTPSamplersAgainstHttpMirrorServer method suite.

// This is used to emulate @before class and @after class
public static Test suite() {
    final TestSuite testSuite = new TestSuite(TestHTTPSamplersAgainstHttpMirrorServer.class);
    // Add parameterised tests. For simplicity we assume each has cases 0-10
    for (int i = 0; i < 11; i++) {
        testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters", i));
        testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testGetRequest_Parameters3", i));
        testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded", i));
        testSuite.addTest(new TestHTTPSamplersAgainstHttpMirrorServer("itemised_testPostRequest_UrlEncoded3", i));
    }
    TestSetup setup = new TestSetup(testSuite) {

        private HttpMirrorServer httpServer;

        @Override
        protected void setUp() throws Exception {
            httpServer = TestHTTPMirrorThread.startHttpMirror(MIRROR_PORT);
            // Create the test file content
            TEST_FILE_CONTENT = "some foo content &?=01234+56789-|⪡♪œ₡ĕͤÅ⁒쎅%C3%85".getBytes("UTF-8");
            // create a temporary file to make sure we always have a file to give to the PostWriter 
            // Whereever we are or Whatever the current path is.
            temporaryFile = File.createTempFile("TestHTTPSamplersAgainstHttpMirrorServer", "tmp");
            OutputStream output = new FileOutputStream(temporaryFile);
            output.write(TEST_FILE_CONTENT);
            output.flush();
            output.close();
        }

        @Override
        protected void tearDown() throws Exception {
            // Shutdown mirror server
            httpServer.stopServer();
            httpServer = null;
            // delete temporay file
            if (!temporaryFile.delete()) {
                Assert.fail("Could not delete file:" + temporaryFile.getAbsolutePath());
            }
        }
    };
    return setup;
}
Also used : TestSetup(junit.extensions.TestSetup) TestSuite(junit.framework.TestSuite) HttpMirrorServer(org.apache.jmeter.protocol.http.control.HttpMirrorServer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream)

Aggregations

TestSetup (junit.extensions.TestSetup)7 TestSuite (junit.framework.TestSuite)5 TestResult (junit.framework.TestResult)3 TestCase (junit.framework.TestCase)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 WasRun (junit.tests.WasRun)1 Configuration (org.apache.hadoop.conf.Configuration)1 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)1 HttpMirrorServer (org.apache.jmeter.protocol.http.control.HttpMirrorServer)1