org.apache.ws.commons.schema.constants.Constants Java Examples

The following examples show how to use org.apache.ws.commons.schema.constants.Constants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrayTypeInfoTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();

    addNamespace("b", "urn:Bean");
    addNamespace("a", "urn:anotherns");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);

    AegisContext context = new AegisContext();
    context.initialize();
    mapping = context.getTypeMapping();

    // address type
    BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
    addressInfo.setTypeMapping(mapping);

    addressType = new StructType(addressInfo);
    addressType.setTypeClass(Address.class);
    addressType.setSchemaType(new QName("urn:Bean", "addr"));
    mapping.register(addressType);
}
 
Example #2
Source File: ParticleInfo.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static void factorySetupType(XmlSchemaElement element, SchemaCollection schemaCollection,
                                     ParticleInfo elementInfo) {
    elementInfo.type = element.getSchemaType();
    if (elementInfo.type == null) {
        if (element.getSchemaTypeName() == null // no type at all -> anyType
            || element.getSchemaTypeName().equals(Constants.XSD_ANYTYPE)) {
            elementInfo.anyType = true;
        } else {
            elementInfo.type = schemaCollection.getTypeByQName(element.getSchemaTypeName());
            if (elementInfo.type == null
                && !element.getSchemaTypeName()
                        .getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
                JavascriptUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
                        .toString(), element.getQName(), element);
            }
        }
    } else if (elementInfo.type.getQName() != null
        && Constants.XSD_ANYTYPE.equals(elementInfo.type.getQName())) {
        elementInfo.anyType = true;
    }
}
 
Example #3
Source File: DualOutServiceTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(DualOutService.class);
    sf.setAddress("local://DualOutService");
    sf.setBus(getBus());
    setupAegis(sf);
    sf.create();

    Document wsdl = getWSDLDocument("DualOutService");
    assertNotNull(wsdl);

    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);

    assertValid(
                "//xsd:complexType[@name='getValuesResponse']//xsd:element"
                + "[@name='return'][@type='xsd:string']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='getValuesResponse']//xsd:element"
                + "[@name='return1'][@type='xsd:string']",
                wsdl);
}
 
Example #4
Source File: NoNamespaceAegisElementProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
protected AegisContext getAegisContext(Class<?> plainClass, Type genericType) {
    AegisContext context = new AegisContext();
    context.setWriteXsiTypes(writeXsiType);
    context.setReadXsiTypes(readXsiType);
    TypeCreationOptions tco = new TypeCreationOptions();
    tco.setQualifyElements(false);
    Set<java.lang.reflect.Type> rootClasses = new HashSet<>();
    rootClasses.add(genericType);
    context.setTypeCreationOptions(tco);
    context.setRootClasses(rootClasses);
    TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
    DefaultTypeMapping mapping = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD, baseMapping);
    TypeCreator stockTypeCreator = createTypeCreator(tco);

    mapping.setTypeCreator(stockTypeCreator);
    context.setTypeMapping(mapping);
    context.initialize();
    return context;
}
 
Example #5
Source File: WadlGenerator.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void handleGrammars(StringBuilder sbApp, StringBuilder sbGrammars, SchemaWriter writer,
                              Map<Class<?>, QName> clsMap) {
    if (writer == null) {
        return;
    }

    Map<String, String> map = new HashMap<>();
    for (QName qname : clsMap.values()) {
        map.put(qname.getPrefix(), qname.getNamespaceURI());
    }
    for (Map.Entry<String, String> entry : map.entrySet()) {
        sbApp.append(" xmlns:").append(entry.getKey()).append("=\"").append(entry.getValue())
            .append('"');
    }

    if (wadlSchemaLocation != null) {
        sbApp.append(" xmlns:xsi=\"").append(Constants.URI_2001_SCHEMA_XSI).append('"');
        sbApp.append(" xsi:schemaLocation=\"")
             .append(getNamespace()).append(' ').append(wadlSchemaLocation)
             .append('"');
    }

    writer.write(sbGrammars);
}
 
Example #6
Source File: ScopedNameVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static CorbaType getCorbaSchemaType(XmlSchema xmlSchema,
                                                TypeMappingType typeMap,
                                                XmlSchemaType stype,
                                                Scope scopedName) {
    CorbaType ctype = null;
    if (stype.getQName().equals(Constants.XSD_STRING)) {
        ctype = new CorbaType();
        ctype.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
        ctype.setQName(CorbaConstants.NT_CORBA_STRING);
        ctype.setType(Constants.XSD_STRING);
    } else {
        QName qname = stype.getQName();
        ctype = findCorbaTypeForSchemaType(typeMap, qname, scopedName);
    }
    return ctype;
}
 
