@Test
public void serializeETagEncoding() throws IOException, XpathException, SAXException, XMLStreamException, FactoryConfigurationError, ODataException {
Edm edm = MockFacade.getMockEdm();
EdmTyped roomIdProperty = edm.getEntityType("RefScenario", "Room").getProperty("Id");
EdmFacets facets = mock(EdmFacets.class);
when(facets.getConcurrencyMode()).thenReturn(EdmConcurrencyMode.Fixed);
when(facets.getMaxLength()).thenReturn(3);
when(((EdmProperty) roomIdProperty).getFacets()).thenReturn(facets);
roomData.put("Id", "<\">");
AtomEntityProvider ser = createAtomEntityProvider();
ODataResponse response = ser.writeEntry(edm.getDefaultEntityContainer().getEntitySet("Rooms"), roomData, DEFAULT_PROPERTIES);
assertNotNull(response);
assertNotNull(response.getEntity());
assertEquals(ContentType.APPLICATION_ATOM_XML_ENTRY_CS_UTF_8.toContentTypeString(), response.getContentHeader());
assertEquals("W/\"<\">.3\"", response.getETag());
String xmlString = StringHelper.inputStreamToString((InputStream) response.getEntity());
assertXpathExists("/a:entry", xmlString);
assertXpathExists("/a:entry/@m:etag", xmlString);
assertXpathEvaluatesTo("W/\"<\">.3\"", "/a:entry/@m:etag", xmlString);
}
AtomEntryProducerTest.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:cloud-odata-java
作者:
评论列表
文章目录