1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.backsource.alert.agent;
21 import java.net.URL;
22 import org.backsource.alert.PropertyConstants;
23 import org.backsource.alert.AlertError;
24 /***
25 * Legacy class from in that check a servlet that access a database.
26 *
27 * <p>User the property {@link org.backsource.alert.PropertyConstants#DB_ALIVE_URL} to point to the servlet.Se {@link UrlCase} for properties partaining to authentication.</p>
28 *
29 *
30 * @author <a href="mailto:pra@tim.se">Peter Antman</a>
31 * @version $Revision: 1.1.1.1 $
32 */
33
34 public class DbAliveTest extends UrlCase{
35 URL url;
36 public DbAliveTest (String name){
37 super(name);
38 }
39
40 protected void setUp() throws Exception{
41 super.setUp();
42 String t = prop.getProperty(PropertyConstants.DB_ALIVE_URL);
43 url = new URL(t);
44 }
45
46 /***
47 * The test method that checks if the db servlet is ok.
48 */
49 public void testDbAlive() {
50 try {
51 checkUrl(url);
52 } catch ( AlertError e) {
53 throw new AlertError("Database/or server probably dead: " + e);
54 }
55
56
57 }
58 public static void main(String[] args){
59 try {
60 DbAliveTest t = new DbAliveTest("main");
61 t.url = new URL("http://localhost:8080/alert/DbServlet");
62 t.testDbAlive();
63 } catch (Exception e) {
64 e.printStackTrace();
65 }
66 }
67 }