Question
How to write Junit tests for Java code below in Java ? How do you write JUnit tests for Part 4 ? I have included
How to write Junit tests for Java code below in Java ?
How do you write JUnit tests for Part 4 ? I have included the code below
I have part 1 , finished
part 2, maybe correct
part 3 correct
part 4
I have included my code below:
Class 3 Chapter 17 Lab( Store objects in a file)
Due Wednesday by 6pm Points 10 Submitting a text entry box, a website url, or a file upload Available Feb 8 at 6pm - Feb 15 at 6pm
Program 3.2 Requirements
Part 1: Maven
Generate a maven project and import it into Eclipse like we did in class. Use the java11-junit5 archetype, the group should be com.jccc.objects.file and the name of the project is objects-file. Take a screenshot of eclipse showing the included project. The project should be expanded, so the folders can be seen. upload the pom.xml and screenshot as part of the this lab.
Part 2 -- create an object
DVDs. The DVDs have 3 attributes: name -- 32 bytes length of film -- 5 bytes MPAA rating -- 2 bytes
Part 3 -- Write a program
The main method of the program should just call the 4 methods below Create a method that creates a List of 5 DVD. The DVD can be whatever you like but must contain all 3 attributes. Write a method Using Object Streams that stores the List of DVDs(use the method above). a Date object for the current time, and the double value 5.5 into a file named class03Object.dat. Write a method Using Object Streams that reads the data from class03Object.dat. The method returns a List
Part 4 -- Write Junit tests --Reminder Test files should have the same name as the file that they are testing plus the ending Test
write a Junit test method that calls the write method Using Object Streams and then call the read method and assert the values read. write a second Junit test method that calls the write method Using RandomAccessFile and then call the read method and assert the values read.
Expected Documentation
JavaDoc with @author and your name and a brief description of the class. Also, each method should have Javadoc on it. Checkstyle must be used. Not using Checkstyle will be an automatic loss of 10%.
Submission
Upload the files for each part to this lab submission page. There should be 5 files.
DVD.java
package com.jccc.objects.file;
public class DVD {
private String name; private String lengthOfFilm; private String rating;
public DVD(String name, String lengthOfFilm, String rating) { super(); this.name = name; this.lengthOfFilm = lengthOfFilm; this.rating = rating; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLengthOfFilm() { return lengthOfFilm; } public void setLengthOfFilm(String lengthOfFilm) { this.lengthOfFilm = lengthOfFilm; } public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; }
}
package com.jccc.objects.file;
import java.io.*; import java.util.ArrayList; import java.util.Date; import java.util.List;
public class mainDvdFile {
public static void main(String[] args) throws IOException, ClassNotFoundException { List
/** * Creates a list of 5 DVD objects */ private static List
/** * Writes the list of DVDs, a Date object, and a double value to an object file */ private static void writeToObjFile(List
/** * Reads the list of DVDs, a Date object, and a double value from an object file */ private static List
/** * Writes the list of DVDs to a random access file */ private static void writeToRAFFile(List
/** * Reads the list of DVDs from a random access file */ private static List
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started