Commit b7fc45c4a12e3fcd66c017af5b6b4773a8ff27cc
1 parent
aaf40ee5
Exists in
master
and in
1 other branch
Utiliza axis da springsource
Utilização da biblioteca axis da springsource, troca da biblioteca na tentativa de corrigir problema de memory leak da biblioteca original da apache.
Showing
11 changed files
with
102 additions
and
112 deletions
Show diff stats
.classpath
... | ... | @@ -21,7 +21,6 @@ |
21 | 21 | <attributes> |
22 | 22 | <attribute name="maven.pomderived" value="true"/> |
23 | 23 | <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> |
24 | - <attribute name="owner.project.facets" value="jboss.m2"/> | |
25 | 24 | </attributes> |
26 | 25 | </classpathentry> |
27 | 26 | <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> |
... | ... | @@ -34,7 +33,5 @@ |
34 | 33 | <attribute name="maven.pomderived" value="true"/> |
35 | 34 | </attributes> |
36 | 35 | </classpathentry> |
37 | - <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> | |
38 | - <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> | |
39 | 36 | <classpathentry kind="output" path="target/classes"/> |
40 | 37 | </classpath> | ... | ... |
pom.xml
... | ... | @@ -171,11 +171,12 @@ |
171 | 171 | |
172 | 172 | <!-- AXIS --> |
173 | 173 | <dependency> |
174 | - <groupId>org.apache.axis</groupId> | |
175 | - <artifactId>axis</artifactId> | |
176 | - <version>1.4</version> | |
174 | + <groupId>org.apache.axis</groupId> | |
175 | + <artifactId>com.springsource.org.apache.axis</artifactId> | |
176 | + <version>1.4.0</version> | |
177 | 177 | </dependency> |
178 | 178 | |
179 | + | |
179 | 180 | <dependency> |
180 | 181 | <groupId>wsdl4j</groupId> |
181 | 182 | <artifactId>wsdl4j</artifactId> | ... | ... |
src/main/java/br/gov/ans/integracao/sei/rest/ProcessoResource.java
src/main/java/br/gov/ans/integracao/sei/utils/Constantes.java
... | ... | @@ -3,6 +3,9 @@ package br.gov.ans.integracao.sei.utils; |
3 | 3 | import javax.enterprise.context.ApplicationScoped; |
4 | 4 | import javax.inject.Named; |
5 | 5 | |
6 | +import org.apache.commons.lang3.time.FastDateFormat; | |
7 | +import org.codehaus.jackson.map.ObjectMapper; | |
8 | + | |
6 | 9 | @Named |
7 | 10 | @ApplicationScoped |
8 | 11 | public class Constantes { |
... | ... | @@ -28,10 +31,15 @@ public class Constantes { |
28 | 31 | public static final String SEI_BROKER = "SEI-Broker"; |
29 | 32 | public static final String SEI_RESPONDEU_COM_SUCESSO = "SEI respondeu com sucesso."; |
30 | 33 | public static String SIM = "S"; |
34 | + public static final String SQL_AND = "AND "; | |
35 | + public static final String SQL_WHERE = "WHERE "; | |
31 | 36 | public static final int TAMANHO_MAXIMO_ARQUIVO = 16777216; |
32 | 37 | public static final int TAMANHO_MAXIMO_DOCUMENTO = 22020096; |
33 | 38 | public static final Integer TAMANHO_PAGINA_PADRAO = 50; |
34 | 39 | public static final String TEMPLATE_DIR = "sei"; |
35 | 40 | public static final String TEMPLATES_HOME = JBOSS_HOME + "/ans/templates/"; |
36 | 41 | public static final String UTF8 = "UTF-8"; |
42 | + | |
43 | + public static final FastDateFormat DATE_FORMATTER = FastDateFormat.getInstance(DATE_PATTERN); | |
44 | + public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | |
37 | 45 | } | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/ContatoHelper.java
1 | 1 | package br.gov.ans.integracao.sei.utils; |
2 | 2 | |
3 | +import static br.gov.ans.integracao.sei.utils.Constantes.DATE_FORMATTER; | |
4 | +import static br.gov.ans.integracao.sei.utils.Constantes.NAO; | |
5 | +import static br.gov.ans.integracao.sei.utils.Constantes.SIM; | |
3 | 6 | import static br.gov.ans.integracao.sei.utils.Util.getSOuN; |
4 | 7 | |
5 | 8 | import java.rmi.RemoteException; |
... | ... | @@ -7,7 +10,6 @@ import java.rmi.RemoteException; |
7 | 10 | import javax.inject.Inject; |
8 | 11 | |
9 | 12 | import org.apache.commons.lang3.StringUtils; |
10 | -import org.apache.commons.lang3.time.FastDateFormat; | |
11 | 13 | |
12 | 14 | import br.gov.ans.exceptions.BusinessException; |
13 | 15 | import br.gov.ans.integracao.sei.client.Contato; |
... | ... | @@ -21,9 +23,7 @@ import br.gov.ans.integracao.sei.modelo.PessoaJuridica; |
21 | 23 | import br.gov.ans.integracao.sei.modelo.enums.TipoPessoa; |
22 | 24 | |
23 | 25 | public class ContatoHelper { |
24 | - | |
25 | - private static final FastDateFormat formatter = FastDateFormat.getInstance(Constantes.DATE_PATTERN); | |
26 | - | |
26 | + | |
27 | 27 | @Inject |
28 | 28 | private ContatoDAO contatoDAO; |
29 | 29 | |
... | ... | @@ -54,7 +54,7 @@ public class ContatoHelper { |
54 | 54 | contato.setOrgaoExpedidor(pessoa.getOrgaoEmissor()); |
55 | 55 | |
56 | 56 | if(pessoa.getDataNascimento() != null){ |
57 | - contato.setDataNascimento(formatter.format(pessoa.getDataNascimento())); | |
57 | + contato.setDataNascimento(DATE_FORMATTER.format(pessoa.getDataNascimento())); | |
58 | 58 | } |
59 | 59 | |
60 | 60 | contato.setMatricula(pessoa.getMatricula()); |
... | ... | @@ -110,9 +110,9 @@ public class ContatoHelper { |
110 | 110 | |
111 | 111 | private void preencherDadosAssociado(Pessoa pessoa, Contato contato) throws RemoteException, BusinessException, Exception{ |
112 | 112 | if(pessoa.getAssociado() == null){ |
113 | - contato.setSinEnderecoAssociado(Constantes.NAO); | |
113 | + contato.setSinEnderecoAssociado(NAO); | |
114 | 114 | }else{ |
115 | - contato.setSinEnderecoAssociado(Constantes.SIM); | |
115 | + contato.setSinEnderecoAssociado(SIM); | |
116 | 116 | |
117 | 117 | contato.setIdContatoAssociado(getIdContato(pessoa.getAssociado().getSigla())+""); |
118 | 118 | contato.setNomeContatoAssociado(pessoa.getAssociado().getNome()); | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/PessoaHelper.java
1 | 1 | package br.gov.ans.integracao.sei.utils; |
2 | 2 | |
3 | +import static br.gov.ans.integracao.sei.utils.Constantes.DATE_FORMATTER; | |
4 | + | |
3 | 5 | import java.lang.reflect.Field; |
4 | 6 | import java.text.ParseException; |
5 | 7 | import java.util.ArrayList; |
... | ... | @@ -10,7 +12,6 @@ import javax.inject.Inject; |
10 | 12 | import org.apache.commons.lang3.ArrayUtils; |
11 | 13 | import org.apache.commons.lang3.StringUtils; |
12 | 14 | import org.apache.commons.lang3.reflect.FieldUtils; |
13 | -import org.apache.commons.lang3.time.FastDateFormat; | |
14 | 15 | import org.jboss.logging.Logger; |
15 | 16 | |
16 | 17 | import br.gov.ans.exceptions.BusinessException; |
... | ... | @@ -39,9 +40,7 @@ public class PessoaHelper { |
39 | 40 | |
40 | 41 | @Inject |
41 | 42 | private MessageUtils messages; |
42 | - | |
43 | - private static final FastDateFormat formatter = FastDateFormat.getInstance(Constantes.DATE_PATTERN); | |
44 | - | |
43 | + | |
45 | 44 | public List<Pessoa> buildPessoa(Contato[] contatos) throws ParseException, BusinessException, IllegalAccessException, ResourceNotFoundException{ |
46 | 45 | if(ArrayUtils.isNotEmpty(contatos)){ |
47 | 46 | ArrayList<Pessoa> pessoas = new ArrayList<Pessoa>(); |
... | ... | @@ -81,7 +80,7 @@ public class PessoaHelper { |
81 | 80 | } |
82 | 81 | |
83 | 82 | if(StringUtils.isNotBlank(contato.getDataNascimento())){ |
84 | - pessoa.setDataNascimento(formatter.parse(contato.getDataNascimento())); | |
83 | + pessoa.setDataNascimento(DATE_FORMATTER.parse(contato.getDataNascimento())); | |
85 | 84 | } |
86 | 85 | |
87 | 86 | pessoa.setCpf(contato.getCpf()); | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/Util.java
1 | 1 | package br.gov.ans.integracao.sei.utils; |
2 | 2 | |
3 | +import static br.gov.ans.integracao.sei.utils.Constantes.DATE_FORMATTER; | |
4 | +import static br.gov.ans.integracao.sei.utils.Constantes.MASCARA_PROCESSO_17; | |
5 | +import static br.gov.ans.integracao.sei.utils.Constantes.MASCARA_PROCESSO_21; | |
6 | +import static br.gov.ans.integracao.sei.utils.Constantes.OBJECT_MAPPER; | |
7 | +import static br.gov.ans.integracao.sei.utils.Constantes.REGEX_SOMENTE_NUMEROS; | |
8 | +import static br.gov.ans.integracao.sei.utils.Constantes.SQL_AND; | |
9 | +import static br.gov.ans.integracao.sei.utils.Constantes.SQL_WHERE; | |
10 | +import static br.gov.ans.integracao.sei.utils.Constantes.TAMANHO_PAGINA_PADRAO; | |
11 | + | |
3 | 12 | import java.io.IOException; |
4 | 13 | import java.text.ParseException; |
5 | 14 | import java.util.Date; |
... | ... | @@ -11,18 +20,13 @@ import javax.swing.text.MaskFormatter; |
11 | 20 | |
12 | 21 | import org.apache.commons.codec.binary.Base64; |
13 | 22 | import org.apache.commons.lang3.StringUtils; |
14 | -import org.apache.commons.lang3.time.FastDateFormat; | |
15 | 23 | import org.codehaus.jackson.JsonParseException; |
16 | 24 | import org.codehaus.jackson.map.JsonMappingException; |
17 | -import org.codehaus.jackson.map.ObjectMapper; | |
18 | 25 | import org.codehaus.jackson.type.TypeReference; |
19 | 26 | |
20 | 27 | import br.gov.ans.exceptions.BusinessException; |
21 | 28 | |
22 | 29 | public class Util { |
23 | - private static final FastDateFormat dateFormater = FastDateFormat.getInstance(Constantes.DATE_PATTERN); | |
24 | - | |
25 | - private static final ObjectMapper mapper = new ObjectMapper(); | |
26 | 30 | |
27 | 31 | public static String getSOuN(String valor){ |
28 | 32 | if("S".equals(valor) || "s".equals(valor)){ |
... | ... | @@ -42,7 +46,7 @@ public class Util { |
42 | 46 | |
43 | 47 | public static String formatarData(Date data){ |
44 | 48 | if(data != null){ |
45 | - return dateFormater.format(data); | |
49 | + return DATE_FORMATTER.format(data); | |
46 | 50 | } |
47 | 51 | |
48 | 52 | return null; |
... | ... | @@ -66,9 +70,9 @@ public class Util { |
66 | 70 | try { |
67 | 71 | switch (numero.length()){ |
68 | 72 | case 17: |
69 | - return formatarString(numero, Constantes.MASCARA_PROCESSO_17); | |
73 | + return formatarString(numero, MASCARA_PROCESSO_17); | |
70 | 74 | case 21: |
71 | - return formatarString(numero, Constantes.MASCARA_PROCESSO_21); | |
75 | + return formatarString(numero, MASCARA_PROCESSO_21); | |
72 | 76 | default: |
73 | 77 | throw new BusinessException("Número de processo inválido."); |
74 | 78 | } |
... | ... | @@ -112,14 +116,14 @@ public class Util { |
112 | 116 | public static Map<String, Object> jsonToMap(String json) throws JsonParseException,JsonMappingException, IOException { |
113 | 117 | Map<String,Object> out = new HashMap<String,Object>(); |
114 | 118 | |
115 | - out = mapper.readValue(json, new TypeReference<Map<String, Object>>(){}); | |
119 | + out = OBJECT_MAPPER.readValue(json, new TypeReference<Map<String, Object>>(){}); | |
116 | 120 | |
117 | 121 | return out; |
118 | 122 | } |
119 | 123 | |
120 | 124 | |
121 | 125 | public static String decodeBase64(String base64){ |
122 | - return new String(Base64.decodeBase64(base64)); | |
126 | + return new String(Base64.decodeBase64(base64.getBytes())); | |
123 | 127 | } |
124 | 128 | |
125 | 129 | public static String encodeBase64(String texto){ |
... | ... | @@ -143,7 +147,7 @@ public class Util { |
143 | 147 | |
144 | 148 | public static void setPaginacaoQuery(Query query, Integer pagina, Integer qtdRegistros){ |
145 | 149 | if(qtdRegistros == null){ |
146 | - qtdRegistros = Constantes.TAMANHO_PAGINA_PADRAO; | |
150 | + qtdRegistros = TAMANHO_PAGINA_PADRAO; | |
147 | 151 | } |
148 | 152 | |
149 | 153 | if(pagina == null){ |
... | ... | @@ -156,14 +160,14 @@ public class Util { |
156 | 160 | } |
157 | 161 | |
158 | 162 | public static String andOrWhere(StringBuilder sql){ |
159 | - if(sql.toString().contains("WHERE ")){ | |
160 | - return "AND "; | |
163 | + if(sql.toString().contains(SQL_WHERE)){ | |
164 | + return SQL_AND; | |
161 | 165 | } |
162 | 166 | |
163 | - return "WHERE "; | |
167 | + return SQL_WHERE; | |
164 | 168 | } |
165 | 169 | |
166 | 170 | public static String getOnlyNumbers(String string) throws Exception{ |
167 | - return string.replaceAll(Constantes.REGEX_SOMENTE_NUMEROS,""); | |
171 | + return string.replaceAll(REGEX_SOMENTE_NUMEROS,""); | |
168 | 172 | } |
169 | 173 | } | ... | ... |
src/test/java/br/gov/ans/integracao/sei/testes/Base64Decoder.java
... | ... | @@ -6,7 +6,7 @@ import org.apache.commons.codec.binary.Base64; |
6 | 6 | public class Base64Decoder { |
7 | 7 | public static void main(String[] args) { |
8 | 8 | String base64 = "PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PlRFU1RFVEVTVEU8L2JvZHk+PC9odG1sPg=="; |
9 | - | |
10 | - System.out.println(new String(Base64.decodeBase64(base64))); | |
9 | + | |
10 | + System.out.println(new String(Base64.decodeBase64(base64.getBytes()))); | |
11 | 11 | } |
12 | 12 | } | ... | ... |
src/test/java/br/gov/ans/integracao/sei/testes/Base64Encoder.java
... | ... | @@ -5,20 +5,21 @@ import java.io.FileInputStream; |
5 | 5 | import java.io.IOException; |
6 | 6 | |
7 | 7 | import org.apache.commons.codec.binary.Base64; |
8 | +import org.apache.commons.io.IOUtils; | |
8 | 9 | |
9 | 10 | public class Base64Encoder { |
10 | 11 | |
11 | 12 | public static void main(String[] args) throws IOException { |
12 | 13 | String string = "{\"content\":\"tentativa 1 
 tentativa 2 tentativa 3 \\r tentativa 4 \\n fim! <br> teste da tag \"}"; |
13 | - | |
14 | -// System.out.println(string); | |
15 | - | |
16 | -// System.out.println(Base64.encodeBase64String(string.getBytes())); | |
14 | + | |
17 | 15 | Base64Encoder encoder = new Base64Encoder(); |
18 | 16 | |
19 | 17 | System.out.println(encoder.getBase64("0693609.pdf")); |
20 | 18 | System.out.println(encoder.getMD5("0693609.pdf")); |
21 | - System.out.println(Base64.encodeBase64String("{\"regAns\":\"363022\",\"razaoSocial\":\"BRADESCO SAUDE E ASSISTENCIA S.A\",\"emailCadop\":\"teste@teste.com\",\"nuCnpj\":\"0000000000\",\"noCargoRepr\":\"Diretor\",\"noRepresentante\":\"André Guimarães\",\"anoInicio\":\"2016\",\"anoFinal\":\"2017\",\"numeroDocumento\":\"00000000\"}".getBytes())); | |
19 | + System.out.println( | |
20 | + new String(Base64.encodeBase64( | |
21 | + "{\"regAns\":\"363022\",\"razaoSocial\":\"BRADESCO SAUDE E ASSISTENCIA S.A\",\"emailCadop\":\"teste@teste.com\",\"nuCnpj\":\"0000000000\",\"noCargoRepr\":\"Diretor\",\"noRepresentante\":\"André Guimarães\",\"anoInicio\":\"2016\",\"anoFinal\":\"2017\",\"numeroDocumento\":\"00000000\"}" | |
22 | + .getBytes()))); | |
22 | 23 | } |
23 | 24 | |
24 | 25 | public String getBase64(String arquivo){ |
... | ... | @@ -34,14 +35,15 @@ public class Base64Encoder { |
34 | 35 | } catch (Exception e) { |
35 | 36 | e.printStackTrace(); |
36 | 37 | } |
37 | - | |
38 | - return Base64.encodeBase64String(bytes); | |
38 | + | |
39 | + return new String(Base64.encodeBase64(bytes)); | |
39 | 40 | } |
40 | 41 | |
41 | 42 | public String getMD5(String arquivo) throws IOException{ |
42 | 43 | ClassLoader classLoader = getClass().getClassLoader(); |
43 | 44 | FileInputStream fis = new FileInputStream(new File(classLoader.getResource(arquivo).getFile())); |
44 | - String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); | |
45 | + | |
46 | + String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(IOUtils.toByteArray(fis)); | |
45 | 47 | fis.close(); |
46 | 48 | |
47 | 49 | return md5; | ... | ... |
src/test/java/br/gov/ans/integracao/sei/testes/FunctionalTest.java
... | ... | @@ -8,7 +8,9 @@ public class FunctionalTest { |
8 | 8 | |
9 | 9 | protected final String USUARIO = "desenv_integracao_sei"; |
10 | 10 | protected final String SENHA = "integra_sei_2016"; |
11 | - protected static final Boolean DESENVOLVIMENTO = false; | |
11 | + protected static final Boolean DESENVOLVIMENTO = true; | |
12 | + | |
13 | + protected static final String BASIC = "Basic ZGVzZW52X2ludGVncmFjYW9fc2VpOmludGVncmFfc2VpXzIwMTY="; | |
12 | 14 | |
13 | 15 | @BeforeClass |
14 | 16 | public static void setup() { | ... | ... |
src/test/java/br/gov/ans/integracao/sei/testes/SeiBrokerTest.java
... | ... | @@ -9,6 +9,7 @@ import java.util.ArrayList; |
9 | 9 | import java.util.List; |
10 | 10 | |
11 | 11 | import org.apache.commons.codec.binary.Base64; |
12 | +import org.apache.commons.io.IOUtils; | |
12 | 13 | import org.junit.FixMethodOrder; |
13 | 14 | import org.junit.Test; |
14 | 15 | import org.junit.runners.MethodSorters; |
... | ... | @@ -47,8 +48,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
47 | 48 | @Test |
48 | 49 | public void AA_incluirProcessoTest(){ |
49 | 50 | Response response = given() |
50 | - .auth() | |
51 | - .basic(USUARIO, SENHA) | |
51 | + .header("Authorization",BASIC) | |
52 | 52 | .contentType("application/json") |
53 | 53 | .accept("application/json") |
54 | 54 | .body(buildNovoProcesso()) |
... | ... | @@ -61,14 +61,13 @@ public class SeiBrokerTest extends FunctionalTest{ |
61 | 61 | |
62 | 62 | @Test |
63 | 63 | public void AB_consultarProcessoTest(){ |
64 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosap/processos/"+processoCriado).then().statusCode(200); | |
64 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosap/processos/"+processoCriado).then().statusCode(200); | |
65 | 65 | } |
66 | 66 | |
67 | 67 | @Test |
68 | 68 | public void AC_incluirDocumentoTest() { |
69 | 69 | Response response = given() |
70 | - .auth() | |
71 | - .basic(USUARIO, SENHA) | |
70 | + .header("Authorization",BASIC) | |
72 | 71 | .contentType("application/json") |
73 | 72 | .accept("application/json") |
74 | 73 | .body(buildDocumento()) |
... | ... | @@ -82,8 +81,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
82 | 81 | @Test |
83 | 82 | public void AD_incluirDocumentoInternoTest() { |
84 | 83 | Response response = given() |
85 | - .auth() | |
86 | - .basic(USUARIO, SENHA) | |
84 | + .header("Authorization",BASIC) | |
87 | 85 | .contentType("application/json") |
88 | 86 | .accept("application/json") |
89 | 87 | .body(buildDocumentoInterno()) |
... | ... | @@ -96,59 +94,58 @@ public class SeiBrokerTest extends FunctionalTest{ |
96 | 94 | |
97 | 95 | @Test |
98 | 96 | public void AE_consultarDocumentoTest() { |
99 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosap/documentos/"+documentoCriado).then().statusCode(200); | |
97 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosap/documentos/"+documentoCriado).then().statusCode(200); | |
100 | 98 | } |
101 | 99 | |
102 | 100 | @Test |
103 | 101 | public void AF_consultarDocumentosEnviadosBrokerTest(){ |
104 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosap/documentos/enviados-broker").then().statusCode(200); | |
102 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosap/documentos/enviados-broker").then().statusCode(200); | |
105 | 103 | } |
106 | 104 | |
107 | 105 | @Test |
108 | 106 | public void AG_consultarDocumentosPorInteressadosTest(){ |
109 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/interessados/363022/documentos").then().statusCode(200); | |
107 | + given().header("Authorization",BASIC).accept("application/json").when().get("/interessados/363022/documentos").then().statusCode(200); | |
110 | 108 | } |
111 | 109 | |
112 | 110 | @Test |
113 | 111 | public void AH_consultarProcessos(){ |
114 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/processos").then().statusCode(200); | |
112 | + given().header("Authorization",BASIC).accept("application/json").when().get("/processos").then().statusCode(200); | |
115 | 113 | } |
116 | 114 | |
117 | 115 | @Test |
118 | 116 | public void AI_exportarDocumentoTest(){ |
119 | - given().auth().basic(USUARIO, SENHA).when().get("/cosap/documentos/"+documentoCriado+"/pdf").then().statusCode(200); | |
117 | + given().header("Authorization",BASIC).when().get("/cosap/documentos/"+documentoCriado+"/pdf").then().statusCode(200); | |
120 | 118 | } |
121 | 119 | |
122 | 120 | @Test |
123 | 121 | public void AJ_listarUnidadesTest(){ |
124 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/unidades").then().statusCode(200); | |
122 | + given().header("Authorization",BASIC).accept("application/json").when().get("/unidades").then().statusCode(200); | |
125 | 123 | } |
126 | 124 | |
127 | 125 | @Test |
128 | 126 | public void AL_listarSeriesTest(){ |
129 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosit/series").then().statusCode(200); | |
127 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosit/series").then().statusCode(200); | |
130 | 128 | } |
131 | 129 | |
132 | 130 | @Test |
133 | 131 | public void AM_listarTiposDeProcessoTest(){ |
134 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosit/processos/tipos").then().statusCode(200); | |
132 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosit/processos/tipos").then().statusCode(200); | |
135 | 133 | } |
136 | 134 | |
137 | 135 | @Test |
138 | 136 | public void AN_listarExtensoesTest(){ |
139 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/cosit/extensoes").then().statusCode(200); | |
137 | + given().header("Authorization",BASIC).accept("application/json").when().get("/cosit/extensoes").then().statusCode(200); | |
140 | 138 | } |
141 | 139 | |
142 | 140 | @Test |
143 | 141 | public void AO_consultarCodigoUnidadeTest(){ |
144 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().get("/unidades/cotec/codigo").then().statusCode(200); | |
142 | + given().header("Authorization",BASIC).accept("application/json").when().get("/unidades/cotec/codigo").then().statusCode(200); | |
145 | 143 | } |
146 | 144 | |
147 | 145 | // @Test |
148 | 146 | public void AP_cancelarDocumentoTest(){ |
149 | 147 | given() |
150 | - .auth() | |
151 | - .basic(USUARIO, SENHA) | |
148 | + .header("Authorization",BASIC) | |
152 | 149 | .contentType("application/json") |
153 | 150 | .accept("application/json") |
154 | 151 | .body(buildCancelamentoDocumento()) |
... | ... | @@ -158,8 +155,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
158 | 155 | @Test |
159 | 156 | public void AQ_concluirProcessoTest(){ |
160 | 157 | given() |
161 | - .auth() | |
162 | - .basic(USUARIO, SENHA) | |
158 | + .header("Authorization",BASIC) | |
163 | 159 | .contentType("application/json") |
164 | 160 | .accept("application/json") |
165 | 161 | .body(processoCriado) |
... | ... | @@ -168,14 +164,13 @@ public class SeiBrokerTest extends FunctionalTest{ |
168 | 164 | |
169 | 165 | @Test |
170 | 166 | public void AR_reabrirProcessoTest(){ |
171 | - given().auth().basic(USUARIO, SENHA).accept("application/json").when().delete("/cosap/processos/concluidos/"+processoCriado).then().statusCode(200); | |
167 | + given().header("Authorization",BASIC).accept("application/json").when().delete("/cosap/processos/concluidos/"+processoCriado).then().statusCode(200); | |
172 | 168 | } |
173 | 169 | |
174 | 170 | @Test |
175 | 171 | public void AS_gerarBlocoReuniaoTest(){ |
176 | 172 | Response response = given() |
177 | - .auth() | |
178 | - .basic(USUARIO, SENHA) | |
173 | + .header("Authorization",BASIC) | |
179 | 174 | .contentType("application/json") |
180 | 175 | .accept("application/json") |
181 | 176 | .body(buildNovoBloco(TipoBloco.REUNIAO)) |
... | ... | @@ -189,8 +184,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
189 | 184 | @Test |
190 | 185 | public void AT_incluirProcessoNoBlocoTest(){ |
191 | 186 | given() |
192 | - .auth() | |
193 | - .basic(USUARIO, SENHA) | |
187 | + .header("Authorization",BASIC) | |
194 | 188 | .body(processoCriado) |
195 | 189 | .when().post("/cosap/blocos/"+blocoCriado+"/processos").then().statusCode(200); |
196 | 190 | |
... | ... | @@ -199,8 +193,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
199 | 193 | @Test |
200 | 194 | public void AU_removerProcessoBlocoTest(){ |
201 | 195 | given() |
202 | - .auth() | |
203 | - .basic(USUARIO, SENHA) | |
196 | + .header("Authorization",BASIC) | |
204 | 197 | .body(processoCriado) |
205 | 198 | .when().delete("/cosap/blocos/"+blocoCriado+"/processos/"+processoCriado).then().statusCode(200); |
206 | 199 | } |
... | ... | @@ -208,8 +201,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
208 | 201 | @Test |
209 | 202 | public void AV_gerarBlocoAssinaturaTest(){ |
210 | 203 | Response response = given() |
211 | - .auth() | |
212 | - .basic(USUARIO, SENHA) | |
204 | + .header("Authorization",BASIC) | |
213 | 205 | .contentType("application/json") |
214 | 206 | .body(buildNovoBloco(TipoBloco.ASSINATURA)) |
215 | 207 | .when().post("/cosap/blocos"); |
... | ... | @@ -222,8 +214,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
222 | 214 | @Test |
223 | 215 | public void AX_incluirDocumentoNoBlocoTest(){ |
224 | 216 | given() |
225 | - .auth() | |
226 | - .basic(USUARIO, SENHA) | |
217 | + .header("Authorization",BASIC) | |
227 | 218 | .body(documentoInternoCriado) |
228 | 219 | .when().post("/cosap/blocos/"+blocoCriado+"/documentos").then().statusCode(200); |
229 | 220 | |
... | ... | @@ -232,8 +223,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
232 | 223 | @Test |
233 | 224 | public void AZ_disponibilizarBlocoTest(){ |
234 | 225 | given() |
235 | - .auth() | |
236 | - .basic(USUARIO, SENHA) | |
226 | + .header("Authorization",BASIC) | |
237 | 227 | .body(blocoCriado) |
238 | 228 | .when().post("/cosap/blocos/disponibilizados").then().statusCode(200); |
239 | 229 | |
... | ... | @@ -242,8 +232,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
242 | 232 | @Test |
243 | 233 | public void BA_indisponibilizarBlocoTest(){ |
244 | 234 | given() |
245 | - .auth() | |
246 | - .basic(USUARIO, SENHA) | |
235 | + .header("Authorization",BASIC) | |
247 | 236 | .when().delete("/cosap/blocos/disponibilizados/"+blocoCriado).then().statusCode(200); |
248 | 237 | |
249 | 238 | } |
... | ... | @@ -251,8 +240,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
251 | 240 | @Test |
252 | 241 | public void BB_consultarBlocoTest(){ |
253 | 242 | given() |
254 | - .auth() | |
255 | - .basic(USUARIO, SENHA) | |
243 | + .header("Authorization",BASIC) | |
256 | 244 | .accept("application/json") |
257 | 245 | .when().get("/cosap/blocos/"+blocoCriado).then().statusCode(200); |
258 | 246 | |
... | ... | @@ -261,24 +249,21 @@ public class SeiBrokerTest extends FunctionalTest{ |
261 | 249 | @Test |
262 | 250 | public void BC_removerDocumentoBlocoTest(){ |
263 | 251 | given() |
264 | - .auth() | |
265 | - .basic(USUARIO, SENHA) | |
252 | + .header("Authorization",BASIC) | |
266 | 253 | .when().delete("/cosap/blocos/"+blocoCriado+"/documentos/"+documentoInternoCriado).then().statusCode(200); |
267 | 254 | } |
268 | 255 | |
269 | 256 | @Test |
270 | 257 | public void BD_excluirBlocoTest(){ |
271 | 258 | given() |
272 | - .auth() | |
273 | - .basic(USUARIO, SENHA) | |
259 | + .header("Authorization",BASIC) | |
274 | 260 | .when().delete("/cosap/blocos/"+blocoCriado).then().statusCode(200); |
275 | 261 | } |
276 | 262 | |
277 | 263 | @Test |
278 | 264 | public void BE_enviarProcessoTest(){ |
279 | 265 | given() |
280 | - .auth() | |
281 | - .basic(USUARIO, SENHA) | |
266 | + .header("Authorization",BASIC) | |
282 | 267 | .contentType("application/json") |
283 | 268 | .accept("application/json") |
284 | 269 | .body(buildEnvioDeProcesso()) |
... | ... | @@ -294,8 +279,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
294 | 279 | // String nomeArquivo = "OF-599-2016-DIDES-33902438169201608-16513178000176-ABI.pdf"; |
295 | 280 | |
296 | 281 | Response response = given() |
297 | - .auth() | |
298 | - .basic(USUARIO, SENHA) | |
282 | + .header("Authorization",BASIC) | |
299 | 283 | .contentType("application/json") |
300 | 284 | .accept("application/json") |
301 | 285 | .body(buildArquivo(nomeArquivo)) |
... | ... | @@ -309,8 +293,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
309 | 293 | @Test |
310 | 294 | public void BG_incluirDocumentoPorArquivoTest() { |
311 | 295 | Response response = given() |
312 | - .auth() | |
313 | - .basic(USUARIO, SENHA) | |
296 | + .header("Authorization",BASIC) | |
314 | 297 | .contentType("application/json") |
315 | 298 | .accept("application/json") |
316 | 299 | .body(buildDocumentoPorArquivo()) |
... | ... | @@ -326,8 +309,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
326 | 309 | String template = "gear-reajuste"; |
327 | 310 | |
328 | 311 | Response response = given() |
329 | - .auth() | |
330 | - .basic(USUARIO, SENHA) | |
312 | + .header("Authorization",BASIC) | |
331 | 313 | .contentType("application/json") |
332 | 314 | .accept("application/json") |
333 | 315 | .body(buildDocumentoComTemplate()) |
... | ... | @@ -347,8 +329,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
347 | 329 | arquivo.setConteudo(partesArquivo.get(0)); |
348 | 330 | |
349 | 331 | Response response = given() |
350 | - .auth() | |
351 | - .basic(USUARIO, SENHA) | |
332 | + .header("Authorization",BASIC) | |
352 | 333 | .contentType("application/json") |
353 | 334 | .accept("application/json") |
354 | 335 | .body(arquivo) |
... | ... | @@ -371,8 +352,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
371 | 352 | parte.setConteudo(partesArquivo.get(i)); |
372 | 353 | |
373 | 354 | response = given() |
374 | - .auth() | |
375 | - .basic(USUARIO, SENHA) | |
355 | + .header("Authorization",BASIC) | |
376 | 356 | .contentType("application/json") |
377 | 357 | .accept("application/json") |
378 | 358 | .body(parte) |
... | ... | @@ -385,8 +365,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
385 | 365 | //// @Test |
386 | 366 | public void BK_incluirDocumentoPorArquivoTest() { |
387 | 367 | Response response = given() |
388 | - .auth() | |
389 | - .basic(USUARIO, SENHA) | |
368 | + .header("Authorization",BASIC) | |
390 | 369 | .contentType("application/json") |
391 | 370 | .accept("application/json") |
392 | 371 | .body(buildDocumentoPorArquivo()) |
... | ... | @@ -400,8 +379,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
400 | 379 | @Test |
401 | 380 | public void BL_abrirProcessoTest(){ |
402 | 381 | Response response = given() |
403 | - .auth() | |
404 | - .basic(USUARIO, SENHA) | |
382 | + .header("Authorization",BASIC) | |
405 | 383 | .contentType("application/json") |
406 | 384 | .accept("application/json") |
407 | 385 | .body(buildNovoProcessoUmaUnidade()) |
... | ... | @@ -419,8 +397,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
419 | 397 | s.setMotivo("Teste automatizado de sobrestamento."); |
420 | 398 | |
421 | 399 | given() |
422 | - .auth() | |
423 | - .basic(USUARIO, SENHA) | |
400 | + .header("Authorization",BASIC) | |
424 | 401 | .contentType("application/json") |
425 | 402 | .accept("application/json") |
426 | 403 | .body(s) |
... | ... | @@ -430,8 +407,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
430 | 407 | @Test |
431 | 408 | public void BN_removerSobrestamentoProcessoTest(){ |
432 | 409 | given() |
433 | - .auth() | |
434 | - .basic(USUARIO, SENHA) | |
410 | + .header("Authorization",BASIC) | |
435 | 411 | .contentType("application/json") |
436 | 412 | .accept("application/json") |
437 | 413 | .when().delete("/cosap/processos/sobrestados/"+processoCriado).then().statusCode(200); |
... | ... | @@ -440,8 +416,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
440 | 416 | @Test |
441 | 417 | public void BO_listarContatos(){ |
442 | 418 | given() |
443 | - .auth() | |
444 | - .basic(USUARIO, SENHA) | |
419 | + .header("Authorization",BASIC) | |
445 | 420 | .contentType("application/json") |
446 | 421 | .accept("application/json") |
447 | 422 | .when().get("cosap/contatos/operadoras?qtdRegistros=20").then().statusCode(200); |
... | ... | @@ -619,7 +594,10 @@ public class SeiBrokerTest extends FunctionalTest{ |
619 | 594 | d.setSigla("alexander.mesquita"); |
620 | 595 | documento.setDestinatarios(new Destinatario[]{d}); |
621 | 596 | |
622 | - documento.setConteudo(Base64.encodeBase64String("{\"regAns\":\"363022\",\"razaoSocial\":\"BRADESCO SAUDE E ASSISTENCIA S.A\",\"emailCadop\":\"teste@teste.com\",\"nuCnpj\":\"0000000000\",\"noCargoRepr\":\"Diretor\",\"noRepresentante\":\"André Guimarães\",\"anoInicio\":\"2016\",\"anoFinal\":\"2017\",\"numeroDocumento\":\"00000000\"}".getBytes())); | |
597 | + documento.setConteudo( | |
598 | + new String(Base64.encodeBase64( | |
599 | + "{\"regAns\":\"363022\",\"razaoSocial\":\"BRADESCO SAUDE E ASSISTENCIA S.A\",\"emailCadop\":\"teste@teste.com\",\"nuCnpj\":\"0000000000\",\"noCargoRepr\":\"Diretor\",\"noRepresentante\":\"André Guimarães\",\"anoInicio\":\"2016\",\"anoFinal\":\"2017\",\"numeroDocumento\":\"00000000\"}" | |
600 | + .getBytes()))); | |
623 | 601 | |
624 | 602 | return documento; |
625 | 603 | } |
... | ... | @@ -658,7 +636,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
658 | 636 | public String getMD5(String arquivo) throws IOException{ |
659 | 637 | ClassLoader classLoader = getClass().getClassLoader(); |
660 | 638 | FileInputStream fis = new FileInputStream(new File(classLoader.getResource(arquivo).getFile())); |
661 | - String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); | |
639 | + String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(IOUtils.toByteArray(fis)); | |
662 | 640 | fis.close(); |
663 | 641 | |
664 | 642 | return md5; |
... | ... | @@ -679,7 +657,7 @@ public class SeiBrokerTest extends FunctionalTest{ |
679 | 657 | e.printStackTrace(); |
680 | 658 | } |
681 | 659 | |
682 | - return Base64.encodeBase64String(bytes); | |
660 | + return new String(Base64.encodeBase64(bytes)); | |
683 | 661 | } |
684 | 662 | |
685 | 663 | public String getProcessoCriado(){ | ... | ... |