Contributions
Validating response through templates
Hello Experts, In my project, I have test cases and each test case has multiple APIs being called sequentially. I have created templates for the API from where the requests contents are being pulled: void insertRequestContent(tCase){ for(int tStepCount=0; tStepCount<tCase.getTestStepCount(); tStepCount++){ def tStep=tCase.getTestStepAt(tStepCount) def tStepName=tStep.getLabel() def directory = new File(projectPath+"\\Templates") //path where I have stored the templates // for each file in the directory directory.eachFile{ file -> def templateName = file.getName() if(tStepName.startsWith(templateName.split("\\.")[0])){ //I have named the templates as *.txt files tStep.getTestRequest().setRequestContent(file.getText()) } } } } This is inserting the content of the request. The data which is being sent into these requests are parameterized usingCustom Properties. I am also executing the tests using testCase.run. Now my question is: I know the format of the response.Say, the format is: <Student> <StudentNo>1234</StudentNo> <StudentFirstName>ABC</StudentFirstName> <StudentLastName>XYZ</StudentLastName> <StudentGrade>5</StudentGrade> </Student> Can I create a template for this and validate the response data? The Groovy assertion script should pick the response tags from the template and validate each of the response data. I have both xml and JSON types ofresponses Thanks, Srikanth1.4KViews0likes3CommentsRe: Connection to MongoDB
Hi Rupert, I am sorry for the late reply. I was not able to use the solution you gave. There may be a reason for this: From my conversation with the architect, I understood that they are using Document DB in the background, on which they are using the Mongo DB adaptor. Ido not understand theimplementation. But, all I know is there is MongoDB layer over the Document DB. This may be the reason. I am still trying different ways to debug this. If I come across anything, I will post here. Thanks a lot for your help, Srikanth1.2KViews0likes1CommentRe: Connection to MongoDB
Hi Rupert, I will have to try this on Monday, once I am in office. def mongo = new GMongo(new MongoURI("mongodb://myUserAdmin:abc123@localhost/admin")) In this request, I am guessing it is: new MongoURI("mongodb://<username>:<password>@<db-address>:<port number>/<table>"? Thanks, Srikanth6.6KViews0likes2CommentsRe: Connection to MongoDB
Hi Rao and Rupert, Thanks for your replies. Two cases: 1) I have downloaded the ivy-2.2.0.jar and placed it in \SmartBear\SoapUI-5.2.1\lib and deleted gmongo-1.5.jar from \SmartBear\SoapUI-5.2.1\bin\ext folder 2) Having the gmongo-1.5.jar at \SmartBear\SoapUI-5.2.1\bin\ext and deleted the ivy-2.2.0.jar in the \SmartBear\SoapUI-5.2.1\lib Both cases I am getting the error (as mentioned in my message above) Thanks, Srikanth6.6KViews0likes6CommentsRe: Connection to MongoDB
Hi Rupert, As in your example, I am using this: import com.gmongo.* import com.mongodb.* import com.gmongo.GMongo import com.mongodb.MongoCredential def credential = MongoCredential.createMongoCRCredential("<username>", "<database>","<password>".toCharArray()) log.info "credential excepted" log.info credential def client = new MongoClient(new ServerAddress("<server address>",port), [credential]) log.info "client excepted" log.info client def mongo = new GMongo (client) log.info "mongo excepted" log.info mongo def db = mongo.getDB("<database>") log.info "db excepted" log.info db def collection = db.getCollection("<collection>") log.info "collection excepted" log.info collection log.info collection.findOne(<key1>:"<value1>").<key2> I am getting the error:ERROR:com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=<address>, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {java.net.SocketTimeoutException: Read timed out}}]. Using the log.info, I am getting the logstill "collection expected" and collection info. Hence, I am assuming, it connected but was not able to execute the last line. Also, in your example, the first line is: @Grab(group='com.gmongo', module='gmongo', version='1.3') I am not sure how to use this. Putting that in my script, the error comes up: java.lang.NoClassDefFoundError: org/apache/ivy/core/settings/IvySettings Thanks, Srikanth6.6KViews0likes9CommentsConnection to MongoDB
Hi All, I am trying to connect to MongoDB using Groovy. Here is what I have tried: import com.gmongo.GMongo def mongo = new GMongo("<server_name>:<port>") def db = mongo.getDB("<DB_Name>") def collection = db.getCollection("<Collection_Name>") log.info collection.findOne(<Key1>:<Value1>).<Key2> I am getting the value associated with Key2. However, this DB is installed in one of local machine and doesn't have authentication involved. The challenge I am facing is to connect to the DB (in cloud), which has authentication involved in it. Can someone guide me?6.9KViews0likes11Comments