MyFileReaderTest.java   import static org.junit.Assert.assertEquals; import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MyFileReaderTest {   MyFileReader myFileReader1; MyFileReader myFileReader2; MyFileReader myFileReader3; MyFileReader myFileReader4; MyFileReader myFileReader5;     @BeforeEach void setUp () { this.myFileReader1 =new MyFileReader("info.txt"); // original info.txt file this.myFileReader2 =new MyFileReader("test2.txt"); // file with multiple words per line this.myFileReader3 =new MyFileReader("test3.txt"); // similar to info.txt file but with leading and trailing whitespace this.myFileReader4 =new MyFileReader("test4.txt"); // similar to info.txt file but with different info this.myFileReader5 =new MyFileReader("test5.txt"); // similar to info.txt file but with blank lines in between lines with information } @Test publicvoid testGetCleanContent(MyFileReader myFileReader2, final MyFileReader myFileReader) { ArrayList actual = myFileReader1.getCleanContent(); final ArrayList expected =new ArrayList();   // test original info.txt file expected.add("Course:"); expected.add("MCIT_590"); expected.add("CourseID:"); expected.add("590"); expected.add("StudentID:"); expected.add("101"); assertEquals(expected, actual);   // test info.txt file with leading and trailing whitespace actual = myFileReader3.getCleanContent(); assertEquals(expected, actual);   // test file with multiple words per line actual = myFileReader.getCleanContent(); expected.removeAll(expected); expected.add("hello world"); expected.add("Course Name and ID"); expected.add("The quick brown fox jumps over the lazy dog."); assertEquals(expected, actual);   // TODO write at least 2 additional test cases using different new MyFileReaders     // test original info.txt file expected.add("Course:"); expected.add("MCIT_590"); expected.add("CourseID:"); expected.add("590"); expected.add("StudentID:"); expected.add("101"); assertEquals(expected, actual);   // test info.txt file with leading and trailing whitespace actual = myFileReader1.getCleanContent(); assertEquals(expected, actual);   // test file with multiple words per line actual = myFileReader3.getCleanContent(); expected.removeAll(expected); expected.add("hello world"); expected.add("Course Name and ID"); expected.add("The quick brown fox jumps over the lazy dog."); assertEquals(expected, actual);       // test original info.txt file expected.add("Course:"); expected.add("MCIT_590"); expected.add("CourseID:"); expected.add("590"); expected.add("StudentID:"); expected.add("101"); assertEquals(expected, actual);   // test info.txt file with leading and trailing whitespace actual = myFileReader2.getCleanContent(); assertEquals(expected, actual);   // test file with multiple words per line actual = myFileReader3.getCleanContent(); expected.removeAll(expected); expected.add("hello world"); expected.add("Course Name and ID"); expected.add("The quick brown fox jumps over the lazy dog."); assertEquals(expected, actual);       // test original info.txt file expected.add("Course:"); expected.add("MCIT_590"); expected.add("CourseID:"); expected.add("590"); expected.add("StudentID:"); expected.add("101"); assertEquals(expected, actual);   // test info.txt file with leading and trailing whitespace actual = myFileReader.getCleanContent(); assertEquals(expected, actual);   // test file with multiple words per line actual = myFileReader1.getCleanContent(); expected.removeAll(expected); expected.add("hello world"); expected.add("Course Name and ID"); expected.add("The quick brown fox jumps over the lazy dog."); assertEquals(expected, actual);   } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

MyFileReaderTest.java

 

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class MyFileReaderTest {
 
MyFileReader myFileReader1;
MyFileReader myFileReader2;
MyFileReader myFileReader3;
MyFileReader myFileReader4;
MyFileReader myFileReader5;
 
 
@BeforeEach
void setUp () {
this.myFileReader1 =new MyFileReader("info.txt"); // original info.txt file
this.myFileReader2 =new MyFileReader("test2.txt"); // file with multiple words per line
this.myFileReader3 =new MyFileReader("test3.txt"); // similar to info.txt file but with leading and trailing whitespace
this.myFileReader4 =new MyFileReader("test4.txt"); // similar to info.txt file but with different info
this.myFileReader5 =new MyFileReader("test5.txt"); // similar to info.txt file but with blank lines in between lines with information
}


@Test
publicvoid testGetCleanContent(MyFileReader myFileReader2, final MyFileReader myFileReader) {
ArrayList<String> actual = myFileReader1.getCleanContent();
final ArrayList<String> expected =new ArrayList<String>();
 
// test original info.txt file
expected.add("Course:");
expected.add("MCIT_590");
expected.add("CourseID:");
expected.add("590");
expected.add("StudentID:");
expected.add("101");
assertEquals(expected, actual);
 
// test info.txt file with leading and trailing whitespace
actual = myFileReader3.getCleanContent();
assertEquals(expected, actual);
 
// test file with multiple words per line
actual = myFileReader.getCleanContent();
expected.removeAll(expected);
expected.add("hello world");
expected.add("Course Name and ID");
expected.add("The quick brown fox jumps over the lazy dog.");
assertEquals(expected, actual);
 
// TODO write at least 2 additional test cases using different new MyFileReaders
 
 
// test original info.txt file
expected.add("Course:");
expected.add("MCIT_590");
expected.add("CourseID:");
expected.add("590");
expected.add("StudentID:");
expected.add("101");
assertEquals(expected, actual);
 
// test info.txt file with leading and trailing whitespace
actual = myFileReader1.getCleanContent();
assertEquals(expected, actual);
 
// test file with multiple words per line
actual = myFileReader3.getCleanContent();
expected.removeAll(expected);
expected.add("hello world");
expected.add("Course Name and ID");
expected.add("The quick brown fox jumps over the lazy dog.");
assertEquals(expected, actual);
 
 
 
// test original info.txt file
expected.add("Course:");
expected.add("MCIT_590");
expected.add("CourseID:");
expected.add("590");
expected.add("StudentID:");
expected.add("101");
assertEquals(expected, actual);
 
// test info.txt file with leading and trailing whitespace
actual = myFileReader2.getCleanContent();
assertEquals(expected, actual);
 
// test file with multiple words per line
actual = myFileReader3.getCleanContent();
expected.removeAll(expected);
expected.add("hello world");
expected.add("Course Name and ID");
expected.add("The quick brown fox jumps over the lazy dog.");
assertEquals(expected, actual);
 
 
 
// test original info.txt file
expected.add("Course:");
expected.add("MCIT_590");
expected.add("CourseID:");
expected.add("590");
expected.add("StudentID:");
expected.add("101");
assertEquals(expected, actual);
 
// test info.txt file with leading and trailing whitespace
actual = myFileReader.getCleanContent();
assertEquals(expected, actual);
 
// test file with multiple words per line
actual = myFileReader1.getCleanContent();
expected.removeAll(expected);
expected.add("hello world");
expected.add("Course Name and ID");
expected.add("The quick brown fox jumps over the lazy dog.");
assertEquals(expected, actual);
 
}

}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY