Skip to content

Commit

Permalink
0004069: SQL Server tests failing because of out of date tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philipmarzullo64 committed Aug 16, 2019
1 parent 1da6ec3 commit f47bb27
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
Expand Up @@ -19,4 +19,4 @@
-- under the License.
--

insert into test_db_import_1 (id,string_value,string_required_value,char_value,char_required_value,date_value,time_value,boolean_value,integer_value,decimal_value,double_value) values (5,'a\b\\c\\\d','junk','j','j',{d '1989-09-21'},{ts '1997-11-06 08:02:33.324'},0,1,1,1);
insert into test_db_import_1 (id,string_value,string_required_value,char_value,char_required_value,date_value,time_value,boolean_value,integer_value,decimal_value,double_value) values (5,'a\b\\c\\\d','junk','j','j',{d '1989-09-21'},{ts '1997-11-06 08:02:33.323'},0,1,1,1);
Expand Up @@ -36,6 +36,7 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jumpmind.db.platform.AbstractDatabasePlatform;
import org.jumpmind.db.platform.mssql.MsSql2008DatabasePlatform;
import org.jumpmind.symmetric.TestConstants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.csv.CsvWriter;
Expand Down Expand Up @@ -307,7 +308,7 @@ public void test05SkippingResentBatch() throws Exception {
getNextBatchId();
for (long i = 0; i < 7; i++) {
batchId--;
testSimple(CsvConstants.INSERT, values, values);
testSimple(CsvConstants.INSERT, values, massageExpectectedResultsForDialect(values));
assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID),
IncomingBatch.Status.OK, "Wrong status");
IncomingBatch batch = getIncomingBatchService().findIncomingBatch(batchId,
Expand All @@ -324,14 +325,27 @@ public void test05SkippingResentBatch() throws Exception {
Thread.sleep(10);
}
}

private String[] massageExpectectedResultsForDialect(String[] values) {
if(values[5] != null && getSymmetricEngine().getDatabasePlatform() instanceof MsSql2008DatabasePlatform) {
// No time portion for a date field
values[5] = values[5].replaceFirst(" \\d\\d:\\d\\d:\\d\\d\\.000", "");
}
if(values[6] != null && getSymmetricEngine().getDatabasePlatform() instanceof MsSql2008DatabasePlatform) {
if(values[6].length() == 23) {
values[6] = values[6] + "0000";
}
}
return values;
}

@Test
public void test06ErrorWhileSkip() throws Exception {
Level old = setLoggingLevelForTest(Level.OFF);
String[] values = { getNextId(), "string2", "string not null2", "char2", "char not null2",
"2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "0.474" };

testSimple(CsvConstants.INSERT, values, values);
testSimple(CsvConstants.INSERT, values, massageExpectectedResultsForDialect(values));
assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID),
IncomingBatch.Status.OK, "Wrong status");
IncomingBatch batch = getIncomingBatchService().findIncomingBatch(batchId,
Expand Down Expand Up @@ -473,7 +487,7 @@ public void test09ErrorThenSuccessBatch() throws Exception {
values[1] = "A smaller string that will succeed";
values[5] = "2007-01-02 00:00:00.000";
values[9] = "67.89";
testSimple(CsvConstants.INSERT, values, values);
testSimple(CsvConstants.INSERT, values, massageExpectectedResultsForDialect(values));
assertEquals(findIncomingBatchStatus(batchId, TestConstants.TEST_CLIENT_EXTERNAL_ID),
IncomingBatch.Status.OK, "Wrong status. " + printDatabase());
IncomingBatch batch = getIncomingBatchService().findIncomingBatch(batchId,
Expand Down Expand Up @@ -517,7 +531,7 @@ public void test10MultipleBatch() throws Exception {

writer.close();
load(out);
assertTestTableEquals(values[0], values);
assertTestTableEquals(values[0], massageExpectectedResultsForDialect(values));
assertTestTableEquals(values2[0], null);

assertEquals(
Expand Down
Expand Up @@ -511,6 +511,7 @@ public void testColumnNotExisting() throws Exception {
String[] values = { getNextId(), "testColumnNotExisting", "string not null", "char",
"i do not exist!", "char not null", "2007-01-02 00:00:00.000",
"2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747" };
massageExpectectedResultsForDialect2(values);
List<String> valuesAsList = new ArrayList<String>(Arrays.asList(values));
valuesAsList.remove(4);
String[] expectedValues = valuesAsList.toArray(new String[valuesAsList.size()]);
Expand Down Expand Up @@ -626,16 +627,27 @@ public void testBenchmark() throws Exception {
private String[] massageExpectectedResultsForDialect(String[] values) {
RoundingMode mode = RoundingMode.DOWN;

if (values[5] != null
if(values[5] != null && platform instanceof MsSql2008DatabasePlatform) {
// No time portion for a date field
values[5] = values[5].replaceFirst(" \\d\\d:\\d\\d:\\d\\d\\.000", "");
} else if (values[5] != null
&& (!(platform instanceof OracleDatabasePlatform
|| platform instanceof TiberoDatabasePlatform
|| platform instanceof MsSql2000DatabasePlatform
|| platform instanceof MsSql2005DatabasePlatform
|| platform instanceof MsSql2008DatabasePlatform
||
// Only SqlServer 2000 and 2005 should not be mangled. 2008 now uses Date and Time data types.
(
(platform instanceof MsSql2000DatabasePlatform || platform instanceof MsSql2005DatabasePlatform
) && ! (platform instanceof MsSql2008DatabasePlatform)
)
|| platform instanceof AseDatabasePlatform
|| platform instanceof SqlAnywhereDatabasePlatform))) {
values[5] = values[5].replaceFirst(" \\d\\d:\\d\\d:\\d\\d\\.?0?", " 00:00:00.0");
}
if(values[6] != null && platform instanceof MsSql2008DatabasePlatform) {
if(values[6].length() == 23) {
values[6] = values[6] + "0000";
}
}
if (values[10] != null) {
values[10] = values[10].replace(',', '.');
}
Expand All @@ -657,4 +669,16 @@ private String[] massageExpectectedResultsForDialect(String[] values) {
return values;
}

private String[] massageExpectectedResultsForDialect2(String[] values) {
if(values[6] != null && platform instanceof MsSql2008DatabasePlatform) {
// No time portion for a date field
values[6] = values[6].replaceFirst(" \\d\\d:\\d\\d:\\d\\d\\.000", "");
}
if(values[7] != null && platform instanceof MsSql2008DatabasePlatform) {
if(values[7].length() == 23) {
values[7] = values[7] + "0000";
}
}
return values;
}
}

0 comments on commit f47bb27

Please sign in to comment.