View Javadoc

1   /*
2    * Copyright 2010 Capgemini
3    * Licensed under the Apache License, Version 2.0 (the "License"); 
4    * you may not use this file except in compliance with the License. 
5    * You may obtain a copy of the License at 
6    * 
7    * http://www.apache.org/licenses/LICENSE-2.0 
8    * 
9    * Unless required by applicable law or agreed to in writing, software 
10   * distributed under the License is distributed on an "AS IS" BASIS, 
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
12   * See the License for the specific language governing permissions and 
13   * limitations under the License. 
14   * 
15   */
16  package net.sf.appstatus.demo.check;
17  
18  import net.sf.appstatus.core.check.ICheckResult;
19  import net.sf.appstatus.core.check.impl.StatusResultImpl;
20  
21  public class DummyStatusChecker extends AbstractHttpCheck {
22  
23  	public ICheckResult checkStatus() {
24  		StatusResultImpl result = new StatusResultImpl();
25  
26  		result.setProbeName(getName());
27  		result.setCode(Math.random() > 0.5 ? ICheckResult.OK
28  				: ICheckResult.ERROR);
29  		if (result.getCode() == ICheckResult.OK) {
30  			result.setDescription("Random is good");
31  			result.setFatal(false);
32  		} else {
33  			result.setDescription("Random failed");
34  			result.setResolutionSteps("This probe fails randomly. Please reload the page for better luck.");
35  			result.setFatal(true);
36  		}
37  		return result;
38  	}
39  
40  	public String getGroup() {
41  		return "dummy";
42  	}
43  
44  	public String getName() {
45  		return "Dummy check";
46  	}
47  
48  }