<commit_before>package fitnesse.responders.run;

import fitnesse.wiki.*;
import static junit.framework.Assert.assertSame;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class PageListSetUpTearDownSurrounderTest {
  private WikiPage root;
  private WikiPage suite;
  private WikiPage testPage;
  private PageCrawler crawler;

  private PageListSetUpTearDownSurrounder surrounder;

  @Before
  public void setUp() throws Exception {
    root = InMemoryPage.makeRoot("RooT");
    crawler = root.getPageCrawler();
    PageData data = root.getData();
    root.commit(data);
    suite = crawler.addPage(root, PathParser.parse("SuitePageName"), "The is the test suite\n");
    testPage = crawler.addPage(suite, PathParser.parse("TestOne"), "My test and has some content");
    surrounder = new PageListSetUpTearDownSurrounder(root);
  }

  @Test
  public void testPagesForTestSystemAreSurroundedByRespectiveSuiteSetupAndTeardown() throws Exception {
    WikiPage slimPage = crawler.addPage(testPage, PathParser.parse("TestPage"));
    WikiPage setUp = crawler.addPage(root, PathParser.parse("SuiteSetUp"));
    WikiPage tearDown = crawler.addPage(root, PathParser.parse("SuiteTearDown"));
    WikiPage setUp2 = crawler.addPage(slimPage, PathParser.parse("SuiteSetUp"));
    WikiPage tearDown2 = crawler.addPage(slimPage, PathParser.parse("SuiteTearDown"));

    SuiteContentsFinder finder = new SuiteContentsFinder(suite, null, root);
    List<WikiPage> testPages = finder.getAllPagesToRunForThisSuite();
    surrounder.surroundGroupsOfTestPagesWithRespectiveSetUpAndTearDowns(testPages);

    assertEquals(6, testPages.size());
    assertEquals(setUp, testPages.get(0));
    assertEquals(testPage, testPages.get(1));
    assertEquals(tearDown, testPages.get(2));
    assertEquals(setUp2, testPages.get(3));
    assertEquals(slimPage, testPages.get(4));
    assertEquals(tearDown2, testPages.get(5));
  }<commit_msg>Fixed bug that was sensitive to order issues in different OS<commit_after>package fitnesse.responders.run;

import fitnesse.wiki.*;
import static junit.framework.Assert.assertSame;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class PageListSetUpTearDownSurrounderTest {
  private WikiPage root;
  private WikiPage suite;
  private WikiPage testPage;
  private PageCrawler crawler;

  private PageListSetUpTearDownSurrounder surrounder;

  @Before
  public void setUp() throws Exception {
    root = InMemoryPage.makeRoot("RooT");
    crawler = root.getPageCrawler();
    PageData data = root.getData();
    root.commit(data);
    suite = crawler.addPage(root, PathParser.parse("SuitePageName"), "The is the test suite\n");
    testPage = crawler.addPage(suite, PathParser.parse("TestPage"), "My test and has some content");
    surrounder = new PageListSetUpTearDownSurrounder(root);
  }

  @Test
  public void testPagesForTestSystemAreSurroundedByRespectiveSuiteSetupAndTeardown() throws Exception {
    WikiPage slimPage = crawler.addPage(testPage, PathParser.parse("SlimPageTest"));
    WikiPage setUp = crawler.addPage(root, PathParser.parse("SuiteSetUp"));
    WikiPage tearDown = crawler.addPage(root, PathParser.parse("SuiteTearDown"));
    WikiPage setUp2 = crawler.addPage(slimPage, PathParser.parse("SuiteSetUp"));
    WikiPage tearDown2 = crawler.addPage(slimPage, PathParser.parse("SuiteTearDown"));

    SuiteContentsFinder finder = new SuiteContentsFinder(suite, null, root);
    List<WikiPage> testPages = finder.getAllPagesToRunForThisSuite();
    surrounder.surroundGroupsOfTestPagesWithRespectiveSetUpAndTearDowns(testPages);

    assertEquals(6, testPages.size());

    int testPageIndex = testPages.indexOf(testPage);
    assertTrue(testPageIndex != -1);
    assertSame(setUp, testPages.get(testPageIndex-1));
    assertSame(tearDown, testPages.get(testPageIndex+1));

    int slimPageIndex = testPages.indexOf(slimPage);
    assertTrue(slimPageIndex != -1);
    assertSame(setUp2, testPages.get(slimPageIndex-1));
    assertSame(tearDown2, testPages.get(slimPageIndex+1));
  }
{'fraction_non_alphanumeric': 0.10743998098407416, 'fraction_numerical': 0.005229379605419538, 'mean_word_length': 5.626771653543307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2370850', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1308, 'n_words': 255}