From f9d8b68fde9f3dc03b7ca1e1c0ffce9b1b72ecd6 Mon Sep 17 00:00:00 2001 From: pushkyn Date: Sun, 29 Oct 2017 01:49:22 +0300 Subject: [PATCH] Test to check year in license file --- LICENSE.md | 2 +- src/test/java/com/sendgrid/LicenseTest.java | 27 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/sendgrid/LicenseTest.java diff --git a/LICENSE.md b/LICENSE.md index 84a49643..1e1037a5 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/src/test/java/com/sendgrid/LicenseTest.java b/src/test/java/com/sendgrid/LicenseTest.java new file mode 100644 index 00000000..82a6432d --- /dev/null +++ b/src/test/java/com/sendgrid/LicenseTest.java @@ -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.txt"))) { + 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); + } +}