• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NamespaceContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.custommonkey.xmlunit.NamespaceContext的典型用法代码示例。如果您正苦于以下问题:Java NamespaceContext类的具体用法?Java NamespaceContext怎么用?Java NamespaceContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamespaceContext类属于org.custommonkey.xmlunit包,在下文中一共展示了NamespaceContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis();


    Map<String,String> m = new HashMap<String,String>();
    m.put("sv", "http://www.jcp.org/jcr/sv/1.0");

    NamespaceContext ctx = new SimpleNamespaceContext(m);
    XMLUnit.setXpathNamespaceContext(ctx);


    final NameValuePairList props = new NameValuePairList();
    props.add("a", "");
    props.add("jcr:mixinTypes", "mix:referenceable");

    firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
    firstUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
    firstPath = getPath(firstCreatedNodeUrl);

    secondCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
    secondUuid = getProperty(secondCreatedNodeUrl, "jcr:uuid");
    secondPath = getPath(secondCreatedNodeUrl);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:26,代码来源:ReferenceTypeHintTest.java


示例2: testLoanRequestAccepted

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestAccepted() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String port = System.getProperty("org.switchyard.component.soap.standalone.port", "8181/cxf");
        String response = httpMixIn.postString("http://localhost:" + port + "/loanService/loanService", SOAP_REQUEST_1);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:accept", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("yes")) {
            fail("Expecting 'yes'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:27,代码来源:BpelServiceLoanApprovalQuickstartTest.java


示例3: testLoanRequestUnableToHandle

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestUnableToHandle() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:" + getSoapClientPort() + "/loanService/loanService", SOAP_REQUEST_2);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        //m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//faultcode", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().endsWith(":unableToHandleRequest")) {
            fail("Expecting 'unableToHandleRequest' fault code");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java


示例4: testDeployment

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Override
@Test
public void testDeployment() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:" + getSoapClientPort() + "/SayHelloService/SayHelloService", SOAP_REQUEST);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://www.jboss.org/bpel/examples");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:result", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("Hello Fred")) {
            fail("Expecting 'Hello Fred'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:27,代码来源:BpelServiceSayHelloQuickstartTest.java


示例5: testLoanRequestAccepted

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestAccepted() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:8080/loanService/loanService", SOAP_REQUEST_1);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//tns:accept", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().equals("yes")) {
            fail("Expecting 'yes'");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java


示例6: testLoanRequestUnableToHandle

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void testLoanRequestUnableToHandle() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();
    httpMixIn.initialize();
    try {
        String response = httpMixIn.postString("http://localhost:8080/loanService/loanService", SOAP_REQUEST_2);

        org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        //m.put("tns", "http://example.com/loan-approval/loanService/");
        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XpathEngine engine = XMLUnit.newXpathEngine();
        engine.setNamespaceContext(ctx);

        NodeList l = engine.getMatchingNodes("//faultcode", d);
        assertEquals(1, l.getLength());
        assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
        
        if (!l.item(0).getTextContent().endsWith(":unableToHandleRequest")) {
            fail("Expecting 'unableToHandleRequest' fault code");
        }
    } finally {
        httpMixIn.uninitialize();
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceLoanApprovalQuickstartTest.java


示例7: testSayHello

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void testSayHello() throws Exception {
	HTTPMixIn httpMixIn = new HTTPMixIn();
	httpMixIn.initialize();
	try {
		String response = httpMixIn.postString("http://localhost:8080/SayHelloService/SayHelloService", SOAP_REQUEST);

		org.w3c.dom.Document d = XMLUnit.buildControlDocument(response);
        java.util.HashMap<String,String> m = new java.util.HashMap<String,String>();
        m.put("tns", "http://www.jboss.org/bpel/examples");
	    NamespaceContext ctx = new SimpleNamespaceContext(m);
	    XpathEngine engine = XMLUnit.newXpathEngine();
	    engine.setNamespaceContext(ctx);

	    NodeList l = engine.getMatchingNodes("//tns:result", d);
	    assertEquals(1, l.getLength());
	    assertEquals(org.w3c.dom.Node.ELEMENT_NODE, l.item(0).getNodeType());
	    
	    if (!l.item(0).getTextContent().equals("Hello Fred")) {
	        fail("Expecting 'Hello Fred'");
	    }
	} finally {
		httpMixIn.uninitialize();
	}
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:26,代码来源:BpelServiceSayHelloQuickstartTest.java


示例8: turnIntoMap

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
static Map<String, String> turnIntoMap(NamespaceContext ctx) {
    Map<String, String> m = new HashMap<String, String>();
    for (Iterator i = ctx.getPrefixes(); i.hasNext(); ) {
        String prefix = (String) i.next();
        String uri = ctx.getNamespaceURI(prefix);
        // according to the Javadocs only the constants defined in
        // XMLConstants are allowed as prefixes for the following
        // two URIs
        if (!XMLConstants.XML_NS_URI.equals(uri)
            && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) {
            m.put(prefix, uri);
        }
    }
    m.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
    m.put(XMLConstants.XMLNS_ATTRIBUTE,
          XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
    return m;
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:19,代码来源:XMLUnitNamespaceContext2Jaxp13.java


示例9: setUp

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule());

  servlet = new DataServiceServlet();

  HandlerRegistry dispatcher = injector.getInstance(HandlerRegistry.class);
  dispatcher.addHandlers(injector.getInstance(Key.get(new TypeLiteral<Set<Object>>(){},
      Names.named("org.apache.shindig.social.handlers"))));
  servlet.setHandlerRegistry(dispatcher);
  servlet.setBeanConverters(new BeanJsonConverter(injector),
      new BeanXStreamConverter(new XStream081Configuration(injector)),
      new BeanXStreamAtomConverter(new XStream081Configuration(injector)));

  res = EasyMock.createMock(HttpServletResponse.class);
  NamespaceContext ns = new SimpleNamespaceContext(ImmutableMap.of("", "http://ns.opensocial.org/2008/opensocial"));
  XMLUnit.setXpathNamespaceContext(ns);
  xp = XMLUnit.newXpathEngine();
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:21,代码来源:AbstractLargeRestfulTests.java


示例10: assertXpathEvaluatesTo

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
/**
 * Assert the values of xpath expression evaluation is exactly the same as expected value.
 * <p>The xpath may contain the xml namespace prefixes, since namespaces from flight example
 * are being registered.
 * @param msg the error message that will be used in case of test failure
 * @param expected the expected value
 * @param xpath the xpath to evaluate
 * @param xmlDoc the xml to use
 * @throws Exception if any error occurs during xpath evaluation
 */
private void assertXpathEvaluatesTo(String msg, String expected, String xpath, String xmlDoc) throws Exception {
	Map<String, String> namespaces = new HashMap<String, String>();
	namespaces.put("tns", "http://samples.springframework.org/flight");
	namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");

	NamespaceContext ctx = new SimpleNamespaceContext(namespaces);
	XpathEngine engine = XMLUnit.newXpathEngine();
	engine.setNamespaceContext(ctx);

	Document doc = XMLUnit.buildControlDocument(xmlDoc);
	NodeList node = engine.getMatchingNodes(xpath, doc);
	assertEquals(msg, expected, node.item(0).getNodeValue());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:CastorMarshallerTests.java


示例11: initializeXmlUnit

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
private static void initializeXmlUnit() {
  HashMap<String, String> m = new HashMap<String, String>();
  m.put("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
  m.put("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
  m.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  m.put("g", "http://www.w3.org/2005/Atom"); // 'g' is a dummy for global namespace

  NamespaceContext ctx = new SimpleNamespaceContext(m);
  XMLUnit.setXpathNamespaceContext(ctx);
  XpathEngine engine = XMLUnit.newXpathEngine();
  engine.setNamespaceContext(ctx);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:13,代码来源:ServiceOperationsTest.java


示例12: writeValidMetadata

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata() throws Exception {
  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  annotationElements.add(new AnnotationElement().setName("test").setText("hallo"));
  Schema schema = new Schema().setAnnotationElements(annotationElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  String metadata = StringHelper.inputStreamToString(csb.getInputStream());
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:28,代码来源:XmlMetadataProducerTest.java


示例13: writeValidMetadata4

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata4() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:39,代码来源:XmlMetadataProducerTest.java


示例14: writeValidMetadata5

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata5() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace(
      "http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:41,代码来源:XmlMetadataProducerTest.java


示例15: assertXpathEvaluatesTo

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
/**
 * Asserts the values of xpath expression evaluation is exactly the same as expected value. </p> The xpath may contain
 * the xml namespace prefixes, since namespaces from flight example are being registered.
 *
 * @param msg the error message that will be used in case of test failure
 * @param expected the expected value
 * @param xpath the xpath to evaluate
 * @param xmlDoc the xml to use
 * @throws Exception if any error occurs during xpath evaluation
 */
private void assertXpathEvaluatesTo(String msg, String expected, String xpath, String xmlDoc) throws Exception {
	Map<String, String> namespaces = new HashMap<String, String>();
	namespaces.put("tns", "http://samples.springframework.org/flight");
	namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");

	NamespaceContext ctx = new SimpleNamespaceContext(namespaces);
	XpathEngine engine = XMLUnit.newXpathEngine();
	engine.setNamespaceContext(ctx);

	Document doc = XMLUnit.buildControlDocument(xmlDoc);
	NodeList node = engine.getMatchingNodes(xpath, doc);
	assertEquals(msg, expected, node.item(0).getNodeValue());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:CastorMarshallerTests.java


示例16: validateQueryUsingIdAttribute

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
protected void validateQueryUsingIdAttribute(InputStream query, InputStream expectedResults) {
String actualResults = executeQuery(query) ;
String xpath = "//ns1:Attribute[@name='id']/@value" ;
Map<String, String> ns = new HashMap<String, String>() ;
ns.put("ns1", "http://CQL.caBIG/1/gov.nih.nci.cagrid.CQLResultSet") ;
NamespaceContext ctx = new SimpleNamespaceContext(ns) ;
XpathEngine engine = XMLUnit.newXpathEngine() ;
engine.setNamespaceContext(ctx) ;
try { 
    NodeList controlList = engine.getMatchingNodes(xpath, XMLUnit.buildControlDocument(asString(expectedResults))) ;
    Set<String> controlIds = new HashSet<String>() ;
    for (int i = 0; i < controlList.getLength(); i++) {
	controlIds.add(controlList.item(i).getNodeValue()) ;
    }
    
    NodeList testList = engine.getMatchingNodes(xpath, XMLUnit.buildControlDocument(actualResults)) ;
    Set<String> testIds = new HashSet<String>() ;
    for (int i = 0; i < testList.getLength(); i++) {
	testIds.add(testList.item(i).getNodeValue()) ;
    }

    assertTrue(controlIds.containsAll(testIds)) ;
    assertTrue(testIds.containsAll(controlIds)) ;
} catch (Exception e) {
    throw new RuntimeException("Exception while comparing ID attributes.", e) ;
}
   }
 
开发者ID:NCIP,项目名称:digital-model-repository,代码行数:28,代码来源:CvitDataServiceTests.java


示例17: writeValidMetadata3

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata3() throws Exception {
  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  annotationElements.add(new AnnotationElement().setName("test").setText("hallo)"));
  Schema schema = new Schema().setAnnotationElements(annotationElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  List<PropertyRef> keys = new ArrayList<PropertyRef>();
  keys.add(new PropertyRef().setName("Id"));
  Key key = new Key().setKeys(keys);
  List<Property> properties = new ArrayList<Property>();
  properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String));
  EntityType entityType = new EntityType().setName("testType").setKey(key).setProperties(properties);
  List<EntityType> entityTypes = new ArrayList<EntityType>();
  entityTypes.add(entityType);
  schema.setEntityTypes(entityTypes);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  String metadata = StringHelper.inputStreamToString(csb.getInputStream());
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata);
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:38,代码来源:XmlMetadataProducerTest.java


示例18: writeValidMetadata4

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata4() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:37,代码来源:XmlMetadataProducerTest.java


示例19: writeValidMetadata5

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata5() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom"));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  schemaElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest2", metadata);
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:37,代码来源:XmlMetadataProducerTest.java


示例20: writeValidMetadata6

import org.custommonkey.xmlunit.NamespaceContext; //导入依赖的package包/类
@Test
public void writeValidMetadata6() throws Exception {

  List<Schema> schemas = new ArrayList<Schema>();

  List<AnnotationAttribute> attributesElement1 = new ArrayList<AnnotationAttribute>();
  attributesElement1.add(new AnnotationAttribute().setName("rel").setText("self").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom"));
  attributesElement1.add(new AnnotationAttribute().setName("href").setText("link").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom"));

  List<AnnotationElement> elementElements = new ArrayList<AnnotationElement>();
  elementElements.add(new AnnotationElement().setName("schemaElementTest2").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));
  elementElements.add(new AnnotationElement().setName("schemaElementTest3").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1));

  List<AnnotationElement> schemaElements = new ArrayList<AnnotationElement>();
  schemaElements.add(new AnnotationElement().setName("schemaElementTest1").setPrefix("atom").setNamespace("http://www.w3.org/2005/Atom").setAttributes(attributesElement1).setChildElements(elementElements));

  Schema schema = new Schema().setAnnotationElements(schemaElements);
  schema.setNamespace("http://namespace.com");
  schemas.add(schema);

  DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
  OutputStreamWriter writer = null;
  CircleStreamBuffer csb = new CircleStreamBuffer();
  writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
  XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
  XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  String metadata = StringHelper.inputStreamToString(csb.getInputStream());

  Map<String, String> prefixMap = new HashMap<String, String>();
  prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
  prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
  prefixMap.put("atom", "http://www.w3.org/2005/Atom");

  NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
  XMLUnit.setXpathNamespaceContext(ctx);

  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1/atom:schemaElementTest2", metadata);
  assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/atom:schemaElementTest1/atom:schemaElementTest3", metadata);
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:41,代码来源:XmlMetadataProducerTest.java



注:本文中的org.custommonkey.xmlunit.NamespaceContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextDirectionHeuristic类代码示例发布时间:2022-05-22
下一篇:
Java RpcServerFactoryPBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap