本文整理汇总了Java中org.custommonkey.xmlunit.exceptions.XpathException类的典型用法代码示例。如果您正苦于以下问题:Java XpathException类的具体用法?Java XpathException怎么用?Java XpathException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XpathException类属于org.custommonkey.xmlunit.exceptions包,在下文中一共展示了XpathException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeIgnoredBranches
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
public Document removeIgnoredBranches(Document document) {
for (String branch : getIgnoredBranches()) {
XpathEngine simpleXpathEngine = XMLUnit.newXpathEngine();
NodeList nodeList;
try {
nodeList = simpleXpathEngine.getMatchingNodes(branch, document);
for (int i = 0; i < nodeList.getLength(); i++) {
Node parentNode = nodeList.item(i).getParentNode();
parentNode.removeChild(nodeList.item(i));
}
} catch (XpathException e) {
e.printStackTrace(); // FIXME : remove printStackTrace()
}
}
return document;
}
示例2: testEntityType
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void testEntityType() throws XpathException, IOException, SAXException {
EdmEntityType.Builder productBuilder = EdmEntityType.newBuilder();
productBuilder = productBuilder.setName("Product").setOpenType(OPENTYPE_TRUE).addKeys("ProductId");
EdmSchema.Builder schema = EdmSchema.newBuilder().setNamespace(SCHEMA);
schema.addEntityTypes(productBuilder);
EdmDataServices.Builder serviceBuilder = EdmDataServices.newBuilder().addSchemas(schema);
EdmDataServices edmService = serviceBuilder.build();
StringWriter writer = new StringWriter();
EdmxFormatWriter.write(edmService, writer);
String xml2 = writer.toString();
assertThat(xml2, containsString("<EntityType OpenType=\"true\" Name=\"Product\">"));
Document inDocument = XMLUnit.buildControlDocument(xml2);
assertXpathExists("//edm:Schema/edm:EntityType/@OpenType", xml2);
}
示例3: testContainer
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void testContainer() throws XpathException, IOException, SAXException {
EdmEntityContainer.Builder entityContainer2 = EdmEntityContainer.newBuilder()
.setName("Container2")
.setExtendz("Container")
.setLazyLoadingEnabled(true);
schema.addEntityContainers(container, entityContainer2);
EdmDataServices.Builder builder = EdmDataServices.newBuilder().addSchemas(schema);
EdmDataServices edmService = builder.build();
StringWriter writer = new StringWriter();
EdmxFormatWriter.write(edmService, writer);
String xml = writer.toString();
assertThat(xml, containsString("Extends=\"Container\""));
assertThat(xml, containsString("LazyLoadingEnabled=\"true\""));
assertXpathExists("//edm:Schema/edm:EntityContainer/@Extends", xml);
assertXpathExists("//edm:Schema/edm:EntityContainer/@annotation:LazyLoadingEnabled", xml);
}
示例4: testForAnnotation
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void testForAnnotation() throws XpathException, IOException, SAXException {
String xml = createXML();
assertXpathExists("//edm:EntityType/edm:Property/myns:mySubproperty", xml);
assertXpathExists("//edm:EntityType/edm:NavigationProperty/myns:MyNavigation", xml);
assertXpathExists("//edm:EntityType/mynamespace:MyEntityTypeProperty/mynamespace:MySubProperty", xml);
assertXpathExists("//edm:ComplexType/myns:MyComplexTypeProperty", xml);
assertXpathExists("//edm:Association/mynamespace:MyAssociation", xml);
assertXpathExists("//edm:Association/edm:End/myns:MyAssociationEnd", xml);
assertXpathExists("//edm:EntityContainer/myns:MyEntitySet", xml);
assertXpathExists("//edm:EntityContainer/edm:EntitySet/myns:MySubSet", xml);
assertXpathExists("//edm:EntityContainer/edm:AssociationSet/mynamespace:MyAssociationSet", xml);
assertXpathExists("//edm:EntityContainer/edm:AssociationSet/edm:End/myns:MyEndElement", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport/myns:MyFunctionImport", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport/edm:Parameter/myns:MyAnnotation", xml);
assertXpathExists("//edm:Schema/myns:MyContainer", xml);
assertXpathExists("//edm:Schema/mynamespace:AnnotElement/mynamespace:testing", xml);
assertXpathExists("//edm:Schema/mynamespace:AnnotElement/mynamespace:another", xml);
assertXpathExists("//edm:Schema/mynamespace:AnnotElement/mynamespace:another/mynamespace:yetanother", xml);
assertXpathExists("//edm:Schema/mynamespace:AnnotElement/mynamespace:another/@mynamespace:foo", xml);
}
示例5: testFunctionImports
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void testFunctionImports() throws XpathException, IOException, SAXException {
String xml = createXML();
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='ProductSearch' and @m:HttpMethod='GET']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='ProductSearch' and not(@IsBindable)]", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='ProductSearch' and not(@IsSideEffecting)]", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='ProductSearch' and not(@m:IsAlwaysBindable)]", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='PerformAction' and @IsBindable='true']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='PerformAction' and @IsSideEffecting='true']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='PerformAction' and @m:IsAlwaysBindable='false']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='PerformAction' and not(@m:HttpMethod)]", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='CalculateStuff' and @IsBindable='true']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='CalculateStuff' and @IsSideEffecting='false']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='CalculateStuff' and @m:IsAlwaysBindable='false']", xml);
assertXpathExists("//edm:EntityContainer/edm:FunctionImport[@Name='CalculateStuff' and not(@m:HttpMethod)]", xml);
}
示例6: testMethodNotFound
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void testMethodNotFound() throws XpathException, IOException, SAXException {
for (FormatType format : ServiceOperationsTest.formats) {
String uri = endpointUri + "MethodNotAllowed" + "?" + this.formatQuery(format);
ResponseData responseData;
responseData = this.rtFacade.putWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
responseData = this.rtFacade.deleteWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
responseData = this.rtFacade.postWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
responseData = this.rtFacade.getWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
responseData = this.rtFacade.patchWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
responseData = this.rtFacade.mergeWebResource(uri, null, null, null);
assertEquals(format.toString(), 404, responseData.getStatusCode());
}
}
示例7: validateXmlServiceDocument
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
private void validateXmlServiceDocument(final String payload) throws IOException, SAXException, XpathException {
assertXpathExists("/app:service", payload);
assertXpathExists("/app:service/app:workspace", payload);
assertXpathExists("/app:service/app:workspace/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Employees\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Employees\"]/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Teams\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Teams\"]/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Rooms\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Rooms\"]/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Managers\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Managers\"]/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Buildings\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Buildings\"]/atom:title", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Photos\"]", payload);
assertXpathExists("/app:service/app:workspace/app:collection[@href=\"Photos\"]/atom:title", payload);
}
示例8: verifySingleProperties
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
private void verifySingleProperties(final String xmlString, final boolean employeeName, final boolean age,
final boolean entryDate, final boolean imageUrl) throws IOException, SAXException, XpathException {
if (employeeName) {
assertXpathExists("/a:entry/m:properties/d:EmployeeName", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:EmployeeName", xmlString);
}
if (age) {
assertXpathExists("/a:entry/m:properties/d:Age", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:Age", xmlString);
}
if (entryDate) {
assertXpathExists("/a:entry/m:properties/d:EntryDate", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:EntryDate", xmlString);
}
if (imageUrl) {
assertXpathExists("/a:entry/m:properties/d:ImageUrl", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:ImageUrl", xmlString);
}
}
示例9: verifyKeyProperties
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
private void verifyKeyProperties(final String xmlString, final boolean employeeId, final boolean managerId,
final boolean roomId, final boolean teamId) throws IOException, SAXException, XpathException {
if (employeeId) {
assertXpathExists("/a:entry/m:properties/d:EmployeeId", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:EmployeeId", xmlString);
}
if (managerId) {
assertXpathExists("/a:entry/m:properties/d:ManagerId", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:ManagerId", xmlString);
}
if (roomId) {
assertXpathExists("/a:entry/m:properties/d:RoomId", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:RoomId", xmlString);
}
if (teamId) {
assertXpathExists("/a:entry/m:properties/d:TeamId", xmlString);
} else {
assertXpathNotExists("/a:entry/m:properties/d:TeamId", xmlString);
}
}
示例10: verifyNavigationProperties
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
private void verifyNavigationProperties(final String xmlString, final boolean neManager, final boolean neRoom,
final boolean neTeam) throws IOException, SAXException, XpathException {
if (neManager) {
assertXpathExists("/a:entry/a:link[@href=\"Employees('1')/ne_Manager\" and @title='ne_Manager']", xmlString);
} else {
assertXpathNotExists("/a:entry/a:link[@href=\"Employees('1')/ne_Manager\" and @title='ne_Manager']", xmlString);
}
if (neRoom) {
assertXpathExists("/a:entry/a:link[@href=\"Employees('1')/ne_Room\" and @title='ne_Room']", xmlString);
} else {
assertXpathNotExists("/a:entry/a:link[@href=\"Employees('1')/ne_Room\" and @title='ne_Room']", xmlString);
}
if (neTeam) {
assertXpathExists("/a:entry/a:link[@href=\"Employees('1')/ne_Team\" and @title='ne_Team']", xmlString);
} else {
assertXpathNotExists("/a:entry/a:link[@href=\"Employees('1')/ne_Team\" and @title='ne_Team']", xmlString);
}
}
示例11: verifyEmployees
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
private void verifyEmployees(final String path, final String xmlString) throws XpathException, IOException,
SAXException {
assertXpathExists(path, xmlString);
assertXpathExists(path + "/m:inline", xmlString);
assertXpathExists(path + "/m:inline/a:feed[@xml:base='" + BASE_URI + "']", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:id", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:title", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:updated", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:category", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:link", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/a:content", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/m:properties", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/m:properties/d:EmployeeId", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/m:properties/d:EmployeeName", xmlString);
assertXpathExists(path + "/m:inline/a:feed/a:entry/m:properties/d:RoomId", xmlString);
assertXpathExists("/a:entry/a:content/m:properties/d:Id", xmlString);
assertXpathExists("/a:entry/a:content/m:properties/d:Name", xmlString);
assertXpathExists("/a:entry/a:content/m:properties/d:Seats", xmlString);
}
示例12: serializeEmployeeWithNullSyndicationTitleProperty
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
/**
* Test serialization of empty syndication title property. EmployeeName is set to NULL after the update (which is
* allowed because EmployeeName has default Nullable behavior which is true).
* Write of an empty atom title tag is allowed within RFC4287 (http://tools.ietf.org/html/rfc4287#section-4.2.14).
*/
@Test
public void serializeEmployeeWithNullSyndicationTitleProperty() throws IOException, XpathException, SAXException,
XMLStreamException, FactoryConfigurationError, ODataException {
AtomEntityProvider ser = createAtomEntityProvider();
EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
employeeData.put("EmployeeName", null);
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"), employeeData,
properties);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry/a:title", xmlString);
assertXpathEvaluatesTo("", "/a:entry/a:title", xmlString);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
assertXpathEvaluatesTo("Employees('1')/$value", "/a:entry/a:content/@src", xmlString);
assertXpathExists("/a:entry/m:properties", xmlString);
}
示例13: serializeEmployeeAndCheckOrderOfPropertyTags
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void serializeEmployeeAndCheckOrderOfPropertyTags() throws IOException, XpathException, SAXException,
XMLStreamException, FactoryConfigurationError, ODataException {
AtomEntityProvider ser = createAtomEntityProvider();
EntityProviderWriteProperties properties =
EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
EdmEntitySet employeeEntitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
ODataResponse response = ser.writeEntry(employeeEntitySet, employeeData, properties);
String xmlString = verifyResponse(response);
// log.debug(xmlString);
assertXpathExists("/a:entry", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
// verify properties
assertXpathExists("/a:entry/m:properties", xmlString);
assertXpathEvaluatesTo("9", "count(/a:entry/m:properties/*)", xmlString);
// verify order of tags
List<String> expectedPropertyNamesFromEdm = employeeEntitySet.getEntityType().getPropertyNames();
verifyTagOrdering(xmlString, expectedPropertyNamesFromEdm.toArray(new String[0]));
}
示例14: serializeAtomEntry
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void serializeAtomEntry() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
final EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"), roomData, properties);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:content", xmlString);
assertXpathEvaluatesTo(ContentType.APPLICATION_XML.toString(), "/a:entry/a:content/@type", xmlString);
assertXpathExists("/a:entry/a:content/m:properties", xmlString);
}
示例15: serializeWithValueEncoding
import org.custommonkey.xmlunit.exceptions.XpathException; //导入依赖的package包/类
@Test
public void serializeWithValueEncoding() throws IOException, XpathException, SAXException, XMLStreamException,
FactoryConfigurationError, ODataException {
photoData.put("Type", "< Ö >");
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response =
ser.writeEntry(MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"), photoData,
DEFAULT_PROPERTIES);
String xmlString = verifyResponse(response);
assertXpathExists("/a:entry", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString(), "/a:entry/@xml:base", xmlString);
assertXpathExists("/a:entry/a:id", xmlString);
assertXpathEvaluatesTo(BASE_URI.toASCIIString() + "Container2.Photos(Id=1,Type='%3C%20%C3%96%20%3E')",
"/a:entry/a:id/text()", xmlString);
assertXpathEvaluatesTo("Container2.Photos(Id=1,Type='%3C%20%C3%96%20%3E')", "/a:entry/a:link/@href", xmlString);
}