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
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) {
658
658
*/
659
659
public PdfPCell addCell (PdfPTable table ) throws DocumentException {
660
660
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" ) );
662
662
}
663
663
defaultCell .setTable (table );
664
664
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
359
359
two.byte.arrays.are.needed.if.the.type1.font.is.embedded=Two byte arrays are needed if the Type1 font is embedded.
360
360
type3.font.used.with.the.wrong.pdfwriter=Type3 font used with the wrong PdfWriter
361
361
types.is.null=types is null
362
+ unable.to.add.self.to.table.contents=Unable to add self to table contents.
362
363
unbalanced.begin.end.marked.content.operators=Unbalanced begin/end marked content operators.
363
364
unbalanced.begin.end.text.operators=Unbalanced begin/end text operators.
364
365
unbalanced.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.
5
5
greaterthan.not.expected='>' inesperado
6
6
pdf.header.not.found=Início de PDF não encontrado.
7
7
pdf.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.
8
9
xref.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