File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing database/data layer without using Singleton method

 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just wondering if I don't use the Singleton pattern for the Data layer of my project, for testing purposes, would I have to use multiple instances of my Data class in testing? For example, say I was testing multiple-threading of 50 reads. Would I need to say, test 25 of these using 1 instance of my Data class and another 25 say using another instance? Basically what I am asking is if one does not use the Singleton pattern for the Data layer when accessing the database functionality, do they have to test application across multiple instances of the data class?
Thanks.
 
Roel De Nijs
Sheriff
Posts: 9180
77
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

That all depends on how you implemented concurrency and making the data class thread-safe. Many possible alternatives to ensure thread-safety, so it has little added value to elaborate on it.

And if you implemented your singleton pattern correctly, you should not be able to create multiple instances of your Data class. Because if you can do it for testing purposes, you also can do it for developing (production) purposes and the singleton pattern is not applied correctly.

Kind regards,
Roel

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic