예제 #1
0
  public void testAddUpdateDeleteNode() {
    System.err.println("testUpdateNode: BEGIN");

    boolean testSuccess = false;

    try {
      // TopoAPI topoApi = com.adventnet.nms.topodb.DBServer.topodb;
      TopoAPI topoApi = getHandle();

      boolean wasAdded = true;
      boolean wasUpdated = true;
      boolean wasDeleted = true;
      final int NUM_NODES = 100;

      for (int i = 1; (i <= NUM_NODES) && wasAdded; i++) {
        // MaxxanNode newNode = new MaxxanNode();
        Printer newNode = new Printer();
        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Node" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setIsSNMP(false);

        wasAdded = wasAdded & topoApi.addObject(newNode);

        if (wasAdded) {
          System.err.println("testAddUpdateDeleteNode: added node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT added");
        }

        ManagedObject updatedObject = (ManagedObject) topoApi.checkOut("Node" + i, 2);
        if (wasAdded) {
          wasUpdated = wasUpdated & topoApi.updateObject(updatedObject, false, false);
        }
        if (wasUpdated) {
          System.err.println("testAddUpdateDeleteNode: updated node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT updated");
        }
        // ManagedObject deleteObject = (ManagedObject)topoApi.checkOut("Node" + i);
        if (wasAdded & wasUpdated) {
          wasDeleted = wasDeleted & topoApi.deleteObject(updatedObject, true, true);
        }
        if (wasDeleted) {
          System.err.println("testAddUpdateDeleteNode: deleted node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT deleted");
        }
      }

      testSuccess = wasAdded & wasUpdated & wasDeleted;
    } catch (Exception exception) {
      System.err.println("testUpdateNode: " + exception.getMessage());

      testSuccess = false;
    }

    System.err.println("testAddUpdateDeleteNode: END");
  }
예제 #2
0
  public void testDelete() {
    System.err.println("testDelete: BEGIN");

    boolean testSuccess = false;

    try {
      // TopoAPI topoApi = com.adventnet.nms.topodb.DBServer.topodb;
      TopoAPI topoApi = getHandle();

      boolean wasAdded = true;
      boolean wasDeleted = true;

      final int NUM_NODES = 255;

      for (int i = 1; (i <= NUM_NODES) && wasAdded && wasDeleted; i++) {

        /*MaxxanNode newNode = new MaxxanNode();

        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Node" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setIsSNMP(false);*/
        Printer newNode = new Printer();
        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Printer4nd" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setConsoleDispBufferText("testval");

        wasAdded = wasAdded && topoApi.addObject(newNode);

        if (wasAdded) {
          System.err.println("testDelete: added node " + i);
        } else {
          System.err.println("testDelete: node " + i + " NOT added");
        }

        ManagedObject updatedObject = (ManagedObject) topoApi.checkOut("Printer4nd" + i);

        wasDeleted = wasDeleted && topoApi.deleteObject(updatedObject, false, true);
        if (wasDeleted) {
          System.err.println("testDelete: deleted node " + i);
        } else {
          System.err.println("testDelete: node " + i + " NOT deleted");
        }
      }

      testSuccess = wasAdded && wasDeleted;
    } catch (Exception exception) {
      System.err.println("testDelete: " + exception.getMessage());
      exception.printStackTrace();

      testSuccess = false;
    }

    System.err.println("testDelete: END");
  }
예제 #3
0
  public void testGetByName() {
    boolean getResult = true;
    ManagedObject getMo = null;
    TopoAPI api = getHandle();

    try {
      boolean wasAdded = true;
      final int NUM_NODES = 255;

      for (int i = 1; (i <= NUM_NODES) && wasAdded; i++) {
        /*MaxxanNode newNode = new MaxxanNode();

        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Node" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setIsSNMP(false);*/
        Printer newNode = new Printer();
        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Printerfortestgetbyname" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setConsoleDispBufferText("testval");

        wasAdded = wasAdded & api.addObject(newNode);

        if (wasAdded) {
          System.err.println("testGetByName: added node " + i);
        } else {
          System.err.println("testGetByName: node " + i + " NOT added");
        }
      }
      java.util.Iterator objNames = api.getCompleteList().iterator();
      while (objNames.hasNext()) {
        String moName = (String) objNames.next();
        getMo = api.checkOut(moName, 2);
        // api.updateObject(getMo,false,false);
        api.unlock(getMo);

        if (getMo == null) {
          System.out.println("testGetByName  : The mo is null");
          getResult = false;
        } else {
          System.out.println("testGetByName : Sucessfully got the mo " + getMo.getName());
          getMo = null;
        }
      }
    } catch (Exception getEx) {
      System.out.println("testGetByName : Exception in testGetByName " + getEx);
    }
  }