diff options
Diffstat (limited to 'common-app-api/src/test')
3 files changed, 80 insertions, 76 deletions
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 1a062576dc..50c2b79d63 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -29,9 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.StringEscapeUtils; -import org.jsoup.Jsoup; -import org.jsoup.safety.Whitelist; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.util.GeneralUtility; @@ -40,7 +38,6 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.common.util.YamlToObjectConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.w3c.dom.html.HTMLStyleElement; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -62,7 +59,9 @@ public class CommonUtilsTest { assertTrue(ValidationUtils.validateComponentNamePattern("1111222")); assertFalse(ValidationUtils.validateComponentNamePattern("11!11222")); assertFalse(ValidationUtils.validateComponentNamePattern("111|`1222")); - + assertFalse(ValidationUtils.validateComponentNamePattern(".")); + assertFalse(ValidationUtils.validateComponentNamePattern("")); + assertTrue(ValidationUtils.validateComponentNamePattern("s")); } @Test @@ -104,38 +103,38 @@ public class CommonUtilsTest { assertFalse(ValidationUtils.validateIconLength("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs")); } - // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed -// @Test -// public void testValidateProjectCode() { -// -// assertTrue(ValidationUtils.validateProjectCode("15555")); -// assertTrue(ValidationUtils.validateProjectCode("12434501")); -// assertTrue(ValidationUtils.validateProjectCode("00000")); -// assertFalse(ValidationUtils.validateProjectCode("something")); -// assertFalse(ValidationUtils.validateProjectCode("som ething")); -// assertFalse(ValidationUtils.validateProjectCode("3255 656")); -// assertFalse(ValidationUtils.validateProjectCode("43535t636")); -// assertFalse(ValidationUtils.validateProjectCode("098&656")); -// } + @Test + public void testValidateProjectCode() { + + assertTrue(ValidationUtils.validateProjectCode("15555")); + assertTrue(ValidationUtils.validateProjectCode("12434501")); + assertTrue(ValidationUtils.validateProjectCode("00000")); + assertTrue(ValidationUtils.validateProjectCode("something")); + assertTrue(ValidationUtils.validateProjectCode("som ething")); + assertTrue(ValidationUtils.validateProjectCode("3255 656")); + assertTrue(ValidationUtils.validateProjectCode("43535t636")); + assertFalse(ValidationUtils.validateProjectCode("098&656")); + } @Test public void testValidateProjectCodeLength() { + assertTrue(ValidationUtils.validateProjectCodeLegth("00000")); assertFalse(ValidationUtils.validateProjectCodeLegth("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs")); + } - // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed -// @Test -// public void testValidateContactId() { -// -// assertTrue(ValidationUtils.validateContactId("ml7889")); -// assertTrue(ValidationUtils.validateContactId("Ml7889")); -// assertTrue(ValidationUtils.validateContactId("ml788r")); -// assertFalse(ValidationUtils.validateContactId("something")); -// assertFalse(ValidationUtils.validateContactId("mlk111")); -// assertFalse(ValidationUtils.validateContactId("12ml89")); -// assertFalse(ValidationUtils.validateContactId("!!78900")); -// } + @Test + public void testValidateContactId() { + + assertTrue(ValidationUtils.validateContactId("ml7889")); + assertTrue(ValidationUtils.validateContactId("Ml7889")); + assertTrue(ValidationUtils.validateContactId("ml788r")); + assertTrue(ValidationUtils.validateContactId("something")); + assertTrue(ValidationUtils.validateContactId("mlk111")); + assertTrue(ValidationUtils.validateContactId("12ml89")); + assertFalse(ValidationUtils.validateContactId("!!78900")); + } @Test public void testRemoveHtml() { @@ -242,8 +241,8 @@ public class CommonUtilsTest { public void validateStringNotEmptyTest() { assertTrue(ValidationUtils.validateStringNotEmpty("fsdlfsdlk")); assertFalse(ValidationUtils.validateStringNotEmpty("")); - assertFalse(ValidationUtils.validateStringNotEmpty(" ")); - assertFalse(ValidationUtils.validateStringNotEmpty(" ")); + assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); + assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); } @Test @@ -475,13 +474,13 @@ public class CommonUtilsTest { String str = yaml.dump(parameters); log.debug(str); } - + @Test public void yamlValidTest() { StringBuffer sb = new StringBuffer(); sb.append("key: \"!@;/?:&=+$,_.~*'()[]\""); - byte[] payload = sb.toString().getBytes();// Base64.decodeBase64(sb.toString()); + byte[] payload = sb.toString().getBytes(); YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); @@ -492,7 +491,7 @@ public class CommonUtilsTest { public void testRemoveOnlyHtmlTags() { assertEquals("gooboo", HtmlCleaner.stripHtml("<b>goo<b></b></b><b>boo</b>")); - String str = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>"); + /*String str = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>");*/ String stripHtmlAndEscape = HtmlCleaner.stripHtml("<esofer><b>goo<b></b><</b><b>boo</b>"); assertEquals("<esofer>goo<boo", stripHtmlAndEscape); diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java index aa3b2e4083..e27e442e84 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/TestExternalConfiguration.java @@ -67,23 +67,26 @@ public class TestExternalConfiguration { ExternalConfiguration.setConfigDir("src/test/resources/config"); ExternalConfiguration.listenForChanges(); - configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName()); + configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), + ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName()); } @Test public void testReadConfigurationFile() { - ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() { + ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, + new FileChangeCallback() { - public void reconfigure(BasicConfiguration obj) { - // TODO Auto-generated method stub - log.debug("In reconfigure of {}", obj); - } + public void reconfigure(BasicConfiguration obj) { + // TODO Auto-generated method stub + log.debug("In reconfigure of {}", obj); + } - }); + }); - TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener); + TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, + configurationListener); assertTrue(testConfiguration != null); log.debug("{}", testConfiguration); @@ -96,16 +99,18 @@ public class TestExternalConfiguration { @Test public void testNotExistConfigurationFile() { - ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() { + ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, + new FileChangeCallback() { - public void reconfigure(BasicConfiguration obj) { - // TODO Auto-generated method stub - log.debug("In reconfigure of {}", obj); - } + public void reconfigure(BasicConfiguration obj) { + // TODO Auto-generated method stub + log.debug("In reconfigure of {}", obj); + } - }); + }); - TestNotExistConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestNotExistConfiguration.class, configurationListener); + TestNotExistConfiguration testConfiguration = configurationSource + .getAndWatchConfiguration(TestNotExistConfiguration.class, configurationListener); assertTrue(testConfiguration == null); @@ -114,21 +119,23 @@ public class TestExternalConfiguration { @Test public void testUpdateConfigurationFile() { - ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() { + ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, + new FileChangeCallback() { - public void reconfigure(BasicConfiguration obj) { - // TODO Auto-generated method stub - log.debug("In reconfigure of {}", obj); - // assertEquals(((TestConfiguration)obj).getBeSslPort(), - // 8444); + public void reconfigure(BasicConfiguration obj) { + // TODO Auto-generated method stub + log.debug("In reconfigure of {}", obj); + // assertEquals(((TestConfiguration)obj).getBeSslPort(), + // 8444); - // assertTrue(((TestConfiguration)obj).getBeSslPort() == - // 8444); - } + // assertTrue(((TestConfiguration)obj).getBeSslPort() == + // 8444); + } - }); + }); - TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, configurationListener); + TestConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(TestConfiguration.class, + configurationListener); assertTrue(testConfiguration != null); log.debug("{}", testConfiguration); @@ -141,13 +148,13 @@ public class TestExternalConfiguration { } private void updateFileContent() { - File file = new File(ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName() + File.separator + "test-configuration.yaml"); + File file = new File(ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName() + + File.separator + "test-configuration.yaml"); replaceFile(file); try { Thread.sleep(5000); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -181,7 +188,6 @@ public class TestExternalConfiguration { try { br.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -189,7 +195,6 @@ public class TestExternalConfiguration { try { fr.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -197,7 +202,6 @@ public class TestExternalConfiguration { try { out.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -205,7 +209,6 @@ public class TestExternalConfiguration { try { fw.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -215,16 +218,18 @@ public class TestExternalConfiguration { @Test public void testReadDistributionEngineConfigurationFile() { - ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, new FileChangeCallback() { + ConfigurationListener configurationListener = new ConfigurationListener(TestConfiguration.class, + new FileChangeCallback() { - public void reconfigure(BasicConfiguration obj) { - // TODO Auto-generated method stub - log.debug("In reconfigure of ", obj); - } + public void reconfigure(BasicConfiguration obj) { + // TODO Auto-generated method stub + log.debug("In reconfigure of ", obj); + } - }); + }); - DistributionEngineConfiguration deConfiguration = configurationSource.getAndWatchConfiguration(DistributionEngineConfiguration.class, configurationListener); + DistributionEngineConfiguration deConfiguration = configurationSource + .getAndWatchConfiguration(DistributionEngineConfiguration.class, configurationListener); assertTrue(deConfiguration != null); log.debug("{}", deConfiguration); diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java index 340bca9f1d..d45a61cebb 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java @@ -51,11 +51,11 @@ public class YamlTest { @Test public void testValidYamlBase64() { - assertTrue(yamlToObjectConverter.isValidYaml(Base64.encodeBase64(validYaml.getBytes()))); + assertTrue(yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(validYaml.getBytes()))); } @Test public void testInvalidYamlBase64() { - assertFalse(yamlToObjectConverter.isValidYaml(Base64.encodeBase64(invalidYaml.getBytes()))); + assertFalse(yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(invalidYaml.getBytes()))); } } |