Skip to content

Commit

Permalink
fixed assert
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-stakeda committed Jun 3, 2020
1 parent 253fcd9 commit 361bf73
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.greaterThan;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -26,8 +28,7 @@
import java.util.List;
import java.util.Properties;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;

/**
* SnowflakeResultSetSerializable tests
Expand All @@ -50,6 +51,8 @@ public static Object[][] data()
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();

private static int ERR_RESULT_SET_CLOSED = 200037;

private static boolean developPrint = false;

private static String queryResultFormat;
Expand Down Expand Up @@ -307,7 +310,7 @@ private void testBasicTableHarness(int rowCount, long maxSizeInBytes,
}

String chunkResultString = deserializeResultSet(fileNameList);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);
}

@Test
Expand Down Expand Up @@ -436,7 +439,7 @@ private void testTimestampHarness(int rowCount,
}

String chunkResultString = deserializeResultSet(fileNameList);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);
}

@Test
Expand Down Expand Up @@ -496,7 +499,7 @@ public void testBasicTableWithSerializeObjectsAfterReadResultSet() throws Throwa
}

String chunkResultString = deserializeResultSet(fileNameList);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);
}

/**
Expand Down Expand Up @@ -585,25 +588,25 @@ public void testSplitResultSetSerializable() throws Throwable
List<String> fileNameSplit3M = splitResultSetSerializables(
fileNameList, 3 * 1024 * 1024);
String chunkResultString = deserializeResultSet(fileNameSplit3M);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);

// Split deserializedResultSet by 2M, the result should be the same
List<String> fileNameSplit2M = splitResultSetSerializables(
fileNameSplit3M, 2 * 1024 * 1024);
chunkResultString = deserializeResultSet(fileNameSplit2M);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);

// Split deserializedResultSet by 1M, the result should be the same
List<String> fileNameSplit1M = splitResultSetSerializables(
fileNameSplit2M, 1 * 1024 * 1024);
chunkResultString = deserializeResultSet(fileNameSplit1M);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);

// Split deserializedResultSet by smallest, the result should be the same
List<String> fileNameSplitSmallest = splitResultSetSerializables(
fileNameSplit1M, 1);
chunkResultString = deserializeResultSet(fileNameSplitSmallest);
assertTrue(chunkResultString.equals(originalResultCSVString));
assertEquals(chunkResultString, originalResultCSVString);
}

/**
Expand Down Expand Up @@ -689,7 +692,7 @@ public void testNegativeWithChunkFileNotExist() throws Throwable
hackToSetupWrongURL(resultSetSerializables);

// Expected to hit credential issue when access the result.
assertTrue(resultSetSerializables.size() == 1);
assertEquals(resultSetSerializables.size(), 1);
try
{
SnowflakeResultSetSerializable resultSetSerializable =
Expand All @@ -705,7 +708,8 @@ public void testNegativeWithChunkFileNotExist() throws Throwable
}
catch (SQLException ex)
{
System.out.println("Negative test hits expected error: " + ex.getMessage());
assertEquals(ex.getErrorCode(),ERR_RESULT_SET_CLOSED);
// System.out.println("Negative test hits expected error: " + ex.getMessage());
}

rs.close();
Expand Down Expand Up @@ -894,7 +898,7 @@ public void testRetrieveMetadata() throws Throwable
100 * 1024 * 1024, "txt");

// Only one serializable object is generated with 100M data.
assertTrue(fileNameList.size() == 1);
assertEquals(fileNameList.size(), 1);

FileInputStream fi = new FileInputStream(fileNameList.get(0));
ObjectInputStream si = new ObjectInputStream(fi);
Expand All @@ -913,9 +917,9 @@ public void testRetrieveMetadata() throws Throwable

rs.close();
}
assertTrue(expectedTotalRowCount == rowCount);
assertTrue(expectedTotalCompressedSize > 0);
assertTrue(expectedTotalUncompressedSize > 0);
assertEquals(expectedTotalRowCount, rowCount);
assertThat(expectedTotalCompressedSize, greaterThan((long)0));
assertThat(expectedTotalUncompressedSize, greaterThan((long)0));

// Split deserializedResultSet by 3M
List<String> fileNameSplit3M = splitResultSetSerializables(
Expand Down

0 comments on commit 361bf73

Please sign in to comment.