23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * CDDL HEADER START
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * The contents of this file are subject to the terms of the
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * Common Development and Distribution License (the "License").
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * You may not use this file except in compliance with the License.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * See the License for the specific language governing permissions
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * and limitations under the License.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * When distributing Covered Code, include this CDDL HEADER in each
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * If applicable, add the following below this CDDL HEADER, with the
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * fields enclosed by brackets "[]" replaced with your own identifying
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * information: Portions Copyright [yyyy] [name of copyright owner]
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * CDDL HEADER END
e77b06d21580f630e0a7c437495ab283d3672828tomee * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * Use is subject to license terms.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * Regression test for serialization and XML encoding/decoding. Tests
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * every Serializable class in the Java DTrace API by creating a dummy
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * instance, writing it to a file, then reading it back in and comparing
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * the string values of the object before and after, as well as
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * verifying object equality before and after if the class overrides the
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee * equals() method.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ExitRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "AggregationRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "Aggregation",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ScalarRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "KernelStackRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "LogDistribution",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "LinearDistribution",
ae94d716ff8759d2dc2de680b5b85a291219a4c1Richard Lowe "LogLinearDistribution",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ProcessState",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ProbeDescription",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "PrintaRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "PrintfRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ProbeData",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "Aggregate",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "UserStackRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "AvgValue",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "CountValue",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "SumValue",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "MinValue",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "MaxValue",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "InterfaceAttributes",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ProgramInfo",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "ProbeInfo",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "KernelSymbolRecord",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "UserSymbolRecord",
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee "UserSymbolRecord$Value",
e77b06d21580f630e0a7c437495ab283d3672828tomee "Program$File",
e77b06d21580f630e0a7c437495ab283d3672828tomee "StddevValue"
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee static void
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static XMLEncoder
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static XMLDecoder
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static XMLDecoder
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee getXMLDecoder(File file, ExceptionListener exceptionListener)
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee decoder = new XMLDecoder(in, null, exceptionListener);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ExitRecord
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee AggregationRecord r = new AggregationRecord(tuple, value);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Aggregation
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ValueRecord v1 = new ScalarRecord(new byte[] {(byte)1, (byte)2,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Tuple
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ValueRecord r4 = new ScalarRecord(new byte[] {(byte)1, (byte)2,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ScalarRecord
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee KernelStackRecord r = new KernelStackRecord(stackFrames,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static LogDistribution
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee if (i == 0) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee bucket = new Distribution.Bucket(lowerBound, upperBound, n++);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee bucket = new Distribution.Bucket(Long.MIN_VALUE, (base - 1), 0);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee bucket = new Distribution.Bucket((n * step) + 1, Long.MAX_VALUE, 0);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee LinearDistribution d = new LinearDistribution(base, step, buckets);
ae94d716ff8759d2dc2de680b5b85a291219a4c1Richard Lowe bucket = new Distribution.Bucket(Long.MIN_VALUE, (value - 1), 0);
ae94d716ff8759d2dc2de680b5b85a291219a4c1Richard Lowe bucket = new Distribution.Bucket(value, value + step - 1, 5);
ae94d716ff8759d2dc2de680b5b85a291219a4c1Richard Lowe bucket = new Distribution.Bucket(value, Long.MAX_VALUE, 0);
ae94d716ff8759d2dc2de680b5b85a291219a4c1Richard Lowe LogLinearDistribution d = new LogLinearDistribution(factor, low, high,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Option
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ProcessState
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ProbeDescription d = new ProbeDescription(256, "syscall", null,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static PrintaRecord
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee List < Aggregation > aggregations = new ArrayList < Aggregation > ();
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "Yes, this is the formatted printa() output");
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static PrintfRecord
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee List < ValueRecord > list = new ArrayList < ValueRecord > ();
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "long formatted string");
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ProbeData
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ProbeData d = new ProbeData(7, 1, getProbeDescription(),
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Aggregate
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee List < Aggregation > list = new ArrayList < Aggregation > ();
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ValueRecord v5 = new ScalarRecord(new Byte((byte) 'C'), 1);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ValueRecord v6 = new ScalarRecord(new Short((short) 7), 2);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static UserStackRecord
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee UserStackRecord r = new UserStackRecord(123456, frames,
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static AvgValue
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static CountValue
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static MinValue
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static MaxValue
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static SumValue
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee 1, 20, "DTRACEFLT_BADALIGN", -1, "error on enabled probe ID 8 " +
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "(ID " + probe.getID() + ": " + probe + "): Bad alignment " +
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "(0x33ef) in action #1 at DIF offset 20");
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Drop
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "Guess we dropped stuff all over the place.");
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ProgramInfo
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ProgramInfo info = new ProgramInfo(getInterfaceAttributes(),
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static ProbeInfo
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee ProbeInfo info = new ProbeInfo(getInterfaceAttributes(),
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Probe
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee Probe p = new Probe(getProbeDescription(), getProbeInfo());
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static Flow
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee KernelSymbolRecord r = new KernelSymbolRecord("mod`func+0x4", -1L);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee UserSymbolRecord r = new UserSymbolRecord(7, "mod`func+0x4", -1L);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee UserSymbolRecord.Value v = new UserSymbolRecord.Value(7, -1L);
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee public static Program
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee final String PROGRAM = "syscall:::entry { @[execname] = count(); }";
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee } catch (DTraceException e) {
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee final String PROGRAM = "syscall:::entry { @[execname] = count(); }";
91cfa10a8e55050a5103c4b2e83b0bf8d783a7cbtomee } catch (Exception e) {
e77b06d21580f630e0a7c437495ab283d3672828tomee public static StddevValue
e77b06d21580f630e0a7c437495ab283d3672828tomee StddevValue v = new StddevValue(37, 114, 5, Integer.toString(9544));
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee if (o instanceof ScalarRecord) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee if (o instanceof byte[]) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } else if (o instanceof Object[]) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee static void
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee // If the class overrides equals(), make sure the re-created
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee // object still equals the original object
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee Method eq = obj.getClass().getDeclaredMethod("equals",
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee if (ret != true) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee // Does not override equals(), although a super-class might.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee // A better test would check for any superclass other than
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee // Object.class.
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee static void
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee Method method = TestBean.class.getDeclaredMethod(methodName);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee System.err.println("serialization failed: " + classname);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee static void
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee Method method = TestBean.class.getDeclaredMethod(methodName);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee System.err.println("bean persistence failed: " + classname);
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee public static void
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee System.err.println("usage: java TestBean < filename > " +
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee "[ < classname > ]");
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (Exception e) {
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee } catch (IOException e) {