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