KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jca > test > DeploymentUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jca.test;
23
24 import java.net.URL JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26
27 import org.jboss.test.JBossTestCase;
28
29
30 /**
31  * DeploymentUnitTestCase.java
32  *
33  *
34  * Created: Fri Nov 22 14:01:07 2002
35  *
36  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
37  * @version
38  */

39
40 public class DeploymentUnitTestCase extends JBossTestCase
41 {
42
43    public DeploymentUnitTestCase(String JavaDoc name)
44    {
45       super(name);
46    }
47
48    public void testMCFDefaultValues() throws Exception JavaDoc
49    {
50       ObjectName JavaDoc mcfName = new ObjectName JavaDoc("jboss.jca:service=ManagedConnectionFactory,name=JBossTestCF");
51       deploy("jbosstestadapter.rar");
52       try
53       {
54          deploy("testadapter-ds.xml");
55          try
56          {
57             assertTrue("MCF should be registered", getServer().isRegistered(mcfName));
58             assertTrue("IntegerProperty should be 2, is " + getAttribute(mcfName, "IntegerProperty"), new Integer JavaDoc(2).equals(getAttribute(mcfName, "IntegerProperty")));
59             assertTrue("BooleanProperty should be false, is " + getAttribute(mcfName, "BooleanProperty"), Boolean.FALSE.equals(getAttribute(mcfName, "BooleanProperty")));
60             assertTrue("DoubleProperty should be 5.5, is " + getAttribute(mcfName, "DoubleProperty"), new Double JavaDoc(5.5).equals(getAttribute(mcfName, "DoubleProperty")));
61             assertTrue("UrlProperty should be 'http://www.jboss.org', is " + getAttribute(mcfName, "UrlProperty"), new URL JavaDoc("http://www.jboss.org").equals(getAttribute(mcfName, "UrlProperty")));
62
63             assertTrue("DefaultIntegerProperty should be 3, is " + getAttribute(mcfName, "DefaultIntegerProperty"), new Integer JavaDoc(3).equals(getAttribute(mcfName, "DefaultIntegerProperty")));
64
65
66          }
67          finally
68          {
69             undeploy("testadapter-ds.xml");
70          } // end of try-catch
71
}
72       finally
73       {
74          undeploy("jbosstestadapter.rar");
75       } // end of try-catch
76

77    }
78
79    private Object JavaDoc getAttribute(ObjectName JavaDoc mcfName, String JavaDoc attrName) throws Exception JavaDoc
80    {
81       return getServer().invoke(mcfName,
82                                 "getManagedConnectionFactoryAttribute",
83                                 new Object JavaDoc[] {attrName},
84                                 new String JavaDoc[] {String JavaDoc.class.getName()});
85    }
86
87 }// DeploymentUnitTestCase
88
Popular Tags