This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from jrmartino/master
release for v 1.4.0
- Loading branch information
Showing
34 changed files
with
2,317 additions
and
989 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
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import java.io.OutputStreamWriter; | ||
import java.nio.charset.StandardCharsets; | ||
import java.sql.SQLException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
@@ -50,27 +51,28 @@ | |
* use the PassLoader to take {@code List} representing the {@code ResultSet} to push this data into our PASS instance | ||
* via the java pass client. | ||
* | ||
* | ||
* A large percentage of the code here is handling exceptional paths, as this is intended to be run in an automated | ||
* fashion, so care must be taken to log errors, report them to STDOUT, and also send email notifications. | ||
* | ||
* @author [email protected] | ||
*/ | ||
abstract class BaseGrantLoaderApp { | ||
private static Logger LOG = LoggerFactory.getLogger(BaseGrantLoaderApp.class); | ||
private static final Logger LOG = LoggerFactory.getLogger(BaseGrantLoaderApp.class); | ||
private EmailService emailService; | ||
|
||
private File appHome; | ||
private final File appHome; | ||
private String startDate; | ||
private String awardEndDate; | ||
private final String awardEndDate; | ||
private File updateTimestampsFile; | ||
private boolean email; | ||
private String mode; | ||
private String action; | ||
private String dataFileName; | ||
private final boolean email; | ||
private final String mode; | ||
private final String action; | ||
private final String dataFileName; | ||
private boolean local = false; | ||
private boolean timestamp = true; | ||
private boolean timestamp = false; | ||
|
||
private String updateTimestampsFileName; | ||
private final String updateTimestampsFileName; | ||
|
||
/** | ||
* Constructor for this class | ||
|
@@ -247,7 +249,7 @@ void run() throws PassCliException { | |
try (FileInputStream fis = new FileInputStream(dataFile); | ||
ObjectInputStream in = new ObjectInputStream(fis) | ||
) { | ||
resultSet = (List<Map<String, String>>)in.readObject(); | ||
resultSet = Collections.unmodifiableList((List<Map<String, String>>) in.readObject()); | ||
} catch (IOException | ClassNotFoundException ex) { | ||
ex.printStackTrace(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -31,12 +31,12 @@ | |
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* An email service for reporting errors or results of running the {@code CoeusGrantLoaderApp} | ||
* An email service for reporting errors or results of running a GrantLoaderApp | ||
* @author [email protected] | ||
*/ | ||
class EmailService { | ||
private static Logger LOG = LoggerFactory.getLogger(EmailService.class); | ||
private Properties mailProperties; | ||
private static final Logger LOG = LoggerFactory.getLogger(EmailService.class); | ||
private final Properties mailProperties; | ||
|
||
/** | ||
* The constructor | ||
|
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
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
import com.icegreen.greenmail.util.GreenMail; | ||
import com.icegreen.greenmail.util.ServerSetupTest; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
|
@@ -28,13 +27,16 @@ | |
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Test classs for email service | ||
* @author [email protected] | ||
*/ | ||
public class EmailServiceTest { | ||
|
||
private Properties mailProperties = System.getProperties(); | ||
private final Properties mailProperties = System.getProperties(); | ||
private EmailService underTest; | ||
private GreenMail testServer; | ||
|
||
|
@@ -63,7 +65,7 @@ public void setup() throws InterruptedException { | |
|
||
if (!started) { | ||
// try one more time | ||
Thread.sleep(5000l); | ||
Thread.sleep(5000L); | ||
testServer.start(); | ||
} | ||
|
||
|
@@ -80,14 +82,14 @@ public void testSendMessage() throws MessagingException, IOException { | |
String messageSubject = "TEST"; | ||
underTest.sendEmailMessage(messageSubject, messageBody); | ||
// Check that only one message was sent | ||
Integer numMessages = testServer.getReceivedMessages().length; | ||
Assert.assertTrue("Expected only one message, got " + numMessages, numMessages == 1); | ||
int numMessages = testServer.getReceivedMessages().length; | ||
assertEquals("Expected only one message, got " + numMessages, 1, numMessages); | ||
|
||
// Check that the message is just a plaintext message | ||
MimeMessage message = testServer.getReceivedMessages()[0]; | ||
Assert.assertTrue("Subject of message was not correct", message.getSubject().equals(messageSubject)); | ||
Assert.assertTrue("Content of message was not a string as expected", message.getContent() instanceof String); | ||
Assert.assertTrue(message.getContent().toString().contains(messageBody)); | ||
assertEquals("Subject of message was not correct", message.getSubject(), messageSubject); | ||
assertTrue("Content of message was not a string as expected", message.getContent() instanceof String); | ||
assertTrue(message.getContent().toString().contains(messageBody)); | ||
} | ||
|
||
@After | ||
|
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
Oops, something went wrong.