KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > JBossClusteredTestCase


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;
23
24 import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
25
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29 /**
30  * Derived implementation of JBossTestCase for cluster testing.
31  *
32  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
33  * @author Scott.Stark@jboss.org
34  * @version $Revision: 58506 $
35  * @see org.jboss.test.JBossTestCase
36  */

37 public class JBossClusteredTestCase extends JBossTestCase
38 {
39    JBossTestClusteredServices clusterServices;
40    
41    // Static --------------------------------------------------------
42

43    /**
44     * Overriden to return JBossTestServices as the test delegate.
45     */

46    public static AbstractTestDelegate getDelegate(Class JavaDoc clazz) throws Exception JavaDoc
47    {
48       AbstractTestDelegate delegate = new JBossTestClusteredServices(clazz);
49       return delegate;
50    }
51
52    public JBossClusteredTestCase(String JavaDoc name)
53    {
54       super(name);
55    }
56    
57    @Override JavaDoc
58    protected void setUp() throws Exception JavaDoc
59    {
60       super.setUp();
61       clusterServices = (JBossTestClusteredServices) delegate;
62    }
63    
64    // Public --------------------------------------------------------
65

66    
67
68    public void testServerFound() throws Exception JavaDoc
69    {
70       if (deploymentException != null)
71          throw deploymentException;
72       assertTrue("Server was not found", getServers() != null);
73    }
74
75
76    public RMIAdaptor[] getAdaptors() throws Exception JavaDoc
77    {
78       return clusterServices.getAdaptors();
79    }
80
81    public String JavaDoc[] getServers() throws Exception JavaDoc
82    {
83       return clusterServices.getServers();
84    }
85
86    public String JavaDoc[] getNamingURLs() throws Exception JavaDoc
87    {
88       return clusterServices.getNamingURLs();
89    }
90    public String JavaDoc[] getHANamingURLs() throws Exception JavaDoc
91    {
92       return clusterServices.getHANamingURLs();
93    }
94    public String JavaDoc[] getHttpURLs() throws Exception JavaDoc
95    {
96       return clusterServices.getHttpURLs();
97    }
98
99    protected void deploy(RMIAdaptor server, String JavaDoc name) throws Exception JavaDoc
100    {
101       clusterServices.deploy(server, name);
102    }
103
104    protected void redeploy(RMIAdaptor server, String JavaDoc name) throws Exception JavaDoc
105    {
106       clusterServices.redeploy(server, name);
107    }
108
109    protected void undeploy(RMIAdaptor server, String JavaDoc name) throws Exception JavaDoc
110    {
111       clusterServices.undeploy(server, name);
112    }
113
114    public static Test getDeploySetup(final Test test, final String JavaDoc jarName)
115       throws Exception JavaDoc
116    {
117       return new JBossTestClusteredSetup(test, jarName);
118    }
119
120    public static Test getDeploySetup(final Class JavaDoc clazz, final String JavaDoc jarName)
121       throws Exception JavaDoc
122    {
123       TestSuite suite = new TestSuite();
124       suite.addTest(new TestSuite(clazz));
125       return getDeploySetup(suite, jarName);
126    }
127
128    /**
129     * anil
130     */

131    public void setServerNames(String JavaDoc[] snames) throws Exception JavaDoc
132    {
133       ((JBossTestClusteredServices) delegate).setServerNames(snames);
134    }
135
136    // Private -------------------------------------------------------
137

138    // Inner classes -------------------------------------------------
139

140 }
141
Popular Tags