From the course: Java EE: Concurrency and Multithreading

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Write a test class and run the application

Write a test class and run the application

From the course: Java EE: Concurrency and Multithreading

Start my 1-month free trial

Write a test class and run the application

- [Narrator] The next step is to test this code out. We've already written the user dao, we've created the user bean, and we've created the callable implementation. Now let's test this out. So, in a test class, the first thing that you have to do is get a collection of string values from that file. So let's come to the IDE, under the Tests folder, let's create a class. Let's call this TestExecutors, and let's grab the main method quickly. Okay, now we're going to write a separate method to read that file, and get a list of all those lines, okay? So, I'm going to say public static getUsersFromFile. The parameter to this will be a file name. And what is this going to return me? This is going to return me a list of string. Each line in the file is one string, and I'll make such a list of strings. Okay, now the file reading code is something that we've already coded in one of our previous demos, so I'm not going to write that code again. I'll pull it out from the AppThread.java class…

Contents