Package commonj.sdo

Examples of commonj.sdo.DataGraph


  }



  public void testDynamicNestedDataObjectsDG() throws Exception {
    DataGraph dataGraph = SDOUtil.createDataGraph();
    DataObject quote = dataGraph.createRootObject(th.getType("http://www.example.com/simple", "Quote"));

    testDynamicNestedDOBody(quote);
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SDOUtil.saveDataGraph(dataGraph, baos, null);
    // SDOUtil.saveDataGraph(dataGraph, System.out, null);
   
   assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));

  
    assertEquals(1, quote.getList("quotes").size());
    assertEquals("fbnt", quote.getString("symbol"));
    dataGraph.getChangeSummary().undoChanges();
    // SDOUtil.saveDataGraph(dataGraph, System.out, null);
    assertEquals(0, quote.getList("quotes").size());
    assertNull(quote.getString("symbol"));
   
View Full Code Here


    }
       
    public void testScopeDefinedSerializeDeserializeOfDataGraph()
    {
        HelperContext hc = SDOUtil.createHelperContext();
        DataGraph testDO = (DataGraph)createDynamically(hc,false);
       
        runSerializeDeserializeWithDataGraph(testDO, hc);
    }
View Full Code Here

       
        if(createDataObject)
            return dataFactory.create(apiXSDType);;
       
        // Create an empty DataGraph and attach the document root to it. Otherwise, where is the documentRoot ?
        DataGraph dataGraph = SDOUtil.createDataGraph();
        /*DataObject testDO =*/ dataGraph.createRootObject(apiXSDType);
       
       
        return dataGraph;
       
    }
View Full Code Here

        List typesDefined = types.define(types2define);

        // Create an empty data graph and add a root object, an instance of customerType
        //

        DataGraph dataGraph = SDOUtil.createDataGraph();
        Type customerTypeDefined = (Type) typesDefined.get(1);
        DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);

        customer1.setInt("custNum", 1);
        customer1.set("firstName", "John");
        customer1.set("lastName", "Adams");
        DataObject address = customer1.createDataObject("address");
        address.set("addrSt", "577 Airport Blvd");

        SDOUtil.registerDataGraphTypes(dataGraph, typesDefined);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SDOUtil.saveDataGraph(dataGraph, baos, null);
        //SDOUtil.saveDataGraph(dataGraph, System.out, null);

        byte[] serialized = baos.toByteArray();
        ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
        DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, null, hc);

        DataObject loadedRootObject = loadedDataGraph.getRootObject();
        assertNotSame(loadedRootObject.getType(), customer1.getType());

        // EqualityHelper requires same Type
        assertEquals(loadedRootObject.getInt("custNum"), customer1.getInt("custNum"));
        assertEquals(loadedRootObject.get("firstName"), customer1.get("firstName"));
View Full Code Here

     * createRootObject(type) test with good parms.
     */
    public void testCreateRootObjectType() throws IOException {
        // Create an empty data graph and add a root object, an instance of type Quote
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote");
        DataObject quote = dataGraph.createRootObject(quoteType);

        assertNotNull(quote);
    }
View Full Code Here

     * createRootObject(type) test with bad parm.
     */
    public void testCreateRootObjectTypeBad() throws IOException {
        // Create an empty data graph and pass bad parms to createRootObject
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        boolean success = false;
        try {
            dataGraph.createRootObject(null);
        } catch(NullPointerException npe) {
            fail("createRootObject with null type threw NullPointerException");
        } catch(Exception e) {
            success = true;
        }
View Full Code Here

     * that IllegalStateException is thrown
     */
    public void testCreateRootObjectTypeIllegalState() throws IOException {
        // Create an empty data graph and add a root object, then add another root object
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        DataObject quote = dataGraph.createRootObject("http://www.example.com/anytype", "Person");
       
        assertNotNull(quote);       

        Type quoteType = dataGraph.getType("http://www.example.com/simple", "Quote");
        assertNotNull(quoteType);
        boolean success = false;
        try {
            dataGraph.createRootObject(quoteType);           
        } catch(IllegalStateException ise) {
            success = true;
        } catch(Exception e) {
            fail("createRootObject called when a root was already created and an exception other than IllegalStateException was thrown: "+e.getMessage());
        }
View Full Code Here

     * that IllegalStateException is thrown
     */
    public void testCreateRootObjectUriTypenameIllegalState() throws IOException {
        // Create an empty data graph and add a root object, then add another root object
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        DataObject quote = dataGraph.createRootObject("http://www.example.com/anytype", "Person");
       
        assertNotNull(quote);       

        boolean success = false;
        try {
            dataGraph.createRootObject("http://www.example.com/simple", "Quote");           
        } catch(IllegalStateException ise) {
            success = true;
        } catch(Exception e) {
            fail("createRootObject called when a root was already created and an exception other than IllegalStateException was thrown: "+e.getMessage());
        }
View Full Code Here

     * createRootObject(uri_string, typeName_string) test with good parms.
     */
    public void testCreateRootObjectUriTypename() throws IOException {
        // Create an empty data graph and add a root object, an instance of type Quote
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        DataObject quote = dataGraph.createRootObject("http://www.example.com/simple", "Quote");

        assertNotNull(quote);
    }
View Full Code Here

     * createRootObject(uri_string, typeName_string) test with bad parms.
     */
    public void testCreateRootObjectUriTypenameBad1() throws IOException {
        // Create an empty data graph and pass bad parms to createRootObject
     
        DataGraph dataGraph = SDOUtil.createDataGraph();
        boolean success = false;
        try {
            dataGraph.createRootObject("http://www.example.com/mangled", "Quote");           
        } catch(NullPointerException npe) {
            fail("createRootObject with mangled URI threw NullPointerException");
        } catch(Exception e) {
            success = true;
        }
View Full Code Here

TOP

Related Classes of commonj.sdo.DataGraph

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.