From 306de4dcbe3fdc7fc4037e0feda58a0ec1d6efc5 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Sat, 26 Oct 2013 21:01:28 +0200 Subject: [PATCH 07/39] Add tests for reason message shortening Related to rhbz#1023081 Related to rhbz#1055581 Signed-off-by: Jakub Filak --- test/CMakeLists.txt | 34 +++++++++ ...eHavingExtremlyLongAndSenselessMethodNames.java | 83 ++++++++++++++++++++++ test/outputs/run_cut_exception_namespace.log.in | 4 ++ test/outputs/run_cut_method_class.log.in | 4 ++ test/outputs/run_cut_method_namespace.log.in | 4 ++ test/outputs/run_cut_reason_message.log.in | 4 ++ 6 files changed, 133 insertions(+) create mode 100644 test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java create mode 100644 test/outputs/run_cut_exception_namespace.log.in create mode 100644 test/outputs/run_cut_method_class.log.in create mode 100644 test/outputs/run_cut_method_namespace.log.in create mode 100644 test/outputs/run_cut_reason_message.log.in diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c84ebe5..5d3aa0d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,6 +45,7 @@ _add_class_target(RemoteTest TEST_JAVA_TARGETS SimpleTest) _add_class_target(MultiThreadTest TEST_JAVA_TARGETS SimpleTest) _add_class_target(Test TEST_JAVA_TARGETS) _add_class_target(com/redhat/abrt/test/Test TEST_JAVA_TARGETS) +_add_class_target(com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames TEST_JAVA_TARGETS) _add_class_target(BadClassTest TEST_JAVA_TARGETS) _add_class_target(MissingClass TEST_JAVA_TARGETS) _add_class_target(MissingClassTest TEST_JAVA_TARGETS MissingClass) @@ -200,6 +201,39 @@ _add_test_target( ) #_add_test(run_overriden_eqauls 2) +_add_test_target( + run_cut_method_namespace + com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames + 3 + DEPENDS ${TEST_JAVA_TARGETS} +) +_add_test(run_cut_method_namespace 2) + +_add_test_target( + run_cut_exception_namespace + com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames + 2 + DEPENDS ${TEST_JAVA_TARGETS} +) +_add_test(run_cut_exception_namespace 2) + +_add_test_target( + run_cut_method_class + com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames + 1 + DEPENDS ${TEST_JAVA_TARGETS} +) +_add_test(run_cut_method_class 2) + +_add_test_target( + run_cut_reason_message + com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames + 0 + DEPENDS ${TEST_JAVA_TARGETS} +) +_add_test(run_cut_reason_message 2) + + add_custom_target( run_thread_stress COMMAND LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src ${Java_JAVA_EXECUTABLE} -agentlib:${AGENT_NAME}=caught=java.lang.ArrayIndexOutOfBoundsException,output= ThreadStressTest diff --git a/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java b/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java new file mode 100644 index 0000000..4a12322 --- /dev/null +++ b/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java @@ -0,0 +1,83 @@ +package com.redhat.abrt.test; + + + +/** + * An exception class with very long name for test of message shortening + * algorithm. + * + * @author Jakub Filak <jfilak@redhat.com> + */ +class UnbelievableLongJavaClassNameException extends RuntimeException { + public UnbelievableLongJavaClassNameException() { super(); } + public UnbelievableLongJavaClassNameException(String message) { super(message); } + public UnbelievableLongJavaClassNameException(String message, Throwable cause) { super(message, cause); } + public UnbelievableLongJavaClassNameException(Throwable cause) { super(cause); } +} + + + +/** + * A class with very long name, method names and throwing an exception with + * very long name for test of message shortening algorithm. + * + * @author Jakub Filak <jfilak@redhat.com> + */ +public class UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames +{ + public static void oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyTwentyOneTwentyTwooTwentyThreeTwentyFourTwentyFiveTwentySixTwentySevenTwentyEightTwentyNineUpToOneHundredThousand() + { + throw new UnbelievableLongJavaClassNameException(); + } + + public static void oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyUpToOneHundredThousand() + { + throw new UnbelievableLongJavaClassNameException(); + } + + public static void oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenUpToOneHundredThousand() + { + throw new UnbelievableLongJavaClassNameException(); + } + + public static void oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenUpToOneHundredThousand() + { + throw new UnbelievableLongJavaClassNameException(); + } + + /** + * Entry point to this shortening test. + */ + public static void main(String args[]) { + System.out.println("Long names handling started"); + if (args.length == 0) { + System.out.println("You better pass an argument from [0, 1, 2]"); + oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyUpToOneHundredThousand(); + } + else { + switch(args[0]) { + case "0": + System.out.println("Last Twenty Nine"); + oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyTwentyOneTwentyTwooTwentyThreeTwentyFourTwentyFiveTwentySixTwentySevenTwentyEightTwentyNineUpToOneHundredThousand(); + break; + case "1": + System.out.println("Last Twenty"); + oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyUpToOneHundredThousand(); + break; + case "2": + System.out.println("Last Seventeen"); + oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenUpToOneHundredThousand(); + break; + case "3": + System.out.println("Last Sixteen"); + oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenUpToOneHundredThousand(); + break; + default: + System.err.println("Argument is not in range [0, 1, 2]: " + args[0]); + System.exit(1); + } + } + + System.exit(0); + } +} diff --git a/test/outputs/run_cut_exception_namespace.log.in b/test/outputs/run_cut_exception_namespace.log.in new file mode 100644 index 0000000..75b54c1 --- /dev/null +++ b/test/outputs/run_cut_exception_namespace.log.in @@ -0,0 +1,4 @@ +Uncaught exception UnbelievableLongJavaClassNameException in method UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenUpToOneHundredThousand() +Exception in thread "main" com.redhat.abrt.test.UnbelievableLongJavaClassNameException + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenUpToOneHundredThousand(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:40) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.main(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:69) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] diff --git a/test/outputs/run_cut_method_class.log.in b/test/outputs/run_cut_method_class.log.in new file mode 100644 index 0000000..eb464a7 --- /dev/null +++ b/test/outputs/run_cut_method_class.log.in @@ -0,0 +1,4 @@ +Uncaught exception UnbelievableLongJavaClassNameException in method oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyUpToOneHundredThousand() +Exception in thread "main" com.redhat.abrt.test.UnbelievableLongJavaClassNameException + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyUpToOneHundredThousand(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:35) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.main(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:65) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] diff --git a/test/outputs/run_cut_method_namespace.log.in b/test/outputs/run_cut_method_namespace.log.in new file mode 100644 index 0000000..0ec2438 --- /dev/null +++ b/test/outputs/run_cut_method_namespace.log.in @@ -0,0 +1,4 @@ +Uncaught exception com.redhat.abrt.test.UnbelievableLongJavaClassNameException in method UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenUpToOneHundredThousand() +Exception in thread "main" com.redhat.abrt.test.UnbelievableLongJavaClassNameException + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenUpToOneHundredThousand(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:45) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.main(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:73) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] diff --git a/test/outputs/run_cut_reason_message.log.in b/test/outputs/run_cut_reason_message.log.in new file mode 100644 index 0000000..5364f65 --- /dev/null +++ b/test/outputs/run_cut_reason_message.log.in @@ -0,0 +1,4 @@ +Uncaught exception UnbelievableLongJavaClassNameException in method oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyTwentyOneTwentyTwooTwentyThreeTwentyFourTwentyFiveTwentySixTwentySevenTwentyEightTwentyNin +Exception in thread "main" com.redhat.abrt.test.UnbelievableLongJavaClassNameException + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.oneTwoThreeFroFiveSixSevenEightNineTenElevenTwelveThirteenSixteenSeventeenEighteenNineteenTwentyTwentyOneTwentyTwooTwentyThreeTwentyFourTwentyFiveTwentySixTwentySevenTwentyEightTwentyNineUpToOneHundredThousand(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:30) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] + at com.redhat.abrt.test.UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.main(UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.java:61) [file:@CMAKE_BINARY_DIR@/test/com/redhat/abrt/test/UnbelievableLongJavaClassNameHavingExtremlyLongAndSenselessMethodNames.class] -- 1.8.3.1