Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test to check year in license file #365

Merged
merged 1 commit into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that this isn't running due to being in the wrong path? We have some other tests here: https://github.com/sendgrid/sendgrid-java/tree/master/src that are running in Travis. Can you please move this file there?


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);
}
}