Example #7
Source File: WadlGenerator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void loadSchemasIntoCache(String loc) throws Exception {
    InputStream is = ResourceUtils.getResourceStream(loc,
        bus == null ? BusFactory.getDefaultBus() : bus);
    if (is == null) {
        return;
    }
    try (ByteArrayInputStream bis = IOUtils.loadIntoBAIS(is)) {
        XMLSource source = new XMLSource(bis);
        source.setBuffering();
        String targetNs = source.getValue("/*/@targetNamespace");

        Map<String, String> nsMap = Collections.singletonMap("xs", Constants.URI_2001_SCHEMA_XSD);
        String[] elementNames = source.getValues("/*/xs:element/@name", nsMap);
        externalQnamesMap.put(targetNs, Arrays.asList(elementNames));
        String schemaValue = source.getNode("/xs:schema", nsMap, String.class);
        externalSchemasCache.add(schemaValue);
    }
}
 
Example #8
Source File: XFireTypeTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    Document wsdl = getWSDLDocument("XFireService");

    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
    assertValid(
                "//xsd:complexType[@name='XFireBean1']/xsd:sequence/xsd:"
                + "element[@name='elementProperty']",
                wsdl);
    assertValid("//xsd:complexType[@name='XFireBean1']/xsd:attribute"
                + "[@name='attributeProperty']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='XFireBean1']/xsd:sequence/xsd:element"
                + "[@name='bogusProperty']",
                wsdl);

    assertValid(
                "//xsd:complexType[@name='XFireBean2']/xsd:sequence/xsd:element"
                + "[@name='element'][@type='xsd:string']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='XFireBean2']/xsd:attribute"
                + "[@name='attribute'][@type='xsd:string']",
                wsdl);
}
 
Example #9
Source File: JAXRSClientServerSpringBookTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkSchemas(String address, String schemaSegment,
                          String includedSchema,
                          String refAttrName) throws Exception {
    WebClient client = WebClient.create(address + schemaSegment);
    WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000L);
    Document doc = StaxUtils.read(new InputStreamReader(client.get(InputStream.class), StandardCharsets.UTF_8));
    Element root = doc.getDocumentElement();
    assertEquals(Constants.URI_2001_SCHEMA_XSD, root.getNamespaceURI());
    assertEquals("schema", root.getLocalName());
    if (includedSchema != null) {
        List<Element> includeEls = DOMUtils.getChildrenWithName(root,
                                                                Constants.URI_2001_SCHEMA_XSD,
                                                                refAttrName);
        assertEquals(1, includeEls.size());
        String href = includeEls.get(0).getAttribute("schemaLocation");
        assertEquals(address + includedSchema, href);
    }

}
 
Example #10
Source File: CollectionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testObjectDTO() {
    tm = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD);
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);

    AegisType dto = creator.createType(ObjectDTO.class);
    Set<AegisType> deps = dto.getDependencies();

    assertFalse(deps.isEmpty());

    AegisType type = deps.iterator().next();

    assertTrue(type instanceof CollectionType);

    CollectionType colType = (CollectionType)type;

    deps = dto.getDependencies();
    assertEquals(1, deps.size());

    AegisType comType = colType.getComponentType();
    assertEquals(Object.class, comType.getTypeClass());
}
 
Example #11
Source File: AnnotatedTypeTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    Document wsdl = getWSDLDocument("AnnotatedService");

    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
    assertValid(
                "//xsd:complexType[@name='AnnotatedBean1']/xsd:sequence/xsd:"
                + "element[@name='elementProperty']",
                wsdl);
    assertValid("//xsd:complexType[@name='AnnotatedBean1']/xsd:attribute"
                + "[@name='attributeProperty']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='AnnotatedBean1']/xsd:sequence/xsd:element"
                + "[@name='bogusProperty']",
                wsdl);

    assertValid(
                "//xsd:complexType[@name='AnnotatedBean2']/xsd:sequence/xsd:element"
                + "[@name='element'][@type='xsd:string']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='AnnotatedBean2']/xsd:attribute"
                + "[@name='attribute'][@type='xsd:string']",
                wsdl);
}
 
Example #12
Source File: StaxDataBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void initialize(Service service) {
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
        SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
        if (schemaCollection.getXmlSchemas().length > 1) {
            // Schemas are already populated.
            continue;
        }
        new ServiceModelVisitor(serviceInfo) {
            public void begin(MessagePartInfo part) {
                if (part.getTypeQName() != null || part.getElementQName() != null) {
                    return;
                }
                part.setTypeQName(Constants.XSD_ANYTYPE);
            }
        } .walk();
    }
}
 
