Java Code Examples for javax.management.openmbean.SimpleType#INTEGER
The following examples show how to use
javax.management.openmbean.SimpleType#INTEGER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttributeNodeForSimpleType.java From datakernel with Apache License 2.0 | 6 votes |
private static SimpleType<?> simpleTypeOf(Class<?> clazz) throws IllegalArgumentException { if (clazz == boolean.class || clazz == Boolean.class) { return SimpleType.BOOLEAN; } else if (clazz == byte.class || clazz == Byte.class) { return SimpleType.BYTE; } else if (clazz == short.class || clazz == Short.class) { return SimpleType.SHORT; } else if (clazz == char.class || clazz == Character.class) { return SimpleType.CHARACTER; } else if (clazz == int.class || clazz == Integer.class) { return SimpleType.INTEGER; } else if (clazz == long.class || clazz == Long.class) { return SimpleType.LONG; } else if (clazz == float.class || clazz == Float.class) { return SimpleType.FLOAT; } else if (clazz == double.class || clazz == Double.class) { return SimpleType.DOUBLE; } else if (clazz == String.class) { return SimpleType.STRING; } else { throw new IllegalArgumentException("There is no SimpleType for " + clazz.getName()); } }
Example 2
Source File: ExceptionStatsTest.java From datakernel with Apache License 2.0 | 6 votes |
@Before public void before() throws OpenDataException { exceptionDetailsItemNames = new String[]{ "lastException", "lastExceptionCausedObject", "lastExceptionStackTrace", "lastExceptionTimestamp", "totalExceptions" }; exceptionDetailsItemTypes = new OpenType<?>[]{ SimpleType.STRING, SimpleType.STRING, new ArrayType<>(1, SimpleType.STRING), SimpleType.LONG, SimpleType.INTEGER }; }
Example 3
Source File: StreamServiceTest.java From cassandra-reaper with Apache License 2.0 | 5 votes |
private CompositeType makeFilesType_2_1_20() throws OpenDataException { String typeName = "org.apache.cassandra.streaming.ProgressInfo"; String description = "ProgressInfo"; String[] itemNames = { "currentBytes", "direction", "fileName", "peer", "planId", "sessionIndex", "totalBytes" }; String[] itemDescriptions = { "currentBytes", "direction", "fileName", "peer", "planId", "sessionIndex", "totalBytes" }; OpenType[] itemTypes = { SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.LONG, }; return new CompositeType(typeName, description, itemNames, itemDescriptions, itemTypes); }
Example 4
Source File: CompatibilityTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@BeforeClass public static void setup() throws Exception { compositeTypeV6 = new CompositeType( StackTraceElement.class.getName(), "StackTraceElement", new String[]{ "className", "methodName", "fileName", "nativeMethod", "lineNumber" }, new String[]{ "className", "methodName", "fileName", "nativeMethod", "lineNumber" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.INTEGER } ); itemsV6 = new HashMap<>(); itemsV6.put("className", "MyClass"); itemsV6.put("methodName", "myMethod"); itemsV6.put("fileName", "MyClass.java"); itemsV6.put("nativeMethod", false); itemsV6.put("lineNumber", 123); compositeDataV6 = new CompositeDataSupport(compositeTypeV6, itemsV6); }
Example 5
Source File: StreamServiceTest.java From cassandra-reaper with Apache License 2.0 | 5 votes |
private CompositeType makeSessionsTypePost2_1() throws OpenDataException { String typeName = "org.apache.cassandra.streaming.SessionInfo"; String description = "SessionInfo"; String[] itemNames = { "connecting", "peer", "planId", "receivingFiles", "receivingSummaries", "sendingFiles", "sendingSummaries", "sessionIndex", "state" }; String[] itemDescriptions = { "connecting", "peer", "planId", "receivingFiles", "receivingSummaries", "sendingFiles", "sendingSummaries", "sessionIndex", "state" }; OpenType[] itemTypes = { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, ArrayType.getArrayType(makeFilesType_2_1_20()), ArrayType.getArrayType(makeSummariesType_pre_4_0()), ArrayType.getArrayType(makeFilesType_2_1_20()), ArrayType.getArrayType(makeSummariesType_pre_4_0()), SimpleType.INTEGER, SimpleType.STRING, }; return new CompositeType(typeName, description, itemNames, itemDescriptions, itemTypes); }
Example 6
Source File: CompositeDataStringTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 7
Source File: CompositeDataStringTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 8
Source File: PropertyNamesTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 9
Source File: CompositeDataStringTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 10
Source File: CompositeDataStringTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 11
Source File: PropertyNamesTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 12
Source File: PropertyNamesTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 13
Source File: PropertyNamesTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 14
Source File: CompositeDataStringTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 15
Source File: PropertyNamesTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 16
Source File: CompositeDataStringTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 17
Source File: PropertyNamesTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 18
Source File: CompositeDataStringTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }
Example 19
Source File: PropertyNamesTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName pointName = new ObjectName("a:type=Point"); PointMXBean pointmx = new PointImpl(); mbs.registerMBean(pointmx, pointName); Point point = new Point(1, 2); PointMXBean pointproxy = JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class); Point point1 = pointproxy.identity(point); if (point1.getX() != point.getX() || point1.getY() != point.getY()) throw new Exception("Point doesn't match"); System.out.println("Point test passed"); ObjectName evolveName = new ObjectName("a:type=Evolve"); EvolveMXBean evolvemx = new EvolveImpl(); mbs.registerMBean(evolvemx, evolveName); Evolve evolve = new Evolve(59, "tralala", Collections.singletonList("tiddly")); EvolveMXBean evolveProxy = JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class); Evolve evolve1 = evolveProxy.identity(evolve); if (evolve1.getOldInt() != evolve.getOldInt() || !evolve1.getNewString().equals(evolve.getNewString()) || !evolve1.getNewerList().equals(evolve.getNewerList())) throw new Exception("Evolve doesn't match"); System.out.println("Evolve test passed"); ObjectName evolvedName = new ObjectName("a:type=Evolved"); EvolveMXBean evolvedmx = new EvolveImpl(); mbs.registerMBean(evolvedmx, evolvedName); CompositeType evolvedType = new CompositeType("Evolved", "descr", new String[] {"oldInt"}, new String[] {"oldInt descr"}, new OpenType[] {SimpleType.INTEGER}); CompositeData evolvedData = new CompositeDataSupport(evolvedType, new String[] {"oldInt"}, new Object[] {5}); CompositeData evolved1 = (CompositeData) mbs.invoke(evolvedName, "identity", new Object[] {evolvedData}, new String[] {CompositeData.class.getName()}); if ((Integer) evolved1.get("oldInt") != 5 || !evolved1.get("newString").equals("defaultString") || ((String[]) evolved1.get("newerList")).length != 0) throw new Exception("Evolved doesn't match: " + evolved1); System.out.println("Evolved test passed"); }
Example 20
Source File: CompositeDataStringTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { CompositeType basicCT = new CompositeType( "basicCT", "basic CompositeType", new String[] {"name", "value"}, new String[] {"name", "value"}, new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER}); CompositeType ct = new CompositeType( "noddy", "descr", new String[] {"strings", "ints", "cds"}, new String[] {"string array", "int array", "composite data array"}, new OpenType<?>[] { ArrayType.getArrayType(SimpleType.STRING), ArrayType.getPrimitiveArrayType(int[].class), ArrayType.getArrayType(basicCT) }); CompositeData basicCD1 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"ceathar", 4}); CompositeData basicCD2 = new CompositeDataSupport( basicCT, new String[] {"name", "value"}, new Object[] {"naoi", 9}); CompositeData cd = new CompositeDataSupport( ct, new String[] {"strings", "ints", "cds"}, new Object[] { new String[] {"fred", "jim", "sheila"}, new int[] {2, 3, 5, 7}, new CompositeData[] {basicCD1, basicCD2} }); String s = cd.toString(); System.out.println("CompositeDataSupport.toString(): " + s); String[] expected = { "fred, jim, sheila", "2, 3, 5, 7", "ceathar", "naoi", }; boolean ok = true; for (String expect : expected) { if (s.contains(expect)) System.out.println("OK: string contains <" + expect + ">"); else { ok = false; System.out.println("NOT OK: string does not contain <" + expect + ">"); } } if (ok) System.out.println("TEST PASSED"); else throw new Exception("TEST FAILED: string did not contain expected substrings"); }