@Test public void testSlash() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " 123 attr=\"abc\\def\" \\ 456=789" ); if (legacyMode) { assertEquals(Maps.mutable.of("attr", "abc\\def", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\"), results.getTwo()); } else { assertEquals(Maps.mutable.of("attr", "abc\\def", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\"), results.getTwo()); } }
@Test public void testBehaviorOfStringStartingWithEqualSign() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " e q =attr 1234 attr2=\"5678\"\" \"\"mytog1\" " ); if (legacyMode) { assertEquals(Maps.mutable.of("", "attr", "attr2", "5678\""), results.getOne()); assertEquals(Sets.mutable.of("1234", "\"\"mytog1\"", "e", "q"), results.getTwo()); } else { assertEquals(Maps.mutable.of("attr2", "5678\""), results.getOne()); assertEquals(Sets.mutable.of("=", "attr", "1234", "\"\"mytog1\"", "e", "q"), results.getTwo()); } }
@Test public void testQuoteWithinStringIsStillPreservedEvenIfStringIsntClosedForBackwardsCompatibility() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " =attr 1234 attr2=\"56\"78 mytog1 " ); if (legacyMode) { assertEquals(Maps.mutable.of("", "attr", "attr2", "\"56\"78"), results.getOne()); assertEquals(Sets.mutable.of("1234", "mytog1"), results.getTwo()); } else { assertEquals(Maps.mutable.of("attr2", "\"56\"78"), results.getOne()); assertEquals(Sets.mutable.of("=", "attr", "1234", "mytog1"), results.getTwo()); } }
@Test public void testSlashWithQuoteNoEscaping2() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " 123 attr=\"abc\\d ef\" \\ 456=789" ); if (legacyMode) { assertEquals(Maps.mutable.of("attr", "\"abc\\d", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\", "ef\""), results.getTwo()); } else { assertEquals(Maps.mutable.of("attr", "abc\\d ef", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\"), results.getTwo()); } }
@Test public void testQuotedSplitWithEqualSign() { String input = "attr=1234 attr2=\"56=78\" mytog1"; if (legacyMode) { try { textMarkupDocumentReader.parseAttrsAndToggles(input); fail("Should have failed here"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Cannot mark = multiple times")); } } else { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input); assertEquals(Maps.mutable.of("attr", "1234", "attr2", "56=78"), results.getOne()); assertEquals(Sets.mutable.of("mytog1"), results.getTwo()); } }
@Test public void testSlashWithQuoteNoEscaping() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " 123 attr=\"abc\\\"d ef\" \\ 456=789" ); if (legacyMode) { assertEquals(Maps.mutable.of("attr", "\"abc\\\"d", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\", "ef\""), results.getTwo()); } else { assertEquals(Maps.mutable.of("attr", "abc\"d ef", "456", "789"), results.getOne()); assertEquals(Sets.mutable.of("123", "\\"), results.getTwo()); } } }
@Test public void testSimpleLineParsing() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( "attr=1234 attr2=\"5678\" mytog1" ); assertEquals(Maps.mutable.of("attr", "1234", "attr2", "5678"), results.getOne()); assertEquals(Sets.mutable.of("mytog1"), results.getTwo()); }
@Test public void testQuoteWithinQuotedStringIsPreservedIfNoSpace() { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles( " abc=attr 1234 attr2=\"56\"78\" mytog1 " ); assertEquals(Maps.mutable.of("abc", "attr", "attr2", "56\"78"), results.getOne()); assertEquals(Sets.mutable.of("1234", "mytog1"), results.getTwo()); }
private void generate(String schema) { MutableSet<MyInput> inputs = Sets.mutable.empty(); inputs.withAll(getUserTypes(numTypes)); inputs.withAll(getTables()); inputs.withAll(getViews()); inputs.withAll(getSps()); MutableSet<String> types = Sets.mutable.of("table", "view", "sp", "usertype"); File outputDir = new File("./target/testoutput"); FileUtils.deleteQuietly(outputDir); outputDir.mkdirs(); for (MyInput input : inputs) { MutableMap<String, Object> params = Maps.mutable.<String, Object>empty().withKeyValue( "name", input.getName() ); for (String type : types) { params.put("dependent" + type + "s", input.getDependenciesByType().get(type)); } File outputFile = new File(outputDir, schema + "/" + input.getType() + "/" + input.getName() + ".sql"); outputFile.getParentFile().mkdirs(); TestTemplateUtil.getInstance().writeTemplate("schemagen/" + input.getType() + ".sql.ftl", params, outputFile); } }
@Test public void testQuotedSplitWithEqualSignAndSpace() { String input = "attr=1234 attr2=\"56 = 78\" mytog1"; if (legacyMode) { try { textMarkupDocumentReader.parseAttrsAndToggles(input); fail("Should have failed here"); } catch (ArrayIndexOutOfBoundsException e) { assertThat(e.getMessage(), notNullValue()); } } else { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input); assertEquals(Maps.mutable.of("attr", "1234", "attr2", "56 = 78"), results.getOne()); assertEquals(Sets.mutable.of("mytog1"), results.getTwo()); } }
@Test public void testWordEndingInEqualSignWillFailInLegacy() { String input = " attr= abc"; if (legacyMode) { try { textMarkupDocumentReader.parseAttrsAndToggles(input); fail("Should have failed here"); } catch (ArrayIndexOutOfBoundsException expected) { } } else { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input); assertEquals(Maps.mutable.of("attr", ""), results.getOne()); assertEquals(Sets.mutable.of("abc"), results.getTwo()); } }
@Test public void testEqualSignAloneWillFailInLegacy() { String input = " a = b "; if (legacyMode) { try { textMarkupDocumentReader.parseAttrsAndToggles(input); fail("Should throw exception here"); } catch (ArrayIndexOutOfBoundsException expected) { } } else { Pair<ImmutableMap<String, String>, ImmutableSet<String>> results = textMarkupDocumentReader.parseAttrsAndToggles(input); assertEquals(Maps.mutable.empty(), results.getOne()); assertEquals(Sets.mutable.of("a", "b", "="), results.getTwo()); } }
)); reconConfig.setInputTables(Lists.mutable.of("TableA", "TableB", "TableC", "TableD")); reconConfig.setExcludedTables(Sets.mutable.of("ExcludedTableA", "ExcludedTableB")); new DbDataComparisonUtil().execute(reconConfig, new File("./comps"));