Example #13
Source File: TypedefVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void generateStringAlias(AST typeDeclaratorNode,
                                 AST identifierNode,
                                 XmlSchemaType schemaType,
                                 CorbaType corbaType,
                                 Scope fqName) {

    Scope typedefScope = new Scope(getScope(), identifierNode);

    Alias corbaString = new Alias();
    if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
        corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
    } else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
    } else {
        // should never get here
        throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid node: "
                                   + typeDeclaratorNode.toString());
    }
    Scope newScope = new Scope(typedefScope.getParent(), identifierNode);
    corbaString.setQName(new QName(typeMap.getTargetNamespace(), newScope.toString()));
    corbaString.setType(Constants.XSD_STRING);
    corbaString.setRepositoryID(newScope.toIDLRepositoryID());

    typeMap.getStructOrExceptionOrUnion().add(corbaString);

}
 
Example #14
Source File: StringVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void visitUnboundedString() {
    // schema type
    setSchemaType(schemas.getTypeByQName(Constants.XSD_STRING));


    // corba type
    CorbaType corbaString = new CorbaType();
    if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
        corbaString.setQName(CorbaConstants.NT_CORBA_STRING);
        corbaString.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
    } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        corbaString.setQName(CorbaConstants.NT_CORBA_WSTRING);
        corbaString.setName(CorbaConstants.NT_CORBA_WSTRING.getLocalPart());
    } else {
        // should never get here
        throw new RuntimeException("StringVisitor attempted to visit an invalid node");
    }
    corbaString.setType(Constants.XSD_STRING);

    setCorbaType(corbaString);
}
 
Example #15
Source File: XMLStreamReaderMappingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();

    addNamespace("b", "urn:beanz");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);

    context = new AegisContext();
    // create a different mapping than the context creates.
    TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
    mapping = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD, baseMapping);
    mapping.register(XMLStreamReader.class,
                     new QName("urn:Bean", "SimpleBean"), new XMLStreamReaderType());
    mapping.setTypeCreator(context.createTypeCreator());
    context.setTypeMapping(mapping);
    context.initialize();
}
 
Example #16
Source File: SourceGenerator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void populateElementTypeMap(Application app, Element schemaEl,
        String systemId, Map<String, String> elementTypeMap) {
    List<Element> elementEls = DOMUtils.getChildrenWithName(schemaEl,
                                                            Constants.URI_2001_SCHEMA_XSD, "element");
    for (Element el : elementEls) {
        String type = el.getAttribute("type");
        if (!type.isEmpty()) {
            elementTypeMap.put(el.getAttribute("name"), type);
        }
    }
    Element includeEl = DOMUtils.getFirstChildWithName(schemaEl,
                                                       Constants.URI_2001_SCHEMA_XSD, "include");
    if (includeEl != null) {
        int ind = systemId.lastIndexOf('/');
        if (ind != -1) {
            String schemaURI = systemId.substring(0, ind + 1) + includeEl.getAttribute("schemaLocation");
            populateElementTypeMap(app, readDocument(schemaURI), schemaURI, elementTypeMap);
        }
    }
}
 
Example #17
Source File: SourceGenerator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private String getPrimitiveType(Element paramEl, ContextInfo info, Set<String> imports) {
    final String defaultValue = "String";
    String type = paramEl.getAttribute("type");
    if (type.isEmpty()) {
        return defaultValue;
    }

    String[] pair = type.split(":");
    if (pair.length == 2) {
        if (XSD_SPECIFIC_TYPE_MAP.containsKey(pair[1])) {
            String expandedName = "{" + Constants.URI_2001_SCHEMA_XSD + "}" + pair[1];
            if (schemaTypeMap.containsKey(expandedName)) {
                return addImportsAndGetSimpleName(imports, schemaTypeMap.get(expandedName));
            }

            String xsdType = XSD_SPECIFIC_TYPE_MAP.get(pair[1]);
            return addImportsAndGetSimpleName(imports, xsdType);
        }

        String value = pair[1].replaceAll("[\\-\\_]", "");
        return convertRefToClassName(pair[0], value, defaultValue, info, imports);
    }
    return addImportsAndGetSimpleName(imports, type);

}
 
