1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.james.transport.mailets;
21  
22  import junit.framework.TestCase;
23  
24  public class UnwrapTextTest extends TestCase {
25  
26      /*
27       * Test method for 'it.voidlabs.elysium.mailgateway.transport.mailets.UnwrapText.unwrap(String)'
28       */
29      public void testUnwrap() {
30          String input, output;
31          
32          assertEquals("", UnwrapText.unwrap(""));
33          assertEquals("a", UnwrapText.unwrap("a"));
34          
35          input = 
36              "Prova per vedere se effettivamente il testo viene wrappato\r\n" +
37              "come dovrebbe.\r\n"+
38              "Chiss\u00E0 se funziona davvero\r\n"+
39              "o se va solo come gli pare";
40          
41          output = 
42              "Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n"+
43              "Chiss\u00E0 se funziona davvero\r\n"+
44              "o se va solo come gli pare";
45          
46          assertEquals(output, UnwrapText.unwrap(input));
47  
48          input = 
49              "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
50              "> come dovrebbe.\r\n"+
51              "> Chiss\u00E0 se funziona davvero\r\n"+
52              "> o se va solo come gli pare";
53          
54          output = 
55              "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n"+
56              "> Chiss\u00E0 se funziona davvero\r\n"+
57              "> o se va solo come gli pare";
58          
59          assertEquals(output, UnwrapText.unwrap(input));
60  
61          input = 
62              "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
63              "> come dovrebbe.\r\n"+
64              "> Chiss\u00E0 se funziona davvero\r\n"+
65              "> o se va solo come gli pare\r\n"+
66              "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
67              "> come dovrebbe.\r\n";
68          
69          output = 
70              "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n"+
71              "> Chiss\u00E0 se funziona davvero\r\n"+
72              "> o se va solo come gli pare\r\n"+
73              "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n";
74          
75          assertEquals(output, UnwrapText.unwrap(input));
76  
77          input = 
78              "> volevo chiedervi un piccolo aiutino. Una signora con un circolare ha un\r\n"+
79              "> dente che si \u00E8 scementato. Il cemento usato per la cementazione \u00E8\r\n"+
80              "> l'harvard.  Il problema \u00E8 che non riesco a decementarlo. Avete qualche\r\n"+
81              "> trucco da  suggerirmi per rimuovere il ponte? Il ponte \u00E8 in ceramica, per\r\n"+
82              "> cui  l'utilizzo degli ultrasuoni puo' essere rischioso (?).\r\n";
83          
84          output = 
85              "> volevo chiedervi un piccolo aiutino. Una signora con un circolare ha un "+
86              "dente che si \u00E8 scementato. Il cemento usato per la cementazione \u00E8 "+
87              "l'harvard.  Il problema \u00E8 che non riesco a decementarlo. Avete qualche "+
88              "trucco da  suggerirmi per rimuovere il ponte? Il ponte \u00E8 in ceramica, per "+
89              "cui  l'utilizzo degli ultrasuoni puo' essere rischioso (?).\r\n";
90  
91          assertEquals(output, UnwrapText.unwrap(input));
92  
93          input = 
94              "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
95              "> com dovrebbe.\r\n"+
96              "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
97              "come\r\n" +
98              "> dovrebbe.\r\n";
99          
100         output = 
101             "> Prova per vedere se effettivamente il testo viene wrappato com dovrebbe.\r\n"+
102             "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe.\r\n";
103 
104         assertEquals(output, UnwrapText.unwrap(input));
105         
106         input = 
107             "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
108             "> com dovrebbe.\r\n"+
109             "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
110             "come\r\n" +
111             ">> dovrebbe.\r\n";
112         
113         output = 
114             "> Prova per vedere se effettivamente il testo viene wrappato com dovrebbe.\r\n"+
115             "> Prova per vedere se effettivamente il testo viene wrappato come\r\n" +
116             ">> dovrebbe.\r\n";
117 
118         assertEquals(output, UnwrapText.unwrap(input));
119 
120         input = 
121             "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
122             "> com dovrebbe.\r\n"+
123             "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
124             "come dovrebbe.\r\n";
125         
126         output = 
127             "> Prova per vedere se effettivamente il testo viene wrappato com dovrebbe.\r\n"+
128             "> Prova per vedere se effettivamente il testo viene wrappato\r\n" +
129             "come dovrebbe.\r\n";
130 
131         assertEquals(output, UnwrapText.unwrap(input));
132 
133         input = 
134             "...pero' devo dire che ai congressi vedo moltissimi casi di carico\r\n"+
135             "immediato, \r\n"+
136             "spesso circolari superiore e inferiore, con estrazione di denti\r\n"+ 
137             "\"parodontosici\" che io terrei li per altri 15 anni...\r\n"+
138             "Non voglio polemizzare ne tantomento accusare nessuno, ma credo che spesso a\r\n"+
139             "accada quello che Alessio suggerisce...\r\n";
140         
141         output = 
142             "...pero' devo dire che ai congressi vedo moltissimi casi di carico immediato, \r\n"+
143             "spesso circolari superiore e inferiore, con estrazione di denti\r\n"+ 
144             "\"parodontosici\" che io terrei li per altri 15 anni...\r\n"+
145             "Non voglio polemizzare ne tantomento accusare nessuno, ma credo che spesso a accada quello che Alessio suggerisce...\r\n";
146 
147         assertEquals(output, UnwrapText.unwrap(input));
148         
149         input = 
150             "> mi trovo in difficolta,ho eseguito un lavoro di protesizzazione in\r\n"+
151             "porcellana\r\n"+
152             "> su 24 25 26 premetto che i denti sottostanti erano pieni di otturazioni in\r\n"+ 
153             "> amalgama ,la giovane paziente ,protesta perche sul 24 c'\u00E8 un leggero\r\n"+
154             "deficit\r\n"+
155             "> di chiusura,esteticamente visibile ma sicuramente la sua reazione \u00E8\r\n"+ 
156             "> sproporzionata,ha un atteggiamento rivendicativo come se l'avessi\r\n"+
157             "> triffata,rifiuta un allungamenti con compositi ceramici .io sono convinto\r\n"+
158             "che\r\n"+
159             "> a tirar giu il lavoro anche con tutte le cautele del caso rischio la\r\n"+
160             "rottura\r\n";
161         
162         output = 
163             "> mi trovo in difficolta,ho eseguito un lavoro di protesizzazione in "+
164             "porcellana "+
165             "su 24 25 26 premetto che i denti sottostanti erano pieni di otturazioni in "+ 
166             "amalgama ,la giovane paziente ,protesta perche sul 24 c'\u00E8 un leggero "+
167             "deficit "+
168             "di chiusura,esteticamente visibile ma sicuramente la sua reazione \u00E8 "+ 
169             "sproporzionata,ha un atteggiamento rivendicativo come se l'avessi "+
170             "triffata,rifiuta un allungamenti con compositi ceramici .io sono convinto "+
171             "che "+
172             "a tirar giu il lavoro anche con tutte le cautele del caso rischio la "+
173             "rottura\r\n";
174 
175         assertEquals(output, UnwrapText.unwrap(input, 79));
176 
177         // Controllo spazi
178         input = 
179             "Prova per vedere se effettivamente il testo viene wrappato\r\n" +
180             "come dovrebbe. \r\n"+
181             "Chiss\u00E0 se funziona davvero \r\n"+
182             "o se va solo come gli pare \r\n"+ 
183             "> Prova per vedere se effettivamente il testo viene wrappato \r\n" +
184             "come \r\n" +
185             "> dovrebbe. \r\n";
186         
187         output = 
188             "Prova per vedere se effettivamente il testo viene wrappato come dovrebbe. \r\n"+
189             "Chiss\u00E0 se funziona davvero \r\n"+
190             "o se va solo come gli pare \r\n" + 
191             "> Prova per vedere se effettivamente il testo viene wrappato come dovrebbe. \r\n";
192         
193         assertEquals(output, UnwrapText.unwrap(input, 79));
194     }
195 
196 }