* org.onap.aai\r
* ================================================================================\r
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * Copyright © 2017-2018 Amdocs\r
+ * Copyright © 2017-2018 Nokia\r
* ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
*\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
*\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
*/\r
package org.onap.aai.datarouter.util;\r
\r
+import java.io.File;\r
+import java.net.URISyntaxException;\r
+import org.junit.Assert;\r
import org.junit.Test;\r
\r
-import static org.junit.Assert.*;\r
-\r
+/**\r
+ * @author Bogumil Zebek\r
+ */\r
public class DataRouterPropertiesTest {\r
\r
@Test\r
- public void testGet(){\r
- DataRouterProperties.get("key");\r
+ public void shouldLoadDataRouterPropertiesProperlyWhenSpecifiedFileExists() throws URISyntaxException {\r
+ // given\r
+ ClassLoader classLoader = getClass().getClassLoader();\r
+\r
+ File file = new File(\r
+ classLoader.getResource("data-router.properties").getFile()\r
+ );\r
+\r
+ // when\r
+ DataRouterProperties.loadProperties(file);\r
+\r
+ //then\r
+ Assert.assertEquals("value1", DataRouterProperties.get("key1"));\r
+ Assert.assertEquals("value2", DataRouterProperties.get("key2"));\r
+ Assert.assertNull(DataRouterProperties.get("nonExistingKey"));\r
+ }\r
+\r
+ @Test\r
+ public void shouldCreateEmptyDataRouterPropertiesContainerWhenSpecifiedFileDoesNotExist() {\r
+ // given\r
+ File nonExistingFile = new File("nonExistingFile.properties");\r
+\r
+ // when\r
+ DataRouterProperties.loadProperties(nonExistingFile);\r
+\r
+ // then\r
+ Assert.assertNull(DataRouterProperties.get("key"));\r
}\r
}
\ No newline at end of file