marcoantoniobferreira commented on a change in pull request #627: TOMEE-2761 
Add Portuguese translation for examples/javamail
URL: https://github.com/apache/tomee/pull/627#discussion_r366927651
 
 

 ##########
 File path: examples/javamail/README_pt.adoc
 ##########
 @@ -0,0 +1,201 @@
+:index-group: Unrevised
+:jbake-type: page
+:jbake-status: status=published
+= Javamail API
+
+Este é apenas um exemplo simples para demonstrar um uso muito básico do
+API. Deve ser o suficiente para você começar a usar o java mail
+pacotes.
+
+== Um serviço REST simples usando a API Javamail
+
+Aqui vemos um terminal RESTful muito simples que pode ser chamado com um
+mensagem a ser enviada por e-mail. Não seria difícil modificar o aplicativo
+para fornecer opções de configuração mais úteis. Como está, isso não enviará
+qualquer coisa, mas se você alterar os parâmetros para corresponder ao seu 
servidor de correio
+você verá a mensagem sendo enviada. Você pode encontrar muito mais detalhado
+informações sobre o
+https://java.net/projects/javamail/pages/Home#Samples[Javamail API here]
+
+....
+package org.superbiz.rest;
+
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import java.util.Date;
+import java.util.Properties;
+
+@Path("/email")
+public class EmailService {
+
+    @POST
+    public String lowerCase(final String message) {
+
+        try {
+
+            //Create some properties and get the default Session
+            final Properties props = new Properties();
+            props.put("mail.smtp.host", "your.mailserver.host");
+            props.put("mail.debug", "true");
+
+            final Session session = Session.getInstance(props, new 
Authenticator() {
+                @Override
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return new PasswordAuthentication("MyUsername", 
"MyPassword");
+                }
+            });
+
+            //Set this just to see some internal logging
+            session.setDebug(true);
+
+            //Create a message
+            final MimeMessage msg = new MimeMessage(session);
+            msg.setFrom(new InternetAddress("your@email.address"));
+            final InternetAddress[] address = {new 
InternetAddress("gene...@email.com")};
+            msg.setRecipients(Message.RecipientType.TO, address);
+            msg.setSubject("JavaMail API test");
+            msg.setSentDate(new Date());
+            msg.setText(message, "UTF-8");
+
+
+            Transport.send(msg);
+        } catch (MessagingException e) {
+            return "Failed to send message: " + e.getMessage();
+        }
+
+        return "Sent";
+    }
+}
+....
+
+== Teste
+
+=== Teste para o serviço JAXRS
+
+O teste usa o OpenEJB ApplicationComposer para torná-lo trivial.
+
+A idéia é primeiro ativar os serviços jaxrs. Isso é feito usando
+Anotação @EnableServices.
+
+Em seguida, criamos rapidamente o aplicativo simplesmente retornando um objeto
+representando o web.xml. Aqui nós simplesmente o usamos para definir o contexto
+raiz, mas você também pode usá-lo para definir seu aplicativo REST. E para
+Para concluir a definição do aplicativo, adicionamos a anotação @Classes para 
definir
+o conjunto de classes para usar neste aplicativo.
+
+Finalmente, para testá-lo, usamos a API do cliente cxf para chamar o serviço 
REST post ()
+método.
+
+....
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs")
+@RunWith(ApplicationComposer.class)
+public class EmailServiceTest {
+
+    @Module
+    @Classes(EmailService.class)
+    public WebApp app() {
+        return new WebApp().contextRoot("test");
+    }
+
+    @Test
+    public void post() throws IOException {
+        final String message = 
WebClient.create("http://localhost:4204";).path("/test/email/").post("Hello 
General", String.class);
+        assertEquals("Failed to send message: Unknown SMTP host: 
your.mailserver.host", message);
+    }
+}
+....
+
+#Corrida
+
+A execução do exemplo é bastante simples. No diretório "javamail-api" corre:
 
 Review comment:
   "execute" instead "corre"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to