Skip to content

Commit d37b357

Browse files
Use custom MessageFormatUtil class instead of MessageFormat class
Autoported commit. Original commit hash: [d970456110]
1 parent 2b6bc8e commit d37b357

File tree

61 files changed

+226
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+226
-185
lines changed

itext.tests/itext.io.tests/itext/io/font/FontProgramTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.IO.Util;
4445

4546
namespace iText.IO.Font {
4647
public class FontProgramTest {
@@ -52,7 +53,8 @@ public virtual void ExceptionMessageTest() {
5253
FontProgramFactory.CreateFont(font);
5354
}
5455
catch (iText.IO.IOException ex) {
55-
NUnit.Framework.Assert.AreEqual(String.Format(iText.IO.IOException.FontFile1NotFound, font), ex.Message);
56+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(iText.IO.IOException.FontFile1NotFound, font), ex
57+
.Message);
5658
}
5759
}
5860

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfActionTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.IO.Util;
4445
using iText.Kernel.Pdf.Action;
4546
using iText.Test;
4647

@@ -63,7 +64,7 @@ public virtual void ActionTest01() {
6364
PdfDocument document = CreateDocument(new PdfWriter(destinationFolder + "actionTest01.pdf"), true);
6465
document.GetCatalog().SetOpenAction(PdfAction.CreateURI("http://itextpdf.com/"));
6566
document.Close();
66-
System.Console.Out.WriteLine(String.Format("Please open document {0} and make sure that you're automatically redirected to {1} site."
67+
System.Console.Out.WriteLine(MessageFormatUtil.Format("Please open document {0} and make sure that you're automatically redirected to {1} site."
6768
, destinationFolder + "actionTest01.pdf", "http://itextpdf.com"));
6869
}
6970

@@ -73,7 +74,7 @@ public virtual void ActionTest02() {
7374
PdfDocument document = CreateDocument(new PdfWriter(destinationFolder + "actionTest02.pdf"), false);
7475
document.GetPage(2).SetAdditionalAction(PdfName.O, PdfAction.CreateURI("http://itextpdf.com/"));
7576
document.Close();
76-
System.Console.Out.WriteLine(String.Format("Please open document {0} at page 2 and make sure that you're automatically redirected to {1} site."
77+
System.Console.Out.WriteLine(MessageFormatUtil.Format("Please open document {0} at page 2 and make sure that you're automatically redirected to {1} site."
7778
, destinationFolder + "actionTest02.pdf", "http://itextpdf.com"));
7879
}
7980

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfCanvasTest.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public virtual void CopyPagesTest2() {
599599
canvas.BeginText();
600600
canvas.SetFontAndSize(PdfFontFactory.CreateFont(FontConstants.COURIER), 12);
601601
canvas.SetTextMatrix(1, 0, 0, 1, 100, 500);
602-
canvas.ShowText(String.Format("Page_{0}", i + 1));
602+
canvas.ShowText(MessageFormatUtil.Format("Page_{0}", i + 1));
603603
canvas.EndText();
604604
canvas.Release();
605605
page1.Flush();
@@ -692,14 +692,14 @@ public virtual void CopyPagesTest4() {
692692
canvas.BeginText();
693693
canvas.SetFontAndSize(PdfFontFactory.CreateFont(FontConstants.COURIER), 12);
694694
canvas.SetTextMatrix(1, 0, 0, 1, 100, 500);
695-
canvas.ShowText(String.Format("Page_{0}", i + 1));
695+
canvas.ShowText(MessageFormatUtil.Format("Page_{0}", i + 1));
696696
canvas.EndText();
697697
canvas.Release();
698698
}
699699
pdfDoc1.Close();
700700
pdfDoc1 = new PdfDocument(new PdfReader(file1));
701701
for (int i = 0; i < 5; i++) {
702-
PdfDocument pdfDoc2 = new PdfDocument(new PdfWriter(destinationFolder + String.Format("copyPages4_{0}.pdf"
702+
PdfDocument pdfDoc2 = new PdfDocument(new PdfWriter(destinationFolder + MessageFormatUtil.Format("copyPages4_{0}.pdf"
703703
, i + 2)));
704704
PdfPage page2 = pdfDoc1.GetPage(i + 1).CopyTo(pdfDoc2);
705705
pdfDoc2.AddPage(page2);
@@ -712,8 +712,8 @@ public virtual void CopyPagesTest4() {
712712
NUnit.Framework.Assert.AreEqual(false, reader1.HasRebuiltXref(), "Rebuilt");
713713
for (int i = 0; i < 5; i++) {
714714
PdfDictionary page1 = doc1.GetPage(i + 1).GetPdfObject();
715-
PdfDocument doc2 = new PdfDocument(new PdfReader(destinationFolder + String.Format("copyPages4_{0}.pdf", i
716-
+ 2)));
715+
PdfDocument doc2 = new PdfDocument(new PdfReader(destinationFolder + MessageFormatUtil.Format("copyPages4_{0}.pdf"
716+
, i + 2)));
717717
PdfDictionary page = doc2.GetPage(1).GetPdfObject();
718718
NUnit.Framework.Assert.IsTrue(cmpTool.CompareDictionaries(page1, page));
719719
doc2.Close();
@@ -727,7 +727,7 @@ public virtual void CopyPagesTest4() {
727727
public virtual void CopyPagesTest5() {
728728
int documentCount = 3;
729729
for (int i = 0; i < documentCount; i++) {
730-
PdfDocument pdfDoc1 = new PdfDocument(new PdfWriter(destinationFolder + String.Format("copyPages5_{0}.pdf"
730+
PdfDocument pdfDoc1 = new PdfDocument(new PdfWriter(destinationFolder + MessageFormatUtil.Format("copyPages5_{0}.pdf"
731731
, i + 1)));
732732
PdfPage page1 = pdfDoc1.AddNewPage();
733733
PdfCanvas canvas = new PdfCanvas(page1);
@@ -736,14 +736,14 @@ public virtual void CopyPagesTest5() {
736736
canvas.BeginText();
737737
canvas.SetFontAndSize(PdfFontFactory.CreateFont(FontConstants.COURIER), 12);
738738
canvas.SetTextMatrix(1, 0, 0, 1, 100, 500);
739-
canvas.ShowText(String.Format("Page_{0}", i + 1));
739+
canvas.ShowText(MessageFormatUtil.Format("Page_{0}", i + 1));
740740
canvas.EndText();
741741
canvas.Release();
742742
pdfDoc1.Close();
743743
}
744744
IList<PdfDocument> docs = new List<PdfDocument>();
745745
for (int i = 0; i < documentCount; i++) {
746-
PdfDocument pdfDoc1 = new PdfDocument(new PdfReader(destinationFolder + String.Format("copyPages5_{0}.pdf"
746+
PdfDocument pdfDoc1 = new PdfDocument(new PdfReader(destinationFolder + MessageFormatUtil.Format("copyPages5_{0}.pdf"
747747
, i + 1)));
748748
docs.Add(pdfDoc1);
749749
}
@@ -757,7 +757,8 @@ public virtual void CopyPagesTest5() {
757757
}
758758
CompareTool cmpTool = new CompareTool();
759759
for (int i = 0; i < 3; i++) {
760-
PdfReader reader1 = new PdfReader(destinationFolder + String.Format("copyPages5_{0}.pdf", i + 1));
760+
PdfReader reader1 = new PdfReader(destinationFolder + MessageFormatUtil.Format("copyPages5_{0}.pdf", i + 1
761+
));
761762
PdfDocument doc1 = new PdfDocument(reader1);
762763
NUnit.Framework.Assert.AreEqual(false, reader1.HasRebuiltXref(), "Rebuilt");
763764
PdfReader reader2 = new PdfReader(destinationFolder + "copyPages5_4.pdf");

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfFontTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,8 @@ public virtual void CreateWrongAfm2() {
902902
catch (iText.IO.IOException e) {
903903
message = e.Message;
904904
}
905-
NUnit.Framework.Assert.AreEqual(String.Format(iText.IO.IOException._1IsNotAnAfmOrPfmFontFile, font), message
906-
);
905+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(iText.IO.IOException._1IsNotAnAfmOrPfmFontFile, font
906+
), message);
907907
}
908908

909909
/// <exception cref="System.IO.IOException"/>

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfReaderTest.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ source product.
4343
using System;
4444
using System.Collections.Generic;
4545
using iText.IO.Source;
46+
using iText.IO.Util;
4647
using iText.Kernel;
4748
using iText.Test;
4849
using iText.Test.Attributes;
@@ -133,7 +134,7 @@ public virtual void OpenDocWithFlateFilter() {
133134
for (int i = 1; i <= document.GetNumberOfPages(); i++) {
134135
PdfPage page = document.GetPage(i);
135136
byte[] content = page.GetFirstContentStream().GetBytes();
136-
NUnit.Framework.Assert.AreEqual(String.Format(contentTemplate, i), iText.IO.Util.JavaUtil.GetStringForBytes
137+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(contentTemplate, i), iText.IO.Util.JavaUtil.GetStringForBytes
137138
(content), "Page content " + i);
138139
}
139140
NUnit.Framework.Assert.IsFalse(reader.HasRebuiltXref(), "No need in rebuildXref()");
@@ -590,23 +591,23 @@ public virtual void PagesTest11() {
590591
document.GetPage(-30);
591592
}
592593
catch (IndexOutOfRangeException e) {
593-
NUnit.Framework.Assert.AreEqual(String.Format(PdfException.RequestedPageNumberIsOutOfBounds, -30), e.Message
594-
);
594+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(PdfException.RequestedPageNumberIsOutOfBounds, -30
595+
), e.Message);
595596
}
596597
try {
597598
document.GetPage(0);
598599
}
599600
catch (IndexOutOfRangeException e) {
600-
NUnit.Framework.Assert.AreEqual(String.Format(PdfException.RequestedPageNumberIsOutOfBounds, 0), e.Message
601-
);
601+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(PdfException.RequestedPageNumberIsOutOfBounds, 0)
602+
, e.Message);
602603
}
603604
document.GetPage(1);
604605
try {
605606
document.GetPage(25);
606607
}
607608
catch (IndexOutOfRangeException e) {
608-
NUnit.Framework.Assert.AreEqual(String.Format(PdfException.RequestedPageNumberIsOutOfBounds, 25), e.Message
609-
);
609+
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(PdfException.RequestedPageNumberIsOutOfBounds, 25
610+
), e.Message);
610611
}
611612
document.Close();
612613
}

itext.tests/itext.layout.tests/itext/layout/AutoTaggingTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ source product.
4444
using System.Text;
4545
using iText.IO.Font;
4646
using iText.IO.Image;
47+
using iText.IO.Util;
4748
using iText.Kernel.Colors;
4849
using iText.Kernel.Font;
4950
using iText.Kernel.Geom;
@@ -245,7 +246,7 @@ public virtual void TableTest04() {
245246
doc.Add(table);
246247
for (int i = 0; i < 20; i++) {
247248
for (int j = 0; j < 4; j++) {
248-
table.AddCell(new Cell().Add(new Paragraph(String.Format("Cell {0}, {1}", i + 1, j + 1))));
249+
table.AddCell(new Cell().Add(new Paragraph(MessageFormatUtil.Format("Cell {0}, {1}", i + 1, j + 1))));
249250
}
250251
if (i % 10 == 0) {
251252
table.Flush();
@@ -640,7 +641,7 @@ public virtual void FlushingTest03() {
640641
doc.Add(table);
641642
for (int i = 0; i < 20; i++) {
642643
for (int j = 0; j < 4; j++) {
643-
table.AddCell(new Cell().Add(new Paragraph(String.Format("Cell {0}, {1}", i + 1, j + 1))));
644+
table.AddCell(new Cell().Add(new Paragraph(MessageFormatUtil.Format("Cell {0}, {1}", i + 1, j + 1))));
644645
}
645646
if (i % 10 == 0) {
646647
table.Flush();

itext.tests/itext.layout.tests/itext/layout/DestinationTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.IO.Util;
4445
using iText.Kernel.Pdf;
4546
using iText.Kernel.Utils;
4647
using iText.Layout.Element;
@@ -68,7 +69,7 @@ public virtual void DestinationTest01() {
6869
String cmpFileName = sourceFolder + "cmp_destinationTest01.pdf";
6970
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
7071
Document doc = new Document(pdfDoc);
71-
Text text = new Text(String.Format("Page {0}", 10));
72+
Text text = new Text(MessageFormatUtil.Format("Page {0}", 10));
7273
text.SetProperty(Property.DESTINATION, "p10");
7374
doc.Add(new Paragraph(text).SetFixedPosition(1, 549, 742, 40).SetMargin(0));
7475
doc.Close();

itext.tests/itext.layout.tests/itext/layout/LargeElementTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.IO.Util;
4445
using iText.Kernel.Colors;
4546
using iText.Kernel.Geom;
4647
using iText.Kernel.Pdf;
@@ -76,7 +77,7 @@ public virtual void LargeTableTest01() {
7677
doc.Add(table);
7778
for (int i = 0; i < 20; i++) {
7879
for (int j = 0; j < 5; j++) {
79-
table.AddCell(new Cell().Add(new Paragraph(String.Format("Cell {0}, {1}", i + 1, j + 1))));
80+
table.AddCell(new Cell().Add(new Paragraph(MessageFormatUtil.Format("Cell {0}, {1}", i + 1, j + 1))));
8081
}
8182
if (i % 10 == 0) {
8283
table.Flush();
@@ -103,7 +104,7 @@ public virtual void LargeTableTest02() {
103104
Table table = new Table(5, true).SetMargins(20, 20, 20, 20);
104105
doc.Add(table);
105106
for (int i = 0; i < 100; i++) {
106-
table.AddCell(new Cell().Add(new Paragraph(String.Format("Cell {0}", i + 1))));
107+
table.AddCell(new Cell().Add(new Paragraph(MessageFormatUtil.Format("Cell {0}", i + 1))));
107108
if (i % 7 == 0) {
108109
table.Flush();
109110
}

itext.tests/itext.layout.tests/itext/layout/TableBorderTest.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44+
using iText.IO.Util;
4445
using iText.Kernel.Colors;
4546
using iText.Kernel.Geom;
4647
using iText.Kernel.Pdf;
@@ -1201,19 +1202,20 @@ public virtual void TableWithHeaderFooterTest14() {
12011202
Table table = new Table(new float[3]);
12021203
for (int r = 0; r < 1; r++) {
12031204
for (int c = 0; c < 3; c++) {
1204-
table.AddHeaderCell(new Cell().Add(String.Format("header row {0} col {1}", r, c)).SetBorder(Border.NO_BORDER
1205-
));
1205+
table.AddHeaderCell(new Cell().Add(MessageFormatUtil.Format("header row {0} col {1}", r, c)).SetBorder(Border
1206+
.NO_BORDER));
12061207
}
12071208
}
12081209
for (int r = 0; r < 3; r++) {
12091210
for (int c = 0; c < 3; c++) {
1210-
table.AddCell(new Cell().Add(String.Format("row {0} col {1}", r, c)).SetBorder(Border.NO_BORDER));
1211+
table.AddCell(new Cell().Add(MessageFormatUtil.Format("row {0} col {1}", r, c)).SetBorder(Border.NO_BORDER
1212+
));
12111213
}
12121214
}
12131215
for (int r = 0; r < 1; r++) {
12141216
for (int c = 0; c < 3; c++) {
1215-
table.AddFooterCell(new Cell().Add(String.Format("footer row {0} col {1}", r, c)).SetBorder(Border.NO_BORDER
1216-
));
1217+
table.AddFooterCell(new Cell().Add(MessageFormatUtil.Format("footer row {0} col {1}", r, c)).SetBorder(Border
1218+
.NO_BORDER));
12171219
}
12181220
}
12191221
table.GetHeader().SetBorderTop(new SolidBorder(2)).SetBorderBottom(new SolidBorder(1));

itext.tests/itext.layout.tests/itext/layout/properties/PropertyTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ source product.
4343
using System;
4444
using System.Collections.Generic;
4545
using System.Reflection;
46+
using iText.IO.Util;
4647
using iText.Test;
4748

4849
namespace iText.Layout.Properties {
@@ -57,17 +58,17 @@ public virtual void PropertyUniquenessTest() {
5758
int value = (int)field.GetValue(null);
5859
maxFieldValue = Math.Max(maxFieldValue, value);
5960
if (fieldValues.Contains(value)) {
60-
NUnit.Framework.Assert.Fail(String.Format("Multiple fields with same value: {0}", value));
61+
NUnit.Framework.Assert.Fail(MessageFormatUtil.Format("Multiple fields with same value: {0}", value));
6162
}
6263
fieldValues.Add(value);
6364
}
6465
}
6566
for (int i = 1; i <= maxFieldValue; i++) {
6667
if (!fieldValues.Contains(i)) {
67-
NUnit.Framework.Assert.Fail(String.Format("Missing value: {0}", i));
68+
NUnit.Framework.Assert.Fail(MessageFormatUtil.Format("Missing value: {0}", i));
6869
}
6970
}
70-
System.Console.Out.WriteLine(String.Format("Max field value: {0}", maxFieldValue));
71+
System.Console.Out.WriteLine(MessageFormatUtil.Format("Max field value: {0}", maxFieldValue));
7172
}
7273
}
7374
}

0 commit comments

Comments
 (0)