How to instantiate a Singleton multiple times?
Posted
by Sebi
on Stack Overflow
See other posts from Stack Overflow
or by Sebi
Published on 2010-06-17T18:53:37Z
Indexed on
2010/06/17
19:03 UTC
Read the original article
Hit count: 169
I need a singleton in my code. I implemented it in Java and it works well. The reason I did it, is to ensure that in a mulitple environment, there is only one instance of this class.
But now I want to test my Singleton object locally with a Unit test. For this reason I need to simulate another instance of this Singleton (the object that would be from another device). So is there a possiblity to instantiate a Singleton a second time for testing purpose or do I have to mock it?
I'm not sure, but I think it could be possible by using a different class loader?
© Stack Overflow or respective owner