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

resource bundle for junit test error strings #698

Merged
merged 9 commits into from
May 29, 2018
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
33 changes: 1 addition & 32 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,33 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain why we are removing these lines? ...A better question, do we want to remove all of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we shouldn't be normalizing anything files should be left alone as is so they can be edited in all platforms. There is no need to specify individual extensions, wild card specifies all should be left alone.


#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.css text
*.md text
*.htm text
*.html text
*.java text
*.js text
*.json text
*.properties text
*.sh text
*.svg text
*.txt text
*.xml text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.gif binary
*.ico binary
*.jar binary
*.jpg binary
*.jpeg binary
*.png binary
*.so binary
*.war binary
* -text
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
import com.microsoft.sqlserver.jdbc.SQLServerStatementColumnEncryptionSetting;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.testframework.AbstractTest;
import com.microsoft.sqlserver.testframework.DBConnection;
import com.microsoft.sqlserver.testframework.Utils;
Expand Down Expand Up @@ -87,7 +88,7 @@ public class AESetup extends AbstractTest {
@BeforeAll
static void setUpConnection() throws TestAbortedException, Exception {
assumeTrue(13 <= new DBConnection(connectionString).getServerVersion(),
"Aborting test case as SQL Server version is not compatible with Always encrypted ");
TestResource.getResource("R_Incompat_SQLServerVersion"));

String AETestConenctionString = connectionString + ";sendTimeAsDateTime=false";
readFromFile(javaKeyStoreInputFile, "Alias name");
Expand Down Expand Up @@ -140,7 +141,7 @@ private static void readFromFile(String inputFile,
filePath = Utils.getCurrentClassPath();
try {
File f = new File(filePath + inputFile);
assumeTrue(f.exists(), "Aborting test case since no java key store and alias name exists!");
assumeTrue(f.exists(), TestResource.getResource("R_noKeyStore"));
try(BufferedReader buffer = new BufferedReader(new FileReader(f))) {
String readLine = "";
String[] linecontents;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
import com.microsoft.sqlserver.jdbc.SQLServerResultSet;
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.testframework.util.RandomData;
import com.microsoft.sqlserver.testframework.util.Util;

Expand Down Expand Up @@ -568,12 +569,12 @@ private void testGetObject(ResultSet rs,
&& objectValue3.equalsIgnoreCase("" + values[index]);

if (("" + values[index]).length() >= 1000) {
assertTrue(matches, "\nDecryption failed with getObject() at index: " + i + ", " + (i + 1) + ", " + (i + 2)
+ ".\nExpected Value at index: " + index);
assertTrue(matches, TestResource.getResource("R_decryptionFailed") + "getObject(): " + i + ", " + (i + 1) + ", " + (i + 2)
+ ".\n" + TestResource.getResource("R_expectedValueAtIndex") + index);
}
else {
assertTrue(matches, "\nDecryption failed with getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3
+ ".\nExpected Value: " + values[index]);
assertTrue(matches, TestResource.getResource("R_decryptionFailed") + "getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + values[index]);
}
}
finally {
Expand Down Expand Up @@ -605,8 +606,7 @@ else if (rs.getMetaData().getColumnTypeName(i).equalsIgnoreCase("datetime")) {
assertTrue(
objectValue1.equalsIgnoreCase("" + expected) && objectValue2.equalsIgnoreCase("" + expected)
&& objectValue3.equalsIgnoreCase("" + expected),
"\nDecryption failed with getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + ".\nExpected Value: "
+ expected);
TestResource.getResource("R_decryptionFailed") + "getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + ".\n" + TestResource.getResource("R_expectedValue") + expected);
}
finally {
index++;
Expand All @@ -633,7 +633,7 @@ private void testGetObjectForBinary(ResultSet rs,
if (null != values.get(index)) {
for (int j = 0; j < expectedBytes.length; j++) {
assertTrue(expectedBytes[j] == objectValue1[j] && expectedBytes[j] == objectValue2[j] && expectedBytes[j] == objectValue3[j],
"Decryption failed with getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + ".\n");
TestResource.getResource("R_decryptionFailed") + "getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + ".\n");
}
}
}
Expand Down Expand Up @@ -685,8 +685,8 @@ else if (values[index].equalsIgnoreCase("-3.4E38")) {
assertTrue(
decimalValue1.equalsIgnoreCase("" + values[index]) && decimalValue2.equalsIgnoreCase("" + values[index])
&& decimalValue3.equalsIgnoreCase("" + values[index]),
"\nDecryption failed with getBigDecimal(): " + decimalValue1 + ", " + decimalValue2 + ", " + decimalValue3
+ ".\nExpected Value: " + values[index]);
TestResource.getResource("R_decryptionFailed") + "getBigDecimal(): " + decimalValue1 + ", " + decimalValue2 + ", " + decimalValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + values[index]);
}
finally {
index++;
Expand Down Expand Up @@ -720,13 +720,12 @@ else if (stringValue1.equalsIgnoreCase("1") && (values[index].equalsIgnoreCase("
&& stringValue3.equalsIgnoreCase("" + values[index]);

if (("" + values[index]).length() >= 1000) {
assertTrue(matches, "\nDecryption failed with getString() at index: " + i + ", " + (i + 1) + ", " + (i + 2)
+ ".\nExpected Value at index: " + index);

assertTrue(matches, TestResource.getResource("R_decryptionFailed") + "getString():" + i + ", " + (i + 1) + ", " + (i + 2)
+ ".\n" + TestResource.getResource("R_expectedValue") + index);
}
else {
assertTrue(matches, "\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + values[index]);
assertTrue(matches, TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + values[index]);
}
}
finally {
Expand All @@ -752,33 +751,33 @@ private void testGetStringForDate(ResultSet rs,
assertTrue(
stringValue1.contains("" + values.get(index)) && stringValue2.contains("" + values.get(index))
&& stringValue3.contains("" + values.get(index)),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + values.get(index));
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + values.get(index));
}
else if (index == 4) // round value for datetime
{
Object datetimeValue = "" + Util.roundDatetimeValue(values.get(index));
assertTrue(
stringValue1.equalsIgnoreCase("" + datetimeValue) && stringValue2.equalsIgnoreCase("" + datetimeValue)
&& stringValue3.equalsIgnoreCase("" + datetimeValue),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + datetimeValue);
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + datetimeValue);
}
else if (index == 5) // round value for smalldatetime
{
Object smalldatetimeValue = "" + Util.roundSmallDateTimeValue(values.get(index));
assertTrue(
stringValue1.equalsIgnoreCase("" + smalldatetimeValue) && stringValue2.equalsIgnoreCase("" + smalldatetimeValue)
&& stringValue3.equalsIgnoreCase("" + smalldatetimeValue),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + smalldatetimeValue);
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + smalldatetimeValue);
}
else {
assertTrue(
stringValue1.contains("" + values.get(index)) && stringValue2.contains("" + values.get(index))
&& stringValue3.contains("" + values.get(index)),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + values.get(index));
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + values.get(index));
}
}
finally {
Expand Down Expand Up @@ -806,7 +805,7 @@ private void testGetBytes(ResultSet rs,
if (null != values.get(index)) {
for (int j = 0; j < expectedBytes.length; j++) {
assertTrue(expectedBytes[j] == b1[j] && expectedBytes[j] == b2[j] && expectedBytes[j] == b3[j],
"Decryption failed with getObject(): " + b1 + ", " + b2 + ", " + b3 + ".\n");
TestResource.getResource("R_decryptionFailed") + "getObject(): " + b1 + ", " + b2 + ", " + b3 + ".\n");
}
}
}
Expand Down Expand Up @@ -841,7 +840,7 @@ private void testGetStringForBinary(ResultSet rs,

try {
assertTrue(stringValue1.startsWith(expectedStr) && stringValue2.startsWith(expectedStr) && stringValue3.startsWith(expectedStr),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + ".\nExpected Value: "
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + ".\n" + TestResource.getResource("R_expectedValue")
+ expectedStr);
}
finally {
Expand Down Expand Up @@ -907,17 +906,17 @@ private void testGetDate(ResultSet rs,
break;

default:
fail("Switch case is not matched with data");
fail(TestResource.getResource("R_switchFailed"));
}

assertTrue(
stringValue1.equalsIgnoreCase(expected) && stringValue2.equalsIgnoreCase(expected) && stringValue3.equalsIgnoreCase(expected),
"\nDecryption failed with testGetDate: " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + ".\nExpected Value: "
TestResource.getResource("R_decryptionFailed") + "testGetDate: " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + ".\n" + TestResource.getResource("R_expectedValue")
+ expected);
}

else {
fail("Result set is not instance of SQLServerResultSet");
fail(TestResource.getResource("R_resultsetNotInstance"));
}
}
}
Expand Down Expand Up @@ -1120,7 +1119,7 @@ else if (expectedValue.equalsIgnoreCase("-3.4E+38")) {
assertTrue(
value1.equalsIgnoreCase("" + expectedValue) && value2.equalsIgnoreCase("" + expectedValue)
&& value3.equalsIgnoreCase("" + expectedValue),
"\nDecryption failed with getBigDecimal(): " + value1 + ", " + value2 + ", " + value3 + ".\nExpected Value: " + expectedValue);
TestResource.getResource("R_decryptionFailed") + "getBigDecimal(): " + value1 + ", " + value2+ ", " + value3 + ".\n" + TestResource.getResource("R_expectedValue"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
import com.microsoft.sqlserver.jdbc.SQLServerResultSet;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.testframework.util.Util;

/**
Expand Down Expand Up @@ -201,15 +202,15 @@ private void testGetString(ResultSet rs,
try {
if (rs.getMetaData().getColumnTypeName(i).equalsIgnoreCase("time")) {
assertTrue(stringValue2.equalsIgnoreCase("" + values[index]) && stringValue3.equalsIgnoreCase("" + values[index]),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + values[index]);
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\n" + TestResource.getResource("R_expectedValue") + ": " + values[index]);
}
else {
assertTrue(
values[index].contains(stringValue1) && stringValue2.equalsIgnoreCase("" + values[index])
&& stringValue3.equalsIgnoreCase("" + values[index]),
"\nDecryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ ".\nExpected Value: " + values[index]);
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3
+ TestResource.getResource("R_expectedValue") + values[index]);
}
}
finally {
Expand All @@ -232,8 +233,8 @@ private void testGetBigDecimal(ResultSet rs,
assertTrue(
decimalValue1.equalsIgnoreCase(values[index]) && decimalValue2.equalsIgnoreCase(values[index])
&& decimalValue3.equalsIgnoreCase(values[index]),
"Decryption failed with getBigDecimal(): " + decimalValue1 + ", " + decimalValue2 + ", " + decimalValue3
+ "\nExpected value: " + values[index]);
TestResource.getResource("R_decryptionFailed") + "getBigDecimal(): " + decimalValue1 + ", " + decimalValue2 + ", " + decimalValue3
+ "\n" + TestResource.getResource("R_expectedValue") + ": " + values[index]);

}
finally {
Expand All @@ -260,7 +261,7 @@ private void testGetObject(ResultSet rs,
assertTrue(
objectValue1.equalsIgnoreCase(values[index]) && objectValue2.equalsIgnoreCase(values[index])
&& objectValue3.equalsIgnoreCase(values[index]),
"Decryption failed with getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + "\nExpected value: "
TestResource.getResource("R_decryptionFailed") + "getObject(): " + objectValue1 + ", " + objectValue2 + ", " + objectValue3 + "\n" + TestResource.getResource("R_expectedValue") + ": "
+ values[index]);

}
Expand Down Expand Up @@ -321,14 +322,13 @@ private void testGetDate(ResultSet rs,
break;

default:
fail("Switch case is not matched with data");
}

try {
assertTrue(
stringValue1.equalsIgnoreCase(dates[index]) && stringValue2.equalsIgnoreCase(dates[index])
&& stringValue3.equalsIgnoreCase(dates[index]),
"Decryption failed with getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + "\nExpected value: "
TestResource.getResource("R_decryptionFailed") + "getString(): " + stringValue1 + ", " + stringValue2 + ", " + stringValue3 + "\n" + TestResource.getResource("R_expectedValue") + ": "
+ dates[index]);
}
finally {
Expand All @@ -337,7 +337,7 @@ private void testGetDate(ResultSet rs,
}

else {
throw new Exception("Result set is not instance of SQLServerResultSet");
throw new Exception(TestResource.getResource("R_resultsetNotInstance"));
}
}
}
Expand Down
Loading