### Question:
WSDL11Validator extends AbstractDefinitionValidator { public boolean isValid() throws ToolException { String schemaDir = getSchemaDir(); SchemaValidator schemaValidator = null; String[] schemas = (String[])env.get(ToolConstants.CFG_SCHEMA_URL); String wsdl = (String)env.get(ToolConstants.CFG_WSDLURL); Document doc = getWSDLDoc(wsdl); if (doc == null) { return true; } if (this.def == null) { try { this.def = getBus().getExtension(WSDLManager.class).getDefinition(wsdl); } catch (WSDLException e) { throw new ToolException(e); } } WSDLRefValidator wsdlRefValidator = new WSDLRefValidator(this.def, doc, getBus()); wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS)); validators.add(wsdlRefValidator); if (env.fullValidateWSDL()) { validators.add(new UniqueBodyPartsValidator(this.def)); validators.add(new WSIBPValidator(this.def)); validators.add(new MIMEBindingValidator(this.def)); } boolean notValid = false; for (AbstractValidator validator : validators) { if (!validator.isValid()) { notValid = true; addErrorMessage(validator.getErrorMessage()); } } if (notValid) { throw new ToolException(this.getErrorMessage()); } if (!env.fullValidateWSDL()) { return true; } if (!StringUtils.isEmpty(schemaDir)) { schemaValidator = new SchemaValidator(schemaDir, wsdl, schemas); } else { try { schemaValidator = new SchemaValidator(getDefaultSchemas(), wsdl, schemas); } catch (IOException e) { throw new ToolException("Schemas can not be loaded before validating wsdl", e); } } if (!schemaValidator.isValid()) { this.addErrorMessage(schemaValidator.getErrorMessage()); throw new ToolException(this.getErrorMessage()); } return true; } WSDL11Validator(final Definition definition);  WSDL11Validator(final Definition definition, final ToolContext pe);  WSDL11Validator(final Definition definition, final ToolContext pe, final Bus b); boolean isValid(); String getSchemaDir();  }### Answer:
@Test public void testWSDLImport() throws Exception { String wsdlSource = getClass().getResource("resources/a.wsdl").toURI().toString(); context.put(ToolConstants.CFG_WSDLURL, wsdlSource); WSDL11Validator validator = new WSDL11Validator(null, context); try { validator.isValid(); fail(); } catch (Exception e) { final String error = "Caused by {http: + "[portType:GreeterA][operation:sayHi] not exist."; assertTrue(e.getMessage(), e.getMessage().contains(error)); assertTrue(validator.getErrorMessage(), validator.getErrorMessage().contains(error)); } }
@Test public void testWSDLImport() throws Exception { String wsdlSource = getClass().getResource("resources/a.wsdl").toURI().toString(); context.put(ToolConstants.CFG_WSDLURL, wsdlSource); WSDL11Validator validator = new WSDL11Validator(null, context); try { assertFalse(validator.isValid()); } catch (Exception e) { assertTrue(e.getMessage(), e.getMessage() .indexOf("Caused by {http: + "[portType:GreeterA][operation:sayHi] not exist.") != -1); } }