Example #18
Source File: AbstractEncodedTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();

    addNamespace("b", "urn:Bean");
    addNamespace("a", "urn:anotherns");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    addNamespace("soapenc", Soap11.getInstance().getSoapEncodingStyle());

    AegisContext context = new AegisContext();
    // create a different mapping than the context creates.
    TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
    mapping = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD, baseMapping);
    mapping.setTypeCreator(context.createTypeCreator());
    context.setTypeMapping(mapping);
    context.initialize();
    // serialization root type
    trailingBlocks = new TrailingBlocks();
}
 
Example #19
Source File: DateTimezoneTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testTimezoneLessDate() throws Exception {
    BeanTypeInfo info = new BeanTypeInfo(DateBean.class, "urn:Bean");
    mapping.register(Date.class, Constants.XSD_DATETIME, new TimezoneLessDateType());
    mapping.register(Date.class, Constants.XSD_DATE, new TimezoneLessDateType());
    info.setTypeMapping(mapping);

    BeanType type = new BeanType(info);
    type.setTypeClass(DateBean.class);
    type.setTypeMapping(mapping);
    type.setSchemaType(new QName("urn:Bean", "bean"));

    DateBean bean = new DateBean();
    bean.setDate(Calendar.getInstance().getTime());
    // Test writing
    Element element = writeObjectToElement(type, bean, getContext());
    assertTimezoneLessString(element.getTextContent());

}
 
Example #20
Source File: AbstractMessageWriter.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void writeXsiType(QName type) {
    if (xsiTypeWritten) {
        return;
    }
    xsiTypeWritten = true;

    /*
     * Do not assume that the prefix supplied with the QName should be used
     * in this case.
     */
    String prefix = getPrefixForNamespace(type.getNamespaceURI(), type.getPrefix());
    String value;
    if (prefix != null && prefix.length() > 0) {
        StringBuilder sb = new StringBuilder(prefix.length() + 1 + type.getLocalPart().length());
        sb.append(prefix);
        sb.append(':');
        sb.append(type.getLocalPart());
        value = sb.toString();
    } else {
        value = type.getLocalPart();
    }
    getAttributeWriter("type", Constants.URI_2001_SCHEMA_XSI).writeValue(value);
}
 
Example #21
Source File: JavascriptUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Return true for xsd:base64Binary or simple restrictions of it, as in the xmime stock type.
 * @param type
 * @return
 */
