Example usage for javax.xml.namespace QName QName

List of usage examples for javax.xml.namespace QName QName

Introduction

In this page you can find the example usage for javax.xml.namespace QName QName.

Prototype

public QName(final String namespaceURI, final String localPart) 

Source Link

Document

QName constructor specifying the Namespace URI and local part.

If the Namespace URI is null, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .

Usage

From source file:edu.jhuapl.tinkerpop.AccumuloGraphConfigurationTest.java

@Test
public void testPropertyValues() throws Exception {
    AccumuloGraph graph = new AccumuloGraph(AccumuloGraphTestUtils.generateGraphConfig("propertyValues"));
    // Tests for serialization/deserialization of properties.
    QName qname = new QName("ns", "prop");
    Vertex v = graph.addVertex(null);/* w  ww.  java  2 s .  c om*/
    v.setProperty("qname", qname);
    assertTrue(v.getProperty("qname") instanceof QName);
    assertTrue(qname.equals(v.getProperty("qname")));
}

From source file:com.xiongyingqi.util.xml.XMLEventStreamWriter.java

@Override
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
    eventWriter.add(eventFactory.createAttribute(new QName(namespaceURI, localName), value));
}

From source file:org.apache.cxf.systest.jaxrs.JAXRSSoapBookTest.java

@Test
public void testHelloSoap() throws Exception {
    final QName serviceName = new QName("http://hello.com", "HelloWorld");
    final QName portName = new QName("http://hello.com", "HelloWorldPort");
    final String address = "http://localhost:" + PORT + "/test/services/hello-soap";

    Service service = Service.create(serviceName);
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, address);

    HelloWorld hw = service.getPort(HelloWorld.class);

    useHelloService(hw);//from www.j  av  a  2s . com
}

From source file:gov.nih.nci.cagrid.caarray.client.CaArray2xGrid.java

protected synchronized long printResults(CQLQueryResults results, String outFileName) {
    try {/* w w  w  .  ja  va2s .  c om*/
        // StringWriter w = new StringWriter();
        String fileName = "test/logs/" + outFileName;
        new File(fileName).delete();
        FileWriter w = new FileWriter(fileName);
        Utils.serializeObject(results,
                new QName("http://CQL.caBIG/1/gov.nih.nci.cagrid.CQLResultSet", "CQLResultSet"), w);
        w.flush();
        w.close();
        long fileSize = new File(fileName).length();

        LOG.debug("... done printing results to : " + outFileName + " size=" + fileSize + " bytes");
        return fileSize;
    } catch (Exception ex) {
        throw new RuntimeException("Error printing results: " + ex.getMessage(), ex);
    }
}

From source file:org.apache.servicemix.jms.JmsProviderEndpointTest.java

