[3782] | 1 | package org.expressolivre.cte.email; |
---|
[3745] | 2 | |
---|
| 3 | import java.lang.reflect.InvocationTargetException; |
---|
| 4 | import java.lang.reflect.Method; |
---|
| 5 | |
---|
| 6 | import org.apache.commons.lang.StringUtils; |
---|
[4627] | 7 | import org.expressolivre.cte.common.BaseTestCase; |
---|
[3782] | 8 | import org.expressolivre.cte.common.Config; |
---|
[4627] | 9 | import org.expressolivre.cte.pages.email.MailPreferencesPage; |
---|
[3745] | 10 | import org.testng.annotations.Test; |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * @author L.F.Estivalet (Serpro) |
---|
| 14 | * |
---|
| 15 | * Created on Feb 3, 2011 at 11:07:04 AM |
---|
| 16 | * |
---|
| 17 | */ |
---|
[4627] | 18 | public class MailPreferencesTestCase extends BaseTestCase { |
---|
[3745] | 19 | |
---|
| 20 | @Test |
---|
| 21 | public void test() throws IllegalArgumentException, IllegalAccessException, |
---|
| 22 | InvocationTargetException { |
---|
[3789] | 23 | openPreferencesPage(); |
---|
[4627] | 24 | MailPreferencesPage prefs = openEmailPreferencesPage(); |
---|
[3745] | 25 | |
---|
[3799] | 26 | // Percorre todos os metodos "setters" da classe |
---|
| 27 | // ExpressoMailPreferencesPage para mudar o valor de cada preferencia. |
---|
[4627] | 28 | Method[] methods = MailPreferencesPage.class.getMethods(); |
---|
[3745] | 29 | for (Method method : methods) { |
---|
[3799] | 30 | // Nao pegar os metodos setComboValue e setSavePreferences que nao |
---|
| 31 | // tem correspondentes no arquivo de configuracao. |
---|
[3745] | 32 | if (method.getName().startsWith("set") |
---|
| 33 | && !method.getName().equals("setComboValue") |
---|
| 34 | && !method.getName().equals("setSavePreferences")) { |
---|
| 35 | String name = StringUtils.uncapitalize(method.getName() |
---|
| 36 | .substring(3)); |
---|
| 37 | System.out.println(name); |
---|
[3799] | 38 | |
---|
| 39 | // Apenas chama o metodo se a preferencia correspondente ao |
---|
| 40 | // metodo get estiver definida no arquivo de configuracao. |
---|
| 41 | if (Config.getInstance().getEmailPreference(name) != null) { |
---|
| 42 | String[] values = Config.getInstance() |
---|
| 43 | .getEmailPreference(name).split(","); |
---|
| 44 | System.out.println(name + " " + values[0]); |
---|
| 45 | method.invoke(prefs, values[0]); |
---|
| 46 | } |
---|
[3745] | 47 | } |
---|
| 48 | } |
---|
[3789] | 49 | prefs.savePreferences(); |
---|
[3745] | 50 | |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | } |
---|