I'm looking to use JUnit to test some code that uses Hibernate to connect to my DB (SQL Server). Although I can do this using a hibernate.cfg.xml file I want to create a super class I can extend so I won't have to rewrite code for each TestCase subclass. To make a long story short I'm trying to define some JNDI properties that will include my DB name, username, and password so hibernate can pick it up. I think I have the basics in my setUp method, but I keep getting a NoIntialContextException. My method is below:
-
-
protected void setUp() throws Exception {
-
Properties env = new Properties();
-
-
env.put(Context.INITIAL_CONTEXT_FACTORY, "javax.naming.spi.InitialContextFactory");
-
env.put("connection.url", "jdbc:sqlserver://localhost:1433;databaseName=DevDB;userName=u53rn@me;password=p@55w0rd;SelectMethod=cursor");
-
Context ctx = new InitialContext(env);
-
}
-
I can't seem to figure out what I'm doing wrong. All the tutorial I've been looking at have not helped. Any ideas?