Search in sources :

Example 6 with Assertion

use of org.junit.contrib.java.lang.system.Assertion in project YCSB by brianfrankcooper.

the class IntegrationTest method testReadOpsBenchmarkFailure.

//All read operations during benchmark are executed with an HTTP 500 error.
@Test
public void testReadOpsBenchmarkFailure() throws InterruptedException {
    exit.expectSystemExit();
    exit.checkAssertionAfterwards(new Assertion() {

        @Override
        public void checkAssertion() throws Exception {
            List<String> results = Utils.read(RESULTS_FILEPATH);
            assertEquals(true, results.contains("[READ], Return=ERROR, 1"));
            Utils.delete(RESULTS_FILEPATH);
        }
    });
    Client.main(getArgs(ERROR_TRACE_FILEPATH, 1, 0, 0, 0));
}
Also used : Assertion(org.junit.contrib.java.lang.system.Assertion) List(java.util.List) LifecycleException(org.apache.catalina.LifecycleException) ServletException(javax.servlet.ServletException) DBException(com.yahoo.ycsb.DBException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 7 with Assertion

use of org.junit.contrib.java.lang.system.Assertion in project YCSB by brianfrankcooper.

the class IntegrationTest method testUpdateOpsBenchmarkSuccess.

//All update operations during benchmark are executed successfully with an HTTP OK status.
@Test
public void testUpdateOpsBenchmarkSuccess() throws InterruptedException {
    exit.expectSystemExit();
    exit.checkAssertionAfterwards(new Assertion() {

        @Override
        public void checkAssertion() throws Exception {
            List<String> results = Utils.read(RESULTS_FILEPATH);
            assertEquals(true, results.contains("[UPDATE], Return=OK, 1"));
            Utils.delete(RESULTS_FILEPATH);
        }
    });
    Client.main(getArgs(TRACE_FILEPATH, 0, 0, 1, 0));
}
Also used : Assertion(org.junit.contrib.java.lang.system.Assertion) List(java.util.List) LifecycleException(org.apache.catalina.LifecycleException) ServletException(javax.servlet.ServletException) DBException(com.yahoo.ycsb.DBException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 8 with Assertion

use of org.junit.contrib.java.lang.system.Assertion in project YCSB by brianfrankcooper.

the class IntegrationTest method testInsertOpsBenchmarkSuccess.

//All insert operations during benchmark are executed successfully with an HTTP OK status.
@Test
public void testInsertOpsBenchmarkSuccess() throws InterruptedException {
    exit.expectSystemExit();
    exit.checkAssertionAfterwards(new Assertion() {

        @Override
        public void checkAssertion() throws Exception {
            List<String> results = Utils.read(RESULTS_FILEPATH);
            assertEquals(true, results.contains("[INSERT], Return=OK, 1"));
            Utils.delete(RESULTS_FILEPATH);
        }
    });
    Client.main(getArgs(TRACE_FILEPATH, 0, 1, 0, 0));
}
Also used : Assertion(org.junit.contrib.java.lang.system.Assertion) List(java.util.List) LifecycleException(org.apache.catalina.LifecycleException) ServletException(javax.servlet.ServletException) DBException(com.yahoo.ycsb.DBException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 9 with Assertion

use of org.junit.contrib.java.lang.system.Assertion in project checkstyle by checkstyle.

the class MainTest method testExistingDirectoryWithViolations.

@Test
public void testExistingDirectoryWithViolations() throws Exception {
    // we just reference there all violations
    final String[][] outputValues = { { "InputComplexityOverflow", "1", "172" } };
    final int allowedLength = 170;
    final String msgKey = "maxLen.file";
    final String bundle = "com.puppycrawl.tools.checkstyle.checks.sizes.messages";
    exit.checkAssertionAfterwards(new Assertion() {

        @Override
        public void checkAssertion() throws IOException {
            final String expectedPath = getFilePath("checks/metrics") + File.separator;
            final StringBuilder sb = new StringBuilder();
            sb.append("Starting audit...").append(System.getProperty("line.separator"));
            final String format = "[WARN] %s.java:%s: %s [FileLength]";
            for (String[] outputValue : outputValues) {
                final String localizedMessage = new LocalizedMessage(0, bundle, msgKey, new Integer[] { Integer.valueOf(outputValue[2]), allowedLength }, null, getClass(), null).getMessage();
                final String line = String.format(Locale.ROOT, format, expectedPath + outputValue[0], outputValue[1], localizedMessage);
                sb.append(line).append(System.getProperty("line.separator"));
            }
            sb.append("Audit done.").append(System.getProperty("line.separator"));
            assertEquals(sb.toString(), systemOut.getLog());
            assertEquals("", systemErr.getLog());
        }
    });
    Main.main("-c", getPath("config-filelength.xml"), getPath("checks/metrics"));
}
Also used : Assertion(org.junit.contrib.java.lang.system.Assertion) IOException(java.io.IOException) LocalizedMessage(com.puppycrawl.tools.checkstyle.api.LocalizedMessage) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)9 Test (org.junit.Test)9 Assertion (org.junit.contrib.java.lang.system.Assertion)9 DBException (com.yahoo.ycsb.DBException)8 FileNotFoundException (java.io.FileNotFoundException)8 List (java.util.List)8 ServletException (javax.servlet.ServletException)8 LifecycleException (org.apache.catalina.LifecycleException)8 LocalizedMessage (com.puppycrawl.tools.checkstyle.api.LocalizedMessage)1