Skip to content

Commit

Permalink
Test to check year in license file
Browse files Browse the repository at this point in the history
  • Loading branch information
pushkyn committed Nov 19, 2017
1 parent da70e5a commit e3a9cdf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2017 SendGrid
Copyright (c) 2013-2017 SendGrid, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/sendgrid/LicenseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.sendgrid;

import org.junit.Assert;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Calendar;

public class LicenseTest {

@Test
public void testLicenseShouldHaveCorrectYear() throws IOException {
String copyrightText = null;
try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) {
for (String line; (line = br.readLine()) != null; ) {
if (line.startsWith("Copyright")) {
copyrightText = line;
break;
}
}
}
String expectedCopyright = String.format("Copyright (c) 2013-%d SendGrid, Inc.", Calendar.getInstance().get(Calendar.YEAR));
Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright);
}
}

0 comments on commit e3a9cdf

Please sign in to comment.