Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Add logs and collector test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljbc committed Dec 14, 2020
1 parent 14f0d9f commit fcd1c06
Show file tree
Hide file tree
Showing 8 changed files with 845 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For the tests that are specific to the workflow of the framework, we designed se

### Test Logs

The logs for the execution of the tests was generated in the HTML format and can be found [**here**](https://htmlpreview.github.io/?https://github.com/danieljbc/collector/blob/master/docs/files/testlogs.html).
The logs for the execution of the tests was generated in the HTML format and can be found [**here**](https://htmlpreview.github.io/?https://github.com/danieljbc/collector/blob/master/docs/files/testlogs.html). You can click on the name of each test to expand the log for each individual test case.

## Framework Instantiation

Expand Down
721 changes: 721 additions & 0 deletions docs/files/testlogs.html

Large diffs are not rendered by default.

83 changes: 80 additions & 3 deletions src/test/java/CollectorTests.java
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.");
}
}
9 changes: 8 additions & 1 deletion src/test/java/fixtures/CollectionTaskScheduler.java
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;
}
}
9 changes: 8 additions & 1 deletion src/test/java/fixtures/CommunicationTaskScheduler.java
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;
}
}
4 changes: 3 additions & 1 deletion src/test/java/fixtures/EmptyTaskScheduler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fixtures;

public class EmptyTaskScheduler {
import collector.TaskScheduler;

public class EmptyTaskScheduler extends TaskScheduler {

public void run(){
// DOES NOTHING
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/fixtures/ProcessingTaskScheduler.java
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;
}
}
16 changes: 16 additions & 0 deletions src/test/java/fixtures/Status.java
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;
}
}

0 comments on commit fcd1c06

Please sign in to comment.