1 package org.kuali.ole.deliver.service;
2
3 import org.apache.log4j.Logger;
4 import org.junit.Test;
5 import org.kuali.ole.deliver.util.XMLFormatterUtil;
6 import org.springframework.core.io.ClassPathResource;
7 import org.springframework.core.io.Resource;
8
9 import java.io.IOException;
10
11 import java.io.*;
12
13
14
15
16 public class OLEPatronService_UT {
17
18 private static final Logger LOG = Logger.getLogger(OLEPatronService_UT.class);
19 private static String APPLICATION_URL = "http://dev.ole.kuali.org";
20
21 @Test
22 public void createPatronTest(){
23 try {
24 String requestContent =readFileContent("org/kuali/ole/deliver/patron/createPatronWsdlXml");
25 String resposneString = OLESOAPService.sendSoapRequest(APPLICATION_URL + "/remoting/olePatronService",requestContent);
26 System.out.println("Response : \n" + XMLFormatterUtil.formatContentForPretty(resposneString));
27
28 } catch (Exception ex) {
29 ex.printStackTrace();
30 }
31 }
32
33 @Test
34 public void createPatronWithAddressTest(){
35 try {
36 String requestContent =readFileContent("org/kuali/ole/deliver/patron/createPatron.xml");
37 String resposneString = OLESOAPService.sendSoapRequest(APPLICATION_URL + "/remoting/olePatronService",requestContent);
38 System.out.println("Response : \n" + XMLFormatterUtil.formatContentForPretty(resposneString));
39
40 } catch (Exception ex) {
41 ex.printStackTrace();
42 }
43 }
44
45 public String readFileContent(String path) throws IOException {
46 BufferedReader br=new BufferedReader(new FileReader(getFilePath(path)));
47 String line=null;
48 String fullContent = "";
49 while ((line=br.readLine())!=null)
50 {
51 fullContent += line;
52 }
53 return fullContent;
54 }
55
56 public String getFilePath(String classpathRelativePath) {
57 try {
58 Resource rsrc = new ClassPathResource(classpathRelativePath);
59 return rsrc.getFile().getAbsolutePath();
60 } catch(Exception e){
61 LOG.error("Error : while accessing file "+e);
62 }
63 return null;
64 }
65
66
67
68 }