Hi Amalka, We can get rid of this static block easily by making AutomationConfigurationReader a proper singleton class.
Handling exceptions in static block depends on the context of application. Given the situation you can only throw run time exception but it's not always recommended. Thanks, Krishantha. On Wed, Aug 6, 2014 at 9:26 PM, Amalka Subasinghe <[email protected]> wrote: > > Hi, > > Depending on the execution mode, ConfigurationMismatchException is thrown > from the validation code; but the test continues and then fails in a > different place because the exception was not handled properly in > AutomationConfiguration static block. > > org.apache.maven.surefire.util.SurefireReflectionException: > java.lang.reflect.InvocationTargetException; nested exception is > java.lang.reflect.InvocationTargetException: null > java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) > at > org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) > at > org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) > at > org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) > at > org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) > Caused by: java.lang.RuntimeException: Error on initializing test > environment > at > org.wso2.carbon.automation.engine.testlisteners.TestExecutionListener.handleException(TestExecutionListener.java:70) > at > org.wso2.carbon.automation.engine.testlisteners.TestExecutionListener.onExecutionStart(TestExecutionListener.java:52) > at org.testng.TestNG.runExecutionListeners(TestNG.java:1032) > at org.testng.TestNG.run(TestNG.java:983) > at > org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:178) > at > org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) > at > org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:96) > ... 9 more > Caused by: java.lang.NullPointerException > at > org.wso2.carbon.automation.engine.context.DefaultInstance.getDefaultManager(DefaultInstance.java:103) > at > org.wso2.carbon.automation.engine.context.AutomationContext.<init>(AutomationContext.java:143) > at > org.wso2.carbon.automation.engine.testlisteners.TestExecutionListener.onExecutionStart(TestExecutionListener.java:41) > ... 14 more > > Thanks > Amalka > > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Krishantha Samaraweera Senior Technical Lead - Test Automation Mobile: +94 77 7759918 WSO2, Inc.; http://wso2.com/ lean . enterprise . middlewear.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
