@Test
 public void testGetInstanceById() {
   try {
     InstanceElement ie = applicationElement.getInstanceById(ODSHelper.asODSLongLong(58));
     assertEquals("1/3 Octave - Zusammenfassung", ie.getName());
     assertEquals(58, ODSHelper.asJLong(ie.getId()));
   } catch (AoException e) {
     fail(e.reason);
   }
   // query non existing instance
   try {
     applicationElement.getInstanceById(ODSHelper.asODSLongLong(999));
     fail("AoException expected");
   } catch (AoException e) {
   }
 }
 @Test
 public void testGetInstanceByName() {
   try {
     InstanceElement ie = applicationElement.getInstanceByName("1/3 Octave - Zusammenfassung");
     assertEquals(58, ODSHelper.asJLong(ie.getId()));
     ie = applicationElement.getInstanceByName("not existing instance");
     assertEquals(null, ie);
   } catch (AoException e) {
     fail(e.reason);
   }
   // check duplicate names
   try {
     ApplicationElement aeParamSet =
         applicationElement.getApplicationStructure().getElementByName("pas");
     aeParamSet.getInstanceByName("basic");
     fail("AoException expected");
   } catch (AoException e) {
   }
 }
 @Test
 public void testCreateInstance() {
   try {
     InstanceElement ie = applicationElement.createInstance("new_instance");
     assertEquals(83, ODSHelper.asJLong(ie.getId()));
     InstanceElement ie1 = applicationElement.createInstance("ni1");
     assertEquals(84, ODSHelper.asJLong(ie1.getId()));
     applicationElement.removeInstance(ie.getId(), false);
     InstanceElement ie2 = applicationElement.createInstance("ni2");
     assertEquals(85, ODSHelper.asJLong(ie2.getId()));
     applicationElement.removeInstance(ie1.getId(), false);
     applicationElement.removeInstance(ie2.getId(), false);
   } catch (AoException e) {
     fail(e.reason);
   }
 }
  @Test
  public void testRemoveInstance() {
    try {
      assertEquals(3, applicationElement.getInstances("*").getCount());

      InstanceElement ie = applicationElement.createInstance("new_instance");
      assertEquals(4, applicationElement.getInstances("*").getCount());
      assertEquals(ie.getName(), applicationElement.getInstanceByName("new_instance").getName());

      applicationElement.removeInstance(ie.getId(), false);
      assertEquals(3, applicationElement.getInstances("*").getCount());
      assertEquals(null, applicationElement.getInstanceByName("new_instance"));
    } catch (AoException e) {
      fail(e.reason);
    }
    // non existing instance
    try {
      applicationElement.removeInstance(ODSHelper.asODSLongLong(999), false);
      fail("AoException expected");
    } catch (AoException e) {
    }
  }