Ejemplo n.º 1
0
  @Test
  public void info() {
    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.getName().equals(name));
  }
Ejemplo n.º 2
0
  @Test
  public void attributes() {
    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.xpath("NAME").equals(name));
  }
Ejemplo n.º 3
0
  @Test
  public void publish() {
    res = vrouter.publish();
    assertTrue(res.getErrorMessage(), !res.isError());

    vrouter.info();
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_U").equals("1"));
  }
Ejemplo n.º 4
0
  @Test
  public void delete() {
    res = vrouter.delete();
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.info();
    assertTrue(res.isError());
  }
Ejemplo n.º 5
0
  /** @throws java.lang.Exception */
  @Before
  public void setUp() throws Exception {
    res = VirtualRouter.allocate(client, template_str);

    int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
    vrouter = new VirtualRouter(oid, client);
  }
Ejemplo n.º 6
0
  @Test
  public void allocate() {
    vrouter.delete();

    res = VirtualRouter.allocate(client, template_str);
    assertTrue(res.getErrorMessage(), !res.isError());

    int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
    vrouter = new VirtualRouter(oid, client);

    vrouterPool.info();

    boolean found = false;
    for (VirtualRouter temp : vrouterPool) {
      found = found || temp.getName().equals(name);
    }

    assertTrue(found);
  }
Ejemplo n.º 7
0
  @Test
  public void chmod() {
    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    String owner_a = vrouter.xpath("PERMISSIONS/OWNER_A");
    String group_a = vrouter.xpath("PERMISSIONS/GROUP_A");

    res = vrouter.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0);
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_U").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_M").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_A").equals(owner_a));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_M").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_A").equals(group_a));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_M").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_A").equals("0"));
  }
Ejemplo n.º 8
0
  @Test
  public void instantiate() {
    VirtualMachinePool vmPool = new VirtualMachinePool(client);

    res = vmPool.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vmPool.getLength() == 0);

    String tmpl_str = "NAME = vrtemplate\n" + "CPU = 0.1\n" + "MEMORY = 64\n";

    res = Template.allocate(client, tmpl_str);
    assertTrue(res.getErrorMessage(), !res.isError());

    int tmplid = Integer.parseInt(res.getMessage());

    res = vrouter.instantiate(3, tmplid);
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vmPool.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vmPool.getLength() == 3);
  }
Ejemplo n.º 9
0
 /** @throws java.lang.Exception */
 @After
 public void tearDown() throws Exception {
   vrouter.delete();
 }
Ejemplo n.º 10
0
  @Test
  public void chown() {
    // Create a new User and Group
    res = User.allocate(client, "template_test_user", "password");
    assertTrue(res.getErrorMessage(), !res.isError());

    int uid = Integer.parseInt(res.getMessage());

    res = Group.allocate(client, "template_test_group");
    assertTrue(res.getErrorMessage(), !res.isError());

    int gid = Integer.parseInt(res.getMessage());

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.uid() == 0);
    assertTrue(vrouter.gid() == 0);

    res = vrouter.chown(uid, gid);
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.uid() == uid);
    assertTrue(vrouter.gid() == gid);

    res = vrouter.chgrp(0);

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.uid() == uid);
    assertTrue(vrouter.gid() == 0);
  }
Ejemplo n.º 11
0
  @Test
  public void chmod_octet() {
    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.chmod(640);
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_M").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_A").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_M").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_A").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_U").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_M").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_A").equals("0"));

    res = vrouter.chmod("147");
    assertTrue(res.getErrorMessage(), !res.isError());

    res = vrouter.info();
    assertTrue(res.getErrorMessage(), !res.isError());

    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_U").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_M").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OWNER_A").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_M").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/GROUP_A").equals("0"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_U").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_M").equals("1"));
    assertTrue(vrouter.xpath("PERMISSIONS/OTHER_A").equals("1"));
  }