KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.Test;
25
26 /**
27  * Derived implementation of JBossTestSetup for cluster testing.
28  *
29  * @see org.jboss.test.JBossTestSetup
30  *
31  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
32  * @version $Revision: 58506 $
33  *
34  * <p><b>Revisions:</b>
35  *
36  * <p><b>12 avril 2002 Sacha Labourey:</b>
37  * <ul>
38  * <li> First implementation </li>
39  * </ul>
40  */

41
42 public class JBossTestClusteredSetup extends JBossTestSetup
43 {
44    
45    // Constants -----------------------------------------------------
46

47    // Attributes ----------------------------------------------------
48

49    private String JavaDoc jarName;
50    // Static --------------------------------------------------------
51

52    // Constructors --------------------------------------------------
53

54    public JBossTestClusteredSetup(Test test, String JavaDoc jar) throws Exception JavaDoc
55    {
56       super(JBossClusteredTestCase.class, test);
57       jarName = jar;
58    }
59    
60    
61    // Public --------------------------------------------------------
62

63    // Z implementation ----------------------------------------------
64

65    // Y overrides ---------------------------------------------------
66

67    // Package protected ---------------------------------------------
68

69    // Protected -----------------------------------------------------
70

71    protected JBossTestServices createTestServices()
72    {
73       return new JBossTestClusteredServices(getClass());
74    }
75    
76    protected void setUp() throws Exception JavaDoc
77    {
78       super.setUp();
79       
80       if (jarName == null) return;
81       JBossTestCase.deploymentException = null;
82       try
83       {
84          this.deploy(jarName);
85          this.getLog().debug("deployed package: " + jarName);
86       }
87       catch (Exception JavaDoc ex)
88       {
89          // Throw this in testServerFound() instead.
90
JBossTestCase.deploymentException = ex;
91       }
92           
93       // wait a few seconds so that the cluster stabilize
94
synchronized (this)
95       {
96          wait(2000);
97       }
98    }
99
100    protected void tearDown() throws Exception JavaDoc
101    {
102       try
103       {
104          if (jarName != null)
105          {
106             this.getLog().debug("Attempt undeploy of " + jarName);
107             this.undeploy(jarName);
108             this.getLog().debug("undeployed package: " + jarName);
109          }
110          super.tearDown();
111       }
112       finally
113       {
114          AbstractTestSetup.delegate = null;
115       }
116      
117    }
118    
119
120    // Private -------------------------------------------------------
121

122    // Inner classes -------------------------------------------------
123

124 }
125
Popular Tags