Пример #1
0
  public void testCreateInstance() throws Exception {
    // create musteri schema manager...
    POSchemaManager musteriSchemaManager = MusteriSchemaManager.getInstance();

    // create an example musteri...
    Musteri musteri = createExampleMusteri();
    // create xml instance of example musteri...
    Document musteriInstance = musteriSchemaManager.createInstanceXML(musteri);
    // assert that musteriInstance is not null...
    assertNotNull(musteriInstance);

    // get Musteri element...
    Element musteriElement = musteriInstance.getDocumentElement();
    // get adSoyad element from Musteri element...
    Element adSoyadElement = (Element) musteriElement.getElementsByTagName("adSoyad").item(0);
    // check "adSoyad"...
    assertEquals("adim soyadim", adSoyadElement.getFirstChild().getNodeValue());

    // get kullaniciAdi element from Musteri element...
    Element kullaniciElement =
        (Element) musteriElement.getElementsByTagName("kullaniciAdi").item(0);
    // check "kullaniciAdi"...
    assertEquals("kullaniciAdim", kullaniciElement.getFirstChild().getNodeValue());

    // check the number of elements of musteri...
    NodeList nodeList = musteriElement.getChildNodes();
    assertEquals(4, nodeList.getLength());
  }
Пример #2
0
  public void testCreateMusteriSchemaModel() throws Exception {
    // create an instance of Musteri schema model
    POSchemaManager musteriSchemaManager = MusteriSchemaManager.getInstance();
    // create a musteri model...
    Document musteriModel = musteriSchemaManager.getSchemaModel();

    // asserting musteri model isnot null
    assertNotNull(musteriModel);

    // get the schema element..
    Element schemaElement = musteriModel.getDocumentElement();
    // assert that schema element is not null
    assertNotNull(schemaElement);

    // get the complex type..
    Element musteriComplexType =
        (Element) musteriModel.getElementsByTagName(XSD_PREFIX + ":" + COMPLEX_TYPE).item(0);
    // assert personel complex type element is not null...
    assertNotNull(musteriComplexType);

    // get sequence element..
    Element sequenceElement =
        (Element) musteriModel.getElementsByTagName(XSD_PREFIX + ":" + SEQUENCE).item(0);
    // assert sequence element is not null...
    assertNotNull(sequenceElement);

    // get adSoyad element from sequence element...
    Element firstElementOfSequence = (Element) sequenceElement.getFirstChild();
    // assert name and the type are equal..
    assertEquals("adSoyad", firstElementOfSequence.getAttribute(NAME));
    assertEquals("xsd:" + "string", firstElementOfSequence.getAttribute(TYPE));

    // assert number of the elements are equal to 4.
    assertEquals(4, sequenceElement.getElementsByTagName("xsd:" + ELEMENT).getLength());
  }
Пример #3
0
  public void testWriteInstanceTo() throws Exception {
    // create musteri schema builder.
    POSchemaManager musteriSchemaManager = MusteriSchemaManager.getInstance();
    // create an example musteri...
    Musteri musteri = createExampleMusteri();
    // create xml instance of example musteri...
    Document dvdInstance = musteriSchemaManager.createInstanceXML(musteri);

    // write dvd schema model to screen;
    musteriSchemaManager.writeInstanceTo(dvdInstance, System.out);
  }