public void testSoapProviderInOut() throws Exception {
    JmsComponent component = new JmsComponent();

    JmsSoapProviderEndpoint endpoint = new JmsSoapProviderEndpoint();
    endpoint.setService(new QName("uri:HelloWorld", "HelloService"));
    endpoint.setEndpoint("HelloPort");
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.setDestinationName("destination");
    endpoint.setReplyDestinationName("reply");
    endpoint.setWsdl(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC.wsdl"));
    component.setEndpoints(new JmsProviderEndpoint[] { endpoint });
    container.activateComponent(component, "servicemix-jms");

    Thread th = new Thread() {
        public void run() {
            try {
                final Message msg = jmsTemplate.receive("destination");
                assertNotNull(msg);/* ww w  . ja v a 2  s  .com*/
                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
                FileUtil.copyInputStream(
                        new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC-Output.xml")
                                .getInputStream(),
                        baos);
                jmsTemplate.send("reply", new MessageCreator() {
                    public Message createMessage(Session session) throws JMSException {
                        TextMessage rep = session.createTextMessage(baos.toString());
                        rep.setJMSCorrelationID(msg.getJMSCorrelationID() != null ? msg.getJMSCorrelationID()
                                : msg.getJMSMessageID());
                        return rep;
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    th.start();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FileUtil.copyInputStream(
            new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml").getInputStream(),
            baos);
    InOut me = client.createInOutExchange();
    me.getInMessage().setContent(new StringSource(baos.toString()));
    me.setOperation(new QName("uri:HelloWorld", "Hello"));
    me.setService(new QName("uri:HelloWorld", "HelloService"));
    client.sendSync(me);
    assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
    assertNotNull(me.getOutMessage());
    assertNotNull(me.getOutMessage().getContent());
    System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
    client.done(me);

}

From source file:com._4dconcept.springframework.data.marklogic.repository.query.PartTreeMarklogicQueryTest.java

@Test
public void collectionFieldsShouldBeConsideredWithASingleParameter() {
    Query query = deriveQueryFromMethod("findBySkills", "foo");

    assertCriteria(query.getCriteria(), is(new QName("http://spring.data.marklogic/test/contact", "skill")),
            is("foo"));
}

From source file:com.evolveum.midpoint.prism.ComplexTypeDefinitionImpl.java

public PrismPropertyDefinition createPropertyDefinition(String localName, String localTypeName) {
    QName name = new QName(getSchemaNamespace(), localName);
    QName typeName = new QName(getSchemaNamespace(), localTypeName);
    return createPropertyDefinition(name, typeName);
}

From source file:egovframework.rte.itl.webservice.service.impl.EgovWebServiceClientImpl.java

/**
 * Constructor// w  w w  . j av  a2s .  c  o m
 * @param classLoader
 *        EgovWebServiceClassLoader
 * @param serviceEndpointInterfaceInfo
 *        ServiceEndpointInterfaceInfo
 * @param messageConverter
 *        MessageConverter
 * @throws IllegalArgumentException
 *         <code>classLoader</code>,
 *         <code>serviceEndpointInterfaceInfo</code>
 *         , <code>messageConverter</code> ?
 *         <code>null</code>? 
 * @throws ClassNotFoundException
 *         Class ?   
 * @throws SecurityException
 * @throws NoSuchMethodException
 * @throws MalformedURLException
 */
public EgovWebServiceClientImpl(EgovWebServiceClassLoader classLoader,
        ServiceEndpointInterfaceInfo serviceEndpointInterfaceInfo, MessageConverter messageConverter)
        throws ClassNotFoundException, SecurityException, NoSuchMethodException, MalformedURLException {
    super();

    LOG.debug("Create EgovWebServiceClient");

    if (classLoader == null) {
        LOG.error("Argument 'classLoader' is null");
        throw new IllegalArgumentException();
    } else if (serviceEndpointInterfaceInfo == null) {
        LOG.error("Argument 'serviceEndpointInterfaeInfo' is null");
        throw new IllegalArgumentException();
    } else if (messageConverter == null) {
        LOG.error("Argument 'messageConverter' is null");
        throw new IllegalArgumentException();
    }

    this.serviceEndpointInterfaceInfo = serviceEndpointInterfaceInfo;
    this.messageConverter = messageConverter;

    // ServiceEndpointInterface Class load.
    serviceEndpointInterfaceClass = classLoader.loadClass(serviceEndpointInterfaceInfo);
    LOG.debug("serviceEndpointInterfaceClass = " + serviceEndpointInterfaceClass);

    // service ?.
    wsdlURL = new URL(serviceEndpointInterfaceInfo.getWsdlAddress());
    LOG.debug("wsdlURL = " + wsdlURL);
    serviceName = new QName(serviceEndpointInterfaceInfo.getNamespace(),
            serviceEndpointInterfaceInfo.getServiceName());
    LOG.debug("serviceName = " + serviceName);
    portName = new QName(serviceEndpointInterfaceInfo.getNamespace(),
            serviceEndpointInterfaceInfo.getPortName());
    LOG.debug("portName = " + portName);

    // Method 
    List<Class<?>> paramClasses = new ArrayList<Class<?>>();
    for (ServiceParamInfo paramInfo : serviceEndpointInterfaceInfo.getParamInfos()) {
        if (paramInfo.getMode().equals(Mode.OUT) || paramInfo.getMode().equals(Mode.INOUT)) {
            paramClasses.add(Holder.class);
        } else {
            paramClasses.add(classLoader.loadClass(paramInfo.getType()));
        }
    }
    this.method = serviceEndpointInterfaceClass.getMethod(serviceEndpointInterfaceInfo.getOperationName(),
            paramClasses.toArray(new Class<?>[] {}));
    LOG.debug("method = " + method);

    LOG.debug("Finish to creating EgovWebServiceClient");
}

From source file:gov.nih.nci.integration.caaers.CaAERSParticipantServiceClientIntegrationTest.java

/**
 * Testcase for marshlling participant type
 * //from www  .  ja v a  2s.  co  m
 * @throws JAXBException - JAXBException
 * @throws DatatypeConfigurationException - DatatypeConfigurationException
 */
@Test
public void marshalParticipantType() throws JAXBException, DatatypeConfigurationException {
    final ParticipantType pt = new ParticipantType();
    pt.setFirstName("fn");
    pt.setLastName("ln");
    pt.setEthnicity(EthnicityType.NOT_HISPANIC_OR_LATINO);
    pt.setGender(GenderType.MALE);
    final DatatypeFactory df = DatatypeFactory.newInstance();
    final GregorianCalendar gc = new GregorianCalendar();
    gc.setTimeInMillis(new Date().getTime());
    pt.setBirthDate(df.newXMLGregorianCalendar(gc));
    pt.setRace(RaceType.WHITE);

    final OrganizationAssignedIdentifierType orgId = new OrganizationAssignedIdentifierType();
    orgId.setType(ParticipantIdentifierType.MRN);
    orgId.setValue("123456");
    orgId.setPrimaryIndicator(true);
    final OrganizationType ot = new OrganizationType();
    ot.setName("UCSF)");
    ot.setNciInstituteCode("UCSF");
    orgId.setOrganization(ot);
    final ParticipantType.Identifiers ids = new ParticipantType.Identifiers();
    ids.getOrganizationAssignedIdentifier().add(orgId);
    pt.setIdentifiers(ids);

    final AssignmentType at = new AssignmentType();
    at.setStudySubjectIdentifier("456");
    final StudySiteType sst = new StudySiteType();
    final OrganizationType ot2 = new OrganizationType();
    ot2.setName("UCSF)");
    ot2.setNciInstituteCode("UCSF");
    sst.setOrganization(ot2);
    final StudyType st = new StudyType();
    final ReducedIdentifierType rit = new ReducedIdentifierType();
    rit.setType(StudyIdentifierType.SITE_IDENTIFIER);
    rit.setValue("1.2.3.4.5");
    final StudyType.Identifiers sids = new StudyType.Identifiers();
    sids.setIdentifier(rit);
    st.setIdentifiers(sids);
    sst.setStudy(st);
    at.setStudySite(sst);

    final Assignments ass = new Assignments();
    ass.getAssignment().add(at);
    pt.setAssignments(ass);

    final QName qname = new QName("http://webservice.caaers.cabig.nci.nih.gov/participant", "participant");
    final JAXBElement<ParticipantType> ptJaxbEle = new JAXBElement<ParticipantType>(qname,
            ParticipantType.class, pt);
    final StringWriter sw = new StringWriter();
    getMarshaller().marshal(ptJaxbEle, sw);
    Assert.assertNotNull(sw.toString());

    JAXBElement<ParticipantType> jaxbEle = (JAXBElement<ParticipantType>) getUnMarshaller()
            .unmarshal(new StreamSource(new StringReader(sw.toString())), ParticipantType.class);
    Assert.assertNotNull(jaxbEle);
    Assert.assertNotNull(jaxbEle.getValue());

    jaxbEle = (JAXBElement<ParticipantType>) getUnMarshaller()
            .unmarshal(new StreamSource(new StringReader(getPStr())), ParticipantType.class);
    Assert.assertNotNull(jaxbEle);
    final ParticipantType ptn = jaxbEle.getValue();
    Assert.assertNotNull(ptn);
}

From source file:net.bpelunit.util.XMLUtilTest.java

@Test
public void testGetQName() throws Exception {
    Document doc = XMLUtil.parseXML(getClass().getResourceAsStream("simple.xml"));
    Element root = doc.getDocumentElement();

    assertEquals(new QName("", "simple"), XMLUtil.getQName(root));
    assertEquals(new QName("", "b"), XMLUtil.getQName(doc.createElement("b")));
    assertEquals(new QName("a", "b"), XMLUtil.getQName(doc.createElementNS("a", "b")));
}