diff options
author | Rob Daugherty <rd472p@att.com> | 2018-03-09 15:02:18 -0500 |
---|---|---|
committer | Rob Daugherty <rd472p@att.com> | 2018-03-09 15:08:14 -0500 |
commit | 96b5a685d0c3afddb632e4a68ca7483f933b55dc (patch) | |
tree | 246399de05a3d429bf45ef1e5af2b9b0218d99f3 /common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java | |
parent | 4475278c81668109b2b37a1d2720d8f2910641c4 (diff) |
Revert Reduce log noise/warnings
This reverts commit 327b17ab250b4c17cf3f91f5e4cd9bffd89f3d1e.
It is seriously impeding our ability complete the promised merge of AT&T
1802 code.
While I'm all for coding standards, if we are serious about using spaces
instead of tabs, then I think we need to (1) agree with the community when
this will happen, (2) do consistently in all files, and (3) enforce it.
Change-Id: Ib9b996f6b6c7d81ac9ac95d58b0c7d8cc39675ff
Issue-ID: SO-368
Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java')
-rw-r--r-- | common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java | 252 |
1 files changed, 119 insertions, 133 deletions
diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java index 5caa137d33..a814c4ea9c 100644 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java +++ b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java @@ -44,145 +44,131 @@ import org.openecomp.mso.properties.MsoPropertiesFactory; /** * This class implements test methods of the MsoPropertiesFactory features. + * + * */ public class MsoPropertiesFactoryConcurrencyTest { - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - public static final String MSO_PROP_ID = "TEST_PROP"; - public static final String PATH_MSO_PROP1 = MsoJavaProperties.class.getClassLoader(). - getResource("mso.properties") - .toString().substring(5); - public static final String PATH_MSO_PROP2 = MsoJavaProperties.class.getClassLoader(). - getResource("mso2.properties") - .toString().substring(5); - - /** - * This method is called before any test occurs. It creates a fake tree from - * scratch - * - * @throws MsoPropertiesException - */ - @BeforeClass - public static final void prepare() throws MsoPropertiesException { - // it's possible to have it already initialized, as tests are executed in the same JVM - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(MSO_PROP_ID, PATH_MSO_PROP1); - } - - private Callable<Integer> taskReload = new Callable<Integer>() { - @Override - public Integer call() { - try { - if (!msoPropertiesFactory.reloadMsoProperties()) { - return 1; - } - } catch (Exception e) { - e.printStackTrace(); - return 1; - } - return 0; - } - }; - - private Callable<Integer> taskRead = new Callable<Integer>() { - @Override - public Integer call() { - try { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_ID); - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", - "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", - "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", - "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", - "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", - "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", - "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", - "defaultValue"); - - assertEquals(property1, "MT"); - assertEquals(property2, "http://localhost:5000/v2.0"); - assertEquals(property3, "John"); - assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "1234"); - assertEquals(property7, "true"); - - } catch (MsoPropertiesException e) { - e.printStackTrace(); - return 1; - } - return 0; - } - }; - - private Callable<Integer> taskReadAll = new Callable<Integer>() { - @Override - public Integer call() { - try { - List<AbstractMsoProperties> msoPropertiesList = msoPropertiesFactory.getAllMsoProperties(); - String property1 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("does.not.exist", "defaultValue"); - String property6 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = ((MsoJavaProperties) msoPropertiesList.get(0)). - getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT"); - assertEquals(property2, "http://localhost:5000/v2.0"); - assertEquals(property3, "John"); - assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "1234"); - assertEquals(property7, "true"); - } catch (Exception e) { - e.printStackTrace(); - return 1; - } - return 0; - } - }; - - @Test - public final void testGetMsoProperties() - throws MsoPropertiesException, InterruptedException, ExecutionException, FileNotFoundException { - - List<Future<Integer>> list = new ArrayList<>(); - ExecutorService executor = Executors.newFixedThreadPool(20); - - for (int i = 0; i <= 100000; i++) { - - Future<Integer> futureResult = executor.submit(taskRead); - list.add(futureResult); - - futureResult = executor.submit(taskReload); - list.add(futureResult); - - futureResult = executor.submit(taskReadAll); - list.add(futureResult); - } - executor.shutdown(); - while (!executor.awaitTermination(5, TimeUnit.SECONDS)) { + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + public static final String MSO_PROP_ID = "TEST_PROP"; + public static final String PATH_MSO_PROP1 = MsoJavaProperties.class.getClassLoader().getResource("mso.properties") + .toString().substring(5); + public static final String PATH_MSO_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.properties") + .toString().substring(5); + + /** + * This method is called before any test occurs. It creates a fake tree from + * scratch + * + * @throws MsoPropertiesException + */ + @BeforeClass + public static final void prepare() throws MsoPropertiesException { + // it's possible to have it already initialized, as tests are executed in the same JVM + msoPropertiesFactory.removeAllMsoProperties (); + msoPropertiesFactory.initializeMsoProperties(MSO_PROP_ID, PATH_MSO_PROP1); + } + + private Callable<Integer> taskReload = new Callable<Integer>() { + @Override + public Integer call() { + try { + if (!msoPropertiesFactory.reloadMsoProperties()) { + return 1; + } + } catch (Exception e) { + e.printStackTrace (); + return 1; + } + return 0; + } + }; + + private Callable<Integer> taskRead = new Callable<Integer>() { + @Override + public Integer call() { + try { + MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_ID); + String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); + String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); + String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); + String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); + String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); + String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); + String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); + + assertEquals(property1, "MT"); + assertEquals(property2, "http://localhost:5000/v2.0"); + assertEquals(property3, "John"); + assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); + assertEquals(property5, "defaultValue"); + assertEquals(property6, "1234"); + assertEquals(property7, "true"); + + } catch (MsoPropertiesException e) { + e.printStackTrace (); + return 1; + } + return 0; + } + }; + + private Callable<Integer> taskReadAll = new Callable<Integer>() { + @Override + public Integer call() { + try { + List<AbstractMsoProperties> msoPropertiesList = msoPropertiesFactory.getAllMsoProperties(); + String property1 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); + String property2 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); + String property3 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); + String property4 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); + String property5 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("does.not.exist", "defaultValue"); + String property6 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.test", "defaultValue"); + String property7 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); + + assertEquals(property1, "MT"); + assertEquals(property2, "http://localhost:5000/v2.0"); + assertEquals(property3, "John"); + assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); + assertEquals(property5, "defaultValue"); + assertEquals(property6, "1234"); + assertEquals(property7, "true"); + } catch (Exception e) { + e.printStackTrace (); + return 1; + } + return 0; + } + }; + + @Test + public final void testGetMsoProperties() + throws MsoPropertiesException, InterruptedException, ExecutionException, FileNotFoundException { + + List<Future<Integer>> list = new ArrayList<>(); + ExecutorService executor = Executors.newFixedThreadPool(20); + + for (int i = 0; i <= 100000; i++) { + + Future<Integer> futureResult = executor.submit(taskRead); + list.add(futureResult); + + futureResult = executor.submit(taskReload); + list.add(futureResult); + + futureResult = executor.submit(taskReadAll); + list.add(futureResult); + } + executor.shutdown(); + while (!executor.awaitTermination(5, TimeUnit.SECONDS)) { ; } - for (Future<Integer> result : list) { - assertTrue(result.get().equals(0)); - } + for (Future<Integer> result : list) { + assertTrue(result.get().equals(0)); + } - } + } } |