KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jmx > export > CustomEditorConfigurerTests


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16
17 package org.springframework.jmx.export;
18
19 import java.text.ParseException JavaDoc;
20 import java.text.SimpleDateFormat JavaDoc;
21 import java.util.Date JavaDoc;
22
23 import javax.management.ObjectName JavaDoc;
24
25 import org.springframework.jmx.AbstractJmxTests;
26
27 /**
28  * @author Rob Harrop
29  */

30 public class CustomEditorConfigurerTests extends AbstractJmxTests {
31
32     private final SimpleDateFormat JavaDoc df = new SimpleDateFormat JavaDoc("yyyy/MM/dd");
33
34     protected String JavaDoc getApplicationContextPath() {
35         return "org/springframework/jmx/export/customConfigurer.xml";
36     }
37
38     public void testDatesInJmx() throws Exception JavaDoc {
39         System.out.println(server.getClass().getName());
40         ObjectName JavaDoc oname = new ObjectName JavaDoc("bean:name=dateRange");
41
42         Date JavaDoc startJmx = (Date JavaDoc) server.getAttribute(oname, "StartDate");
43         Date JavaDoc endJmx = (Date JavaDoc) server.getAttribute(oname, "EndDate");
44
45         assertEquals("startDate ", getStartDate(), startJmx);
46         assertEquals("endDate ", getEndDate(), endJmx);
47     }
48
49     public void testGetDates() throws Exception JavaDoc {
50         DateRange dr = (DateRange) getContext().getBean("dateRange");
51
52         assertEquals("startDate ", getStartDate(), dr.getStartDate());
53         assertEquals("endDate ", getEndDate(), dr.getEndDate());
54     }
55
56     private Date JavaDoc getStartDate() throws ParseException JavaDoc {
57         Date JavaDoc start = df.parse("2004/10/12");
58         return start;
59     }
60
61     private Date JavaDoc getEndDate() throws ParseException JavaDoc {
62         Date JavaDoc end = df.parse("2004/11/13");
63         return end;
64     }
65
66 }
67
Popular Tags