public static boolean mtomCandidateType(XmlSchemaType type) {
    if (type == null) {
        return false;
    }
    if (Constants.XSD_BASE64.equals(type.getQName())) {
        return true;
    }
    // there could be some disagreement whether the following is a good enough test.
    // what if 'base64binary' was extended in some crazy way? At runtime, either it has
    // an xop:Include or it doesn't.
    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType)type;
        if (complexType.getContentModel() instanceof XmlSchemaSimpleContent) {
            XmlSchemaSimpleContent content = (XmlSchemaSimpleContent)complexType.getContentModel();
            if (content.getContent() instanceof XmlSchemaSimpleContentExtension) {
                XmlSchemaSimpleContentExtension extension =
                    (XmlSchemaSimpleContentExtension)content.getContent();
                if (Constants.XSD_BASE64.equals(extension.getBaseTypeName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #22
Source File: DateTimezoneTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testTimezoneLessCalendar() throws Exception {
    BeanTypeInfo info = new BeanTypeInfo(CalendarBean.class, "urn:Bean");
    mapping.register(Calendar.class, Constants.XSD_DATETIME, new TimezoneLessDateType());
    mapping.register(Calendar.class, Constants.XSD_DATE, new TimezoneLessDateType());
    info.setTypeMapping(mapping);

    BeanType type = new BeanType(info);
    type.setTypeClass(CalendarBean.class);
    type.setTypeMapping(mapping);
    type.setSchemaType(new QName("urn:Bean", "bean"));

    CalendarBean bean = new CalendarBean();
    bean.setCalendar(Calendar.getInstance());
    // Test writing
    Element element = writeObjectToElement(type, bean, getContext());

    assertTimezoneLessString(element.getTextContent());
}
 
Example #23
Source File: WadlGeneratorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkGrammarsWithLinks(Element appElement, List<String> links) {
    assertFalse(links.isEmpty());
    List<Element> grammarEls = DOMUtils.getChildrenWithName(appElement, WadlGenerator.WADL_NS,
                                                            "grammars");
    assertEquals(1, grammarEls.size());
    List<Element> schemasEls = DOMUtils.getChildrenWithName(grammarEls.get(0),
                                                            Constants.URI_2001_SCHEMA_XSD,
                                                            "schema");
    assertEquals(0, schemasEls.size());

    List<Element> includeEls = DOMUtils.getChildrenWithName(grammarEls.get(0), WadlGenerator.WADL_NS,
                                                            "include");
    assertEquals(links.size(), includeEls.size());
    for (Element el : includeEls) {
        assertTrue(links.contains(el.getAttribute("href")));
    }
}
 
Example #24
Source File: CollectionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCollectionDTO() {
    tm = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD);
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);

    AegisType dto = creator.createType(CollectionDTO.class);
    Set<AegisType> deps = dto.getDependencies();

    AegisType type = deps.iterator().next();

    assertTrue(type instanceof CollectionType);

    CollectionType colType = (CollectionType)type;

    deps = dto.getDependencies();
    assertEquals(1, deps.size());

    AegisType comType = colType.getComponentType();
    assertEquals(String.class, comType.getTypeClass());
}
 
Example #25
Source File: ClassTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void writeSchema(XmlSchema root) {
    XmlSchemaSimpleType xst = new XmlSchemaSimpleType(root, true);
    xst.setName("class");

    XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction();
    content.setBaseTypeName(Constants.XSD_STRING);
    xst.setContent(content);
}
 
Example #26
Source File: EnumTypeTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * {@link https://issues.apache.org/jira/browse/CXF-7188}
*/
@Test
public void testWsdlFromJaxbAnnotations() throws Exception {
    AegisType type = tm.getTypeCreator().createType(JaxbTestEnum.class);
    XmlSchema schema = newXmlSchema("urn:test");
    type.writeSchema(schema);

    XmlSchemaSerializer ser = new XmlSchemaSerializer();
    Document doc = ser.serializeSchema(schema, false)[0];
    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
    assertValid("//xsd:simpleType[@name='bar']/xsd:restriction[@base='xsd:string']", doc);
    assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='Value1']", doc);
    assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='VALUE2']", doc);
}
 
Example #27
Source File: DocLiteralInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) {
    // TO DO : check duplicate operation with no input and also check if the action matches
    for (OperationInfo op : operations) {
        MessageInfo bmsg = op.getInput();
        int bPartsNum = bmsg.getMessagePartsNumber();
        if (bPartsNum == 0
            || (bPartsNum == 1
                && Constants.XSD_ANYTYPE.equals(bmsg.getFirstMessagePart().getTypeQName()))) {
            BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op);
            exchange.put(BindingOperationInfo.class, boi);
            exchange.setOneWay(op.isOneWay());
        }
    }
}
 
Example #28
Source File: OperationNSTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    Collection<Document> wsdls = getWSDLDocuments("NotificationService");

    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
    //assertValid("//xsd:element[@name='Notify']", wsdl);
    assertTrue(isExist(wsdls, "//xsd:element[@name='Notify']", getNamespaces()));
}
 
Example #29
Source File: EnumTypeTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    EnumType type = new EnumType();
    type.setTypeClass(SmallEnum.class);
    type.setSchemaType(new QName("urn:test", "test"));
    XmlSchema schema = newXmlSchema("urn:test");
    type.writeSchema(schema);

    XmlSchemaSerializer ser = new XmlSchemaSerializer();
    Document doc = ser.serializeSchema(schema, false)[0];
    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
    assertValid("//xsd:simpleType[@name='test']/xsd:restriction[@base='xsd:string']", doc);
    assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='VALUE1']", doc);
    assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='VALUE2']", doc);
}
 
Example #30
Source File: BeanTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testByteBean() throws Exception {
    defaultContext();
    BeanTypeInfo info = new BeanTypeInfo(ByteBean.class, "urn:Bean");
    info.setTypeMapping(mapping);

    BeanType type = new BeanType(info);
    type.setTypeClass(ByteBean.class);
    type.setTypeMapping(mapping);
    type.setSchemaType(new QName("urn:Bean", "bean"));

    QName name = new QName("urn:Bean", "data");
    AegisType dataType = type.getTypeInfo().getType(name);
    assertNotNull(dataType);

    assertTrue(type.getTypeInfo().isNillable(name));

    ByteBean bean = new ByteBean();

    // Test writing
    Element element = writeObjectToElement(type, bean, getContext());

    // Make sure the date doesn't have an element. Its non nillable so it
    // just
    // shouldn't be there.

    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    assertValid("/b:root/b:data[@xsi:nil='true']", element);

    XMLStreamReader sreader = StaxUtils.createXMLStreamReader(element);
    bean = (ByteBean)type.readObject(new ElementReader(sreader), getContext());
    assertNotNull(bean);
    assertNull(bean.getData());
}