summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-10-14 16:46:25 +0530
committerSelvasundaram <selvam@gluster.com>2011-11-07 18:23:41 +0530
commit42c8f489c680b6028c0849551422a2fddaa1e936 (patch)
treead731c98f24bf7ee677f603f17c952a716c5770c
parent25a1d358bb97bf696c9f916d0bafb20898c54a02 (diff)
Migrate brick dialog shows the source and target brick selection dynamically in the message.
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java6
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java16
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java82
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java304
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java205
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java483
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java35
7 files changed, 1124 insertions, 7 deletions
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java
index db416c07..a8667c33 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java
@@ -54,7 +54,11 @@ public class MigrateBrickAction extends AbstractActionDelegate {
action.setEnabled(false);
if (selectedEntity instanceof Brick) {
bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class);
- brick = bricks.iterator().next();
+ if ( bricks.iterator().hasNext()) {
+ brick = bricks.iterator().next();
+ } else {
+ brick = null;
+ }
action.setEnabled(brick != null);
}
}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java
index dfa0b352..e3d9d2bf 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java
@@ -147,18 +147,18 @@ public class MigrateBrickPage1 extends WizardPage {
this.volume = volume;
this.fromBrick = brick;
setTitle("Migrate Brick [" + volume.getName() + "]");
- setPageDescription(null, null);
+ setPageDescription(fromBrick.getQualifiedName(), null);
setPageComplete(false);
}
private void setPageDescription(String source, String target) {
- if (source == null || source.equals("")) {
- source = "From Brick";
+ if (source == null) {
+ source = "";
}
- if (target == null || target.equals("")) {
- target = "To Brick";
+ if (target == null) {
+ target = "";
}
- setDescription("Migrate volume data from \"" + source + "\" to \"" + target + "\"");
+ setDescription("Migrate data from \"" + source + "\" to \"" + target + "\"");
}
private Object getSelectedItem(TableViewer tableViewer) {
@@ -194,6 +194,9 @@ public class MigrateBrickPage1 extends WizardPage {
public String getTargetBrickDir() {
Device targetDevice = (Device)getSelectedItem(tableViewerTo);
+ if (targetDevice == null) {
+ return "";
+ }
return targetDevice.getQualifiedBrickName(volume.getName());
}
@@ -290,6 +293,7 @@ public class MigrateBrickPage1 extends WizardPage {
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshButtonStatus();
+ setPageDescription(getSourceBrickDir(), getTargetBrickDir());
}
});
return tableViewer;
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java
new file mode 100644
index 00000000..81c7a601
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java
@@ -0,0 +1,82 @@
+package com.gluster.storage.management.core.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gluster.storage.management.core.model.Alert.ALERT_TYPES;
+
+/**
+ * The class <code>AlertTest</code> contains tests for the class <code>{@link Alert}</code>.
+ *
+ * @generatedBy CodePro at 10/17/11 3:32 PM
+ * @author root
+ * @version $Revision: 1.0 $
+ */
+public class AlertTest {
+
+ /**
+ * Run the void copyFrom(Alert) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 3:32 PM
+ */
+ @Test
+ public void testCopyFrom_1()
+ throws Exception {
+ Alert fixture = new Alert(ALERT_TYPES.DISK_USAGE_ALERT, "server1:sda",
+ Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [85% used] in disk [server1:sda]");
+ Alert alert = new Alert();
+ alert.copyFrom(fixture);
+
+ assertEquals(fixture.getId(), alert.getId());
+ assertEquals(fixture.getReference(), alert.getReference());
+ assertEquals(fixture.getType(), alert.getType());
+ assertEquals(fixture.getMessage(), alert.getMessage());
+ assertNotNull(alert);
+ }
+
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 10/17/11 3:32 PM
+ */
+ @Before
+ public void setUp()
+ throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 10/17/11 3:32 PM
+ */
+ @After
+ public void tearDown()
+ throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 10/17/11 3:32 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(AlertTest.class);
+ }
+} \ No newline at end of file
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java
new file mode 100644
index 00000000..329ee926
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java
@@ -0,0 +1,304 @@
+package com.gluster.storage.management.core.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gluster.storage.management.core.model.Brick.BRICK_STATUS;
+
+/**
+ * The class <code>BrickTest</code> contains tests for the class <code>{@link Brick}</code>.
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ * @author root
+ * @version $Revision: 1.0 $
+ */
+public class BrickTest {
+ /**
+ * Run the void copyFrom(Brick) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testCopyFrom_1()
+ throws Exception {
+ Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs");
+ Brick newBrick = new Brick();
+ newBrick.copyFrom(fixture);
+
+ assertEquals(fixture.getServerName(), newBrick.getServerName());
+ assertEquals(fixture.getBrickDirectory(), newBrick.getBrickDirectory());
+ assertEquals(fixture.getStatus(), newBrick.getStatus());
+ assertEquals(fixture.getQualifiedName(), newBrick.getQualifiedName());
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testEquals_1()
+ throws Exception {
+ Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs");
+ Brick newBrick = new Brick();
+ newBrick.copyFrom(fixture);
+
+ boolean result = fixture.equals(newBrick);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testEquals_2()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+ Brick newBrick = new Brick();
+ newBrick.copyFrom(fixture);
+
+ boolean result = fixture.equals(newBrick);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testEquals_3()
+ throws Exception {
+ Brick fixture = new Brick("", BRICK_STATUS.ONLINE, "");
+ Brick newBrick = new Brick();
+ newBrick.copyFrom(fixture);
+
+ boolean result = fixture.equals(newBrick);
+ assertTrue(result);
+ }
+
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_1()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String filterString = "Ser";
+ boolean caseSensitive = true;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_2()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String filterString = "ser";
+ boolean caseSensitive = true;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertEquals(result, false);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_3()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String filterString = "Ser";
+ boolean caseSensitive = false;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_4()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.ONLINE, "/md1/test");
+
+ String filterString = "ser";
+ boolean caseSensitive = false;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_5()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String filterString = "";
+ boolean caseSensitive = false;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testFilter_6()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String filterString = "";
+ boolean caseSensitive = true;
+
+ boolean result = fixture.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+
+ /**
+ * Run the String getQualifiedName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testGetQualifiedName_1()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String result = fixture.getQualifiedName();
+
+ assertNotNull(result);
+ assertEquals(result, "Server2:/md1/test");
+ }
+
+ /**
+ * Run the String getQualifiedName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testGetQualifiedName_2()
+ throws Exception {
+ Brick fixture = new Brick("", BRICK_STATUS.OFFLINE, "");
+
+ String result = fixture.getQualifiedName();
+
+ assertNotNull(result);
+ assertEquals(result, ":");
+ }
+
+
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Test
+ public void testToString_1()
+ throws Exception {
+ Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test");
+
+ String result = fixture.toString();
+
+ assertNotNull(result);
+ assertEquals(result, "Server2:/md1/test");
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @Before
+ public void setUp()
+ throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ @After
+ public void tearDown()
+ throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 10/17/11 4:39 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(BrickTest.class);
+ }
+} \ No newline at end of file
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java
new file mode 100644
index 00000000..c2e488b1
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java
@@ -0,0 +1,205 @@
+package com.gluster.storage.management.core.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gluster.storage.management.core.model.Brick.BRICK_STATUS;
+import com.gluster.storage.management.core.model.Device.DEVICE_STATUS;
+import com.gluster.storage.management.core.model.Device.DEVICE_TYPE;
+import com.gluster.storage.management.core.model.Server.SERVER_STATUS;
+import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE;
+import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
+import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE;
+
+/**
+ * The class <code>ClusterTest</code> contains tests for the class <code>{@link Cluster}</code>.
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ * @author root
+ * @version $Revision: 1.0 $
+ */
+public class ClusterTest {
+ private Cluster fixture;
+
+ public List<Disk> getDisks(Server server) {
+ List<Disk> disks = new ArrayList<Disk>();
+ disks.add(new Disk(server, "sda", "", 12456.0, 0.0, DEVICE_STATUS.UNINITIALIZED));
+ Disk disk = new Disk(server, "sdb1", "/export", 134342456.0, 120343.0, DEVICE_STATUS.INITIALIZED);
+ disk.setType(DEVICE_TYPE.DATA);
+ disks.add(disk);
+ disk = new Disk(server, "sdc2", "/export", 876534346.0, 56334.0, DEVICE_STATUS.INITIALIZED);
+ disk.setType(DEVICE_TYPE.DATA);
+ disks.add(disk);
+ return disks;
+ }
+
+ public List<GlusterServer> getServers() {
+ List<GlusterServer> servers = new ArrayList<GlusterServer>();
+ GlusterServer server1 = new GlusterServer("Server1", null, SERVER_STATUS.ONLINE, 2, 10, 8, 4);
+ server1.addDisks(getDisks(server1));
+ servers.add(server1);
+
+ GlusterServer server2 = new GlusterServer("Server2", null, SERVER_STATUS.ONLINE, 1, 90, 10, 9);
+ server2.addDisks(getDisks(server2));
+ servers.add(server2);
+
+ GlusterServer server3 = new GlusterServer("Server3", null, SERVER_STATUS.ONLINE, 4, 50, 6, 5);
+ server3.addDisks(getDisks(server3));
+ servers.add(server3);
+
+ GlusterServer server4 = new GlusterServer("Server4", null, SERVER_STATUS.ONLINE, 2, 40, 4, 3);
+ server4.addDisks(getDisks(server4));
+ servers.add(server4);
+
+ return servers;
+ }
+
+ public List<Brick> getBricks(String volumeName) {
+ List<Brick> bricks = new ArrayList<Brick>();
+ Brick brick1 = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/"+volumeName);
+ bricks.add(brick1);
+ Brick brick2 = new Brick("Server2", BRICK_STATUS.ONLINE, "/sdb1/"+volumeName);
+ bricks.add(brick2);
+ Brick brick3 = new Brick("Server3", BRICK_STATUS.ONLINE, "/sdc1/"+volumeName);
+ bricks.add(brick3);
+ Brick brick4 = new Brick("Server4", BRICK_STATUS.OFFLINE, "/sda2/"+volumeName);
+ bricks.add(brick4);
+ return bricks;
+ }
+
+
+ public void populateVolumes(Cluster cluster) {
+ Volume volume1 = new Volume("Songs", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET,
+ VOLUME_STATUS.ONLINE);
+ volume1.addBricks(getBricks(volume1.getName()));
+ cluster.addVolume(volume1);
+
+ Volume volume2 = new Volume("Movie", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET,
+ VOLUME_STATUS.ONLINE);
+ volume2.addBricks(getBricks(volume1.getName()));
+ cluster.addVolume(volume2);
+
+ Volume volume3 = new Volume("graphics", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.INFINIBAND,
+ VOLUME_STATUS.ONLINE);
+ volume3.addBricks(getBricks(volume1.getName()));
+ cluster.addVolume(volume3);
+
+ Volume volume4 = new Volume("cartoon", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET,
+ VOLUME_STATUS.ONLINE);
+ volume4.addBricks(getBricks(volume1.getName()));
+ cluster.addVolume(volume4);
+ return;
+ }
+
+ /**
+ * Run the double getDiskSpaceInUse() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @Test
+ public void testGetDiskSpaceInUse_1()
+ throws Exception {
+ double result = fixture.getDiskSpaceInUse();
+
+ assertEquals(706708.0, result, 0.1);
+ }
+
+ /**
+ * Run the GlusterServer getServer(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @Test
+ public void testGetServer_1()
+ throws Exception {
+ GlusterServer result = fixture.getServer("Server1");
+
+ assertNotNull(result);
+ assertEquals("Server1", result.getName());
+ assertEquals(2, result.getNumOfCPUs());
+ assertEquals(3, result.getNumOfDisks() );
+ }
+
+ /**
+ * Run the double getTotalDiskSpace() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @Test
+ public void testGetTotalDiskSpace_1()
+ throws Exception {
+ double result = fixture.getTotalDiskSpace();
+ assertEquals(4043557032.0, result, 0.1); // Including unformatted disks(!)
+ }
+
+ /**
+ * Run the double getTotalDiskSpace() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @Test
+ public void testGetVolume_1()
+ throws Exception {
+ populateVolumes(fixture);
+ Volume result = fixture.getVolume("Songs");
+ assertNotNull(result);
+ assertTrue(result instanceof Volume);
+ }
+
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @Before
+ public void setUp()
+ throws Exception {
+ fixture = new Cluster();
+ fixture.setServers(getServers());
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ @After
+ public void tearDown()
+ throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 10/18/11 2:53 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(ClusterTest.class);
+ }
+} \ No newline at end of file
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java
new file mode 100644
index 00000000..b6bd4142
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java
@@ -0,0 +1,483 @@
+package com.gluster.storage.management.core.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gluster.storage.management.core.model.Device.DEVICE_STATUS;
+import com.gluster.storage.management.core.model.Device.DEVICE_TYPE;
+
+/**
+ * The class <code>DiskTest</code> contains tests for the class <code>{@link Disk}</code>.
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ * @author root
+ * @version $Revision: 1.0 $
+ */
+public class DiskTest {
+ private Disk disk;
+
+ /**
+ * Run the Disk() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testDisk_1()
+ throws Exception {
+
+ // add additional test code here
+ assertNotNull(disk);
+ assertEquals(new Double(5000.0), disk.getSpace());
+ assertEquals("Hitachi HTS72323 ATA", disk.getDescription());
+ assertEquals(true, disk.isReady());
+ assertEquals(null, disk.getDiskInterface());
+ assertEquals(null, disk.getRaidDisks());
+ assertEquals(false, disk.hasPartitions());
+ assertEquals(new Double(3000.0), disk.getSpaceInUse());
+ assertEquals(DEVICE_TYPE.DATA, disk.getType());
+ assertEquals(new Double(2000.0), disk.getFreeSpace());
+ assertEquals(DEVICE_STATUS.INITIALIZED, disk.getStatus());
+ assertEquals("Server1:sda1", disk.getQualifiedName());
+ assertEquals(true, disk.isInitialized());
+ assertEquals(false, disk.hasErrors());
+ assertEquals("Server1", disk.getServerName());
+ assertEquals("Available", disk.getStatusStr());
+ assertEquals(false, disk.isUninitialized());
+ assertEquals("/md0/sda1", disk.getMountPoint());
+ assertEquals("ext4", disk.getFsType());
+ assertEquals("3.2.3", disk.getFsVersion());
+ assertEquals("sda1", disk.toString());
+ assertEquals("sda1", disk.getName());
+ assertTrue(disk.getParent() instanceof Server);
+ }
+
+ /**
+ * Run the Disk(Server,String,String,Double,Double,DEVICE_STATUS) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testDisk_2()
+ throws Exception {
+ Server server = new Server();
+ String name = "";
+ String mountPoint = "";
+ Double space = new Double(1.0);
+ Double spaceInUse = new Double(1.0);
+ Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED;
+
+ Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status);
+
+ // add additional test code here
+ assertNotNull(newDisk);
+ assertEquals(new Double(1.0), newDisk.getSpace());
+ assertEquals(null, newDisk.getDescription());
+ assertEquals(false, newDisk.isReady());
+ assertEquals(null, newDisk.getDiskInterface());
+ assertEquals(null, newDisk.getRaidDisks());
+ assertEquals(false, newDisk.hasPartitions());
+ assertEquals(new Double(1.0), newDisk.getSpaceInUse());
+ assertEquals(null, newDisk.getType());
+ assertEquals(new Double(0.0), newDisk.getFreeSpace());
+ assertEquals("null:", newDisk.getQualifiedName());
+ assertEquals(true, newDisk.isInitialized());
+ assertEquals(false, newDisk.hasErrors());
+ assertEquals(null, newDisk.getServerName());
+ assertEquals("Initialized", newDisk.getStatusStr());
+ assertEquals(false, newDisk.isUninitialized());
+ assertEquals("", newDisk.getMountPoint());
+ assertEquals(null, newDisk.getFsType());
+ assertEquals(null, newDisk.getFsVersion());
+ assertEquals("", newDisk.toString());
+ assertEquals("", newDisk.getName());
+ }
+
+ /**
+ * Run the void copyFrom(Disk) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testCopyFrom_1()
+ throws Exception {
+ Disk newDisk = new Disk();
+ newDisk.copyFrom(disk);
+
+ assertEquals(newDisk.getSpace(), disk.getSpace());
+ assertEquals(newDisk.getDescription(), disk.getDescription());
+ assertEquals(newDisk.isReady(), disk.isReady());
+ assertEquals(newDisk.getDiskInterface(), disk.getDiskInterface());
+ assertEquals(newDisk.getRaidDisks(), disk.getRaidDisks());
+ assertEquals(newDisk.hasPartitions(), disk.hasPartitions());
+ assertEquals(newDisk.getSpaceInUse(), disk.getSpaceInUse());
+ assertEquals(newDisk.getType(), disk.getType());
+ assertEquals(newDisk.getFreeSpace(), disk.getFreeSpace());
+ assertEquals(newDisk.getStatus(), disk.getStatus());
+ assertEquals(newDisk.getQualifiedName(), disk.getQualifiedName());
+ assertEquals(newDisk.isInitialized(), disk.isInitialized());
+ assertEquals(newDisk.hasErrors(), disk.hasErrors());
+ assertEquals(newDisk.getServerName(), disk.getServerName());
+ assertEquals(newDisk.getStatusStr(), disk.getStatusStr());
+ assertEquals(newDisk.isUninitialized(), disk.isUninitialized());
+ assertEquals(newDisk.getMountPoint(), disk.getMountPoint());
+ assertEquals(newDisk.getFsType(), disk.getFsType());
+ assertEquals(newDisk.getFsVersion(), disk.getFsVersion());
+ assertEquals(newDisk.toString(), disk.toString());
+ assertEquals(newDisk.getName(), disk.getName());
+ assertEquals(newDisk.getParent(), disk.getParent());
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testEquals_1()
+ throws Exception {
+
+ Disk newDisk = new Disk();
+ newDisk.copyFrom(disk);
+ boolean result = newDisk.equals(disk);
+
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testEquals_2()
+ throws Exception {
+ Server server = new Server();
+ String name = "";
+ String mountPoint = "";
+ Double space = new Double(1.0);
+ Double spaceInUse = new Double(1.0);
+ Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED;
+ Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status);
+
+ boolean result = newDisk.equals(disk);
+
+ assertTrue(!result);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testEquals_3()
+ throws Exception {
+
+ Disk newDisk = new Disk();
+ newDisk.copyFrom(disk);
+ boolean result = newDisk.equals(disk);
+
+ assertTrue(result);
+ }
+
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testFilter_1()
+ throws Exception {
+ String filterString = "";
+ boolean caseSensitive = true;
+ boolean result = disk.filter(filterString, caseSensitive);
+
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testFilter_2()
+ throws Exception {
+ String filterString = "Serv";
+ boolean caseSensitive = true;
+ boolean result = disk.filter(filterString, caseSensitive);
+
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testFilter_3()
+ throws Exception {
+ String filterString = "serv";
+ boolean caseSensitive = true;
+ boolean result = disk.filter(filterString, caseSensitive);
+ assertTrue(!result);
+ }
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testFilter_4()
+ throws Exception {
+ String filterString = "hitachi";
+ boolean caseSensitive = true;
+
+ boolean result = disk.filter(filterString, caseSensitive);
+ assertTrue(!result);
+ }
+
+
+
+ /**
+ * Run the boolean filter(String,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testFilter_5()
+ throws Exception {
+ String filterString = "hitachi";
+ boolean caseSensitive = false;
+
+ boolean result = disk.filter(filterString, caseSensitive);
+ assertTrue(result);
+ }
+
+
+ /**
+ * Run the Double getSpace() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testGetSpace_1()
+ throws Exception {
+ Double result = disk.getSpace();
+ assertNotNull(result);
+ assertTrue(result instanceof Double);
+ }
+
+
+
+ /**
+ * Run the Double getSpaceInUse() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testGetSpaceInUse_1()
+ throws Exception {
+ Double result = disk.getSpaceInUse();
+ assertNotNull(result);
+ assertTrue(result instanceof Double);
+ }
+
+
+ /**
+ * Run the boolean hasPartitions() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testHasPartitions_1()
+ throws Exception {
+ disk.setPartitions(new ArrayList<Partition>());
+ boolean result = disk.hasPartitions();
+ assertTrue(!result);
+ }
+
+
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_1()
+ throws Exception {
+ boolean result = disk.isReady();
+ System.out.println("Disk status is [" + result + "] on [" + disk.getName() +"] and Status is [" + disk.getStatusStr() +"]");
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_2()
+ throws Exception {
+ disk.setPartitions(new ArrayList<Partition>());
+ boolean result = disk.isReady();
+ assertTrue(result);
+ }
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_3()
+ throws Exception {
+ disk.setStatus(DEVICE_STATUS.UNINITIALIZED);
+ boolean result = disk.isReady();
+ assertTrue(!result);
+ }
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_4()
+ throws Exception {
+ disk.setStatus(DEVICE_STATUS.IO_ERROR);
+ boolean result = disk.isReady();
+
+ assertTrue(!result);
+ }
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_5()
+ throws Exception {
+ disk.setStatus(DEVICE_STATUS.INITIALIZING);
+ boolean result = disk.isReady();
+
+ assertTrue(!result);
+ }
+
+ /**
+ * Run the boolean isReady() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Test
+ public void testIsReady_6()
+ throws Exception {
+ disk.setStatus(DEVICE_STATUS.UNKNOWN);
+ boolean result = disk.isReady();
+
+ assertTrue(!result);
+ }
+
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @Before
+ public void setUp()
+ throws Exception {
+ Server server = new Server("Server1", null, 2, 25D, 5000D, 2000D);
+ disk = new Disk(server,"sda1", "/md0/sda1", 5000D, 3000D, DEVICE_STATUS.INITIALIZED);
+ disk.setDescription("Hitachi HTS72323 ATA");
+ disk.setFsType("ext4");
+ disk.setFsVersion("3.2.3");
+ disk.setType(DEVICE_TYPE.DATA);
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ @After
+ public void tearDown()
+ throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(DiskTest.class);
+ }
+} \ No newline at end of file
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java
new file mode 100644
index 00000000..159ff256
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java
@@ -0,0 +1,35 @@
+package com.gluster.storage.management.core.model;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * The class <code>TestAll</code> builds a suite that can be used to run all
+ * of the tests within its package as well as within any subpackages of its
+ * package.
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ * @author root
+ * @version $Revision: 1.0 $
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ BrickTest.class,
+ ClusterTest.class,
+ AlertTest.class,
+ DiskTest.class,
+})
+public class TestAll {
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 10/19/11 6:26 PM
+ */
+ public static void main(String[] args) {
+ JUnitCore.runClasses(new Class[] { TestAll.class });
+ }
+}