File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed
java/com/lowagie/text/pdf
resources/com/lowagie/text/error_messages
test/java/com/lowagie/text/pdf Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -658,7 +658,7 @@ public PdfPCell addCell(String text) {
658658 */
659659 public PdfPCell addCell (PdfPTable table ) throws DocumentException {
660660 if (table == this ) {
661- throw new DocumentException ("unable.to.add.self.to.table.contents" );
661+ throw new DocumentException (MessageLocalization . getMessage ( "unable.to.add.self.to.table.contents" ) );
662662 }
663663 defaultCell .setTable (table );
664664 addCell (defaultCell );
Original file line number Diff line number Diff line change @@ -359,6 +359,7 @@ tsa.1.failed.to.return.time.stamp.token.2=TSA '{1}' failed to return time stamp
359359two.byte.arrays.are.needed.if.the.type1.font.is.embedded=Two byte arrays are needed if the Type1 font is embedded.
360360type3.font.used.with.the.wrong.pdfwriter=Type3 font used with the wrong PdfWriter
361361types.is.null=types is null
362+ unable.to.add.self.to.table.contents=Unable to add self to table contents.
362363unbalanced.begin.end.marked.content.operators=Unbalanced begin/end marked content operators.
363364unbalanced.begin.end.text.operators=Unbalanced begin/end text operators.
364365unbalanced.layer.operators=Unbalanced layer operators.
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ fdf.header.not.found=Início de FDF não encontrado.
55greaterthan.not.expected='>' inesperado
66pdf.header.not.found=Início de PDF não encontrado.
77pdf.startxref.not.found=startxref de PDF não encontrado.
8+ unable.to.add.self.to.table.contents=Não é possível adicionar a si mesmo ao conteúdo da tabela.
89xref.infinite.loop=Um loop infinito foi detectado na tabela xref.
Original file line number Diff line number Diff line change 1+ package com .lowagie .text .pdf ;
2+
3+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
4+
5+ import com .lowagie .text .DocumentException ;
6+ import com .lowagie .text .error_messages .MessageLocalization ;
7+ import java .io .IOException ;
8+ import org .junit .jupiter .api .Test ;
9+
10+ class PdfPTableTest {
11+
12+ @ Test
13+ void whenAddCellWithSelf_shouldThrowException () {
14+ PdfPTable table = new PdfPTable (1 );
15+ assertThatThrownBy (() -> table .addCell (table ))
16+ .isInstanceOf (DocumentException .class )
17+ .hasMessage ("Unable to add self to table contents." );
18+ }
19+
20+ @ Test
21+ void whenAddCellWithSelf_shouldThrowException_pt () throws IOException {
22+ MessageLocalization .setLanguage ("pt" , null );
23+ PdfPTable table = new PdfPTable (1 );
24+ assertThatThrownBy (() -> table .addCell (table ))
25+ .isInstanceOf (DocumentException .class )
26+ .hasMessage ("Não é possível adicionar a si mesmo ao conteúdo da tabela." );
27+ MessageLocalization .setLanguage ("en" , null );
28+ }
29+
30+
31+ }
You can’t perform that action at this time.
0 commit comments