Forum Discussion

aly's avatar
aly
New Contributor
9 years ago

Is it possible to connect to mongodb from soapUI opensource using овис component?

Hello

I am now trying to connect to mongoDB from SoapUI opensource.
I have seen some topics here but have not seen if it is possible to resolve this problem with JDBC component in SOAPUI?

What I am doing is:

I downloaded mongoDB drivers from here http://mvnrepository.com/artifact/org.mongodb/mongo-java-driver
and here http://mvnrepository.com/artifact/com.gmongo/gmongo
and have put them to soapui/bin/ext folder

Then I use jdbc component to connect. I type there the following: 

 

2016-01-29_0935.png

 

but I always get the following issue, even if I try other format of connection string. Has anyone resolved this issue?
Would be very grateful for your help!

7 Replies

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi aly,

     

    I never thought of using the JDBC TestStep to talk to MongoDB, quite interesting! I normally use the GMongo wrapper or MongoDB REST API instead, the GMongo Groovy TestStep option works great.

     

    But, if I was to try I think the driver class and connection string may be different if you try a raw JDBC connection e.g.

     

    JDBC Driver class name:  mongodb.jdbc.MongoDriver
    URL format:              jdbc:mongo://<serverName>/<databaseName>

    Taken from http://www.unityjdbc.com/mongojdbc/mongo_jdbc.php

     

    Also I don't think adding the GMongo driver is necessary for the JDBC test step, as the GMongo is just a nice Groovy wrapper that the JDBC TestStep cant use - think it might just need the JDBC driver details. 

     

    Does that help?

     

    Otherwise, using the GMongo Groovy TestStep Option is suprisingly nice e.g. something like (needs both the drivers you added)

     

     import com.gmongo.GMongo
         
    def mongo = new GMongo('localhost:27017')
    def db = mongo.getDB('test')
    
    log.info db.invoices.findOne()

    I have also seen other use the Mongo REST API as a service / Request TestStep option - https://docs.mongodb.org/ecosystem/tools/http-interfaces/

     

    Hope this helps,

    Rup

     

    Incidentally, 

    • TesterNo1's avatar
      TesterNo1
      Contributor

      i tried  and could not get it working from JDBC test step.In jDBC step, you can write groovy code to access the db.It requires gmongo jar file and mongo diver  to be copied to ext folder .

      • rupert_anderson's avatar
        rupert_anderson
        Valued Contributor

        Hi,

         

        Ok, I got this update from you on the ticket:

         

        http://screencast.com/t/WjMwVq54c

         

        Check teh screencast.It worked for me.

         

        Which looked cool, nice screencast to share the solution :-)

         

        But then you edited the post with whats currently written there - so are you ok with this now? or are there still problems I can try to help with?

         

        Thanks,

        Rupert