1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.neo4j.examples;
21
22 import static org.junit.Assert.assertTrue;
23
24 import java.util.Date;
25
26 import org.junit.Test;
27 import org.neo4j.graphdb.GraphDatabaseService;
28 import org.neo4j.jmx.Kernel;
29 import org.neo4j.kernel.EmbeddedGraphDatabase;
30
31 public class JmxTest
32 {
33 @Test
34 public void readJmxProperties()
35 {
36 GraphDatabaseService graphDbService = new EmbeddedGraphDatabase(
37 "target/jmx-db" );
38 Date startTime = getStartTimeFromManagementBean( graphDbService );
39 Date now = new Date();
40 System.out.println( startTime + " " + now );
41 assertTrue( startTime.before( now ) || startTime.equals( now ) );
42 }
43
44
45 private static Date getStartTimeFromManagementBean(
46 GraphDatabaseService graphDbService )
47 {
48
49 EmbeddedGraphDatabase graphDb = (EmbeddedGraphDatabase) graphDbService;
50 Kernel kernel = graphDb.getManagementBean( Kernel.class );
51 Date startTime = kernel.getKernelStartTime();
52 return startTime;
53 }
54
55 }