Skip to content

Commit fe032c9

Browse files
author
Matt Bernier
authored
Merge pull request sendgrid#365 from pushkyn/test-license-date-range
Test to check year in license file
2 parents da70e5a + e3a9cdf commit fe032c9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2017 SendGrid
3+
Copyright (c) 2013-2017 SendGrid, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.sendgrid;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
import java.io.BufferedReader;
7+
import java.io.FileReader;
8+
import java.io.IOException;
9+
import java.util.Calendar;
10+
11+
public class LicenseTest {
12+
13+
@Test
14+
public void testLicenseShouldHaveCorrectYear() throws IOException {
15+
String copyrightText = null;
16+
try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) {
17+
for (String line; (line = br.readLine()) != null; ) {
18+
if (line.startsWith("Copyright")) {
19+
copyrightText = line;
20+
break;
21+
}
22+
}
23+
}
24+
String expectedCopyright = String.format("Copyright (c) 2013-%d SendGrid, Inc.", Calendar.getInstance().get(Calendar.YEAR));
25+
Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright);
26+
}
27+
}

0 commit comments

Comments
 (0)