/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @summary Test that SnmpTimeTicks wraps around when it is passed a long
* value
* @bug 4955105
* @build TimeTicksWrapping
* @run main TimeTicksWrapping
*/
public class TimeTicksWrapping {
// We use an SnmpTimeticksBuilder in order to adapt this test case to a
// configuration where the SNMP packages are not present in rt.jar.
//
public static final class SnmpTimeticksBuilder {
"com.sun.jmx.snmp.SnmpTimeticks";
static {
try {
} catch (ClassNotFoundException x) {
} catch (NoClassDefFoundError x) {
}
if (SNMP_TIME_TICKS_CLASS != null) {
try {
SNMP_TIME_TICKS_CLASS.getConstructor(long.class);
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
} else {
}
if (SNMP_TIME_TICKS_CLASS != null) {
try {
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
} else {
}
if (SNMP_TIME_TICKS_CLASS != null) {
try {
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
} else {
}
}
}
}
}
public static boolean isSnmpPresent() {
": Testing for SNMP Packages...");
return SNMP_TIME_TICKS_CLASS != null;
}
throws Exception {
try {
} catch (InvocationTargetException x) {
throw x;
}
}
throws Exception {
try {
} catch (InvocationTargetException x) {
throw x;
}
}
throws Exception {
try {
} catch (InvocationTargetException x) {
throw x;
}
}
}
public static final long[] oks = {
};
public static final long[] kos = {
};
if (!SnmpTimeticksBuilder.isSnmpPresent()) {
" not present.");
": test skipped.");
return;
}
try {
SnmpTimeticksBuilder t = null;
throw new Exception("Value should have wrapped: " +
throw new Exception("Value should have wrapped: " +
throw new Exception("Value should have wrapped " +
t1 + " exceeds max: " +
throw new Exception("Value should have wrapped " +
t2 + " exceeds max: " +
if (t1 < 0)
throw new Exception("Value should have wrapped: " +
t1 + " is negative");
if (t2 < 0)
throw new Exception("Value should have wrapped: " +
t2 + " is negative");
"] rightfully accepted: " + t3);
}
try {
t = new SnmpTimeticksBuilder(kos[i]);
throw new Exception("Value should have been rejected: " +
kos[i]);
} catch (IllegalArgumentException x) {
// OK!
}
try {
throw new Exception("Value should have been rejected: " +
} catch (IllegalArgumentException x) {
// OK!
}
"] rightfully rejected.");
}
} catch(Exception x) {
x.printStackTrace();
}
}
}