<commit_before>package green.bunny

import spock.lang.Specification

import java.security.SecureRandom

abstract class IntegrationSpec extends Specification {
  def Connection conn
  def Channel ch

  def setup() {
    conn = connect()
    ch = openChannel()
  }

  protected Connection connect() {
    GreenBunny.connect()
  }

  protected Channel openChannel() {
    conn.createChannel()
  }

  def cleanup() {
    if (conn != null && conn.isOpen) {
      conn.close()
    }
    conn = null
  }

  //
  // Helpers
  //

  protected int portInRange(int min, int max) {
    // port range
    def sr = new SecureRandom()
    def n = sr.nextInt(max - min) + min
    n
  }

  //
  // Matchers
  //

  void ensureServerNamed(Queue q) {
    assert q.name =~ /^amq\./
    assert q.isServerNamed
  }

  void ensureServerNamed(String q) {
    assert q =~ /^amq\./
  }

  void ensureClientNamed(Queue q) {
    assert !(q.name =~ /^amq\./)
    assert !q.isServerNamed
  }

  void ensureDeclared(Channel ch, Queue q) {
    assert q.channel == ch
    assert ch.queueDeclarePassive(q.name)
  }

  void ensureDeclared(String q) {
    assert ch.queueDeclarePassive(q)
  }

  void ensureDeleted(Queue q) {
    ensureDeleted(q.name)
  }

  void ensureDeleted(String q) {
    def tmpCh = conn.createChannel()
    try {
      tmpCh.queueDeclarePassive(q)
      assert false
    } catch (IOException _) {
      // expected
    }
  }
}<commit_msg>Eliminate a warning<commit_after>package green.bunny

import spock.lang.Specification

import java.security.SecureRandom

abstract class IntegrationSpec extends Specification {
  def Connection conn
  def Channel ch

  def setup() {
    conn = connect()
    ch = openChannel()
  }

  protected Connection connect() {
    GreenBunny.connect()
  }

  protected Channel openChannel() {
    conn.createChannel()
  }

  def cleanup() {
    if (conn != null && conn.isOpen) {
      conn.close()
    }
    conn = null
  }

  //
  // Helpers
  //

  protected int portInRange(int min, int max) {
    // port range
    def sr = new SecureRandom()
    def n = sr.nextInt(max - min) + min
    n
  }

  //
  // Matchers
  //

  void ensureServerNamed(Queue q) {
    assert q.name =~ /^amq\./
    assert q.isServerNamed
  }

  void ensureServerNamed(String q) {
    assert q =~ /^amq\./
  }

  void ensureClientNamed(Queue q) {
    assert !(q.name =~ /^amq\./)
    assert !q.isServerNamed
  }

  void ensureDeclared(Channel ch, Queue q) {
    assert q.channel == ch
    assert ch.queueDeclarePassive(q.name)
  }

  void ensureDeclared(String q) {
    assert ch.queueDeclarePassive(q)
  }

  void ensureDeleted(Queue q) {
    ensureDeleted(q.name)
  }

  void ensureDeleted(String q) {
    def tmpCh = conn.createChannel()
    try {
      tmpCh.queueDeclarePassive(q)
      assert false
    } catch (IOException ignored) {
      // expected
    }
  }
}
{'fraction_non_alphanumeric': 0.11522346368715083, 'fraction_numerical': 0.0, 'mean_word_length': 2.4066587395957195, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4621069', 'n_tokens_mistral': 995, 'n_tokens_neox': 961, 'n_words': 231}