Giter Club home page Giter Club logo

Comments (10)

lordofthejars avatar lordofthejars commented on July 30, 2024 2

I will try to do today, if I finish one thing :) if not then hope that during this week. Sorry :)

from nosql-unit.

tinesoft avatar tinesoft commented on July 30, 2024

Any updates on this? :(

from nosql-unit.

lordofthejars avatar lordofthejars commented on July 30, 2024

No idea, why this is happening in this case, notice that for example here https://github.com/lordofthejars/nosql-unit/blob/master/nosqlunit-demo/src/test/java/com/lordofthejars/nosqlunit/demo/mongodb/WhenYouFindAllBooks.java I am using two tests. Can you debug https://github.com/lordofthejars/nosql-unit/blob/master/nosqlunit-mongodb/src/main/java/com/lordofthejars/nosqlunit/mongodb/MongoOperation.java tocheck what is happening to MongoClient?

from nosql-unit.

tinesoft avatar tinesoft commented on July 30, 2024

The connection to Mongo obtained from Spring, is closed in AbstractNoSqlTestRule#apply()'s finally block, after the first test method has run. So subsequent attempts to insert data in following tests failed because the connection is closed (in fact, there is a safety assertion: isTrue("open", !isClosed()); in Mongo impl. to ensure that).

In your example, the second test method use the DELETE_ALL strategy (and not a CLEAN_INSERT or INSERT as in my use case): so there is no 2nd attempt to insert data in the db, just a deletion.

Besides, your are using a newMongoDbRule().defaultEmbeddedMongoDb()
to get the MongoDbRule, which internally used a inMemoryMongoDb Fongo implementation (not a real remote db as in my use case...).

As i have mentioned, the Fongo implementation works great, simply because there is no isTrue("open", !isClosed()); assertion as in the Mongo's.

from nosql-unit.

lordofthejars avatar lordofthejars commented on July 30, 2024

I see, I think that the problem happens because of Spring integration, because then the Mongo Client is started by Spring but closed by NoSQLUnit. I will need to figure out if there is a way to detect this

from nosql-unit.

tinesoft avatar tinesoft commented on July 30, 2024

Yep. Maybe SpringMongoDbRule should override close() to do nothing... and let Spring manage the closing when destroying the context at the end of the tests?

That's the workaround i've implemented for my tests...

from nosql-unit.

lordofthejars avatar lordofthejars commented on July 30, 2024

Yes I think this is right. Can you provide a PR?

from nosql-unit.

tinesoft avatar tinesoft commented on July 30, 2024

Sure, i will push it tonight

from nosql-unit.

stefluhh avatar stefluhh commented on July 30, 2024

Hello @lordofthejars

when is this fix to be expected to be included into a release?

from nosql-unit.

smirzai avatar smirzai commented on July 30, 2024

The change does not exist in the latest release of the maven:
https://mvnrepository.com/artifact/com.lordofthejars/nosqlunit-mongodb/1.0.0-rc.5 and it dates back to more than a year ago.
Is there any more recent repository for maven artifacts ?

from nosql-unit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.