/** * Tests test() with configuration that should NOT be correct. Expects a RuntimeException to be * thrown. */ @Test public void testTestFail() { final String testPropertyName = "testsuite." + TEST_NAME + "." + PROPERTY_NAME_INVALID_CONFIG; // run test only in case operation is supported if (ConnectorHelper.operationsSupported(getConnectorFacade(), getAPIOperations())) { // READ THE TEST PROPERTY WITH WRONG CONFIGURATIONS THAT OVERRIDE THE DEFAULT CONFIGURATION Object o = null; try { o = getDataProvider().getTestSuiteAttribute(PROPERTY_NAME_INVALID_CONFIG, TEST_NAME); } catch (ObjectNotFoundException ex) { fail(String.format("Missing test property: '%s'", testPropertyName)); } if (!(o instanceof List<?>)) { fail(String.format("Test property '%s' should be of type List", testPropertyName)); } final List<?> wrongConfigList = (List<?>) o; for (Object currentWrongConfigMap : wrongConfigList) { if (!(currentWrongConfigMap instanceof Map<?, ?>)) { fail( String.format( "Test property '%s' contains other than Map properties.", testPropertyName)); } Map<?, ?> currentWrongMapConfig = (Map<?, ?>) currentWrongConfigMap; _connFacade = ConnectorHelper.createConnectorFacadeWithWrongConfiguration( getDataProvider(), currentWrongMapConfig); try { // should throw RuntimeException getConnectorFacade().test(); String msg = String.format( "test() should throw RuntimeException because configuration should be invalid. Wrong properties used: \n%s", currentWrongMapConfig.toString()); fail(msg); } catch (RuntimeException ex) { // expected } } } else { LOG.info("--------------------------------"); LOG.info("Skipping test ''testTestFail''."); LOG.info("--------------------------------"); } }