Search in sources :

Example 1 with BindException

use of com.hazelcast.simulator.utils.BindException in project hazelcast-simulator by hazelcast.

the class TestSuite method load.

@SuppressFBWarnings("DM_DEFAULT_ENCODING")
private void load(String testContent) {
    Properties properties = new Properties();
    try {
        properties.load(new StringReader(testContent));
    } catch (UnsupportedEncodingException e) {
        throw rethrow(e);
    } catch (IOException e) {
        throw rethrow(e);
    }
    Map<String, TestCase> testCases = createTestCases(properties);
    if (testCases.isEmpty()) {
        throw new BindException("No tests are defined.");
    }
    if (testCases.size() == 1) {
        // use classname instead of empty desc in single test scenarios
        TestCase testCase = testCases.values().iterator().next();
        String className = testCase.getClassname();
        if (testCase.getId().isEmpty() && className != null) {
            String desc = className.substring(className.lastIndexOf('.') + 1);
            testCases = singletonMap(desc, new TestCase(desc, testCase.getProperties()));
        }
    }
    for (String testCaseId : getTestCaseIds(testCases)) {
        TestCase testCase = testCases.get(testCaseId);
        if (testCase.getClassname() == null) {
            String msg;
            if (testCaseId.isEmpty()) {
                msg = "There is no class set. Add class=YourTestClass";
            } else {
                msg = format("There is no class set for test [%s]. Add %s.class=YourTestClass", testCaseId, testCaseId);
            }
            throw new BindException(msg);
        }
        addTest(testCase);
    }
}
Also used : TestCase(com.hazelcast.simulator.common.TestCase) StringReader(java.io.StringReader) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BindException(com.hazelcast.simulator.utils.BindException) IOException(java.io.IOException) Properties(java.util.Properties) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

TestCase (com.hazelcast.simulator.common.TestCase)1 BindException (com.hazelcast.simulator.utils.BindException)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Properties (java.util.Properties)1