Guest User

Untitled

a guest
Mar 22nd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.81 KB | None | 0 0
  1. //Define Groovy Utils and holder for validating the XML reponse content
  2. import com.eviware.soapui.SoapUI
  3. import com.eviware.soapui.settings.HttpSettings
  4. import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
  5.  
  6.  
  7.  
  8.  
  9. def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
  10. // create new instance of your class
  11. def mailSender = new SendMailTLS(log: log);
  12. // send the mail passing the status code
  13.  
  14. def holder
  15. log.info "Response :" + messageExchange.responseContent
  16. if (null != messageExchange.responseContent) {
  17.  
  18. holder = groovyUtils.getXmlHolder(messageExchange.responseContent)
  19. //Define the NameSpace
  20. holder.namespaces["ns"] = "http://www.crm.org/CustomerService/"
  21.  
  22. //Get the Value of the Node 'GetMember' and assign to a variable
  23. def getMemberResponse = holder.getNodeValue("//ns:RetrieveCustomerByCriteriaResponse/customers/id")
  24.  
  25. //print the value of the GetMember Response
  26. log.info "GetMember Response status : " + getMemberResponse
  27.  
  28.  
  29.  
  30. def timeOutLimit = 30000
  31. def timeTaken = messageExchange.timeTaken;
  32. mailSender.sendMail(getMemberResponse, timeTaken, timeOutLimit);
  33.  
  34. }else{
  35.  
  36. mailSender.sendMail("Failure", 10, 0);
  37. }
  38. import java.util.Properties;
  39. import javax.mail.Message;
  40. import javax.mail.MessagingException;
  41. import javax.mail.PasswordAuthentication;
  42. import javax.mail.Session;
  43. import javax.mail.Transport;
  44. import javax.mail.internet.InternetAddress;
  45. import javax.mail.internet.MimeMessage;
  46.  
  47. // define the class
  48. class SendMailTLS {
  49.  
  50. def log
  51. public void sendMail(String MemberResponse, long timeTaken, int timeOutLimit) {
  52.  
  53.  
  54. final String username = "sairam.svu@gmail.com";
  55. final String password = "sai123@123";
  56.  
  57. Properties props = new Properties();
  58. props.put("mail.smtp.auth", "true");
  59. props.put("mail.smtp.starttls.enable", "true");
  60. props.put("mail.smtp.host", "smtp.gmail.com");
  61. props.put("mail.smtp.port", "587");
  62.  
  63. Session session = Session.getInstance(props,
  64. new javax.mail.Authenticator() {
  65. protected PasswordAuthentication getPasswordAuthentication() {
  66. return new PasswordAuthentication(username, password);
  67. }
  68. });
  69.  
  70. try {
  71.  
  72. Message message = new MimeMessage(session);
  73. message.setFrom(new InternetAddress("sairam.svu@gmail.com"));
  74. message.setRecipients(Message.RecipientType.TO,
  75. InternetAddress.parse("sairam.svu@gmail.com"));
  76.  
  77. log.info "Time Taken :" + timeTaken
  78.  
  79. if (timeTaken > timeOutLimit) {
  80. message.setSubject("Time out alert for Customer");
  81. message.setText(" IT Monitoring System " +"nn Assignment Groupt:tt Platform Services" +"nn Notification Typet: tt PROBLEM" +"nn SERVICE URLtt:tt http://http://localhost:7001/basic-osb-service/proxy/CustomerService"+ "nn Response Timet:tt" + timeTaken + "ms" + "nn The service is behaving in an unexpected manner ");
  82. Transport.send(message);
  83.  
  84. } else if (!MemberResponse.equals("2")) {
  85. message.setSubject("Status alert for Customer");
  86. message.setText(" IT Monitoring System " +"nn Assignment Groupt:tt Platform Services" +"nn Notification Typet: tt PROBLEM" +"nn SERVICE URLtt:tt http://http://localhost:7001/basic-osb-service/proxy/CustomerService"+ "nn Response Timet:tt" + timeTaken + "ms" + "nn The service is behaving in an unexpected manner ");
  87.  
  88. Transport.send(message);
  89.  
  90. }
  91.  
  92. } catch (MessagingException e) {
  93. throw new RuntimeException(e);
  94. }
  95. }
  96. }
  97.  
  98. Running SoapUI TestRunner for [CustomerService-Testing]
  99. directory: C:Program FilesSmartBearSoapUI-5.0.0bin
  100. command: cmd.exe /C testrunner.bat -sCustomerServiceTestSuite - cCustomerServiceTestCase -r -a -j -fD:SoapuiReports C:UserssaiDesktopTestingjobsCustomerService-Testing-soapui-project.xml
  101. SoapUI 5.0.0 TestCase Runner
  102. Configuring log4j from [C:Program FilesSmartBearSoapUI- 5.0.0binsoapui-log4j.xml]
  103. 23:32:19,127 INFO [DefaultSoapUICore] initialized soapui-settings from [C:Userssaisoapui-settings.xml]
  104. 23:32:23,176 INFO [WsdlProject] Loaded project from [file:/C:/Users/sai/Desktop/Testingjobs/CustomerService-Testing-soapui- project.xml]
  105. 23:32:25,443 INFO [SoapUITestCaseRunner] Running SoapUI tests in project [CustomerService-Testing]
  106. 23:32:25,444 INFO [SoapUITestCaseRunner] Running TestCase [CustomerServiceTestCase]
  107. 23:32:25,566 INFO [SoapUITestCaseRunner] Running SoapUI testcase [CustomerServiceTestCase]
  108. 23:32:25,587 INFO [SoapUITestCaseRunner] running step [Test Request]
  109. 23:32:27,112 ERROR [WsdlSubmit] Exception in request: java.net.SocketTimeoutException: Read timed out
  110. 23:32:27,113 ERROR [SoapUI] An error occurred [Read timed out], see error log for details
  111. 23:32:27,137 INFO [SoapUITestCaseRunner] Assertion [SOAP Response] has status UNKNOWN
  112. 23:32:27,138 INFO [SoapUITestCaseRunner] Assertion [Schema Compliance] has status UNKNOWN
  113. 23:32:27,138 INFO [SoapUITestCaseRunner] Assertion [Not SOAP Fault] has status UNKNOWN
  114. 23:32:27,139 INFO [SoapUITestCaseRunner] Assertion [Script Assertion] has status UNKNOWN
  115. 23:32:27,140 ERROR [SoapUITestCaseRunner] Test Request failed, exporting to [D:SoapuiReportsCustomerServiceTestSuite-CustomerServiceTestCase- Test_Request-0-FAILED.txt]
  116. java.net.SocketTimeoutException: Read timed out
  117. at java.net.SocketInputStream.socketRead0(Native Method)
  118. at java.net.SocketInputStream.read(Unknown Source)
  119. at java.net.SocketInputStream.read(Unknown Source)
  120. at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
  121. at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:110)
  122. at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:264)
  123. at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
  124. at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
  125. at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
  126. at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
  127. at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
  128. at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$SoapUIHttpRequestExecutor.doReceiveResponse(HttpClientSupport.java:147)
  129. at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
  130. at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:633)
  131. at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:454)
  132. at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
  133. at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
  134. at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.execute(HttpClientSupport.java:247)
  135. at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport.execute(HttpClientSupport.java:362)
  136. at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.submitRequest(HttpClientRequestTransport.java:324)
  137. at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:237)
  138. at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:127)
  139. at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:80)
  140. at com.eviware.soapui.impl.wsdl.WsdlRequest.submit(WsdlRequest.java:242)
  141. at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.run(WsdlTestRequestStep.java:419)
  142. at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
  143. at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
  144. at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
  145. at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
  146. at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
  147. at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:81)
  148. at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:645)
  149. at com.eviware.soapui.tools.SoapUITestCaseRunner.runTestCase(SoapUITestCaseRunner.java:602)
  150. at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:399)
  151. at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:162)
  152. at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:93)
  153. at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:119)
  154. 23:32:27,253 INFO [SoapUITestCaseRunner] Finished running SoapUI testcase [CustomerServiceTestCase], time taken: 1530ms, status: FAILED
  155. 23:32:27,254 INFO [SoapUITestCaseRunner] TestCase [CustomerServiceTestCase] finished with status [FAILED] in 1530ms
  156.  
  157. SoapUI 5.0.0 TestCaseRunner Summary
  158. -----------------------------
  159. Time Taken: 1809ms
  160. Total TestSuites: 0
  161. Total TestCases: 1 (1 failed)
  162. Total TestSteps: 1
  163. Total Request Assertions: 4
  164. Total Failed Assertions: 0
  165. Total Exported Results: 1
  166. 23:32:27,321 ERROR [SoapUITestCaseRunner] java.lang.Exception: TestCase [CustomerServiceTestCase] failed without assertions
  167.  
  168. 23:32:27,322 ERROR [SoapUI] An error occurred [TestCase [CustomerServiceTestCase] failed without assertions
  169. ], see error log for details
  170. java.lang.Exception: TestCase [CustomerServiceTestCase] failed without assertions
  171.  
  172. at com.eviware.soapui.tools.SoapUITestCaseRunner.throwFailureException(SoapUITestCaseRunner.java:535)
  173. at com.eviware.soapui.tools.SoapUITestCaseRunner.runRunner(SoapUITestCaseRunner.java:437)
  174. at com.eviware.soapui.tools.AbstractSoapUIRunner.run(AbstractSoapUIRunner.java:162)
  175. at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:93)
  176. at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:119)
Add Comment
Please, Sign In to add comment