org.ehcache.xml.exceptions.XmlConfigurationException.getCause()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.ehcache.xml.exceptions.XmlConfigurationException.getCause()方法的一些代码示例,展示了XmlConfigurationException.getCause()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlConfigurationException.getCause()方法的具体详情如下:
包路径:org.ehcache.xml.exceptions.XmlConfigurationException
类名称:XmlConfigurationException
方法名:getCause

XmlConfigurationException.getCause介绍

暂无

代码示例

代码示例来源:origin: ehcache/ehcache3

@Test
 public void testFailsWithInvalidClusterUri() {
  try {
   new XmlConfiguration(getClass().getResource("/configs/cluster-invalid-uri.xml"));
  } catch (XmlConfigurationException e) {
   assertThat(e.getCause().getMessage(), containsString("not facet-valid with respect to pattern"));
  }
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testInvalidServiceConfiguration() throws Exception {
 try {
  new XmlConfiguration(XmlConfigurationTest.class.getResource("/configs/invalid-service.xml"));
  fail();
 } catch (XmlConfigurationException xce) {
  SAXParseException e = (SAXParseException) xce.getCause();
  assertThat(e.getLineNumber(), is(6));
  assertThat(e.getColumnNumber(), is(15));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testInvalidCoreConfiguration() throws Exception {
 try {
  new XmlConfiguration(XmlConfigurationTest.class.getResource("/configs/invalid-core.xml"));
  fail();
 } catch (XmlConfigurationException xce) {
  SAXParseException e = (SAXParseException) xce.getCause();
  assertThat(e.getLineNumber(), is(5));
  assertThat(e.getColumnNumber(), is(29));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testGetUnknownCacheInvalidElement() {
 try {
  new XmlConfiguration(this.getClass().getResource("/configs/unknown-cluster-cache-invalid-element.xml"));
  fail("Expected XmlConfigurationException");
 } catch(XmlConfigurationException xce) {
  Assert.assertThat(xce.getCause().getMessage(), endsWith("Element 'tc:clustered' must have no character or element information item [children], because the type's content type is empty."));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testGetUnknownCacheInvalidAttribute() {
 try {
  new XmlConfiguration(this.getClass().getResource("/configs/unknown-cluster-cache-invalid-attribute.xml"));
  fail("Expected XmlConfigurationException");
 } catch(XmlConfigurationException xce) {
  Assert.assertThat(xce.getCause().getMessage(), endsWith("Attribute 'unit' is not allowed to appear in element 'tc:clustered'."));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testNonExistentAdvisorClassInCacheThrowsException() throws Exception {
 try {
  new XmlConfiguration(XmlConfigurationTest.class.getResource("/configs/nonExistentAdvisor-cache.xml"));
  fail();
 } catch (XmlConfigurationException xce) {
  assertThat(xce.getCause(), instanceOf(ClassNotFoundException.class));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testNonExistentAdvisorClassInTemplateThrowsException() throws Exception {
 try {
  new XmlConfiguration(XmlConfigurationTest.class.getResource("/configs/nonExistentAdvisor-template.xml"));
  fail();
 } catch (XmlConfigurationException xce) {
  assertThat(xce.getCause(), instanceOf(ClassNotFoundException.class));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testGetTimeoutUnitBad() throws Exception {
 final String[] config = new String[]
  {
   "<ehcache:config",
   "    xmlns:ehcache=\"http://www.ehcache.org/v3\"",
   "    xmlns:tc=\"http://www.ehcache.org/v3/clustered\">",
   "",
   "  <ehcache:service>",
   "    <tc:cluster>",
   "      <tc:connection url=\"terracotta://example.com:9540/cachemanager\"/>",
   "      <tc:read-timeout unit=\"femtos\">5</tc:read-timeout>",
   "    </tc:cluster>",
   "  </ehcache:service>",
   "",
   "</ehcache:config>"
  };
 try {
  new XmlConfiguration(makeConfig(config));
  fail("Expecting XmlConfigurationException");
 } catch (XmlConfigurationException e) {
  assertThat(e.getMessage(), containsString("Error parsing XML configuration "));
  assertThat(e.getCause().getMessage(), containsString("Value 'femtos' is not facet-valid with respect to enumeration "));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testGetTimeoutValueOmitted() throws Exception {
 final String[] config = new String[]
  {
   "<ehcache:config",
   "    xmlns:ehcache=\"http://www.ehcache.org/v3\"",
   "    xmlns:tc=\"http://www.ehcache.org/v3/clustered\">",
   "",
   "  <ehcache:service>",
   "    <tc:cluster>",
   "      <tc:connection url=\"terracotta://example.com:9540/cachemanager\"/>",
   "      <tc:read-timeout unit=\"seconds\"></tc:read-timeout>",
   "    </tc:cluster>",
   "  </ehcache:service>",
   "",
   "</ehcache:config>"
  };
 try {
  new XmlConfiguration(makeConfig(config));
  fail("Expecting XmlConfigurationException");
 } catch (XmlConfigurationException e) {
  assertThat(e.getMessage(), containsString("Error parsing XML configuration "));
  assertThat(e.getCause().getMessage(), containsString("'' is not a valid value for 'integer'"));
 }
}

相关文章