List of usage examples for java.io FileWriter flush
public void flush() throws IOException
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.DsetAdDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from www.jav a 2 s. c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { DsetAdDataType searchObject = new DsetAdDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.DsetAdDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { DsetAdDataType obj = (DsetAdDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/DsetAdDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("DsetAdDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.DsetCdDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set// w w w. j av a 2 s . c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { DsetCdDataType searchObject = new DsetCdDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.DsetCdDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { DsetCdDataType obj = (DsetCdDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/DsetCdDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("DsetCdDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.DsetIiDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from w w w . ja v a 2 s . c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { DsetIiDataType searchObject = new DsetIiDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.DsetIiDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { DsetIiDataType obj = (DsetIiDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/DsetIiDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("DsetIiDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.DsetTelDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w ww . j av a 2 s .com*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { DsetTelDataType searchObject = new DsetTelDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.DsetTelDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { DsetTelDataType obj = (DsetTelDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/DsetTelDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("DsetTelDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.EdDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from ww w .j a v a2 s . co m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { EdDataType searchObject = new EdDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.EdDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { EdDataType obj = (EdDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/EdDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("EdDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.EdTextDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w ww . j av a 2 s. c om*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { EdTextDataType searchObject = new EdTextDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.EdTextDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { EdTextDataType obj = (EdTextDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/EdTextDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("EdTextDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.EnDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from w ww .j av a 2s . co m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { EnDataType searchObject = new EnDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.EnDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { EnDataType obj = (EnDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/EnDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("EnDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.EnOnDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from www . java 2 s . c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { EnOnDataType searchObject = new EnOnDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.EnOnDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { EnOnDataType obj = (EnOnDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/EnOnDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("EnOnDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.EnPnDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from www . j a v a2s. c o m*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { EnPnDataType searchObject = new EnPnDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.EnPnDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { EnPnDataType obj = (EnPnDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/EnPnDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("EnPnDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IiDataTypeResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/* w ww.j a v a 2 s. c o m*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { IiDataType searchObject = new IiDataType(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.datatype.IiDataType", searchObject); String id = ""; if (results != null && results.size() > 0) { IiDataType obj = (IiDataType) ((List) results).get(0); Integer idVal = obj.getId(); id = new Integer(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/IiDataType/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("IiDataType" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }