From: Alexandre Montplaisir Date: Wed, 20 Jan 2016 21:55:45 +0000 (-0500) Subject: Split the tests package in 3 separate artifacts X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4821eac962d2f707558b6d9a5b66af9dbe89b933;p=lttng-ust-java-tests.git Split the tests package in 3 separate artifacts Instead of one test package containing both the JUL and log4j tests, we can define three different ones (-common, -jul, -log4j, similar to the runtime packages) so that the code only depend on its minimal set of dependencies. Will also make it easier to integrate in the runtime project once we move that to Maven too... Signed-off-by: Alexandre Montplaisir --- diff --git a/.project b/.project new file mode 100644 index 0000000..4e95b2d --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + lttng-ust-java-parent + + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/README.md b/README.md index c30e7f3..9955df1 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Please make sure you have no `lttng` session active prior to or during the tests, or it might interfere with the test runs! Detailed JUnit test reports will be available under -`lttng-ust-java-tests/target/failsafe-reports/` +`lttng-ust-java-tests-{jul|log4j}/target/failsafe-reports/` Running the benchmarks diff --git a/lttng-ust-java-tests-common/.classpath b/lttng-ust-java-tests-common/.classpath new file mode 100644 index 0000000..af1430b --- /dev/null +++ b/lttng-ust-java-tests-common/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-common/.project b/lttng-ust-java-tests-common/.project new file mode 100644 index 0000000..592a25a --- /dev/null +++ b/lttng-ust-java-tests-common/.project @@ -0,0 +1,23 @@ + + + lttng-ust-java-tests-common + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/lttng-ust-java-tests-common/.settings/org.eclipse.core.resources.prefs b/lttng-ust-java-tests-common/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..8dd9b1d --- /dev/null +++ b/lttng-ust-java-tests-common/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.core.prefs b/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f1acd28 --- /dev/null +++ b/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,392 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.ui.prefs b/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..b883c15 --- /dev/null +++ b/lttng-ust-java-tests-common/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,62 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spaces +formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/lttng-ust-java-tests-common/.settings/org.eclipse.m2e.core.prefs b/lttng-ust-java-tests-common/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/lttng-ust-java-tests-common/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/lttng-ust-java-tests-common/pom.xml b/lttng-ust-java-tests-common/pom.xml new file mode 100644 index 0000000..5073553 --- /dev/null +++ b/lttng-ust-java-tests-common/pom.xml @@ -0,0 +1,56 @@ + + + + + 4.0.0 + + + org.lttng.ust + lttng-ust-java-parent + 1.0.0 + + + lttng-ust-java-tests-common + jar + + LTTng-UST Java Agent Integration Tests Common Package + + + + org.lttng.ust.agent + lttng-ust-agent-common + + + + org.lttng.tools + lttng-tools-java + + + + junit + junit + + compile + + + + diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java new file mode 100644 index 0000000..5659493 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Base abstract class to implement all sorts of integration tests verifying the + * presence of enabled events in resulting traces. + */ +@RunWith(TestPrintRunner.class) +public abstract class EnabledEventsITBase { + + protected static final String EVENT_NAME_A = "EventA"; + protected static final String EVENT_NAME_B = "EventAB"; + protected static final String EVENT_NAME_C = "EventABC"; + protected static final String EVENT_NAME_D = "EventABCD"; + + private ILttngSession session; + + /* Fields defined by the sub-class */ + protected ILttngHandler handlerA; + protected ILttngHandler handlerB; + protected ILttngHandler handlerC; + + protected abstract Domain getDomain(); + + protected abstract void sendEventsToLoggers(); + + /** + * Base test setup + */ + @Before + public void testSetup() { + session = ILttngSession.createSession(null, getDomain()); + } + + /** + * Base test teardown + */ + @After + public void testTeardown() { + session.close(); + + handlerA.close(); + handlerB.close(); + handlerC.close(); + + handlerA = null; + handlerB = null; + handlerC = null; + } + + /** + * Test sending events on the Java side, but no events enabled in the + * tracing session. There should be nothing in the resulting trace, and + * handlers should not have logged anything. + */ + @Test + public void testNoEvents() { + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertTrue(output.isEmpty()); + + assertEquals(0, handlerA.getEventCount()); + assertEquals(0, handlerB.getEventCount()); + assertEquals(0, handlerC.getEventCount()); + } + + /** + * Test sending events on the Java side, and all events enabled in the + * tracing session. All handlers should have sent their events. + */ + @Test + public void testAllEvents() { + assertTrue(session.enableAllEvents()); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(30, output.size()); // loggerD has no handler attached + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } + + /** + * Test sending events on the Java side, with only some of them enabled in + * the tracing session. Only the subset that is enabled should be received. + */ + @Test + public void testSomeEvents() { + assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D)); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(20, output.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(0, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } + + /** + * Test with all events enabled (-a), plus some other events added manually. + * Events should still be retained, but there should be no duplicates. + */ + @Test + public void testAllEventsAndSome() { + assertTrue(session.enableAllEvents()); + assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_B)); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(30, output.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } + + /** + * Same as {@link #testSomeEvents()}, but some events were enabled first, + * then disabled. Makes sure the enabled-event refcounting works properly. + */ + @Test + public void testSomeEventsAfterDisabling() { + assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D)); + assertTrue(session.disableEvents(EVENT_NAME_C)); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(10, output.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(0, handlerB.getEventCount()); + assertEquals(0, handlerC.getEventCount()); + } + + /** + * Test enabling an event prefix, which means an event name ending with a *, + * to match all events starting with this name. + */ + @Test + public void testEventPrefix() { + // should match event/loggers B and C, but not A. + assertTrue(session.enableEvents("EventAB*")); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(20, output.size()); + + assertEquals(0, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } + + /** + * Same as {@link #testEventPrefix()}, but with multiple prefixes that + * overlap. There should not be any duplicate events in the trace or in the + * handlers. + */ + @Test + public void testEventPrefixOverlapping() { + // should still match B and C + assertTrue(session.enableEvents("EventAB*", "EventABC*")); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(20, output.size()); + + assertEquals(0, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } + + /** + * Test with all events enabled (-a), plus an event prefix. Once again, + * there should be no duplicates. + */ + @Test + public void testAllEventsAndPrefix() { + assertTrue(session.enableAllEvents()); + assertTrue(session.enableEvents("EventAB*")); + assertTrue(session.start()); + + sendEventsToLoggers(); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(30, output.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + } +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java new file mode 100644 index 0000000..ec4e0c1 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.lttng.tools.ILttngSession; + +/** + * Base class for the list events command tests + */ +public abstract class ListEventsITBase { + + protected static final String LOGGER_NAME_1 = "org.lttng"; + protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent"; + protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent"; + + private ILttngSession session; + + /** + * Common test setup + */ + @Before + public void testSetup() { + session = ILttngSession.createSession(null, getDomain()); + } + + /** + * Common test teardown + */ + @After + public void testTeardown() { + session.close(); + } + + protected abstract ILttngSession.Domain getDomain(); + + protected abstract void attachHandlerToLogger(int handlerIndex, int loggerIndex); + + protected abstract void detachHandlerFromLogger(int handlerIndex, int loggerIndex); + + /** + * Test with many loggers existing, but none of them having a LTTng handler + * attached. + */ + @Test + public void testManyLoggersNoneAttached() { + /* Don't attach anything */ + Set actualEvents = session.listEvents(); + assertTrue(actualEvents.isEmpty()); + } + + /** + * Test with many loggers existing, but only a subset of them has a LTTng + * handler attached. + */ + @Test + public void testManyLoggersSomeAttached() { + attachHandlerToLogger(1, 1); + + Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1)); + Set actualEvents = session.listEvents(); + + assertEquals(expectedEvents, actualEvents); + } + + /** + * Test with many loggers existing, and all of them having a LTTng handler + * attached. + */ + @Test + public void testManyLoggersAllAttached() { + attachHandlerToLogger(1, 1); + attachHandlerToLogger(2, 2); + attachHandlerToLogger(2, 3); + + Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3)); + Set actualEvents = session.listEvents(); + + assertEquals(expectedEvents, actualEvents); + } + + /** + * Test with some loggers having had handlers attached but then detached. + */ + @Test + public void testLoggersSomeDetached() { + attachHandlerToLogger(1, 1); + attachHandlerToLogger(2, 2); + + attachHandlerToLogger(2, 3); + detachHandlerFromLogger(2, 3); + /* Only loggers 1 and 2 will be attached */ + + Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2)); + Set actualEvents = session.listEvents(); + + assertEquals(expectedEvents, actualEvents); + } + + /** + * Test with all loggers having had handlers attached and then detached. + */ + @Test + public void testLoggersAllDetached() { + attachHandlerToLogger(1, 1); + attachHandlerToLogger(2, 2); + attachHandlerToLogger(2, 3); + detachHandlerFromLogger(1, 1); + detachHandlerFromLogger(2, 2); + detachHandlerFromLogger(2, 3); + + Set actualEvents = session.listEvents(); + assertTrue(actualEvents.isEmpty()); + } +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java new file mode 100644 index 0000000..6864292 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java @@ -0,0 +1,363 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Base abstract class for tests with multiple concurrent tracing sessions + */ +@RunWith(TestPrintRunner.class) +public abstract class MultiSessionITBase { + + protected static final String EVENT_NAME_A = "EventA"; + protected static final String EVENT_NAME_B = "EventAB"; + protected static final String EVENT_NAME_C = "EventABC"; + protected static final String EVENT_NAME_D = "EventABCD"; + + private ILttngSession session1; + private ILttngSession session2; + private ILttngSession session3; + + /* Fields defined by the sub-class */ + protected ILttngHandler handlerA; + protected ILttngHandler handlerB; + protected ILttngHandler handlerC; + protected ILttngHandler handlerD; + + protected abstract Domain getDomain(); + + protected abstract void sendEventsToLoggers(); + + /** + * Base test setup + */ + @Before + public void testSetup() { + session1 = ILttngSession.createSession(null, getDomain()); + session2 = ILttngSession.createSession(null, getDomain()); + session3 = ILttngSession.createSession(null, getDomain()); + } + + /** + * Base test teardown + */ + @After + public void testTeardown() { + session1.close(); + session2.close(); + session3.close(); + + handlerA.close(); + handlerB.close(); + handlerC.close(); + handlerD.close(); + + handlerA = null; + handlerB = null; + handlerC = null; + handlerD = null; + } + + /** + * Test with no events in any session. + */ + @Test + public void testNoEvents() { + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertTrue(output1.isEmpty()); + assertTrue(output2.isEmpty()); + assertTrue(output3.isEmpty()); + + assertEquals(0, handlerA.getEventCount()); + assertEquals(0, handlerB.getEventCount()); + assertEquals(0, handlerC.getEventCount()); + assertEquals(0, handlerD.getEventCount()); + } + + /** + * Test with all events enabled in one session only. Everything should be + * sent through JNI, but only that session should keep the trace events. + */ + @Test + public void testAllEventsOneSession() { + assertTrue(session1.enableAllEvents()); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(40, output1.size()); + assertTrue(output2.isEmpty()); + assertTrue(output3.isEmpty()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } + + /** + * Test with all events enabled in all sessions. All traces and handlers + * should see every event that was logged. + */ + @Test + public void testAllEventsAllSessions() { + assertTrue(session1.enableAllEvents()); + assertTrue(session2.enableAllEvents()); + assertTrue(session3.enableAllEvents()); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(40, output1.size()); + assertEquals(40, output2.size()); + assertEquals(40, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } + + /** + * Test enabling some events in some sessions only. + */ + @Test + public void testSomeEvents() { + assertTrue(session1.enableEvents(EVENT_NAME_A)); + assertTrue(session2.enableEvents(EVENT_NAME_B)); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(10, output1.size()); + assertEquals(10, output2.size()); + assertEquals(0, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(0, handlerC.getEventCount()); + assertEquals(0, handlerD.getEventCount()); + } + + /** + * Test with all events enabled in one session, and some others in another. + * All events should arrive where expected, with no duplicates. + */ + @Test + public void testAllEventsAndSome() { + assertTrue(session1.enableAllEvents()); + assertTrue(session2.enableEvents(EVENT_NAME_D)); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(40, output1.size()); + assertEquals(10, output2.size()); + assertEquals(0, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } + + /** + * Test with enabling then disabling some events. Makes sure the refcounting + * works properly. + */ + @Test + public void testSomeEventsAfterDisabling() { + assertTrue(session1.enableEvents(EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C)); + assertTrue(session2.enableEvents(EVENT_NAME_B, EVENT_NAME_C, EVENT_NAME_D)); + assertTrue(session3.enableEvents(EVENT_NAME_A)); + + assertTrue(session1.disableEvents(EVENT_NAME_C)); + assertTrue(session2.disableEvents(EVENT_NAME_B, EVENT_NAME_C)); + assertTrue(session3.disableEvents(EVENT_NAME_A)); + + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(20, output1.size()); + assertEquals(10, output2.size()); + assertEquals(0, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(0, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } + + /** + * Test with a prefix in one session and a standard event in another. + */ + @Test + public void testPrefixAndEvent() { + assertTrue(session1.enableEvents("EventAB*")); + assertTrue(session3.enableEvents(EVENT_NAME_A)); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(30, output1.size()); + assertEquals(0, output2.size()); + assertEquals(10, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } + + /** + * Test with all events enabled in one session, and an event prefix in + * another. Once again, there should be no duplicates. + */ + @Test + public void testAllEventsAndPrefix() { + assertTrue(session1.enableAllEvents()); + assertTrue(session2.enableEvents("EventABC*")); + assertTrue(session1.start()); + assertTrue(session2.start()); + assertTrue(session3.start()); + + sendEventsToLoggers(); + + assertTrue(session1.stop()); + assertTrue(session2.stop()); + assertTrue(session3.stop()); + + List output1 = session1.view(); + List output2 = session2.view(); + List output3 = session3.view(); + assertNotNull(output1); + assertNotNull(output2); + assertNotNull(output3); + assertEquals(40, output1.size()); + assertEquals(20, output2.size()); + assertEquals(0, output3.size()); + + assertEquals(10, handlerA.getEventCount()); + assertEquals(10, handlerB.getEventCount()); + assertEquals(10, handlerC.getEventCount()); + assertEquals(10, handlerD.getEventCount()); + } +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java new file mode 100644 index 0000000..020ad36 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.filter.FilterChangeNotifier; +import org.lttng.ust.agent.filter.IFilterChangeListener; +import org.lttng.ust.agent.session.EventRule; +import org.lttng.ust.agent.session.LogLevelSelector; +import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType; +import org.lttng.ust.agent.utils.EventRuleFactory; +import org.lttng.ust.agent.utils.ILogLevelStrings; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Base test class for {@link IFilterChangeListener} tests. + * + * @author Alexandre Montplaisir + */ +@RunWith(TestPrintRunner.class) +public abstract class FilterListenerITBase { + + private static final String EVENT_NAME_A = "eventA"; + private static final String EVENT_NAME_B = "eventB"; + private static final String EVENT_NAME_C = "eventC"; + + private ILttngSession session; + private TestFilterListener listener; + private ILttngHandler handler; + + protected abstract ILttngSession.Domain getSessionDomain(); + protected abstract ILttngHandler getLogHandler() throws SecurityException, IOException; + protected abstract ILogLevelStrings getLogLevelStrings(); + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void setup() throws SecurityException, IOException { + handler = getLogHandler(); + listener = new TestFilterListener(); + FilterChangeNotifier.getInstance().registerListener(listener); + session = ILttngSession.createSession(null, getSessionDomain()); + } + + /** + * Test teardown + */ + @After + public void teardown() { + session.close(); + FilterChangeNotifier.getInstance().unregisterListener(listener); + handler.close(); + } + + /** + * Test not sending any commands. + */ + @Test + public void testNoRules() { + assertEquals(0, listener.getNbNotifications()); + assertEquals(Collections.EMPTY_SET, listener.getCurrentRules()); + } + + /** + * Test sending one event rule. + */ + @Test + public void testOneRule() { + Set rules = Collections.singleton( + EventRuleFactory.createRule(EVENT_NAME_A)); + + session.enableEvent(EVENT_NAME_A, null, false, null); + + assertEquals(1, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test sending many event rules. + */ + @Test + public void testManyRules() { + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B), + EventRuleFactory.createRule(EVENT_NAME_C)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + session.enableEvent(EVENT_NAME_C, null, false, null); + + assertEquals(3, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test enabling then disabling some events. + */ + @Test + public void testManyRulesDisableSome() { + Set rules = Collections.singleton( + EventRuleFactory.createRule(EVENT_NAME_A)); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + session.enableEvent(EVENT_NAME_C, null, false, null); + session.disableEvents(EVENT_NAME_B); + session.disableEvents(EVENT_NAME_C); + + assertEquals(5, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test enabling some rules, then calling disable-event -a. + */ + @Test + public void testManyRulesDisableAll() { + Set rules = Collections.EMPTY_SET; + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + session.enableEvent(EVENT_NAME_C, null, false, null); + session.disableAllEvents(); + + /* + * We should receive 6 notifications, because a "disable-event -a" sends + * one for each event that was enabled. + */ + assertEquals(6, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test enabling the same event name with various values of loglevels. + */ + @Test + public void testSameEventsDiffLogLevels() { + LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); + LogLevelSelector lls3 = new LogLevelSelector(getLogLevelStrings().infoInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A, lls1), + EventRuleFactory.createRule(EVENT_NAME_A, lls2), + EventRuleFactory.createRule(EVENT_NAME_A, lls3)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().infoName(), false, null); + + assertEquals(3, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test enabling the same event name with various filters. + */ + @Test + public void testSameEventsDiffFilters() { + String filterA = "filterA"; + String filterB = "filterB"; + + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterA), + EventRuleFactory.createRule(EVENT_NAME_C, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterB)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, filterA); + session.enableEvent(EVENT_NAME_C, null, false, filterB); + + assertEquals(3, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Test sending some notifications then detaching a listener. Subsequent + * notifications should not be sent. + */ + @Test + public void testDetachingListener() { + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + FilterChangeNotifier.getInstance().unregisterListener(listener); + session.enableEvent(EVENT_NAME_C, null, false, null); + + assertEquals(2, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + } + + /** + * Run a test with multiple listeners attached to the manager. All listeners + * should receive all the data. + */ + @Test + public void testMultipleListeners() { + FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); + TestFilterListener listener2 = new TestFilterListener(); + TestFilterListener listener3 = new TestFilterListener(); + fcn.registerListener(listener2); + fcn.registerListener(listener3); + + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + session.enableEvent(EVENT_NAME_C, null, false, null); + session.disableEvents(EVENT_NAME_C); + + assertEquals(4, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + + assertEquals(4, listener2.getNbNotifications()); + assertEquals(rules, listener2.getCurrentRules()); + + assertEquals(4, listener3.getNbNotifications()); + assertEquals(rules, listener3.getCurrentRules()); + + fcn.unregisterListener(listener2); + fcn.unregisterListener(listener3); + } + + /** + * Test with both attached and unattached listeners. The unattached ones + * should not receive anything, but should not interfere with the other + * ones. + */ + @Test + public void testUnattachedListeners() { + FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); + TestFilterListener listener2 = new TestFilterListener(); + TestFilterListener listener3 = new TestFilterListener(); + /* We attach then detach listener2. We never attach listener3 */ + fcn.registerListener(listener2); + fcn.unregisterListener(listener2); + + Set rules = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + + assertEquals(2, listener.getNbNotifications()); + assertEquals(rules, listener.getCurrentRules()); + + assertEquals(0, listener2.getNbNotifications()); + assertEquals(Collections.EMPTY_SET, listener2.getCurrentRules()); + + assertEquals(0, listener3.getNbNotifications()); + assertEquals(Collections.EMPTY_SET, listener3.getCurrentRules()); + } + + /** + * Test that a newly-registered listener correctly receives the "statedump", + * which means all the rules currently active, upon registration. + */ + @Test + public void testStatedump() { + FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); + TestFilterListener listener2 = new TestFilterListener(); + + Set rules1 = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B)) + .collect(Collectors.toSet()); + Set rules2 = Stream.of( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_C)) + .collect(Collectors.toSet()); + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + fcn.registerListener(listener2); + + /* We should have received the "statedump" when registering */ + assertEquals(2, listener2.getNbNotifications()); + assertEquals(rules1, listener2.getCurrentRules()); + + session.enableEvent(EVENT_NAME_C, null, false, null); + session.disableEvents(EVENT_NAME_B); + + /* Subsequent changes should also be received */ + assertEquals(4, listener2.getNbNotifications()); + assertEquals(rules2, listener2.getCurrentRules()); + + fcn.unregisterListener(listener2); + } + + /** + * The filter listener used for tests. + */ + private static class TestFilterListener implements IFilterChangeListener { + + private final Set currentRules = new HashSet<>(); + private volatile int currentNotifications = 0; + + public TestFilterListener() {} + + @Override + public void eventRuleAdded(EventRule rule) { + currentRules.add(rule); + currentNotifications++; + } + + @Override + public void eventRuleRemoved(EventRule rule) { + currentRules.remove(rule); + currentNotifications++; + } + + public int getNbNotifications() { + return currentNotifications; + } + + public Set getCurrentRules() { + return currentRules; + } + } + +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java new file mode 100644 index 0000000..fd1a46b --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/EventRuleFactory.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +import java.util.StringJoiner; + +import org.lttng.ust.agent.session.EventRule; +import org.lttng.ust.agent.session.LogLevelSelector; + +/** + * Factory class for {@link EventRule} objects, offering convenience methods + * that mimic the results of passing the given arguments on the command-line. + * + * @author Alexandre Montplaisir + */ +public final class EventRuleFactory { + + /** Name of the "all" (-a) event */ + public static final String EVENT_NAME_ALL = "*"; + + /** Log level set by default when it is not specified */ + public static final LogLevelSelector LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(Integer.MIN_VALUE, 0); + + private EventRuleFactory() {} + + /** + * Construct an event by only passing the event name on the command-line. + * + * @param eventName + * The event name + * @return The corresponding event rule + */ + public static EventRule createRule(String eventName) { + return new EventRule(eventName, LOG_LEVEL_UNSPECIFIED, filterStringFromEventName(eventName)); + } + + /** + * Construct and event rule by specifying the event name and log level. + * + * @param eventName + * The event name + * @param logLevelSelector + * The log level + * @return The corresponding event rule + */ + public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector) { + StringJoiner sj = new StringJoiner(") && (", "(", ")"); + String filterStr = sj.add(filterStringFromEventName(eventName)) + .add(filterStringFromLogLevel(logLevelSelector)) + .toString(); + return new EventRule(eventName, logLevelSelector, filterStr); + } + + /** + * Construct and event rule by specifying the event name, log level, and a + * filter string. + * + * @param eventName + * The event name + * @param logLevelSelector + * The log level + * @param extraFilter + * The filter string passed on the command-line + * @return The corresponding event rule + */ + public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) { + StringJoiner sj1 = new StringJoiner(") && (", "(", ")"); + sj1.add(extraFilter); + sj1.add(filterStringFromEventName(eventName)); + String firstPart = sj1.toString(); + + if (logLevelSelector.equals(LOG_LEVEL_UNSPECIFIED)) { + return new EventRule(eventName, logLevelSelector, firstPart); + } + + /* + * If there is both a filter and a log level, the filter + event name is + * "resolved" first. + */ + StringJoiner sj2 = new StringJoiner(") && (", "(", ")"); + sj2.add(firstPart); + sj2.add(filterStringFromLogLevel(logLevelSelector)); + return new EventRule(eventName, logLevelSelector, sj2.toString()); + } + + /** + * Construct an event rule corresponding to enabling all (-a) events. + * + * @return The corresponding event rule + */ + public static EventRule createRuleAllEvents() { + return new EventRule(EVENT_NAME_ALL, LOG_LEVEL_UNSPECIFIED, ""); + } + + private static String filterStringFromEventName(String eventName) { + return "logger_name == \"" + eventName + "\""; + } + + private static String filterStringFromLogLevel(LogLevelSelector logLevelSelector) { + StringBuilder sb = new StringBuilder(); + sb.append("int_loglevel "); + + switch (logLevelSelector.getLogLevelType()) { + case LTTNG_EVENT_LOGLEVEL_RANGE: + sb.append(">="); + break; + case LTTNG_EVENT_LOGLEVEL_SINGLE: + sb.append("=="); + break; + case LTTNG_EVENT_LOGLEVEL_ALL: + default: + throw new IllegalArgumentException(); + } + + sb.append(" " + logLevelSelector.getLogLevel()); + return sb.toString(); + } + +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java new file mode 100644 index 0000000..e46a718 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/ILogLevelStrings.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +/** + * Interface to match the log level values used by LTTng to their representation + * (name and integer value) used by the logging APIs. + * + * @author Alexandre Montplaisir + */ +public interface ILogLevelStrings { + + /** + * @return The string representation of the "warning" level + */ + String warningName(); + + /** + * @return The integer representation of the "warning" level + */ + int warningInt(); + + /** + * @return The string representation of the "info" level + */ + String infoName(); + + /** + * @return The integer representation of the "info" level + */ + int infoInt(); + + /** + * Values for JUL + */ + ILogLevelStrings JUL_LOGLEVEL_STRINGS = new ILogLevelStrings() { + + @Override + public String warningName() { + return "warning"; + } + + @Override + public int warningInt() { + return 900; + } + + @Override + public String infoName() { + return "info"; + } + + @Override + public int infoInt() { + return 800; + } + }; + + /** + * Values for log4j 1.x + */ + ILogLevelStrings LOG4J_LOGLEVEL_STRINGS = new ILogLevelStrings() { + + @Override + public String warningName() { + return "warn"; + } + + @Override + public int warningInt() { + return 30000; + } + + @Override + public String infoName() { + return "info"; + } + + @Override + public int infoInt() { + return 20000; + } + }; + +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/LttngUtils.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/LttngUtils.java new file mode 100644 index 0000000..884d69c --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/LttngUtils.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +import java.util.Arrays; +import java.util.List; + +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.utils.ShellUtils; + +/** + * Utility methods to test the presence of certain LTTng tools or libraries in + * the runtime environment. + */ +public final class LttngUtils { + + private LttngUtils() {} + + /** + * Check that lttng-tools and babeltrace are installed on the system and + * working. + * + * @param domain + * The tracing domain to test for (we will try to setup a session + * with this domain) + * @return True if the environment should allow tracing fine, false if there + * was an error + */ + public static boolean checkForLttngTools(Domain domain) { + try (ILttngSession session = ILttngSession.createSession(null, domain)) { + boolean ret1 = session.enableAllEvents(); + boolean ret2 = session.start(); + boolean ret3 = session.stop(); + /* + * "lttng view" also tests that Babeltrace is installed and working + */ + List contents = session.view(); + return (ret1 && ret2 && ret3 && contents.isEmpty()); + } + } + + /** + * Check if there is a user session daemon currently running on the system. + * It needs to be of the same user as the application running this program. + * + * @return If there is a user session daemon currently running + */ + public static boolean checkForUserSessiond() { + String userName = System.getProperty("user.name"); + + /* The user name is truncated to 7 characters in "ps" */ + String shortUserName = userName.substring(0, Math.min(userName.length(), 7)); + + List command = Arrays.asList("ps", "-e", "u"); + List output = ShellUtils.getOutputFromCommand(false, command); + return output.stream() + .filter(s -> s.contains("lttng-sessiond")) + .anyMatch(s -> s.startsWith(shortUserName)); + } + + /** + * Check if there is a root user session daemon daemon currently running on + * the system. + * + * @return If there is a root session daemon currently running + */ + public static boolean checkForRootSessiond() { + List command = Arrays.asList("ps", "-e", "u"); + List output = ShellUtils.getOutputFromCommand(false, command); + return output.stream() + .filter(s -> s.contains("lttng-sessiond")) + .anyMatch(s -> s.startsWith("root")); + } + +} diff --git a/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java new file mode 100644 index 0000000..1285984 --- /dev/null +++ b/lttng-ust-java-tests-common/src/main/java/org/lttng/ust/agent/utils/TestPrintRunner.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +import org.junit.runner.Description; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.InitializationError; + +/** + * Test runner that will print the name of the test being run to stdout. + * + * Thanks to http://stackoverflow.com/a/27070843/4227853 for the tips. + * + * @author Alexandre Montplaisir + */ +public class TestPrintRunner extends BlockJUnit4ClassRunner { + + /** + * Constructor + * + * @param klass + * @throws InitializationError + */ + public TestPrintRunner(Class klass) throws InitializationError { + super(klass); + } + + @Override + public void run(RunNotifier notifier) { + RunListener listener = new TestPrintListener(); + + notifier.addListener(listener); + super.run(notifier); + notifier.removeListener(listener); + } + + /** + * Listener that will print the class and test name to stdout. + */ + public static class TestPrintListener extends RunListener { + + @Override + public void testStarted(Description description) { + System.out.println("Running " + getTestName(description)); + } + + @Override + public void testAssumptionFailure(Failure failure) { + System.out.println("SKIPPING TEST: " + getTestName(failure.getDescription())); + System.out.println(failure.getMessage()); + } + + /** + * Get the className#methodName from a Description. + */ + private static String getTestName(Description description) { + return description.getClassName() + '#' + description.getMethodName(); + } + } + +} diff --git a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java new file mode 100644 index 0000000..703e0e3 --- /dev/null +++ b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.client; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.lttng.ust.agent.client.ILttngTcpClientListener; +import org.lttng.ust.agent.session.EventRule; + +/** + * TCP client listener used for test. Instead of "handling" commands, it just + * keep tracks of commands it receives. + * + * @author Alexandre Montplaisir + */ +public class TcpClientDebugListener implements ILttngTcpClientListener { + + private final List enabledEventCommands = Collections.synchronizedList(new ArrayList<>()); + private final List disabledEventCommands = Collections.synchronizedList(new ArrayList<>()); + + @Override + public boolean eventEnabled(EventRule rule) { + enabledEventCommands.add(rule); + return true; + } + + @Override + public boolean eventDisabled(String name) { + disabledEventCommands.add(name); + return true; + } + + /** + * Not yet implemented + */ + @Override + public List listAvailableEvents() { + // TODO NYI + return Collections.EMPTY_LIST; + } + + /** + * @return The "enable-event" commands that were received, since + * instantiation or the last {@link #clearAllCommands}. + */ + public List getEnabledEventCommands() { + synchronized (enabledEventCommands) { + return new ArrayList<>(enabledEventCommands); + } + } + + /** + * @return The "disable-event" commands that were received, since + * instantiation or the last {@link #clearAllCommands}. + */ + public List getDisabledEventCommands() { + synchronized (disabledEventCommands) { + return new ArrayList<>(disabledEventCommands); + } + } + + /** + * Clear all tracked data. + */ + public void clearAllCommands() { + enabledEventCommands.clear(); + disabledEventCommands.clear(); + } + +} diff --git a/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java new file mode 100644 index 0000000..2794dfa --- /dev/null +++ b/lttng-ust-java-tests-common/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java @@ -0,0 +1,376 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.client; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.ILttngAgent; +import org.lttng.ust.agent.client.LttngTcpSessiondClient; +import org.lttng.ust.agent.session.EventRule; +import org.lttng.ust.agent.session.LogLevelSelector; +import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType; +import org.lttng.ust.agent.utils.EventRuleFactory; +import org.lttng.ust.agent.utils.ILogLevelStrings; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Tests for the TCP client only, without using an agent. + * + * This test suite requires that a *root* session daemon is running on the + * system. Since we have to explicitly tell the TCP client which sessiond to + * connect to, we have to hard-code it in here. + * + * @author Alexandre Montplaisir + */ +@RunWith(TestPrintRunner.class) +public class TcpClientIT { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private static final String EVENT_NAME_A = "eventA"; + private static final String EVENT_NAME_B = "eventB"; + private static final String EVENT_NAME_C = "eventC"; + + /* Test configuration */ + private static final int DOMAIN_VALUE = ILttngAgent.Domain.JUL.value(); + private static final ILttngSession.Domain SESSION_DOMAIN = ILttngSession.Domain.JUL; + private static final boolean ROOT_SESSIOND = true; + + private static TcpClientDebugListener clientListener; + private static LttngTcpSessiondClient client; + private static Thread clientThread; + + private ILttngSession session; + + // ------------------------------------------------------------------------ + // Maintenance + // ------------------------------------------------------------------------ + + /** + * Class setup + */ + @BeforeClass + public static void setupClass() { + LttngToolsHelper.destroyAllSessions(); + + clientListener = new TcpClientDebugListener(); + client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, ROOT_SESSIOND); + + clientThread = new Thread(client); + clientThread.start(); + + assumeTrue("Timed out waiting for root sessiond", client.waitForConnection(5)); + } + + /** + * Class teardown + */ + @AfterClass + public static void teardownClass() { + if (client != null) { + client.close(); + } + if (clientThread != null) { + try { + clientThread.join(); + } catch (InterruptedException e) { + } + } + } + + /** + * Test setup + */ + @Before + public void setup() { + session = ILttngSession.createSession(null, SESSION_DOMAIN); + clientListener.clearAllCommands(); + } + + /** + * Test teardown + */ + @After + public void teardown() { + session.close(); + } + + + private static ILogLevelStrings getLogLevelStrings() { + return ILogLevelStrings.JUL_LOGLEVEL_STRINGS; + } + + /** + * Check that two lists contain the exact same element (including + * duplicates), but their order does not matter. + */ + private static > boolean containSameElements(List list1, List list2) { + List newlist1 = new ArrayList<>(list1); + List newlist2 = new ArrayList<>(list2); + Collections.sort(newlist1); + Collections.sort(newlist2); + return (newlist1.equals(newlist2)); + + } + + // ------------------------------------------------------------------------ + // Test cases + // ------------------------------------------------------------------------ + + /** + * Test enabling one event. + */ + @Test + public void testEnableEvent() { + session.enableEvent(EVENT_NAME_A, null, false, null); + + List expectedCommands = Collections.singletonList( + EventRuleFactory.createRule(EVENT_NAME_A)); + + List actualCommands = clientListener.getEnabledEventCommands(); + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test an "enable-event -a" command. + */ + @Test + public void testEnableAllEvents() { + session.enableAllEvents(); + + List expectedCommands = Collections.singletonList( + EventRuleFactory.createRuleAllEvents()); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test enabling then disabling one event. + */ + @Test + public void testEnableThenDisableOneEvent() { + session.enableEvent(EVENT_NAME_A, null, false, null); + session.disableEvents(EVENT_NAME_A); + + List expectedEnableCommands = Collections.singletonList( + EventRuleFactory.createRule(EVENT_NAME_A)); + List expectedDisableCommands = Collections.singletonList(EVENT_NAME_A); + + assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); + assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); + } + + /** + * Test enabling some events manually, then disabling all events (-a). + */ + @Test + public void testEnableSomeThenDisableAll() { + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_B, null, false, null); + session.enableEvent(EVENT_NAME_C, null, false, null); + session.disableAllEvents(); + + List expectedEnableCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_B), + EventRuleFactory.createRule(EVENT_NAME_C)); + /* + * A "disable-event -a" will send one command for each enabled event. + * The order may be different though. + */ + List expectedDisableCommands = Arrays.asList( + EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C); + + assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); + assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); + } + + /** + * Test enabling then (enable-event -a) then disabling all (disable-event -a) events. + */ + @Test + public void testEnableAllThenDisableAll() { + session.enableAllEvents(); + session.disableAllEvents(); + + List expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents()); + List expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL); + + assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); + assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); + } + + /** + * Test specifying an event with a --loglevel option. + */ + @Test + public void testEnableEventLogLevelRange() { + LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + + List expectedCommands = Collections.singletonList( + EventRuleFactory.createRule(EVENT_NAME_A, lls)); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test enabling an event with a --loglevel-only option. + */ + @Test + public void testEnableEventLogLevelSingle() { + LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); + + List expectedCommands = Collections.singletonList( + EventRuleFactory.createRule(EVENT_NAME_A, lls)); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test enabling an event twice, for the same loglevel, with --loglevel followed by --loglevel-only. + */ + @Test + public void testEnableEventsLogLevelRangeAndSingle() { + LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); + + List expectedCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A, lls1), + EventRuleFactory.createRule(EVENT_NAME_A, lls2) + ); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test enabling an event twice, for the same loglevel, with --loglevel-only followed by --loglevel. + */ + @Test + public void testEnableEventsLogLevelSingleAndRange() { + LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); + LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + + List expectedCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A, lls1), + EventRuleFactory.createRule(EVENT_NAME_A, lls2) + ); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Test enabling the same event, same loglevel, but different loglevel types + * (--loglevel vs --loglevel-only) in two separate sessions. + */ + @Test + public void testEnableEventsLogLevelRangeAndSingleDiffSessions() { + try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) { + + LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); + + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); + + List expectedCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A, lls1), + EventRuleFactory.createRule(EVENT_NAME_A, lls2)); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + } + + /** + * Enable the same event multiple times with different filter strings. + */ + @Test + public void testEnableEventsDiffFilters() { + final String filter1 = "filter1"; + final String filter2 = "filter2"; + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_A, null, false, filter1); + session.enableEvent(EVENT_NAME_A, null, false, filter2); + + List expectedCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), + EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } + + /** + * Enable the same event multiple times with different log levels and + * filters. + */ + @Test + public void testEnableEventsLogLevelAndFilters() { + final LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); + final String filter = "filter1"; + + session.enableEvent(EVENT_NAME_A, null, false, null); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); + session.enableEvent(EVENT_NAME_A, null, false, filter); + session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter); + + List expectedCommands = Arrays.asList( + EventRuleFactory.createRule(EVENT_NAME_A), + EventRuleFactory.createRule(EVENT_NAME_A, lls), + EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), + EventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); + List actualCommands = clientListener.getEnabledEventCommands(); + + assertEquals(expectedCommands, actualCommands); + } +} diff --git a/lttng-ust-java-tests-jul/.classpath b/lttng-ust-java-tests-jul/.classpath new file mode 100644 index 0000000..af1430b --- /dev/null +++ b/lttng-ust-java-tests-jul/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-jul/.project b/lttng-ust-java-tests-jul/.project new file mode 100644 index 0000000..6a18819 --- /dev/null +++ b/lttng-ust-java-tests-jul/.project @@ -0,0 +1,23 @@ + + + lttng-ust-java-tests-jul + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/lttng-ust-java-tests-jul/.settings/org.eclipse.core.resources.prefs b/lttng-ust-java-tests-jul/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..8dd9b1d --- /dev/null +++ b/lttng-ust-java-tests-jul/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.core.prefs b/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f1acd28 --- /dev/null +++ b/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,392 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.ui.prefs b/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..b883c15 --- /dev/null +++ b/lttng-ust-java-tests-jul/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,62 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spaces +formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/lttng-ust-java-tests-jul/.settings/org.eclipse.m2e.core.prefs b/lttng-ust-java-tests-jul/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/lttng-ust-java-tests-jul/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/lttng-ust-java-tests-jul/pom.xml b/lttng-ust-java-tests-jul/pom.xml new file mode 100644 index 0000000..ab7186d --- /dev/null +++ b/lttng-ust-java-tests-jul/pom.xml @@ -0,0 +1,80 @@ + + + + + 4.0.0 + + + org.lttng.ust + lttng-ust-java-parent + 1.0.0 + + + lttng-ust-java-tests-jul + jar + + LTTng-UST Java Agent JUL API Integration Tests + + + + org.lttng.ust.agent + lttng-ust-agent-common + + + org.lttng.ust.agent + lttng-ust-agent-jul + + + org.lttng.tools + lttng-tools-java + + + org.lttng.ust + lttng-ust-java-tests-common + + + junit + junit + + + + + + + benchmark + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + **/*Benchmark.java + + + + + + + + + diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java new file mode 100644 index 0000000..9ac3df5 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler; + +import java.util.LinkedList; +import java.util.List; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Base abstract class for JUL benchmarks. Sub-classes can setup parameters to + * test different types of log handlers. + */ +public abstract class JulHandlerBenchmarkBase { + + // ------------------------------------------------------------------------ + // Configurable test parameters + // ------------------------------------------------------------------------ + + /** Nb of runs per test, result will be averaged */ + private static final int NB_RUNS = 10; + + /** Trace/log events per run */ + private static final int NB_ITER = 100000; + + /** Which tests to run (for different number of threads) */ + private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8}; + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + protected Logger logger; + protected Handler handler; + + // ------------------------------------------------------------------------ + // Maintenance methods + // ------------------------------------------------------------------------ + + /** + * Base test setup + */ + @Before + public void setup() { + /* Set up the logger */ + logger = Logger.getLogger("Test logger"); + logger.setUseParentHandlers(false); + logger.setLevel(Level.ALL); + + /* Sub-classes' @Before will setup the Handler */ + } + + /** + * Base test teardown + */ + @After + public void teardown() { + if (handler != null) { + logger.removeHandler(handler); + handler.close(); + } + handler = null; + logger = null; + } + + // ------------------------------------------------------------------------ + // Test methods + // ------------------------------------------------------------------------ + + /** + * Main test class for running the benchmark + */ + @Test + public void runBenchmark() { + if (handler != null) { + logger.addHandler(handler); + } + + System.out.println(); + System.out.println("Running benchmark: " + this.getClass().getCanonicalName()); + for (int i : NB_THREADS) { + runTest(logger, i); + } + } + + private static void runTest(Logger log, int nbThreads) { + long start, end, average, total = 0; + for (int i = 0; i < NB_RUNS; i++) { + Runner runner = new Runner(nbThreads, NB_ITER, log); + + start = System.nanoTime(); + runner.run(); + end = System.nanoTime(); + + total += (end - start); + } + average = total / NB_RUNS; + System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event"); + } + + // ------------------------------------------------------------------------ + // Helper classes + // ------------------------------------------------------------------------ + + private static class Runner implements Runnable { + + private final List workers = new LinkedList<>(); + private final List workerThreads = new LinkedList<>(); + + public Runner(int nbThreads, int nbIter, Logger log) { + + for (int id = 0; id < nbThreads; id++) { + Worker curWorker = new Worker(id, nbIter, log); + workers.add(curWorker); + workerThreads.add(new Thread(curWorker, "worker " + id)); + } + } + + @Override + public void run() { + for (Thread curThread : workerThreads) { + curThread.start(); + } + + for (Thread curThread : workerThreads) { + try { + curThread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + private static class Worker implements Runnable { + + private final Logger log; + private final int threadId; + private final int nbIter; + + public Worker(int threadId, int nbIter, Logger log) { + this.log = log; + this.threadId = threadId; + this.nbIter = nbIter; + } + + @Override + public void run() { + for (int i = 0; i < nbIter; i++) { + log.info("Thread " + threadId + ", iteration " + i); + } + } + + } + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java new file mode 100644 index 0000000..44a5290 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.builtin; + +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +import org.junit.Before; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; + +/** + * Test suite of using a "dummy" handler, which means a handler that does + * exactly nothing. + */ +public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase { + + /** + * Test setup + */ + @Before + public void testSetup() { + handler = new DummyHandler(); + } + + private static class DummyHandler extends Handler { + + public DummyHandler() { + super(); + } + + @Override + public void close() throws SecurityException {} + + @Override + public void flush() {} + + @Override + public void publish(LogRecord record) {} + + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java new file mode 100644 index 0000000..af4ab7c --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.builtin; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.logging.FileHandler; +import java.util.logging.SimpleFormatter; + +import org.junit.After; +import org.junit.Before; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; + +/** + * Test class using a {@link FileHandler}, which a {@link SimpleFormatter}. + */ +public class FileHandlerBenchmark extends JulHandlerBenchmarkBase { + + private Path outputFile; + + /** + * Test setup + * + * @throws SecurityException + * If there is problem setting up the handler + * @throws IOException + * If there is problem setting up the handler + */ + @Before + public void testSetup() throws SecurityException, IOException { + outputFile = Files.createTempFile(this.getClass().getSimpleName(), null); + + handler = new FileHandler(outputFile.toString(), false); + handler.setFormatter(new SimpleFormatter()); + } + + /** + * Test cleanup + * + * @throws IOException + * If we could not delete the test file + */ + @After + public void testTeardown() throws IOException { + Files.deleteIfExists(outputFile); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java new file mode 100644 index 0000000..09457d2 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.builtin; + +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; + +/** + * Benchmark that will attach no {@link java.util.logging.Handler} to the + * {@link java.util.logging.Logger} object. + */ +public class NoHandlerBenchmark extends JulHandlerBenchmarkBase { + + /* Do not setup any handler */ +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java new file mode 100644 index 0000000..d0e514c --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.lttng; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.junit.After; +import org.junit.Before; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; +import org.lttng.ust.agent.jul.LttngLogHandler; + +/** + * Benchmark the LTTng-JUL handler, but with tracing disabled in the tracing + * session. + */ +public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { + + private ILttngSession session; + + /** + * Test setup + * + * @throws IOException + */ + @Before + public void testSetup() throws IOException { + handler = new LttngLogHandler(); + + session = ILttngSession.createSession(null, Domain.JUL); + assertTrue(session.enableEvents("non-event")); + assertTrue(session.start()); + } + + /** + * Test cleanup + */ + @After + public void testTeardown() { + assertTrue(session.stop()); + session.close(); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java new file mode 100644 index 0000000..c594de4 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.lttng; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.junit.After; +import org.junit.Before; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; +import org.lttng.ust.agent.jul.LttngLogHandler; + +/** + * Test the LTTng-JUL handler, with it actually sending events to the tracer. + */ +public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { + + private ILttngSession session; + + /** + * Test setup + * + * @throws IOException + */ + @Before + public void testSetup() throws IOException { + handler = new LttngLogHandler(); + + session = ILttngSession.createSession(null, Domain.JUL); + assertTrue(session.enableAllEvents()); + assertTrue(session.start()); + } + + /** + * Test cleanup + */ + @After + public void testTeardown() { + assertTrue(session.stop()); + session.close(); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java new file mode 100644 index 0000000..112b0f0 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old; + +import static org.junit.Assert.assertTrue; + +import org.junit.After; +import org.junit.Before; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.LTTngAgent; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; + +/** + * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is + * disabled in the tracing session. + */ +@SuppressWarnings("deprecation") +public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { + + private ILttngSession session; + + /** + * Test setup + */ + @Before + public void testSetup() { + LTTngAgent.getLTTngAgent(); + + session = ILttngSession.createSession(null, Domain.JUL); + assertTrue(session.enableEvents("non-event")); + assertTrue(session.start()); + } + + /** + * Test cleanup + */ + @After + public void testTeardown() { + assertTrue(session.stop()); + session.close(); + + LTTngAgent.dispose(); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java new file mode 100644 index 0000000..a36578b --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.lang.reflect.Field; + +import org.junit.After; +import org.junit.Before; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.ust.agent.LTTngAgent; +import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; +import org.lttng.ust.agent.jul.LttngLogHandler; + +/** + * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is + * enabled in the tracing session. + */ +@SuppressWarnings("deprecation") +public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { + + private ILttngSession session; + private LttngLogHandler agentHandler; + + + /** + * Test setup + */ + @Before + public void testSetup() { + LTTngAgent agentInstance = LTTngAgent.getLTTngAgent(); + + /* + * The "old API" works by attaching a handler managed by the agent to + * the root JUL logger. This causes problems here, because we use + * logger.setUserParentHandler(false), which does not trigger the + * handler as would be expected. + * + * Instead we will retrieve this handler through reflection, and attach + * it to our own logger here for the duration of the test. + */ + try { + Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler"); + julHandlerField.setAccessible(true); + agentHandler = (LttngLogHandler) julHandlerField.get(agentInstance); + + logger.addHandler(agentHandler); + + } catch (ReflectiveOperationException e) { + fail(); + } + + session = ILttngSession.createSession(null, Domain.JUL); + assertTrue(session.enableAllEvents()); + assertTrue(session.start()); + } + + /** + * Test cleanup + */ + @After + public void testTeardown() { + assertTrue(session.stop()); + session.close(); + + logger.removeHandler(agentHandler); + LTTngAgent.dispose(); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java new file mode 100644 index 0000000..b0a9738 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulEnabledEventsIT.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.EnabledEventsITBase; +import org.lttng.ust.agent.jul.LttngLogHandler; +import org.lttng.ust.agent.utils.JulTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Enabled events test for the LTTng-UST JUL log handler. + */ +public class JulEnabledEventsIT extends EnabledEventsITBase { + + private static final Domain DOMAIN = Domain.JUL; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeClass + public static void julClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(JulTestUtils.checkForJulLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class cleanup + */ + @AfterClass + public static void julClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void julSetup() throws SecurityException, IOException { + loggerA = Logger.getLogger(EVENT_NAME_A); + loggerB = Logger.getLogger(EVENT_NAME_B); + loggerC = Logger.getLogger(EVENT_NAME_C); + loggerD = Logger.getLogger(EVENT_NAME_D); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + loggerC.setLevel(Level.ALL); + loggerD.setLevel(Level.ALL); + + handlerA = new LttngLogHandler(); + handlerB = new LttngLogHandler(); + handlerC = new LttngLogHandler(); + + loggerA.addHandler((Handler) handlerA); + loggerB.addHandler((Handler) handlerB); + loggerC.addHandler((Handler) handlerC); + } + + /** + * Test teardown + */ + @After + public void julTeardown() { + loggerA.removeHandler((Handler) handlerA); + loggerB.removeHandler((Handler) handlerB); + loggerC.removeHandler((Handler) handlerC); + + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + } + + @Override + protected Domain getDomain() { + return DOMAIN; + } + + @Override + protected void sendEventsToLoggers() { + JulTestUtils.send10EventsTo(loggerA); + JulTestUtils.send10EventsTo(loggerB); + JulTestUtils.send10EventsTo(loggerC); + JulTestUtils.send10EventsTo(loggerD); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java new file mode 100644 index 0000000..9a20f89 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLegacyApiIT.java @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.LTTngAgent; +import org.lttng.ust.agent.utils.JulTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Enabled events test for the LTTng-UST JUL log handler, using the legacy API. + */ +@RunWith(TestPrintRunner.class) +@SuppressWarnings("deprecation") +public class JulLegacyApiIT { + + private static final Domain DOMAIN = Domain.JUL; + + private static final String EVENT_NAME_A = "EventA"; + private static final String EVENT_NAME_B = "EventB"; + + private ILttngSession session; + + private Logger loggerA; + private Logger loggerB; + + /** + * Class setup + */ + @BeforeClass + public static void julClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(JulTestUtils.checkForJulLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class cleanup + */ + @AfterClass + public static void julClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + */ + @Before + public void setup() { + loggerA = Logger.getLogger(EVENT_NAME_A); + LTTngAgent.getLTTngAgent(); + loggerB = Logger.getLogger(EVENT_NAME_B); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + + session = ILttngSession.createSession(null, DOMAIN); + } + + /** + * Test cleanup + */ + @After + public void tearDown() { + session.close(); + + LTTngAgent.dispose(); + + loggerA = null; + loggerB = null; + } + + /** + * Test tracing with no events enabled in the tracing session. + */ + @Test + public void testNoEvents() { + assertTrue(session.start()); + + JulTestUtils.send10EventsTo(loggerA); + JulTestUtils.send10EventsTo(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertTrue(output.isEmpty()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(0, handler.getEventCount()); + } + + /** + * Test tracing with all events enabled (-j -a) in the tracing session. + */ + @Test + public void testAllEvents() { + assertTrue(session.enableAllEvents()); + assertTrue(session.start()); + + JulTestUtils.send10EventsTo(loggerA); + JulTestUtils.send10EventsTo(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(20, output.size()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(20, handler.getEventCount()); + } + + /** + * Test tracing with a subset of events enabled in the tracing session. + */ + @Test + public void testSomeEvents() { + assertTrue(session.enableEvents(EVENT_NAME_A)); + assertTrue(session.start()); + + JulTestUtils.send10EventsTo(loggerA); + JulTestUtils.send10EventsTo(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(10, output.size()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(10, handler.getEventCount()); + } + + /** + * Get the singleton JUL Handler currently managed by the LTTngAgent. It is + * not public, so we need reflection to access it. + * + * @return The agent's JUL handler + */ + private static ILttngHandler getAgentHandler() { + try { + Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler"); + julHandlerField.setAccessible(true); + return (ILttngHandler) julHandlerField.get(LTTngAgent.getLTTngAgent()); + } catch (ReflectiveOperationException | SecurityException e) { + fail(); + return null; + } + } + +} + diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java new file mode 100644 index 0000000..6b78cb2 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulListEventsIT.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.util.logging.Handler; +import java.util.logging.Logger; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.ListEventsITBase; +import org.lttng.ust.agent.jul.LttngLogHandler; +import org.lttng.ust.agent.utils.JulTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Test suite for the list events command for the JUL domain + */ +public class JulListEventsIT extends ListEventsITBase { + + private Logger[] loggers; + private Handler[] handlers; + + /** + * Test class setup + */ + @BeforeClass + public static void testClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(JulTestUtils.checkForJulLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void julSetup() throws SecurityException, IOException { + loggers = new Logger[] { + Logger.getLogger(LOGGER_NAME_1), + Logger.getLogger(LOGGER_NAME_2), + Logger.getLogger(LOGGER_NAME_3) + }; + + handlers = new Handler[] { + new LttngLogHandler(), + new LttngLogHandler() + }; + } + + /** + * Test teardown. Detach and close all log handlers. + */ + @After + public void julTeardown() { + for (Logger logger : loggers) { + for (Handler handler : handlers) { + logger.removeHandler(handler); + } + } + + for (Handler handler : handlers) { + handler.close(); + } + handlers = null; + loggers = null; + } + + @Override + protected ILttngSession.Domain getDomain() { + return ILttngSession.Domain.JUL; + } + + @Override + protected void attachHandlerToLogger(int handlerIndex, int loggerIndex) { + loggers[loggerIndex - 1].addHandler(handlers[handlerIndex - 1]); + } + + @Override + protected void detachHandlerFromLogger(int handlerIndex, int loggerIndex) { + loggers[loggerIndex - 1].removeHandler(handlers[handlerIndex - 1]); + } + +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java new file mode 100644 index 0000000..33116b0 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulMultiSessionIT.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.MultiSessionITBase; +import org.lttng.ust.agent.jul.LttngLogHandler; +import org.lttng.ust.agent.utils.JulTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * JUL tests for multiple concurrent tracing sessions + */ +public class JulMultiSessionIT extends MultiSessionITBase { + + private static final Domain DOMAIN = Domain.JUL; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeClass + public static void julClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(JulTestUtils.checkForJulLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class cleanup + */ + @AfterClass + public static void julClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void julSetup() throws SecurityException, IOException { + loggerA = Logger.getLogger(EVENT_NAME_A); + loggerB = Logger.getLogger(EVENT_NAME_B); + loggerC = Logger.getLogger(EVENT_NAME_C); + loggerD = Logger.getLogger(EVENT_NAME_D); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + loggerC.setLevel(Level.ALL); + loggerD.setLevel(Level.ALL); + + handlerA = new LttngLogHandler(); + handlerB = new LttngLogHandler(); + handlerC = new LttngLogHandler(); + handlerD = new LttngLogHandler(); + + loggerA.addHandler((Handler) handlerA); + loggerB.addHandler((Handler) handlerB); + loggerC.addHandler((Handler) handlerC); + loggerD.addHandler((Handler) handlerD); + } + + /** + * Test teardown + */ + @After + public void julTeardown() { + loggerA.removeHandler((Handler) handlerA); + loggerB.removeHandler((Handler) handlerB); + loggerC.removeHandler((Handler) handlerC); + loggerD.removeHandler((Handler) handlerD); + + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + } + + @Override + protected Domain getDomain() { + return DOMAIN; + } + + @Override + protected void sendEventsToLoggers() { + JulTestUtils.send10EventsTo(loggerA); + JulTestUtils.send10EventsTo(loggerB); + JulTestUtils.send10EventsTo(loggerC); + JulTestUtils.send10EventsTo(loggerD); + } +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java new file mode 100644 index 0000000..3db70b5 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.jul.LttngLogHandler; +import org.lttng.ust.agent.utils.ILogLevelStrings; +import org.lttng.ust.agent.utils.JulTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Filter notifications tests using the JUL logging API. + * + * @author Alexandre Montplaisir + */ +public class JulFilterListenerIT extends FilterListenerITBase { + + /** + * Class setup + */ + @BeforeClass + public static void julClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(JulTestUtils.checkForJulLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.JUL)); + LttngToolsHelper.destroyAllSessions(); + } + + @Override + protected ILttngSession.Domain getSessionDomain() { + return ILttngSession.Domain.JUL; + } + + @Override + protected ILttngHandler getLogHandler() throws SecurityException, IOException { + return new LttngLogHandler(); + } + + @Override + protected ILogLevelStrings getLogLevelStrings() { + return ILogLevelStrings.JUL_LOGLEVEL_STRINGS; + } + +} diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java new file mode 100644 index 0000000..4008815 --- /dev/null +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/utils/JulTestUtils.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.lttng.ust.agent.jul.LttngLogHandler; + +/** + * Utility methods for JUL tests + */ +public final class JulTestUtils { + + private JulTestUtils() { + } + + /** + * Check the the JUL native library is available, effectively allowing LTTng + * JUL handlers to be used. + * + * @return True if JUL works fine, false if it does not. + */ + public static boolean checkForJulLibrary() { + try { + LttngLogHandler testHandler = new LttngLogHandler(); + testHandler.close(); + } catch (SecurityException | IOException e) { + return false; + } + return true; + } + + /** + * Send 10 dummy events through the provided logger + * + * @param logger + * The logger to use to send events + */ + public static void send10EventsTo(Logger logger) { + String a = new String("a"); + Object[] params = { a, new String("b"), new Object() }; + + // Levels are FINE, FINER, FINEST, INFO, SEVERE, WARNING + logger.fine("A fine level message"); + logger.finer("A finer level message"); + logger.finest("A finest level message"); + logger.info("A info level message"); + logger.severe("A severe level message"); + logger.warning("A warning level message"); + logger.warning("Another warning level message"); + logger.log(Level.WARNING, "A warning message using Logger.log()"); + logger.log(Level.INFO, "A message with one parameter", a); + logger.log(Level.INFO, "A message with parameters", params); + } +} diff --git a/lttng-ust-java-tests-log4j/.classpath b/lttng-ust-java-tests-log4j/.classpath new file mode 100644 index 0000000..af1430b --- /dev/null +++ b/lttng-ust-java-tests-log4j/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lttng-ust-java-tests-log4j/.project b/lttng-ust-java-tests-log4j/.project new file mode 100644 index 0000000..440b11c --- /dev/null +++ b/lttng-ust-java-tests-log4j/.project @@ -0,0 +1,23 @@ + + + lttng-ust-java-tests-log4j + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/lttng-ust-java-tests-log4j/.settings/org.eclipse.core.resources.prefs b/lttng-ust-java-tests-log4j/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..8dd9b1d --- /dev/null +++ b/lttng-ust-java-tests-log4j/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.core.prefs b/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f1acd28 --- /dev/null +++ b/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,392 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.ui.prefs b/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..b883c15 --- /dev/null +++ b/lttng-ust-java-tests-log4j/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,62 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Spaces +formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=false +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=false +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/lttng-ust-java-tests-log4j/.settings/org.eclipse.m2e.core.prefs b/lttng-ust-java-tests-log4j/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/lttng-ust-java-tests-log4j/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/lttng-ust-java-tests-log4j/pom.xml b/lttng-ust-java-tests-log4j/pom.xml new file mode 100644 index 0000000..f289f50 --- /dev/null +++ b/lttng-ust-java-tests-log4j/pom.xml @@ -0,0 +1,63 @@ + + + + + 4.0.0 + + + org.lttng.ust + lttng-ust-java-parent + 1.0.0 + + + lttng-ust-java-tests-log4j + jar + + LTTng-UST Java Agent Log4j API Integration Tests + + + + org.lttng.ust.agent + lttng-ust-agent-common + + + org.lttng.ust.agent + lttng-ust-agent-log4j + + + org.lttng.tools + lttng-tools-java + + + org.lttng.ust + lttng-ust-java-tests-common + + + log4j + log4j + + + junit + junit + + + + diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java new file mode 100644 index 0000000..f331711 --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jEnabledEventsIT.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.log4j.Appender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.EnabledEventsITBase; +import org.lttng.ust.agent.log4j.LttngLogAppender; +import org.lttng.ust.agent.utils.Log4jTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Enabled events test for the LTTng-UST Log4j log handler. + */ +public class Log4jEnabledEventsIT extends EnabledEventsITBase { + + private static final Domain DOMAIN = Domain.LOG4J; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeClass + public static void log4jClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(Log4jTestUtils.checkForLog4jLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class teardown + */ + @AfterClass + public static void log4jClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void log4jSetup() throws SecurityException, IOException { + loggerA = Logger.getLogger(EVENT_NAME_A); + loggerB = Logger.getLogger(EVENT_NAME_B); + loggerC = Logger.getLogger(EVENT_NAME_C); + loggerD = Logger.getLogger(EVENT_NAME_D); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + loggerC.setLevel(Level.ALL); + loggerD.setLevel(Level.ALL); + + handlerA = new LttngLogAppender(); + handlerB = new LttngLogAppender(); + handlerC = new LttngLogAppender(); + + loggerA.addAppender((Appender) handlerA); + loggerB.addAppender((Appender) handlerB); + loggerC.addAppender((Appender) handlerC); + } + + /** + * Test teardown + */ + @After + public void log4jTeardown() { + loggerA.removeAppender((Appender) handlerA); + loggerB.removeAppender((Appender) handlerB); + loggerC.removeAppender((Appender) handlerC); + + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + } + + @Override + protected Domain getDomain() { + return DOMAIN; + } + + @Override + protected void sendEventsToLoggers() { + Log4jTestUtils.send10Events(loggerA); + Log4jTestUtils.send10Events(loggerB); + Log4jTestUtils.send10Events(loggerC); + Log4jTestUtils.send10Events(loggerD); + } +} diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java new file mode 100644 index 0000000..e6b9a79 --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jLegacyApiIT.java @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.lang.reflect.Field; +import java.util.List; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.LTTngAgent; +import org.lttng.ust.agent.utils.Log4jTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; +import org.lttng.ust.agent.utils.TestPrintRunner; + +/** + * Enabled events test for the LTTng-UST Log4j log handler, using the legacy + * API. + */ +@RunWith(TestPrintRunner.class) +@SuppressWarnings("deprecation") +public class Log4jLegacyApiIT { + + private static final Domain DOMAIN = Domain.LOG4J; + + private static final String EVENT_NAME_A = "EventA"; + private static final String EVENT_NAME_B = "EventB"; + + private ILttngSession session; + + private Logger loggerA; + private Logger loggerB; + + /** + * Class setup + */ + @BeforeClass + public static void classSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(Log4jTestUtils.checkForLog4jLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class cleanup + */ + @AfterClass + public static void classCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + */ + @Before + public void setup() { + loggerA = Logger.getLogger(EVENT_NAME_A); + LTTngAgent.getLTTngAgent(); + loggerB = Logger.getLogger(EVENT_NAME_B); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + + session = ILttngSession.createSession(null, DOMAIN); + } + + /** + * Test cleanup + */ + @After + public void tearDown() { + session.close(); + + LTTngAgent.dispose(); + + loggerA = null; + loggerB = null; + } + + /** + * Test tracing with no events enabled in the tracing session. + */ + @Test + public void testNoEvents() { + assertTrue(session.start()); + + Log4jTestUtils.send10Events(loggerA); + Log4jTestUtils.send10Events(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertTrue(output.isEmpty()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(0, handler.getEventCount()); + } + + /** + * Test tracing with all events enabled (-l -a) in the tracing session. + */ + @Test + public void testAllEvents() { + assertTrue(session.enableAllEvents()); + assertTrue(session.start()); + + Log4jTestUtils.send10Events(loggerA); + Log4jTestUtils.send10Events(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(20, output.size()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(20, handler.getEventCount()); + } + + /** + * Test tracing with a subset of events enabled in the tracing session. + */ + @Test + public void testSomeEvents() { + assertTrue(session.enableEvents(EVENT_NAME_A)); + assertTrue(session.start()); + + Log4jTestUtils.send10Events(loggerA); + Log4jTestUtils.send10Events(loggerB); + + assertTrue(session.stop()); + + List output = session.view(); + assertNotNull(output); + assertEquals(10, output.size()); + + ILttngHandler handler = getAgentHandler(); + assertEquals(10, handler.getEventCount()); + } + + /** + * Get the singleton Log4j Handler currently managed by the LTTngAgent. It + * is not public, so we need reflection to access it. + * + * @return The agent's Log4j handler + */ + private static ILttngHandler getAgentHandler() { + try { + Field log4jAppenderField = LTTngAgent.class.getDeclaredField("log4jAppender"); + log4jAppenderField.setAccessible(true); + return (ILttngHandler) log4jAppenderField.get(LTTngAgent.getLTTngAgent()); + } catch (ReflectiveOperationException | SecurityException e) { + fail(); + return null; + } + } + +} + diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java new file mode 100644 index 0000000..e06abf8 --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jListEventsIT.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.log4j.Appender; +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.ListEventsITBase; +import org.lttng.ust.agent.log4j.LttngLogAppender; +import org.lttng.ust.agent.utils.Log4jTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Test suite for the list events command for the log4j domain + */ +public class Log4jListEventsIT extends ListEventsITBase { + + private Logger[] loggers; + private Appender[] appenders; + + /** + * Test class setup + */ + @BeforeClass + public static void testClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(Log4jTestUtils.checkForLog4jLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void log4jSetup() throws SecurityException, IOException { + loggers = new Logger[] { + Logger.getLogger(LOGGER_NAME_1), + Logger.getLogger(LOGGER_NAME_2), + Logger.getLogger(LOGGER_NAME_3) + }; + + appenders = new Appender[] { + new LttngLogAppender(), + new LttngLogAppender() + }; + } + + /** + * Test teardown. Detach and close all log handlers. + */ + @After + public void log4jTeardown() { + for (Logger logger : loggers) { + for (Appender appender : appenders) { + logger.removeAppender(appender); + } + } + + for (Appender appender : appenders) { + appender.close(); + } + appenders = null; + loggers = null; + } + + @Override + protected ILttngSession.Domain getDomain() { + return ILttngSession.Domain.LOG4J; + } + + @Override + protected void attachHandlerToLogger(int handlerIndex, int loggerIndex) { + loggers[loggerIndex - 1].addAppender(appenders[handlerIndex - 1]); + } + + @Override + protected void detachHandlerFromLogger(int handlerIndex, int loggerIndex) { + loggers[loggerIndex - 1].removeAppender(appenders[handlerIndex - 1]); + } + +} diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java new file mode 100644 index 0000000..c32a825 --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/events/Log4jMultiSessionIT.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.events; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.apache.log4j.Appender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession.Domain; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.integration.events.MultiSessionITBase; +import org.lttng.ust.agent.log4j.LttngLogAppender; +import org.lttng.ust.agent.utils.Log4jTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Log4j tests for multiple concurrent tracing sessions + */ +public class Log4jMultiSessionIT extends MultiSessionITBase { + + private static final Domain DOMAIN = Domain.LOG4J; + + private Logger loggerA; + private Logger loggerB; + private Logger loggerC; + private Logger loggerD; + + /** + * Class setup + */ + @BeforeClass + public static void log4jClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(Log4jTestUtils.checkForLog4jLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); + + LttngToolsHelper.destroyAllSessions(); + } + + /** + * Class teardown + */ + @AfterClass + public static void log4jClassCleanup() { + LttngToolsHelper.deleteAllTraces(); + } + + /** + * Test setup + * + * @throws SecurityException + * @throws IOException + */ + @Before + public void log4jSetup() throws SecurityException, IOException { + // TODO Wipe all existing LTTng sessions? + + loggerA = Logger.getLogger(EVENT_NAME_A); + loggerB = Logger.getLogger(EVENT_NAME_B); + loggerC = Logger.getLogger(EVENT_NAME_C); + loggerD = Logger.getLogger(EVENT_NAME_D); + + loggerA.setLevel(Level.ALL); + loggerB.setLevel(Level.ALL); + loggerC.setLevel(Level.ALL); + loggerD.setLevel(Level.ALL); + + handlerA = new LttngLogAppender(); + handlerB = new LttngLogAppender(); + handlerC = new LttngLogAppender(); + handlerD = new LttngLogAppender(); + + loggerA.addAppender((Appender) handlerA); + loggerB.addAppender((Appender) handlerB); + loggerC.addAppender((Appender) handlerC); + loggerD.addAppender((Appender) handlerD); + } + + /** + * Test teardown + */ + @After + public void log4jTeardown() { + loggerA.removeAppender((Appender) handlerA); + loggerB.removeAppender((Appender) handlerB); + loggerC.removeAppender((Appender) handlerC); + loggerD.removeAppender((Appender) handlerD); + + loggerA = null; + loggerB = null; + loggerC = null; + loggerD = null; + } + + @Override + protected Domain getDomain() { + return DOMAIN; + } + + @Override + protected void sendEventsToLoggers() { + Log4jTestUtils.send10Events(loggerA); + Log4jTestUtils.send10Events(loggerB); + Log4jTestUtils.send10Events(loggerC); + Log4jTestUtils.send10Events(loggerD); + } +} diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java new file mode 100644 index 0000000..d40dd95 --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.integration.filter; + +import static org.junit.Assume.assumeTrue; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.lttng.tools.ILttngSession; +import org.lttng.tools.LttngToolsHelper; +import org.lttng.ust.agent.ILttngHandler; +import org.lttng.ust.agent.log4j.LttngLogAppender; +import org.lttng.ust.agent.utils.ILogLevelStrings; +import org.lttng.ust.agent.utils.Log4jTestUtils; +import org.lttng.ust.agent.utils.LttngUtils; + +/** + * Filter notifications tests using the log4j logging API. + * + * @author Alexandre Montplaisir + */ +public class Log4jFilterListenerIT extends FilterListenerITBase { + + /** + * Class setup + */ + @BeforeClass + public static void log4jClassSetup() { + /* Skip tests if we can't find the JNI library or lttng-tools */ + assumeTrue(Log4jTestUtils.checkForLog4jLibrary()); + assumeTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.LOG4J)); + LttngToolsHelper.destroyAllSessions(); + } + + @Override + protected ILttngSession.Domain getSessionDomain() { + return ILttngSession.Domain.LOG4J; + } + + @Override + protected ILttngHandler getLogHandler() throws SecurityException, IOException { + return new LttngLogAppender(); + } + + @Override + protected ILogLevelStrings getLogLevelStrings() { + return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS; + } + +} diff --git a/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java new file mode 100644 index 0000000..3e67f1f --- /dev/null +++ b/lttng-ust-java-tests-log4j/src/test/java/org/lttng/ust/agent/utils/Log4jTestUtils.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.lttng.ust.agent.utils; + +import java.io.IOException; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.lttng.ust.agent.log4j.LttngLogAppender; + +/** + * Utility methods for log4j tests + */ +public final class Log4jTestUtils { + + private Log4jTestUtils() { + } + + /** + * Check the the Log4j native library is available, effectively allowing + * LTTng Log4j appenders to be used. + * + * @return True if Log4j works fine, false if it does not. + */ + public static boolean checkForLog4jLibrary() { + try { + LttngLogAppender testAppender = new LttngLogAppender(); + testAppender.close(); + } catch (SecurityException | IOException e) { + return false; + } + return true; + } + + /** + * Send 10 dummy events through the provided logger + * + * @param logger + * The logger to use to send events + */ + public static void send10Events(Logger logger) { + // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN + logger.debug("Debug message. Lost among so many."); + logger.debug("Debug message with a throwable", new IOException()); + logger.error("Error messsage. This might be bad."); + logger.error("Error message with a throwable", new IOException()); + logger.fatal("A fatal message. You are already dead."); + logger.info("A info message. Lol, who cares."); + logger.trace("A trace message. No, no *that* trace"); + logger.warn("A warn message. Yellow underline."); + logger.log(Level.DEBUG, "A debug message using .log()"); + logger.log(Level.ERROR, "A error message using .log()"); + } +} diff --git a/lttng-ust-java-tests/.classpath b/lttng-ust-java-tests/.classpath deleted file mode 100644 index af1430b..0000000 --- a/lttng-ust-java-tests/.classpath +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lttng-ust-java-tests/.project b/lttng-ust-java-tests/.project deleted file mode 100644 index a7601a3..0000000 --- a/lttng-ust-java-tests/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - lttng-ust-agent-tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/lttng-ust-java-tests/.settings/org.eclipse.core.resources.prefs b/lttng-ust-java-tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 8dd9b1d..0000000 --- a/lttng-ust-java-tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 diff --git a/lttng-ust-java-tests/.settings/org.eclipse.jdt.core.prefs b/lttng-ust-java-tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f1acd28..0000000 --- a/lttng-ust-java-tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,392 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.autoboxing=warning -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=false -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=120 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/lttng-ust-java-tests/.settings/org.eclipse.jdt.ui.prefs b/lttng-ust-java-tests/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index b883c15..0000000 --- a/lttng-ust-java-tests/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_Spaces -formatter_settings_version=12 -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=false -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_functional_interfaces=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=false -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=true -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=false -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=false -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=false -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=true -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true -sp_cleanup.use_type_arguments=false diff --git a/lttng-ust-java-tests/.settings/org.eclipse.m2e.core.prefs b/lttng-ust-java-tests/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/lttng-ust-java-tests/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/lttng-ust-java-tests/pom.xml b/lttng-ust-java-tests/pom.xml deleted file mode 100644 index c5fecc7..0000000 --- a/lttng-ust-java-tests/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - 4.0.0 - - - org.lttng.ust - lttng-ust-java-parent - 1.0.0 - - - lttng-ust-java-tests - jar - - LTTng-UST Java Agent Integration Tests - - - - /usr/local/share/java/lttng-ust-agent-common-1.0.0.jar - /usr/local/share/java/lttng-ust-agent-jul-1.0.0.jar - /usr/local/share/java/lttng-ust-agent-log4j-1.0.0.jar - -Djava.library.path=/usr/local/lib - - - - - - org.lttng.ust.agent - lttng-ust-agent-common - 1.0.0 - system - ${common-jar-location} - - - org.lttng.ust.agent - lttng-ust-agent-jul - 1.0.0 - system - ${jul-jar-location} - - - org.lttng.ust.agent - lttng-ust-agent-log4j - 1.0.0 - system - ${log4j-jar-location} - - - - - org.lttng.tools - lttng-tools-java - 1.0.0 - - - log4j - log4j - 1.2.17 - - - junit - junit - 4.12 - test - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18.1 - - - - integration-test - verify - - - - - - - - - - benchmark - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18.1 - - - **/*Benchmark.java - - - - - - - - - diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java deleted file mode 100644 index 9ac3df5..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler; - -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Base abstract class for JUL benchmarks. Sub-classes can setup parameters to - * test different types of log handlers. - */ -public abstract class JulHandlerBenchmarkBase { - - // ------------------------------------------------------------------------ - // Configurable test parameters - // ------------------------------------------------------------------------ - - /** Nb of runs per test, result will be averaged */ - private static final int NB_RUNS = 10; - - /** Trace/log events per run */ - private static final int NB_ITER = 100000; - - /** Which tests to run (for different number of threads) */ - private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8}; - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - protected Logger logger; - protected Handler handler; - - // ------------------------------------------------------------------------ - // Maintenance methods - // ------------------------------------------------------------------------ - - /** - * Base test setup - */ - @Before - public void setup() { - /* Set up the logger */ - logger = Logger.getLogger("Test logger"); - logger.setUseParentHandlers(false); - logger.setLevel(Level.ALL); - - /* Sub-classes' @Before will setup the Handler */ - } - - /** - * Base test teardown - */ - @After - public void teardown() { - if (handler != null) { - logger.removeHandler(handler); - handler.close(); - } - handler = null; - logger = null; - } - - // ------------------------------------------------------------------------ - // Test methods - // ------------------------------------------------------------------------ - - /** - * Main test class for running the benchmark - */ - @Test - public void runBenchmark() { - if (handler != null) { - logger.addHandler(handler); - } - - System.out.println(); - System.out.println("Running benchmark: " + this.getClass().getCanonicalName()); - for (int i : NB_THREADS) { - runTest(logger, i); - } - } - - private static void runTest(Logger log, int nbThreads) { - long start, end, average, total = 0; - for (int i = 0; i < NB_RUNS; i++) { - Runner runner = new Runner(nbThreads, NB_ITER, log); - - start = System.nanoTime(); - runner.run(); - end = System.nanoTime(); - - total += (end - start); - } - average = total / NB_RUNS; - System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event"); - } - - // ------------------------------------------------------------------------ - // Helper classes - // ------------------------------------------------------------------------ - - private static class Runner implements Runnable { - - private final List workers = new LinkedList<>(); - private final List workerThreads = new LinkedList<>(); - - public Runner(int nbThreads, int nbIter, Logger log) { - - for (int id = 0; id < nbThreads; id++) { - Worker curWorker = new Worker(id, nbIter, log); - workers.add(curWorker); - workerThreads.add(new Thread(curWorker, "worker " + id)); - } - } - - @Override - public void run() { - for (Thread curThread : workerThreads) { - curThread.start(); - } - - for (Thread curThread : workerThreads) { - try { - curThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - private static class Worker implements Runnable { - - private final Logger log; - private final int threadId; - private final int nbIter; - - public Worker(int threadId, int nbIter, Logger log) { - this.log = log; - this.threadId = threadId; - this.nbIter = nbIter; - } - - @Override - public void run() { - for (int i = 0; i < nbIter; i++) { - log.info("Thread " + threadId + ", iteration " + i); - } - } - - } - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java deleted file mode 100644 index 44a5290..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.builtin; - -import java.util.logging.Handler; -import java.util.logging.LogRecord; - -import org.junit.Before; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; - -/** - * Test suite of using a "dummy" handler, which means a handler that does - * exactly nothing. - */ -public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase { - - /** - * Test setup - */ - @Before - public void testSetup() { - handler = new DummyHandler(); - } - - private static class DummyHandler extends Handler { - - public DummyHandler() { - super(); - } - - @Override - public void close() throws SecurityException {} - - @Override - public void flush() {} - - @Override - public void publish(LogRecord record) {} - - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java deleted file mode 100644 index af4ab7c..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.builtin; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.logging.FileHandler; -import java.util.logging.SimpleFormatter; - -import org.junit.After; -import org.junit.Before; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; - -/** - * Test class using a {@link FileHandler}, which a {@link SimpleFormatter}. - */ -public class FileHandlerBenchmark extends JulHandlerBenchmarkBase { - - private Path outputFile; - - /** - * Test setup - * - * @throws SecurityException - * If there is problem setting up the handler - * @throws IOException - * If there is problem setting up the handler - */ - @Before - public void testSetup() throws SecurityException, IOException { - outputFile = Files.createTempFile(this.getClass().getSimpleName(), null); - - handler = new FileHandler(outputFile.toString(), false); - handler.setFormatter(new SimpleFormatter()); - } - - /** - * Test cleanup - * - * @throws IOException - * If we could not delete the test file - */ - @After - public void testTeardown() throws IOException { - Files.deleteIfExists(outputFile); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java deleted file mode 100644 index 09457d2..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.builtin; - -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; - -/** - * Benchmark that will attach no {@link java.util.logging.Handler} to the - * {@link java.util.logging.Logger} object. - */ -public class NoHandlerBenchmark extends JulHandlerBenchmarkBase { - - /* Do not setup any handler */ -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java deleted file mode 100644 index d0e514c..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.lttng; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.junit.After; -import org.junit.Before; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; -import org.lttng.ust.agent.jul.LttngLogHandler; - -/** - * Benchmark the LTTng-JUL handler, but with tracing disabled in the tracing - * session. - */ -public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { - - private ILttngSession session; - - /** - * Test setup - * - * @throws IOException - */ - @Before - public void testSetup() throws IOException { - handler = new LttngLogHandler(); - - session = ILttngSession.createSession(null, Domain.JUL); - assertTrue(session.enableEvents("non-event")); - assertTrue(session.start()); - } - - /** - * Test cleanup - */ - @After - public void testTeardown() { - assertTrue(session.stop()); - session.close(); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java deleted file mode 100644 index c594de4..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.lttng; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.junit.After; -import org.junit.Before; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; -import org.lttng.ust.agent.jul.LttngLogHandler; - -/** - * Test the LTTng-JUL handler, with it actually sending events to the tracer. - */ -public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { - - private ILttngSession session; - - /** - * Test setup - * - * @throws IOException - */ - @Before - public void testSetup() throws IOException { - handler = new LttngLogHandler(); - - session = ILttngSession.createSession(null, Domain.JUL); - assertTrue(session.enableAllEvents()); - assertTrue(session.start()); - } - - /** - * Test cleanup - */ - @After - public void testTeardown() { - assertTrue(session.stop()); - session.close(); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java deleted file mode 100644 index 112b0f0..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old; - -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.LTTngAgent; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; - -/** - * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is - * disabled in the tracing session. - */ -@SuppressWarnings("deprecation") -public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase { - - private ILttngSession session; - - /** - * Test setup - */ - @Before - public void testSetup() { - LTTngAgent.getLTTngAgent(); - - session = ILttngSession.createSession(null, Domain.JUL); - assertTrue(session.enableEvents("non-event")); - assertTrue(session.start()); - } - - /** - * Test cleanup - */ - @After - public void testTeardown() { - assertTrue(session.stop()); - session.close(); - - LTTngAgent.dispose(); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java deleted file mode 100644 index a36578b..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.lang.reflect.Field; - -import org.junit.After; -import org.junit.Before; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.LTTngAgent; -import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase; -import org.lttng.ust.agent.jul.LttngLogHandler; - -/** - * Benchmark for the LTTng-UST handler, using the legacy API. Tracing is - * enabled in the tracing session. - */ -@SuppressWarnings("deprecation") -public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase { - - private ILttngSession session; - private LttngLogHandler agentHandler; - - - /** - * Test setup - */ - @Before - public void testSetup() { - LTTngAgent agentInstance = LTTngAgent.getLTTngAgent(); - - /* - * The "old API" works by attaching a handler managed by the agent to - * the root JUL logger. This causes problems here, because we use - * logger.setUserParentHandler(false), which does not trigger the - * handler as would be expected. - * - * Instead we will retrieve this handler through reflection, and attach - * it to our own logger here for the duration of the test. - */ - try { - Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler"); - julHandlerField.setAccessible(true); - agentHandler = (LttngLogHandler) julHandlerField.get(agentInstance); - - logger.addHandler(agentHandler); - - } catch (ReflectiveOperationException e) { - fail(); - } - - session = ILttngSession.createSession(null, Domain.JUL); - assertTrue(session.enableAllEvents()); - assertTrue(session.start()); - } - - /** - * Test cleanup - */ - @After - public void testTeardown() { - assertTrue(session.stop()); - session.close(); - - logger.removeHandler(agentHandler); - LTTngAgent.dispose(); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java deleted file mode 100644 index 703e0e3..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientDebugListener.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.client; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.lttng.ust.agent.client.ILttngTcpClientListener; -import org.lttng.ust.agent.session.EventRule; - -/** - * TCP client listener used for test. Instead of "handling" commands, it just - * keep tracks of commands it receives. - * - * @author Alexandre Montplaisir - */ -public class TcpClientDebugListener implements ILttngTcpClientListener { - - private final List enabledEventCommands = Collections.synchronizedList(new ArrayList<>()); - private final List disabledEventCommands = Collections.synchronizedList(new ArrayList<>()); - - @Override - public boolean eventEnabled(EventRule rule) { - enabledEventCommands.add(rule); - return true; - } - - @Override - public boolean eventDisabled(String name) { - disabledEventCommands.add(name); - return true; - } - - /** - * Not yet implemented - */ - @Override - public List listAvailableEvents() { - // TODO NYI - return Collections.EMPTY_LIST; - } - - /** - * @return The "enable-event" commands that were received, since - * instantiation or the last {@link #clearAllCommands}. - */ - public List getEnabledEventCommands() { - synchronized (enabledEventCommands) { - return new ArrayList<>(enabledEventCommands); - } - } - - /** - * @return The "disable-event" commands that were received, since - * instantiation or the last {@link #clearAllCommands}. - */ - public List getDisabledEventCommands() { - synchronized (disabledEventCommands) { - return new ArrayList<>(disabledEventCommands); - } - } - - /** - * Clear all tracked data. - */ - public void clearAllCommands() { - enabledEventCommands.clear(); - disabledEventCommands.clear(); - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java deleted file mode 100644 index 2794dfa..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/client/TcpClientIT.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.client; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.ILttngAgent; -import org.lttng.ust.agent.client.LttngTcpSessiondClient; -import org.lttng.ust.agent.session.EventRule; -import org.lttng.ust.agent.session.LogLevelSelector; -import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType; -import org.lttng.ust.agent.utils.EventRuleFactory; -import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Tests for the TCP client only, without using an agent. - * - * This test suite requires that a *root* session daemon is running on the - * system. Since we have to explicitly tell the TCP client which sessiond to - * connect to, we have to hard-code it in here. - * - * @author Alexandre Montplaisir - */ -@RunWith(TestPrintRunner.class) -public class TcpClientIT { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private static final String EVENT_NAME_A = "eventA"; - private static final String EVENT_NAME_B = "eventB"; - private static final String EVENT_NAME_C = "eventC"; - - /* Test configuration */ - private static final int DOMAIN_VALUE = ILttngAgent.Domain.JUL.value(); - private static final ILttngSession.Domain SESSION_DOMAIN = ILttngSession.Domain.JUL; - private static final boolean ROOT_SESSIOND = true; - - private static TcpClientDebugListener clientListener; - private static LttngTcpSessiondClient client; - private static Thread clientThread; - - private ILttngSession session; - - // ------------------------------------------------------------------------ - // Maintenance - // ------------------------------------------------------------------------ - - /** - * Class setup - */ - @BeforeClass - public static void setupClass() { - LttngToolsHelper.destroyAllSessions(); - - clientListener = new TcpClientDebugListener(); - client = new LttngTcpSessiondClient(clientListener, DOMAIN_VALUE, ROOT_SESSIOND); - - clientThread = new Thread(client); - clientThread.start(); - - assumeTrue("Timed out waiting for root sessiond", client.waitForConnection(5)); - } - - /** - * Class teardown - */ - @AfterClass - public static void teardownClass() { - if (client != null) { - client.close(); - } - if (clientThread != null) { - try { - clientThread.join(); - } catch (InterruptedException e) { - } - } - } - - /** - * Test setup - */ - @Before - public void setup() { - session = ILttngSession.createSession(null, SESSION_DOMAIN); - clientListener.clearAllCommands(); - } - - /** - * Test teardown - */ - @After - public void teardown() { - session.close(); - } - - - private static ILogLevelStrings getLogLevelStrings() { - return ILogLevelStrings.JUL_LOGLEVEL_STRINGS; - } - - /** - * Check that two lists contain the exact same element (including - * duplicates), but their order does not matter. - */ - private static > boolean containSameElements(List list1, List list2) { - List newlist1 = new ArrayList<>(list1); - List newlist2 = new ArrayList<>(list2); - Collections.sort(newlist1); - Collections.sort(newlist2); - return (newlist1.equals(newlist2)); - - } - - // ------------------------------------------------------------------------ - // Test cases - // ------------------------------------------------------------------------ - - /** - * Test enabling one event. - */ - @Test - public void testEnableEvent() { - session.enableEvent(EVENT_NAME_A, null, false, null); - - List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); - - List actualCommands = clientListener.getEnabledEventCommands(); - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test an "enable-event -a" command. - */ - @Test - public void testEnableAllEvents() { - session.enableAllEvents(); - - List expectedCommands = Collections.singletonList( - EventRuleFactory.createRuleAllEvents()); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test enabling then disabling one event. - */ - @Test - public void testEnableThenDisableOneEvent() { - session.enableEvent(EVENT_NAME_A, null, false, null); - session.disableEvents(EVENT_NAME_A); - - List expectedEnableCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A)); - List expectedDisableCommands = Collections.singletonList(EVENT_NAME_A); - - assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); - assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); - } - - /** - * Test enabling some events manually, then disabling all events (-a). - */ - @Test - public void testEnableSomeThenDisableAll() { - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - session.enableEvent(EVENT_NAME_C, null, false, null); - session.disableAllEvents(); - - List expectedEnableCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B), - EventRuleFactory.createRule(EVENT_NAME_C)); - /* - * A "disable-event -a" will send one command for each enabled event. - * The order may be different though. - */ - List expectedDisableCommands = Arrays.asList( - EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C); - - assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); - assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); - } - - /** - * Test enabling then (enable-event -a) then disabling all (disable-event -a) events. - */ - @Test - public void testEnableAllThenDisableAll() { - session.enableAllEvents(); - session.disableAllEvents(); - - List expectedEnableCommands = Arrays.asList(EventRuleFactory.createRuleAllEvents()); - List expectedDisableCommands = Arrays.asList(EventRuleFactory.EVENT_NAME_ALL); - - assertEquals(expectedEnableCommands, clientListener.getEnabledEventCommands()); - assertTrue(containSameElements(expectedDisableCommands, clientListener.getDisabledEventCommands())); - } - - /** - * Test specifying an event with a --loglevel option. - */ - @Test - public void testEnableEventLogLevelRange() { - LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - - List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test enabling an event with a --loglevel-only option. - */ - @Test - public void testEnableEventLogLevelSingle() { - LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); - - List expectedCommands = Collections.singletonList( - EventRuleFactory.createRule(EVENT_NAME_A, lls)); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test enabling an event twice, for the same loglevel, with --loglevel followed by --loglevel-only. - */ - @Test - public void testEnableEventsLogLevelRangeAndSingle() { - LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); - - List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) - ); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test enabling an event twice, for the same loglevel, with --loglevel-only followed by --loglevel. - */ - @Test - public void testEnableEventsLogLevelSingleAndRange() { - LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); - LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - - List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2) - ); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Test enabling the same event, same loglevel, but different loglevel types - * (--loglevel vs --loglevel-only) in two separate sessions. - */ - @Test - public void testEnableEventsLogLevelRangeAndSingleDiffSessions() { - try (ILttngSession session2 = ILttngSession.createSession(null, SESSION_DOMAIN);) { - - LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - session2.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); - - List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2)); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - } - - /** - * Enable the same event multiple times with different filter strings. - */ - @Test - public void testEnableEventsDiffFilters() { - final String filter1 = "filter1"; - final String filter2 = "filter2"; - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_A, null, false, filter1); - session.enableEvent(EVENT_NAME_A, null, false, filter2); - - List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter1), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter2)); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } - - /** - * Enable the same event multiple times with different log levels and - * filters. - */ - @Test - public void testEnableEventsLogLevelAndFilters() { - final LogLevelSelector lls = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - final String filter = "filter1"; - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - session.enableEvent(EVENT_NAME_A, null, false, filter); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, filter); - - List expectedCommands = Arrays.asList( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_A, lls), - EventRuleFactory.createRule(EVENT_NAME_A, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filter), - EventRuleFactory.createRule(EVENT_NAME_A, lls, filter)); - List actualCommands = clientListener.getEnabledEventCommands(); - - assertEquals(expectedCommands, actualCommands); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java deleted file mode 100644 index 5659493..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/EnabledEventsITBase.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Base abstract class to implement all sorts of integration tests verifying the - * presence of enabled events in resulting traces. - */ -@RunWith(TestPrintRunner.class) -public abstract class EnabledEventsITBase { - - protected static final String EVENT_NAME_A = "EventA"; - protected static final String EVENT_NAME_B = "EventAB"; - protected static final String EVENT_NAME_C = "EventABC"; - protected static final String EVENT_NAME_D = "EventABCD"; - - private ILttngSession session; - - /* Fields defined by the sub-class */ - protected ILttngHandler handlerA; - protected ILttngHandler handlerB; - protected ILttngHandler handlerC; - - protected abstract Domain getDomain(); - - protected abstract void sendEventsToLoggers(); - - /** - * Base test setup - */ - @Before - public void testSetup() { - session = ILttngSession.createSession(null, getDomain()); - } - - /** - * Base test teardown - */ - @After - public void testTeardown() { - session.close(); - - handlerA.close(); - handlerB.close(); - handlerC.close(); - - handlerA = null; - handlerB = null; - handlerC = null; - } - - /** - * Test sending events on the Java side, but no events enabled in the - * tracing session. There should be nothing in the resulting trace, and - * handlers should not have logged anything. - */ - @Test - public void testNoEvents() { - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertTrue(output.isEmpty()); - - assertEquals(0, handlerA.getEventCount()); - assertEquals(0, handlerB.getEventCount()); - assertEquals(0, handlerC.getEventCount()); - } - - /** - * Test sending events on the Java side, and all events enabled in the - * tracing session. All handlers should have sent their events. - */ - @Test - public void testAllEvents() { - assertTrue(session.enableAllEvents()); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(30, output.size()); // loggerD has no handler attached - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } - - /** - * Test sending events on the Java side, with only some of them enabled in - * the tracing session. Only the subset that is enabled should be received. - */ - @Test - public void testSomeEvents() { - assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D)); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(20, output.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(0, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } - - /** - * Test with all events enabled (-a), plus some other events added manually. - * Events should still be retained, but there should be no duplicates. - */ - @Test - public void testAllEventsAndSome() { - assertTrue(session.enableAllEvents()); - assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_B)); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(30, output.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } - - /** - * Same as {@link #testSomeEvents()}, but some events were enabled first, - * then disabled. Makes sure the enabled-event refcounting works properly. - */ - @Test - public void testSomeEventsAfterDisabling() { - assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D)); - assertTrue(session.disableEvents(EVENT_NAME_C)); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(10, output.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(0, handlerB.getEventCount()); - assertEquals(0, handlerC.getEventCount()); - } - - /** - * Test enabling an event prefix, which means an event name ending with a *, - * to match all events starting with this name. - */ - @Test - public void testEventPrefix() { - // should match event/loggers B and C, but not A. - assertTrue(session.enableEvents("EventAB*")); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(20, output.size()); - - assertEquals(0, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } - - /** - * Same as {@link #testEventPrefix()}, but with multiple prefixes that - * overlap. There should not be any duplicate events in the trace or in the - * handlers. - */ - @Test - public void testEventPrefixOverlapping() { - // should still match B and C - assertTrue(session.enableEvents("EventAB*", "EventABC*")); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(20, output.size()); - - assertEquals(0, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } - - /** - * Test with all events enabled (-a), plus an event prefix. Once again, - * there should be no duplicates. - */ - @Test - public void testAllEventsAndPrefix() { - assertTrue(session.enableAllEvents()); - assertTrue(session.enableEvents("EventAB*")); - assertTrue(session.start()); - - sendEventsToLoggers(); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(30, output.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java deleted file mode 100644 index ec4e0c1..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/ListEventsITBase.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.lttng.tools.ILttngSession; - -/** - * Base class for the list events command tests - */ -public abstract class ListEventsITBase { - - protected static final String LOGGER_NAME_1 = "org.lttng"; - protected static final String LOGGER_NAME_2 = "org.lttng.mycomponent"; - protected static final String LOGGER_NAME_3 = "org.lttng.myothercomponent"; - - private ILttngSession session; - - /** - * Common test setup - */ - @Before - public void testSetup() { - session = ILttngSession.createSession(null, getDomain()); - } - - /** - * Common test teardown - */ - @After - public void testTeardown() { - session.close(); - } - - protected abstract ILttngSession.Domain getDomain(); - - protected abstract void attachHandlerToLogger(int handlerIndex, int loggerIndex); - - protected abstract void detachHandlerFromLogger(int handlerIndex, int loggerIndex); - - /** - * Test with many loggers existing, but none of them having a LTTng handler - * attached. - */ - @Test - public void testManyLoggersNoneAttached() { - /* Don't attach anything */ - Set actualEvents = session.listEvents(); - assertTrue(actualEvents.isEmpty()); - } - - /** - * Test with many loggers existing, but only a subset of them has a LTTng - * handler attached. - */ - @Test - public void testManyLoggersSomeAttached() { - attachHandlerToLogger(1, 1); - - Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1)); - Set actualEvents = session.listEvents(); - - assertEquals(expectedEvents, actualEvents); - } - - /** - * Test with many loggers existing, and all of them having a LTTng handler - * attached. - */ - @Test - public void testManyLoggersAllAttached() { - attachHandlerToLogger(1, 1); - attachHandlerToLogger(2, 2); - attachHandlerToLogger(2, 3); - - Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2, LOGGER_NAME_3)); - Set actualEvents = session.listEvents(); - - assertEquals(expectedEvents, actualEvents); - } - - /** - * Test with some loggers having had handlers attached but then detached. - */ - @Test - public void testLoggersSomeDetached() { - attachHandlerToLogger(1, 1); - attachHandlerToLogger(2, 2); - - attachHandlerToLogger(2, 3); - detachHandlerFromLogger(2, 3); - /* Only loggers 1 and 2 will be attached */ - - Set expectedEvents = new HashSet<>(Arrays.asList(LOGGER_NAME_1, LOGGER_NAME_2)); - Set actualEvents = session.listEvents(); - - assertEquals(expectedEvents, actualEvents); - } - - /** - * Test with all loggers having had handlers attached and then detached. - */ - @Test - public void testLoggersAllDetached() { - attachHandlerToLogger(1, 1); - attachHandlerToLogger(2, 2); - attachHandlerToLogger(2, 3); - detachHandlerFromLogger(1, 1); - detachHandlerFromLogger(2, 2); - detachHandlerFromLogger(2, 3); - - Set actualEvents = session.listEvents(); - assertTrue(actualEvents.isEmpty()); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java deleted file mode 100644 index 6864292..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/MultiSessionITBase.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Base abstract class for tests with multiple concurrent tracing sessions - */ -@RunWith(TestPrintRunner.class) -public abstract class MultiSessionITBase { - - protected static final String EVENT_NAME_A = "EventA"; - protected static final String EVENT_NAME_B = "EventAB"; - protected static final String EVENT_NAME_C = "EventABC"; - protected static final String EVENT_NAME_D = "EventABCD"; - - private ILttngSession session1; - private ILttngSession session2; - private ILttngSession session3; - - /* Fields defined by the sub-class */ - protected ILttngHandler handlerA; - protected ILttngHandler handlerB; - protected ILttngHandler handlerC; - protected ILttngHandler handlerD; - - protected abstract Domain getDomain(); - - protected abstract void sendEventsToLoggers(); - - /** - * Base test setup - */ - @Before - public void testSetup() { - session1 = ILttngSession.createSession(null, getDomain()); - session2 = ILttngSession.createSession(null, getDomain()); - session3 = ILttngSession.createSession(null, getDomain()); - } - - /** - * Base test teardown - */ - @After - public void testTeardown() { - session1.close(); - session2.close(); - session3.close(); - - handlerA.close(); - handlerB.close(); - handlerC.close(); - handlerD.close(); - - handlerA = null; - handlerB = null; - handlerC = null; - handlerD = null; - } - - /** - * Test with no events in any session. - */ - @Test - public void testNoEvents() { - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertTrue(output1.isEmpty()); - assertTrue(output2.isEmpty()); - assertTrue(output3.isEmpty()); - - assertEquals(0, handlerA.getEventCount()); - assertEquals(0, handlerB.getEventCount()); - assertEquals(0, handlerC.getEventCount()); - assertEquals(0, handlerD.getEventCount()); - } - - /** - * Test with all events enabled in one session only. Everything should be - * sent through JNI, but only that session should keep the trace events. - */ - @Test - public void testAllEventsOneSession() { - assertTrue(session1.enableAllEvents()); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(40, output1.size()); - assertTrue(output2.isEmpty()); - assertTrue(output3.isEmpty()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } - - /** - * Test with all events enabled in all sessions. All traces and handlers - * should see every event that was logged. - */ - @Test - public void testAllEventsAllSessions() { - assertTrue(session1.enableAllEvents()); - assertTrue(session2.enableAllEvents()); - assertTrue(session3.enableAllEvents()); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(40, output1.size()); - assertEquals(40, output2.size()); - assertEquals(40, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } - - /** - * Test enabling some events in some sessions only. - */ - @Test - public void testSomeEvents() { - assertTrue(session1.enableEvents(EVENT_NAME_A)); - assertTrue(session2.enableEvents(EVENT_NAME_B)); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(10, output1.size()); - assertEquals(10, output2.size()); - assertEquals(0, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(0, handlerC.getEventCount()); - assertEquals(0, handlerD.getEventCount()); - } - - /** - * Test with all events enabled in one session, and some others in another. - * All events should arrive where expected, with no duplicates. - */ - @Test - public void testAllEventsAndSome() { - assertTrue(session1.enableAllEvents()); - assertTrue(session2.enableEvents(EVENT_NAME_D)); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(40, output1.size()); - assertEquals(10, output2.size()); - assertEquals(0, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } - - /** - * Test with enabling then disabling some events. Makes sure the refcounting - * works properly. - */ - @Test - public void testSomeEventsAfterDisabling() { - assertTrue(session1.enableEvents(EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C)); - assertTrue(session2.enableEvents(EVENT_NAME_B, EVENT_NAME_C, EVENT_NAME_D)); - assertTrue(session3.enableEvents(EVENT_NAME_A)); - - assertTrue(session1.disableEvents(EVENT_NAME_C)); - assertTrue(session2.disableEvents(EVENT_NAME_B, EVENT_NAME_C)); - assertTrue(session3.disableEvents(EVENT_NAME_A)); - - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(20, output1.size()); - assertEquals(10, output2.size()); - assertEquals(0, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(0, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } - - /** - * Test with a prefix in one session and a standard event in another. - */ - @Test - public void testPrefixAndEvent() { - assertTrue(session1.enableEvents("EventAB*")); - assertTrue(session3.enableEvents(EVENT_NAME_A)); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(30, output1.size()); - assertEquals(0, output2.size()); - assertEquals(10, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } - - /** - * Test with all events enabled in one session, and an event prefix in - * another. Once again, there should be no duplicates. - */ - @Test - public void testAllEventsAndPrefix() { - assertTrue(session1.enableAllEvents()); - assertTrue(session2.enableEvents("EventABC*")); - assertTrue(session1.start()); - assertTrue(session2.start()); - assertTrue(session3.start()); - - sendEventsToLoggers(); - - assertTrue(session1.stop()); - assertTrue(session2.stop()); - assertTrue(session3.stop()); - - List output1 = session1.view(); - List output2 = session2.view(); - List output3 = session3.view(); - assertNotNull(output1); - assertNotNull(output2); - assertNotNull(output3); - assertEquals(40, output1.size()); - assertEquals(20, output2.size()); - assertEquals(0, output3.size()); - - assertEquals(10, handlerA.getEventCount()); - assertEquals(10, handlerB.getEventCount()); - assertEquals(10, handlerC.getEventCount()); - assertEquals(10, handlerD.getEventCount()); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulEnabledEventsIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulEnabledEventsIT.java deleted file mode 100644 index 3b292fe..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulEnabledEventsIT.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.jul; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.EnabledEventsITBase; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Enabled events test for the LTTng-UST JUL log handler. - */ -public class JulEnabledEventsIT extends EnabledEventsITBase { - - private static final Domain DOMAIN = Domain.JUL; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeClass - public static void julClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForJulLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class cleanup - */ - @AfterClass - public static void julClassCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void julSetup() throws SecurityException, IOException { - loggerA = Logger.getLogger(EVENT_NAME_A); - loggerB = Logger.getLogger(EVENT_NAME_B); - loggerC = Logger.getLogger(EVENT_NAME_C); - loggerD = Logger.getLogger(EVENT_NAME_D); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - loggerC.setLevel(Level.ALL); - loggerD.setLevel(Level.ALL); - - handlerA = new LttngLogHandler(); - handlerB = new LttngLogHandler(); - handlerC = new LttngLogHandler(); - - loggerA.addHandler((Handler) handlerA); - loggerB.addHandler((Handler) handlerB); - loggerC.addHandler((Handler) handlerC); - } - - /** - * Test teardown - */ - @After - public void julTeardown() { - loggerA.removeHandler((Handler) handlerA); - loggerB.removeHandler((Handler) handlerB); - loggerC.removeHandler((Handler) handlerC); - - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - } - - @Override - protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected void sendEventsToLoggers() { - JulTestUtils.send10EventsTo(loggerA); - JulTestUtils.send10EventsTo(loggerB); - JulTestUtils.send10EventsTo(loggerC); - JulTestUtils.send10EventsTo(loggerD); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulLegacyApiIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulLegacyApiIT.java deleted file mode 100644 index fc0353b..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulLegacyApiIT.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.jul; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.lang.reflect.Field; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.LTTngAgent; -import org.lttng.ust.agent.utils.LttngUtils; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Enabled events test for the LTTng-UST JUL log handler, using the legacy API. - */ -@RunWith(TestPrintRunner.class) -@SuppressWarnings("deprecation") -public class JulLegacyApiIT { - - private static final Domain DOMAIN = Domain.JUL; - - private static final String EVENT_NAME_A = "EventA"; - private static final String EVENT_NAME_B = "EventB"; - - private ILttngSession session; - - private Logger loggerA; - private Logger loggerB; - - /** - * Class setup - */ - @BeforeClass - public static void julClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForJulLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class cleanup - */ - @AfterClass - public static void julClassCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - */ - @Before - public void setup() { - loggerA = Logger.getLogger(EVENT_NAME_A); - LTTngAgent.getLTTngAgent(); - loggerB = Logger.getLogger(EVENT_NAME_B); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - - session = ILttngSession.createSession(null, DOMAIN); - } - - /** - * Test cleanup - */ - @After - public void tearDown() { - session.close(); - - LTTngAgent.dispose(); - - loggerA = null; - loggerB = null; - } - - /** - * Test tracing with no events enabled in the tracing session. - */ - @Test - public void testNoEvents() { - assertTrue(session.start()); - - JulTestUtils.send10EventsTo(loggerA); - JulTestUtils.send10EventsTo(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertTrue(output.isEmpty()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(0, handler.getEventCount()); - } - - /** - * Test tracing with all events enabled (-j -a) in the tracing session. - */ - @Test - public void testAllEvents() { - assertTrue(session.enableAllEvents()); - assertTrue(session.start()); - - JulTestUtils.send10EventsTo(loggerA); - JulTestUtils.send10EventsTo(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(20, output.size()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(20, handler.getEventCount()); - } - - /** - * Test tracing with a subset of events enabled in the tracing session. - */ - @Test - public void testSomeEvents() { - assertTrue(session.enableEvents(EVENT_NAME_A)); - assertTrue(session.start()); - - JulTestUtils.send10EventsTo(loggerA); - JulTestUtils.send10EventsTo(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(10, output.size()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(10, handler.getEventCount()); - } - - /** - * Get the singleton JUL Handler currently managed by the LTTngAgent. It is - * not public, so we need reflection to access it. - * - * @return The agent's JUL handler - */ - private static ILttngHandler getAgentHandler() { - try { - Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler"); - julHandlerField.setAccessible(true); - return (ILttngHandler) julHandlerField.get(LTTngAgent.getLTTngAgent()); - } catch (ReflectiveOperationException | SecurityException e) { - fail(); - return null; - } - } - -} - diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulListEventsIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulListEventsIT.java deleted file mode 100644 index 2025a97..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulListEventsIT.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.jul; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.util.logging.Handler; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.ListEventsITBase; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Test suite for the list events command for the JUL domain - */ -public class JulListEventsIT extends ListEventsITBase { - - private Logger[] loggers; - private Handler[] handlers; - - /** - * Test class setup - */ - @BeforeClass - public static void testClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForJulLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void julSetup() throws SecurityException, IOException { - loggers = new Logger[] { - Logger.getLogger(LOGGER_NAME_1), - Logger.getLogger(LOGGER_NAME_2), - Logger.getLogger(LOGGER_NAME_3) - }; - - handlers = new Handler[] { - new LttngLogHandler(), - new LttngLogHandler() - }; - } - - /** - * Test teardown. Detach and close all log handlers. - */ - @After - public void julTeardown() { - for (Logger logger : loggers) { - for (Handler handler : handlers) { - logger.removeHandler(handler); - } - } - - for (Handler handler : handlers) { - handler.close(); - } - handlers = null; - loggers = null; - } - - @Override - protected ILttngSession.Domain getDomain() { - return ILttngSession.Domain.JUL; - } - - @Override - protected void attachHandlerToLogger(int handlerIndex, int loggerIndex) { - loggers[loggerIndex - 1].addHandler(handlers[handlerIndex - 1]); - } - - @Override - protected void detachHandlerFromLogger(int handlerIndex, int loggerIndex) { - loggers[loggerIndex - 1].removeHandler(handlers[handlerIndex - 1]); - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulMultiSessionIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulMultiSessionIT.java deleted file mode 100644 index 59c8e39..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulMultiSessionIT.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.jul; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.MultiSessionITBase; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * JUL tests for multiple concurrent tracing sessions - */ -public class JulMultiSessionIT extends MultiSessionITBase { - - private static final Domain DOMAIN = Domain.JUL; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeClass - public static void julClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForJulLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.JUL)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class cleanup - */ - @AfterClass - public static void julClassCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void julSetup() throws SecurityException, IOException { - loggerA = Logger.getLogger(EVENT_NAME_A); - loggerB = Logger.getLogger(EVENT_NAME_B); - loggerC = Logger.getLogger(EVENT_NAME_C); - loggerD = Logger.getLogger(EVENT_NAME_D); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - loggerC.setLevel(Level.ALL); - loggerD.setLevel(Level.ALL); - - handlerA = new LttngLogHandler(); - handlerB = new LttngLogHandler(); - handlerC = new LttngLogHandler(); - handlerD = new LttngLogHandler(); - - loggerA.addHandler((Handler) handlerA); - loggerB.addHandler((Handler) handlerB); - loggerC.addHandler((Handler) handlerC); - loggerD.addHandler((Handler) handlerD); - } - - /** - * Test teardown - */ - @After - public void julTeardown() { - loggerA.removeHandler((Handler) handlerA); - loggerB.removeHandler((Handler) handlerB); - loggerC.removeHandler((Handler) handlerC); - loggerD.removeHandler((Handler) handlerD); - - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - } - - @Override - protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected void sendEventsToLoggers() { - JulTestUtils.send10EventsTo(loggerA); - JulTestUtils.send10EventsTo(loggerB); - JulTestUtils.send10EventsTo(loggerC); - JulTestUtils.send10EventsTo(loggerD); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulTestUtils.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulTestUtils.java deleted file mode 100644 index 2d98496..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/jul/JulTestUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.jul; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Utility methods for JUL tests - */ -final class JulTestUtils { - - JulTestUtils() { - } - - static void send10EventsTo(Logger logger) { - String a = new String("a"); - Object[] params = { a, new String("b"), new Object() }; - - // Levels are FINE, FINER, FINEST, INFO, SEVERE, WARNING - logger.fine("A fine level message"); - logger.finer("A finer level message"); - logger.finest("A finest level message"); - logger.info("A info level message"); - logger.severe("A severe level message"); - logger.warning("A warning level message"); - logger.warning("Another warning level message"); - logger.log(Level.WARNING, "A warning message using Logger.log()"); - logger.log(Level.INFO, "A message with one parameter", a); - logger.log(Level.INFO, "A message with parameters", params); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jEnabledEventsIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jEnabledEventsIT.java deleted file mode 100644 index 120143d..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jEnabledEventsIT.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.log4j; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.apache.log4j.Appender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.EnabledEventsITBase; -import org.lttng.ust.agent.log4j.LttngLogAppender; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Enabled events test for the LTTng-UST Log4j log handler. - */ -public class Log4jEnabledEventsIT extends EnabledEventsITBase { - - private static final Domain DOMAIN = Domain.LOG4J; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeClass - public static void log4jClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForLog4jLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class teardown - */ - @AfterClass - public static void log4jClassCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void log4jSetup() throws SecurityException, IOException { - loggerA = Logger.getLogger(EVENT_NAME_A); - loggerB = Logger.getLogger(EVENT_NAME_B); - loggerC = Logger.getLogger(EVENT_NAME_C); - loggerD = Logger.getLogger(EVENT_NAME_D); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - loggerC.setLevel(Level.ALL); - loggerD.setLevel(Level.ALL); - - handlerA = new LttngLogAppender(); - handlerB = new LttngLogAppender(); - handlerC = new LttngLogAppender(); - - loggerA.addAppender((Appender) handlerA); - loggerB.addAppender((Appender) handlerB); - loggerC.addAppender((Appender) handlerC); - } - - /** - * Test teardown - */ - @After - public void log4jTeardown() { - loggerA.removeAppender((Appender) handlerA); - loggerB.removeAppender((Appender) handlerB); - loggerC.removeAppender((Appender) handlerC); - - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - } - - @Override - protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected void sendEventsToLoggers() { - Log4jTestUtils.send10Events(loggerA); - Log4jTestUtils.send10Events(loggerB); - Log4jTestUtils.send10Events(loggerC); - Log4jTestUtils.send10Events(loggerD); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jLegacyApiIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jLegacyApiIT.java deleted file mode 100644 index d673cfa..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jLegacyApiIT.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.log4j; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.lang.reflect.Field; -import java.util.List; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.LTTngAgent; -import org.lttng.ust.agent.utils.LttngUtils; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Enabled events test for the LTTng-UST Log4j log handler, using the legacy - * API. - */ -@RunWith(TestPrintRunner.class) -@SuppressWarnings("deprecation") -public class Log4jLegacyApiIT { - - private static final Domain DOMAIN = Domain.LOG4J; - - private static final String EVENT_NAME_A = "EventA"; - private static final String EVENT_NAME_B = "EventB"; - - private ILttngSession session; - - private Logger loggerA; - private Logger loggerB; - - /** - * Class setup - */ - @BeforeClass - public static void classSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForLog4jLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class cleanup - */ - @AfterClass - public static void classCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - */ - @Before - public void setup() { - loggerA = Logger.getLogger(EVENT_NAME_A); - LTTngAgent.getLTTngAgent(); - loggerB = Logger.getLogger(EVENT_NAME_B); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - - session = ILttngSession.createSession(null, DOMAIN); - } - - /** - * Test cleanup - */ - @After - public void tearDown() { - session.close(); - - LTTngAgent.dispose(); - - loggerA = null; - loggerB = null; - } - - /** - * Test tracing with no events enabled in the tracing session. - */ - @Test - public void testNoEvents() { - assertTrue(session.start()); - - Log4jTestUtils.send10Events(loggerA); - Log4jTestUtils.send10Events(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertTrue(output.isEmpty()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(0, handler.getEventCount()); - } - - /** - * Test tracing with all events enabled (-l -a) in the tracing session. - */ - @Test - public void testAllEvents() { - assertTrue(session.enableAllEvents()); - assertTrue(session.start()); - - Log4jTestUtils.send10Events(loggerA); - Log4jTestUtils.send10Events(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(20, output.size()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(20, handler.getEventCount()); - } - - /** - * Test tracing with a subset of events enabled in the tracing session. - */ - @Test - public void testSomeEvents() { - assertTrue(session.enableEvents(EVENT_NAME_A)); - assertTrue(session.start()); - - Log4jTestUtils.send10Events(loggerA); - Log4jTestUtils.send10Events(loggerB); - - assertTrue(session.stop()); - - List output = session.view(); - assertNotNull(output); - assertEquals(10, output.size()); - - ILttngHandler handler = getAgentHandler(); - assertEquals(10, handler.getEventCount()); - } - - /** - * Get the singleton Log4j Handler currently managed by the LTTngAgent. It - * is not public, so we need reflection to access it. - * - * @return The agent's Log4j handler - */ - private static ILttngHandler getAgentHandler() { - try { - Field log4jAppenderField = LTTngAgent.class.getDeclaredField("log4jAppender"); - log4jAppenderField.setAccessible(true); - return (ILttngHandler) log4jAppenderField.get(LTTngAgent.getLTTngAgent()); - } catch (ReflectiveOperationException | SecurityException e) { - fail(); - return null; - } - } - -} - diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jListEventsIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jListEventsIT.java deleted file mode 100644 index 2dc566e..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jListEventsIT.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.log4j; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.apache.log4j.Appender; -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.ListEventsITBase; -import org.lttng.ust.agent.log4j.LttngLogAppender; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Test suite for the list events command for the log4j domain - */ -public class Log4jListEventsIT extends ListEventsITBase { - - private Logger[] loggers; - private Appender[] appenders; - - /** - * Test class setup - */ - @BeforeClass - public static void testClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForLog4jLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void log4jSetup() throws SecurityException, IOException { - loggers = new Logger[] { - Logger.getLogger(LOGGER_NAME_1), - Logger.getLogger(LOGGER_NAME_2), - Logger.getLogger(LOGGER_NAME_3) - }; - - appenders = new Appender[] { - new LttngLogAppender(), - new LttngLogAppender() - }; - } - - /** - * Test teardown. Detach and close all log handlers. - */ - @After - public void log4jTeardown() { - for (Logger logger : loggers) { - for (Appender appender : appenders) { - logger.removeAppender(appender); - } - } - - for (Appender appender : appenders) { - appender.close(); - } - appenders = null; - loggers = null; - } - - @Override - protected ILttngSession.Domain getDomain() { - return ILttngSession.Domain.LOG4J; - } - - @Override - protected void attachHandlerToLogger(int handlerIndex, int loggerIndex) { - loggers[loggerIndex - 1].addAppender(appenders[handlerIndex - 1]); - } - - @Override - protected void detachHandlerFromLogger(int handlerIndex, int loggerIndex) { - loggers[loggerIndex - 1].removeAppender(appenders[handlerIndex - 1]); - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jMultiSessionIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jMultiSessionIT.java deleted file mode 100644 index 0821744..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jMultiSessionIT.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.log4j; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.apache.log4j.Appender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.integration.events.MultiSessionITBase; -import org.lttng.ust.agent.log4j.LttngLogAppender; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Log4j tests for multiple concurrent tracing sessions - */ -public class Log4jMultiSessionIT extends MultiSessionITBase { - - private static final Domain DOMAIN = Domain.LOG4J; - - private Logger loggerA; - private Logger loggerB; - private Logger loggerC; - private Logger loggerD; - - /** - * Class setup - */ - @BeforeClass - public static void log4jClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForLog4jLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(Domain.LOG4J)); - - LttngToolsHelper.destroyAllSessions(); - } - - /** - * Class teardown - */ - @AfterClass - public static void log4jClassCleanup() { - LttngToolsHelper.deleteAllTraces(); - } - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void log4jSetup() throws SecurityException, IOException { - // TODO Wipe all existing LTTng sessions? - - loggerA = Logger.getLogger(EVENT_NAME_A); - loggerB = Logger.getLogger(EVENT_NAME_B); - loggerC = Logger.getLogger(EVENT_NAME_C); - loggerD = Logger.getLogger(EVENT_NAME_D); - - loggerA.setLevel(Level.ALL); - loggerB.setLevel(Level.ALL); - loggerC.setLevel(Level.ALL); - loggerD.setLevel(Level.ALL); - - handlerA = new LttngLogAppender(); - handlerB = new LttngLogAppender(); - handlerC = new LttngLogAppender(); - handlerD = new LttngLogAppender(); - - loggerA.addAppender((Appender) handlerA); - loggerB.addAppender((Appender) handlerB); - loggerC.addAppender((Appender) handlerC); - loggerD.addAppender((Appender) handlerD); - } - - /** - * Test teardown - */ - @After - public void log4jTeardown() { - loggerA.removeAppender((Appender) handlerA); - loggerB.removeAppender((Appender) handlerB); - loggerC.removeAppender((Appender) handlerC); - loggerD.removeAppender((Appender) handlerD); - - loggerA = null; - loggerB = null; - loggerC = null; - loggerD = null; - } - - @Override - protected Domain getDomain() { - return DOMAIN; - } - - @Override - protected void sendEventsToLoggers() { - Log4jTestUtils.send10Events(loggerA); - Log4jTestUtils.send10Events(loggerB); - Log4jTestUtils.send10Events(loggerC); - Log4jTestUtils.send10Events(loggerD); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jTestUtils.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jTestUtils.java deleted file mode 100644 index e7e645e..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/events/log4j/Log4jTestUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.events.log4j; - -import java.io.IOException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -/** - * Utility methods for log4j tests - */ -final class Log4jTestUtils { - - private Log4jTestUtils() { - } - - static void send10Events(Logger logger) { - // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN - logger.debug("Debug message. Lost among so many."); - logger.debug("Debug message with a throwable", new IOException()); - logger.error("Error messsage. This might be bad."); - logger.error("Error message with a throwable", new IOException()); - logger.fatal("A fatal message. You are already dead."); - logger.info("A info message. Lol, who cares."); - logger.trace("A trace message. No, no *that* trace"); - logger.warn("A warn message. Yellow underline."); - logger.log(Level.DEBUG, "A debug message using .log()"); - logger.log(Level.ERROR, "A error message using .log()"); - } -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java deleted file mode 100644 index 020ad36..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/FilterListenerITBase.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.filter; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.lttng.tools.ILttngSession; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.filter.FilterChangeNotifier; -import org.lttng.ust.agent.filter.IFilterChangeListener; -import org.lttng.ust.agent.session.EventRule; -import org.lttng.ust.agent.session.LogLevelSelector; -import org.lttng.ust.agent.session.LogLevelSelector.LogLevelType; -import org.lttng.ust.agent.utils.EventRuleFactory; -import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.TestPrintRunner; - -/** - * Base test class for {@link IFilterChangeListener} tests. - * - * @author Alexandre Montplaisir - */ -@RunWith(TestPrintRunner.class) -public abstract class FilterListenerITBase { - - private static final String EVENT_NAME_A = "eventA"; - private static final String EVENT_NAME_B = "eventB"; - private static final String EVENT_NAME_C = "eventC"; - - private ILttngSession session; - private TestFilterListener listener; - private ILttngHandler handler; - - protected abstract ILttngSession.Domain getSessionDomain(); - protected abstract ILttngHandler getLogHandler() throws SecurityException, IOException; - protected abstract ILogLevelStrings getLogLevelStrings(); - - /** - * Test setup - * - * @throws SecurityException - * @throws IOException - */ - @Before - public void setup() throws SecurityException, IOException { - handler = getLogHandler(); - listener = new TestFilterListener(); - FilterChangeNotifier.getInstance().registerListener(listener); - session = ILttngSession.createSession(null, getSessionDomain()); - } - - /** - * Test teardown - */ - @After - public void teardown() { - session.close(); - FilterChangeNotifier.getInstance().unregisterListener(listener); - handler.close(); - } - - /** - * Test not sending any commands. - */ - @Test - public void testNoRules() { - assertEquals(0, listener.getNbNotifications()); - assertEquals(Collections.EMPTY_SET, listener.getCurrentRules()); - } - - /** - * Test sending one event rule. - */ - @Test - public void testOneRule() { - Set rules = Collections.singleton( - EventRuleFactory.createRule(EVENT_NAME_A)); - - session.enableEvent(EVENT_NAME_A, null, false, null); - - assertEquals(1, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test sending many event rules. - */ - @Test - public void testManyRules() { - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B), - EventRuleFactory.createRule(EVENT_NAME_C)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - session.enableEvent(EVENT_NAME_C, null, false, null); - - assertEquals(3, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test enabling then disabling some events. - */ - @Test - public void testManyRulesDisableSome() { - Set rules = Collections.singleton( - EventRuleFactory.createRule(EVENT_NAME_A)); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - session.enableEvent(EVENT_NAME_C, null, false, null); - session.disableEvents(EVENT_NAME_B); - session.disableEvents(EVENT_NAME_C); - - assertEquals(5, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test enabling some rules, then calling disable-event -a. - */ - @Test - public void testManyRulesDisableAll() { - Set rules = Collections.EMPTY_SET; - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - session.enableEvent(EVENT_NAME_C, null, false, null); - session.disableAllEvents(); - - /* - * We should receive 6 notifications, because a "disable-event -a" sends - * one for each event that was enabled. - */ - assertEquals(6, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test enabling the same event name with various values of loglevels. - */ - @Test - public void testSameEventsDiffLogLevels() { - LogLevelSelector lls1 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - LogLevelSelector lls2 = new LogLevelSelector(getLogLevelStrings().warningInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_SINGLE); - LogLevelSelector lls3 = new LogLevelSelector(getLogLevelStrings().infoInt(), LogLevelType.LTTNG_EVENT_LOGLEVEL_RANGE); - - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A, lls1), - EventRuleFactory.createRule(EVENT_NAME_A, lls2), - EventRuleFactory.createRule(EVENT_NAME_A, lls3)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), false, null); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().warningName(), true, null); - session.enableEvent(EVENT_NAME_A, getLogLevelStrings().infoName(), false, null); - - assertEquals(3, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test enabling the same event name with various filters. - */ - @Test - public void testSameEventsDiffFilters() { - String filterA = "filterA"; - String filterB = "filterB"; - - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterA), - EventRuleFactory.createRule(EVENT_NAME_C, EventRuleFactory.LOG_LEVEL_UNSPECIFIED, filterB)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, filterA); - session.enableEvent(EVENT_NAME_C, null, false, filterB); - - assertEquals(3, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Test sending some notifications then detaching a listener. Subsequent - * notifications should not be sent. - */ - @Test - public void testDetachingListener() { - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - FilterChangeNotifier.getInstance().unregisterListener(listener); - session.enableEvent(EVENT_NAME_C, null, false, null); - - assertEquals(2, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - } - - /** - * Run a test with multiple listeners attached to the manager. All listeners - * should receive all the data. - */ - @Test - public void testMultipleListeners() { - FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); - TestFilterListener listener2 = new TestFilterListener(); - TestFilterListener listener3 = new TestFilterListener(); - fcn.registerListener(listener2); - fcn.registerListener(listener3); - - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - session.enableEvent(EVENT_NAME_C, null, false, null); - session.disableEvents(EVENT_NAME_C); - - assertEquals(4, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - - assertEquals(4, listener2.getNbNotifications()); - assertEquals(rules, listener2.getCurrentRules()); - - assertEquals(4, listener3.getNbNotifications()); - assertEquals(rules, listener3.getCurrentRules()); - - fcn.unregisterListener(listener2); - fcn.unregisterListener(listener3); - } - - /** - * Test with both attached and unattached listeners. The unattached ones - * should not receive anything, but should not interfere with the other - * ones. - */ - @Test - public void testUnattachedListeners() { - FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); - TestFilterListener listener2 = new TestFilterListener(); - TestFilterListener listener3 = new TestFilterListener(); - /* We attach then detach listener2. We never attach listener3 */ - fcn.registerListener(listener2); - fcn.unregisterListener(listener2); - - Set rules = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - - assertEquals(2, listener.getNbNotifications()); - assertEquals(rules, listener.getCurrentRules()); - - assertEquals(0, listener2.getNbNotifications()); - assertEquals(Collections.EMPTY_SET, listener2.getCurrentRules()); - - assertEquals(0, listener3.getNbNotifications()); - assertEquals(Collections.EMPTY_SET, listener3.getCurrentRules()); - } - - /** - * Test that a newly-registered listener correctly receives the "statedump", - * which means all the rules currently active, upon registration. - */ - @Test - public void testStatedump() { - FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); - TestFilterListener listener2 = new TestFilterListener(); - - Set rules1 = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_B)) - .collect(Collectors.toSet()); - Set rules2 = Stream.of( - EventRuleFactory.createRule(EVENT_NAME_A), - EventRuleFactory.createRule(EVENT_NAME_C)) - .collect(Collectors.toSet()); - - session.enableEvent(EVENT_NAME_A, null, false, null); - session.enableEvent(EVENT_NAME_B, null, false, null); - fcn.registerListener(listener2); - - /* We should have received the "statedump" when registering */ - assertEquals(2, listener2.getNbNotifications()); - assertEquals(rules1, listener2.getCurrentRules()); - - session.enableEvent(EVENT_NAME_C, null, false, null); - session.disableEvents(EVENT_NAME_B); - - /* Subsequent changes should also be received */ - assertEquals(4, listener2.getNbNotifications()); - assertEquals(rules2, listener2.getCurrentRules()); - - fcn.unregisterListener(listener2); - } - - /** - * The filter listener used for tests. - */ - private static class TestFilterListener implements IFilterChangeListener { - - private final Set currentRules = new HashSet<>(); - private volatile int currentNotifications = 0; - - public TestFilterListener() {} - - @Override - public void eventRuleAdded(EventRule rule) { - currentRules.add(rule); - currentNotifications++; - } - - @Override - public void eventRuleRemoved(EventRule rule) { - currentRules.remove(rule); - currentNotifications++; - } - - public int getNbNotifications() { - return currentNotifications; - } - - public Set getCurrentRules() { - return currentRules; - } - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java deleted file mode 100644 index b82e41f..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/JulFilterListenerIT.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.filter; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Filter notifications tests using the JUL logging API. - * - * @author Alexandre Montplaisir - */ -public class JulFilterListenerIT extends FilterListenerITBase { - - /** - * Class setup - */ - @BeforeClass - public static void julClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForJulLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.JUL)); - LttngToolsHelper.destroyAllSessions(); - } - - @Override - protected ILttngSession.Domain getSessionDomain() { - return ILttngSession.Domain.JUL; - } - - @Override - protected ILttngHandler getLogHandler() throws SecurityException, IOException { - return new LttngLogHandler(); - } - - @Override - protected ILogLevelStrings getLogLevelStrings() { - return ILogLevelStrings.JUL_LOGLEVEL_STRINGS; - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java deleted file mode 100644 index c01bc84..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/integration/filter/Log4jFilterListenerIT.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.integration.filter; - -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; - -import org.junit.BeforeClass; -import org.lttng.tools.ILttngSession; -import org.lttng.tools.LttngToolsHelper; -import org.lttng.ust.agent.ILttngHandler; -import org.lttng.ust.agent.log4j.LttngLogAppender; -import org.lttng.ust.agent.utils.ILogLevelStrings; -import org.lttng.ust.agent.utils.LttngUtils; - -/** - * Filter notifications tests using the log4j logging API. - * - * @author Alexandre Montplaisir - */ -public class Log4jFilterListenerIT extends FilterListenerITBase { - - /** - * Class setup - */ - @BeforeClass - public static void log4jClassSetup() { - /* Skip tests if we can't find the JNI library or lttng-tools */ - assumeTrue(LttngUtils.checkForLog4jLibrary()); - assumeTrue(LttngUtils.checkForLttngTools(ILttngSession.Domain.LOG4J)); - LttngToolsHelper.destroyAllSessions(); - } - - @Override - protected ILttngSession.Domain getSessionDomain() { - return ILttngSession.Domain.LOG4J; - } - - @Override - protected ILttngHandler getLogHandler() throws SecurityException, IOException { - return new LttngLogAppender(); - } - - @Override - protected ILogLevelStrings getLogLevelStrings() { - return ILogLevelStrings.LOG4J_LOGLEVEL_STRINGS; - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/EventRuleFactory.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/EventRuleFactory.java deleted file mode 100644 index fd1a46b..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/EventRuleFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.utils; - -import java.util.StringJoiner; - -import org.lttng.ust.agent.session.EventRule; -import org.lttng.ust.agent.session.LogLevelSelector; - -/** - * Factory class for {@link EventRule} objects, offering convenience methods - * that mimic the results of passing the given arguments on the command-line. - * - * @author Alexandre Montplaisir - */ -public final class EventRuleFactory { - - /** Name of the "all" (-a) event */ - public static final String EVENT_NAME_ALL = "*"; - - /** Log level set by default when it is not specified */ - public static final LogLevelSelector LOG_LEVEL_UNSPECIFIED = new LogLevelSelector(Integer.MIN_VALUE, 0); - - private EventRuleFactory() {} - - /** - * Construct an event by only passing the event name on the command-line. - * - * @param eventName - * The event name - * @return The corresponding event rule - */ - public static EventRule createRule(String eventName) { - return new EventRule(eventName, LOG_LEVEL_UNSPECIFIED, filterStringFromEventName(eventName)); - } - - /** - * Construct and event rule by specifying the event name and log level. - * - * @param eventName - * The event name - * @param logLevelSelector - * The log level - * @return The corresponding event rule - */ - public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector) { - StringJoiner sj = new StringJoiner(") && (", "(", ")"); - String filterStr = sj.add(filterStringFromEventName(eventName)) - .add(filterStringFromLogLevel(logLevelSelector)) - .toString(); - return new EventRule(eventName, logLevelSelector, filterStr); - } - - /** - * Construct and event rule by specifying the event name, log level, and a - * filter string. - * - * @param eventName - * The event name - * @param logLevelSelector - * The log level - * @param extraFilter - * The filter string passed on the command-line - * @return The corresponding event rule - */ - public static EventRule createRule(String eventName, LogLevelSelector logLevelSelector, String extraFilter) { - StringJoiner sj1 = new StringJoiner(") && (", "(", ")"); - sj1.add(extraFilter); - sj1.add(filterStringFromEventName(eventName)); - String firstPart = sj1.toString(); - - if (logLevelSelector.equals(LOG_LEVEL_UNSPECIFIED)) { - return new EventRule(eventName, logLevelSelector, firstPart); - } - - /* - * If there is both a filter and a log level, the filter + event name is - * "resolved" first. - */ - StringJoiner sj2 = new StringJoiner(") && (", "(", ")"); - sj2.add(firstPart); - sj2.add(filterStringFromLogLevel(logLevelSelector)); - return new EventRule(eventName, logLevelSelector, sj2.toString()); - } - - /** - * Construct an event rule corresponding to enabling all (-a) events. - * - * @return The corresponding event rule - */ - public static EventRule createRuleAllEvents() { - return new EventRule(EVENT_NAME_ALL, LOG_LEVEL_UNSPECIFIED, ""); - } - - private static String filterStringFromEventName(String eventName) { - return "logger_name == \"" + eventName + "\""; - } - - private static String filterStringFromLogLevel(LogLevelSelector logLevelSelector) { - StringBuilder sb = new StringBuilder(); - sb.append("int_loglevel "); - - switch (logLevelSelector.getLogLevelType()) { - case LTTNG_EVENT_LOGLEVEL_RANGE: - sb.append(">="); - break; - case LTTNG_EVENT_LOGLEVEL_SINGLE: - sb.append("=="); - break; - case LTTNG_EVENT_LOGLEVEL_ALL: - default: - throw new IllegalArgumentException(); - } - - sb.append(" " + logLevelSelector.getLogLevel()); - return sb.toString(); - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/ILogLevelStrings.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/ILogLevelStrings.java deleted file mode 100644 index e46a718..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/ILogLevelStrings.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.utils; - -/** - * Interface to match the log level values used by LTTng to their representation - * (name and integer value) used by the logging APIs. - * - * @author Alexandre Montplaisir - */ -public interface ILogLevelStrings { - - /** - * @return The string representation of the "warning" level - */ - String warningName(); - - /** - * @return The integer representation of the "warning" level - */ - int warningInt(); - - /** - * @return The string representation of the "info" level - */ - String infoName(); - - /** - * @return The integer representation of the "info" level - */ - int infoInt(); - - /** - * Values for JUL - */ - ILogLevelStrings JUL_LOGLEVEL_STRINGS = new ILogLevelStrings() { - - @Override - public String warningName() { - return "warning"; - } - - @Override - public int warningInt() { - return 900; - } - - @Override - public String infoName() { - return "info"; - } - - @Override - public int infoInt() { - return 800; - } - }; - - /** - * Values for log4j 1.x - */ - ILogLevelStrings LOG4J_LOGLEVEL_STRINGS = new ILogLevelStrings() { - - @Override - public String warningName() { - return "warn"; - } - - @Override - public int warningInt() { - return 30000; - } - - @Override - public String infoName() { - return "info"; - } - - @Override - public int infoInt() { - return 20000; - } - }; - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/LttngUtils.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/LttngUtils.java deleted file mode 100644 index b68d979..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/LttngUtils.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.utils; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import org.lttng.tools.ILttngSession; -import org.lttng.tools.ILttngSession.Domain; -import org.lttng.tools.utils.ShellUtils; -import org.lttng.ust.agent.jul.LttngLogHandler; -import org.lttng.ust.agent.log4j.LttngLogAppender; - -/** - * Utility methods to test the presence of certain LTTng tools or libraries in - * the runtime environment. - */ -public final class LttngUtils { - - private LttngUtils() {} - - /** - * Check the the JUL native library is available, effectively allowing LTTng - * JUL handlers to be used. - * - * @return True if JUL works fine, false if it does not. - */ - public static boolean checkForJulLibrary() { - try { - LttngLogHandler testHandler = new LttngLogHandler(); - testHandler.close(); - } catch (SecurityException | IOException e) { - return false; - } - return true; - } - - /** - * Check the the Log4j native library is available, effectively allowing - * LTTng Log4j appenders to be used. - * - * @return True if Log4j works fine, false if it does not. - */ - public static boolean checkForLog4jLibrary() { - try { - LttngLogAppender testAppender = new LttngLogAppender(); - testAppender.close(); - } catch (SecurityException | IOException e) { - return false; - } - return true; - } - - /** - * Check that lttng-tools and babeltrace are installed on the system and - * working. - * - * @param domain - * The tracing domain to test for (we will try to setup a session - * with this domain) - * @return True if the environment should allow tracing fine, false if there - * was an error - */ - public static boolean checkForLttngTools(Domain domain) { - try (ILttngSession session = ILttngSession.createSession(null, domain)) { - boolean ret1 = session.enableAllEvents(); - boolean ret2 = session.start(); - boolean ret3 = session.stop(); - /* - * "lttng view" also tests that Babeltrace is installed and working - */ - List contents = session.view(); - return (ret1 && ret2 && ret3 && contents.isEmpty()); - } - } - - /** - * Check if there is a user session daemon currently running on the system. - * It needs to be of the same user as the application running this program. - * - * @return If there is a user session daemon currently running - */ - public static boolean checkForUserSessiond() { - String userName = System.getProperty("user.name"); - - /* The user name is truncated to 7 characters in "ps" */ - String shortUserName = userName.substring(0, Math.min(userName.length(), 7)); - - List command = Arrays.asList("ps", "-e", "u"); - List output = ShellUtils.getOutputFromCommand(false, command); - return output.stream() - .filter(s -> s.contains("lttng-sessiond")) - .anyMatch(s -> s.startsWith(shortUserName)); - } - - /** - * Check if there is a root user session daemon daemon currently running on - * the system. - * - * @return If there is a root session daemon currently running - */ - public static boolean checkForRootSessiond() { - List command = Arrays.asList("ps", "-e", "u"); - List output = ShellUtils.getOutputFromCommand(false, command); - return output.stream() - .filter(s -> s.contains("lttng-sessiond")) - .anyMatch(s -> s.startsWith("root")); - } - -} diff --git a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/TestPrintRunner.java b/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/TestPrintRunner.java deleted file mode 100644 index 1285984..0000000 --- a/lttng-ust-java-tests/src/test/java/org/lttng/ust/agent/utils/TestPrintRunner.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.lttng.ust.agent.utils; - -import org.junit.runner.Description; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunListener; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.InitializationError; - -/** - * Test runner that will print the name of the test being run to stdout. - * - * Thanks to http://stackoverflow.com/a/27070843/4227853 for the tips. - * - * @author Alexandre Montplaisir - */ -public class TestPrintRunner extends BlockJUnit4ClassRunner { - - /** - * Constructor - * - * @param klass - * @throws InitializationError - */ - public TestPrintRunner(Class klass) throws InitializationError { - super(klass); - } - - @Override - public void run(RunNotifier notifier) { - RunListener listener = new TestPrintListener(); - - notifier.addListener(listener); - super.run(notifier); - notifier.removeListener(listener); - } - - /** - * Listener that will print the class and test name to stdout. - */ - public static class TestPrintListener extends RunListener { - - @Override - public void testStarted(Description description) { - System.out.println("Running " + getTestName(description)); - } - - @Override - public void testAssumptionFailure(Failure failure) { - System.out.println("SKIPPING TEST: " + getTestName(failure.getDescription())); - System.out.println(failure.getMessage()); - } - - /** - * Get the className#methodName from a Description. - */ - private static String getTestName(Description description) { - return description.getClassName() + '#' + description.getMethodName(); - } - } - -} diff --git a/pom.xml b/pom.xml index 2c09828..786ed97 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,13 @@ UTF-8 UTF-8 + + + /usr/local/share/java/lttng-ust-agent-common-1.0.0.jar + /usr/local/share/java/lttng-ust-agent-jul-1.0.0.jar + /usr/local/share/java/lttng-ust-agent-log4j-1.0.0.jar + -Djava.library.path=/usr/local/lib @@ -49,13 +56,85 @@ 1.8 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + + integration-test + verify + + + + - - + + + + + + org.lttng.ust.agent + lttng-ust-agent-common + 1.0.0 + system + ${common-jar-location} + + + + org.lttng.ust.agent + lttng-ust-agent-jul + 1.0.0 + system + ${jul-jar-location} + + + + org.lttng.ust.agent + lttng-ust-agent-log4j + 1.0.0 + system + ${log4j-jar-location} + + + + + org.lttng.tools + lttng-tools-java + 1.0.0 + + + + org.lttng.ust + lttng-ust-java-tests-common + 1.0.0 + + + + + log4j + log4j + 1.2.17 + + + + junit + junit + RELEASE + test + + + + + - lttng-ust-java-tests lttng-tools-java + lttng-ust-java-tests-common + lttng-ust-java-tests-jul + lttng-ust-java-tests-log4j