Package commonj.sdo.helper

Examples of commonj.sdo.helper.XSDHelper


        type = hc.getTypeHelper().getType("testNS", "Sequenced");
        localA = type.getProperty("localA");
        choiceX = type.getProperty("choiceX");
        choiceY = type.getProperty("choiceY");
        localB = type.getProperty("localB");
        XSDHelper xsdHelper = hc.getXSDHelper();
        open = xsdHelper.getGlobalProperty("testNS", "open", true);
    }
View Full Code Here


        modelURL = getClass().getResource(TEST_MODEL);
        xsdCornersURL = getClass().getResource(TEST_MODEL2);
    }

    public void testDefineWithLocation() throws IOException {
        XSDHelper xsdHelper = hc.getXSDHelper();
        List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
        assertEquals(2, types.size());
    }
View Full Code Here

        List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
        assertEquals(2, types.size());
    }

    public void testDefineWithNoLocation() {
        XSDHelper xsdHelper = hc.getXSDHelper();
        List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null);
        assertEquals(2, types.size());
    }
View Full Code Here

        List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null);
        assertEquals(2, types.size());
    }

    public void testDuplicateDefineWithLocation() throws IOException {
        XSDHelper xsdHelper = hc.getXSDHelper();
        List types = xsdHelper.define(modelURL.openStream(), modelURL.toString());
        assertEquals(2, types.size());

        List types2 = xsdHelper.define(modelURL.openStream(), modelURL.toString());
        assertEquals(0, types2.size());
    }
View Full Code Here

    {
        //test for static sdo type.  The test succeeds if the IllegalArgumentException is thrown
        //by XSDHelper.generate method in which case the string xsd must be null;

        SimpleFactory.INSTANCE.register(hc);
        XSDHelper xsdHelper = hc.getXSDHelper();
        DataObject quoteSDO = (DataObject)SimpleFactory.INSTANCE.createQuote();
        List typeList = new Vector();
        typeList.add(quoteSDO.getType());
        String xsd = null;
       
        try
        {
            xsd = xsdHelper.generate(typeList);
            xsd = "";
        }
        catch ( IllegalArgumentException e )
        {
        }
View Full Code Here

   
    public void testXSDGeneration_DynamicSDOType() throws IOException
    {
        //test for dynamic SDOs that have no XSD model.  Here the testcase succeeds only if the
        //xsd is generated by XSDHelper in which case xsd must not be null
        XSDHelper xsdHelper = hc.getXSDHelper();
        DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
        quoteType.set("uri", "http://www.example.com/dynamic");
        quoteType.set("name", "DynamicQuote");
       
        DataObject aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "symbol");
        aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "String"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "price");
        aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Decimal"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "volume");
        aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Double"));
       
        TypeHelper.INSTANCE.define(quoteType);
       
        Type dynamicQuoteType =
            TypeHelper.INSTANCE.getType("http://www.example.com/dynamic", "DynamicQuote");
       
        Vector types = new Vector();
        types.add(dynamicQuoteType);
        String xsd = null;
       
        try
        {
            xsd = xsdHelper.generate(types);
            //System.out.println(xsd);
        }
        catch ( IllegalArgumentException e )
        {
        }
View Full Code Here

    {
        //testing static SDO with XSD Model being contained in a Dynamic SDO not having an XSD Model.
        //the schema must be generated with imports / includes for the XSD corresponding to the static
        //sdo types.
        TypeHelper typeHelper = hc.getTypeHelper();
        XSDHelper xsdHelper = hc.getXSDHelper();

        SimpleFactory.INSTANCE.register(hc);
        DataObject quoteSDO = (DataObject)SimpleFactory.INSTANCE.createQuote();
       
       
        DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
        quoteType.set("uri", "http://www.example.com/dynamic");
        quoteType.set("name", "DynamicQuote");
       
        DataObject aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "symbol");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "String"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "price");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "volume");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "Double"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "containedQuotes");
        aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
        aProperty.set("containment", new Boolean(true));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "referredQuotes");
        aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
       
        typeHelper.define(quoteType);
       
        Type dynamicQuoteType =
            typeHelper.getType("http://www.example.com/dynamic", "DynamicQuote");
        Vector types = new Vector();
        types.add(dynamicQuoteType);
        String xsd = null;
       
        try
        {
            Hashtable schemaLocationMap = new Hashtable();
            schemaLocationMap.put("http://www.example.com/simple", "http://www.example.com/simple/xsd");
            xsd = xsdHelper.generate(types, schemaLocationMap);
            //System.out.println(xsd);
        }
        catch ( IllegalArgumentException e )
        {
        }
View Full Code Here

        assertNotNull(xsd);
       
    }
   
    public void testPrefixFromNSWithHyphenNumber() throws IOException {
        XSDHelper xsdHelper = hc.getXSDHelper();
        xsdHelper.define(xsdCornersURL.openStream(), xsdCornersURL.toString());
        DataFactory df = hc.getDataFactory();
        DataObject root = df.create("http://www.example.com/simple-1", "A");
        root.setString("a1", "a1s");
        root.setString("a2", "a2s");
       
View Full Code Here

        String doc = hc.getXMLHelper().save(root, "http://www.example.com/simple-1", "a");
        assertTrue(doc.indexOf("xmlns:s1=\"http://www.example.com/simple-1\"") != -1);
    }

    public void testShortPrefix() throws IOException {
        XSDHelper xsdHelper = hc.getXSDHelper();
        URL url = getClass().getResource("/prefix.xsd");
        xsdHelper.define(url.openStream(), url.toString());
        DataObject cmd = hc.getDataFactory().create("http://soaassureservice.soabench.ibm.com", "CreateClaim");
        cmd.setString("requestInfo", "cost");
        String doc = hc.getXMLHelper().save(cmd, "http://soaassureservice.soabench.ibm.com", "createClaim");
        assertTrue(doc.indexOf("xmlns:as=\"http://soaassureservice.soabench.ibm.com\"") != -1);
    }
View Full Code Here

        assertNotNull(rootType);
        assertSame(containerType, rootType);

        // now load xml to get a reference data object using schema
        HelperContext hcRef = SDOUtil.createHelperContext();
        XSDHelper xsdHelper = hcRef.getXSDHelper();
        List typeList = xsdHelper.define(DYNAMIC_TYPES_SCHEMA_STRING);
        assertNotNull(typeList);
        TypeHelper thRef = hcRef.getTypeHelper();
        Type rootTypeRef = thRef.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0);

        assertNotNull(rootTypeRef);
View Full Code Here

TOP

Related Classes of commonj.sdo.helper.XSDHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.