/*
 * JBoss, the OpenSource J2EE webOS
 * 
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.test.jca.xads;

import java.sql.SQLException;

import javax.naming.InitialContext;
import javax.sql.DataSource;

import org.jboss.system.ServiceMBeanSupport;

public class Test extends ServiceMBeanSupport implements TestMBean
{
   public Test()
   {
      System.setProperty("org.jboss.test.jca.xads.SomeProperty", "${org.jboss.test.jca.xads.SomeProperty2}");
      System.setProperty("org.jboss.test.jca.xads.SomeProperty2", "DOUBLE REPLACEMENT");
      System.setProperty("org.jboss.test.jca.xads.BackSlash", "\\");
   }
   
   public void test() throws Exception
   {
      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup("java:/TestXADS");
      try
      {
         ds.getConnection();
      }
      catch (SQLException expected)
      {
         Throwable t = expected;
         while (t.getCause() != null)
            t = t.getCause();
         
         if (t instanceof SQLException == false)
            throw new RuntimeException("Wrong exception: ", t);
      }
   }
}
