This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
845 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,86 @@ | ||
import collector.Collector; | ||
import fixtures.CollectionTaskScheduler; | ||
import fixtures.EmptyTaskScheduler; | ||
import org.junit.Test; | ||
import fixtures.*; | ||
|
||
public class CollectorTests { | ||
|
||
@Test | ||
public void testCaseOne(){ | ||
|
||
@Test(timeout = 5000) | ||
public void onlyCollection(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new CollectionTaskScheduler(), new EmptyTaskScheduler(), new EmptyTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.collectionFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void onlyProcessing(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new EmptyTaskScheduler(), new ProcessingTaskScheduler(), new EmptyTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.processingFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void onlyCommunication(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new EmptyTaskScheduler(), new EmptyTaskScheduler(), new CommunicationTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.communicationFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void collectionAndProcessing(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new CollectionTaskScheduler(), new ProcessingTaskScheduler(), new EmptyTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.collectionFinished || !Status.processingFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void processingAndCommunication(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new EmptyTaskScheduler(), new ProcessingTaskScheduler(), new CommunicationTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.communicationFinished || !Status.processingFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void collectionAndCommunication(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new CollectionTaskScheduler(), new EmptyTaskScheduler(), new CommunicationTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.collectionFinished || !Status.communicationFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
@Test(timeout = 5000) | ||
public void allSteps(){ | ||
Status.clear(); | ||
System.out.println("Initializing collector and starting schedulers."); | ||
Collector collector = new Collector(new CollectionTaskScheduler(), new ProcessingTaskScheduler(), new CommunicationTaskScheduler()); | ||
collector.startCollector(); | ||
while (!Status.collectionFinished || !Status.processingFinished || !Status.communicationFinished){ | ||
// DO NOTHING, WILL TIMEOUT IF IT DOESN'T FINISH SUCESSFULLY. | ||
} | ||
System.out.println("Collector finished successfully."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package fixtures; | ||
|
||
public class CollectionTaskScheduler { | ||
import collector.TaskScheduler; | ||
|
||
public class CollectionTaskScheduler extends TaskScheduler { | ||
@Override | ||
public void run() { | ||
Status.collectionFinished = true; | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package fixtures; | ||
|
||
public class CommunicationTaskScheduler { | ||
import collector.TaskScheduler; | ||
|
||
public class CommunicationTaskScheduler extends TaskScheduler { | ||
@Override | ||
public void run() { | ||
Status.communicationFinished = true; | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
package fixtures; | ||
|
||
public class ProcessingTaskScheduler { | ||
import collector.TaskScheduler; | ||
|
||
public class ProcessingTaskScheduler extends TaskScheduler { | ||
@Override | ||
public void run() { | ||
Status.processingFinished = true; | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fixtures; | ||
|
||
/** | ||
* Class that used to monitor the state of the threads in the dummy collector; | ||
*/ | ||
public class Status { | ||
static public boolean collectionFinished = false; | ||
static public boolean processingFinished = false; | ||
static public boolean communicationFinished = false; | ||
|
||
public static void clear(){ | ||
collectionFinished = false; | ||
processingFinished = false; | ||
communicationFinished = false; | ||
} | ||
} |