コード例 #1
0
 @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) {
   }
 }
コード例 #2
0
  @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) {
    }
  }