Allon Mureinik has uploaded a new change for review. Change subject: webadmin: LinuxMountPointValidationTest ......................................................................
webadmin: LinuxMountPointValidationTest Introducing an initial revision of a test suite for LinuxMountPointValidation. Change-Id: If6c159073b6e76097d769f02b05d8860196f83e6 Signed-off-by: Allon Mureinik <[email protected]> --- A frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/validation/LinuxMountPointValidationTest.java 1 file changed, 106 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/30964/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/validation/LinuxMountPointValidationTest.java b/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/validation/LinuxMountPointValidationTest.java new file mode 100644 index 0000000..4346a81 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/validation/LinuxMountPointValidationTest.java @@ -0,0 +1,106 @@ +package org.ovirt.engine.ui.uicommonweb.validation; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +@SuppressWarnings("HardcodedFileSeparator") +public class LinuxMountPointValidationTest { + private LinuxMountPointValidation validation; + + @Before + public void setUp() { + validation = new LinuxMountPointValidation() { + /** Stubbed away to avoid GWT dependencies*/ + @Override + protected String composeMessage() { + return null; + } + }; + } + + + /* Tests */ + + @Test + public void validWithFQDN() { + assertValid("somehost.somedoamin.com:/path/to/dir"); + } + + @Test + public void validWithFQDNNumber() { + assertValid("somehost.somedoamin.com2:/path/to/dir"); + } + + @Test + public void validWithHost() { + assertValid("somehost:/path/to/dir"); + } + + @Test + public void validWithHostNumber() { + assertValid("somehost2:/path/to/dir"); + } + + @Test + public void validWithIP() { + assertValid("1.2.3.4:/path/to/dir"); + } + + @Test + public void invalidJustPath() { + assertInvalid("/path/to/dir"); + } + + @Test + public void invalidColonAndPath() { + assertInvalid(":/path/to/dir"); + } + + @Test + public void invalidJustFQDN() { + assertInvalid("somehost.somedomain.com"); + } + + @Test + public void invalidColonAndFQDN() { + assertInvalid("somehost.somedomain.com:"); + } + + @Test + public void invalidJustHost() { + assertInvalid("somehost"); + } + + @Test + public void invalidColonAndHost() { + assertInvalid("somehost:"); + } + + @Test + public void invalidJustIP() { + assertInvalid("1.2.3.4"); + } + + @Test + public void invalidColonAndIP() { + assertInvalid("1.2.3.4:"); + } + + + /* Helper Methods */ + + private void assertValid(String path) { + assertTrue(pathToBool(path)); + } + + private void assertInvalid(String path) { + assertFalse(pathToBool(path)); + } + + private boolean pathToBool(String path) { + return validation.validate(path).getSuccess(); + } +} -- To view, visit http://gerrit.ovirt.org/30964 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If6c159073b6e76097d769f02b05d8860196f83e6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
