<commit_before># Copyright (c) 2015 AppNeta, Inc.
# All rights reserved.

require 'minitest_helper'
require 'rack/test'
require 'rack/lobster'
require 'traceview/inst/rack'

class AVWTraceTest  < Minitest::Test
  include Rack::Test::Methods

  def app
    @app = Rack::Builder.new {
      use Rack::CommonLogger
      use Rack::ShowExceptions
      use TraceView::Rack
      map "/lobster" do
        use Rack::Lint
        run Rack::Lobster.new
      end
    }
  end

  def setup
    clear_all_traces
    TraceView::Config[:tracing_mode] = :always
  end

  def test_avw_collection_with_through
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :through
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')

    response = get "/lobster"
    response.header.key?('X-Trace').must_equal true
  end

  def test_avw_collection_with_always
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :always
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')<commit_msg>Fix AVW test; false when through/AVW<commit_after># Copyright (c) 2015 AppNeta, Inc.
# All rights reserved.

require 'minitest_helper'
require 'rack/test'
require 'rack/lobster'
require 'traceview/inst/rack'

class AVWTraceTest  < Minitest::Test
  include Rack::Test::Methods

  def app
    @app = Rack::Builder.new {
      use Rack::CommonLogger
      use Rack::ShowExceptions
      use TraceView::Rack
      map "/lobster" do
        use Rack::Lint
        run Rack::Lobster.new
      end
    }
  end

  def setup
    clear_all_traces
    TraceView::Config[:tracing_mode] = :always
  end

  def test_avw_collection_with_through
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :through
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')

    response = get "/lobster"
    response.header.key?('X-Trace').must_equal false
  end

  def test_avw_collection_with_always
    # Skip under JRuby/Joboe for now. Due to Java instrumentation
    # variation that is being investigated in TVI-2348
    skip if defined?(JRUBY_VERSION)

    TV::Config[:tracing_mode] = :always
    header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')
{'fraction_non_alphanumeric': 0.09512390087929656, 'fraction_numerical': 0.009592326139088728, 'mean_word_length': 3.4937163375224416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371070', 'n_tokens_mistral': 893, 'n_tokens_neox': 836, 'n_words': 210}