I've started developing a Java API which will consist of just a couple of public classes, a public interface (to be implemented by the user and used as a callback, like in the Observer pattern). All other classes are private and/or package-private. I want to use TDD. For all the reasons stated in other posts on this site, I want to write unit tests only for my public classes and methods.
My problem is that this API is going to be implemented, in its first version, using a REST client from a suitable third-party library to get data from a remote web app. In a future version, it might possibly use JDBC or a NoSQL facility to obtain the data from a remote database instead. The thing is, that's all private implementation detail that's not exposed to the user.
How do I mock the remote connections for unit testing? Ordinarily, I would use Dependency Injection. That is, I would pass a connection object (the dependency) to the public class, and that connection object would be either the real connection object or the mock one. The thing is, I don't want to complicate the API that is exposed to the user, just so that I can test its workings. I don't want the user to have to know there is such a thing as a "connection object" that needs to be passed to the public class. So I don't think I can use DI in my case. What can I do instead?