List of usage examples for java.io FileWriter flush
public void flush() throws IOException
From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.twolevelinheritance.LCDMonitorResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from ww w . j av a 2 s . c om * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { LCDMonitor searchObject = new LCDMonitor(); Collection results = getApplicationService().search( "gov.nih.nci.cacoresdk.domain.inheritance.twolevelinheritance.LCDMonitor", searchObject); String id = ""; if (results != null && results.size() > 0) { LCDMonitor obj = (LCDMonitor) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/LCDMonitor/" + 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("LCDMonitor" + "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.inheritance.twolevelinheritance.MonitorResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w ww . j a va2s . c o m*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Monitor searchObject = new Monitor(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.inheritance.twolevelinheritance.Monitor", searchObject); String id = ""; if (results != null && results.size() > 0) { Monitor obj = (Monitor) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Monitor/" + 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("Monitor" + "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.interfaze.DogResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//www. j a va 2 s . c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Dog searchObject = new Dog(); Collection results = getApplicationService().search("gov.nih.nci.cacoresdk.domain.interfaze.Dog", searchObject); String id = ""; if (results != null && results.size() > 0) { Dog obj = (Dog) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Dog/" + 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("Dog" + "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.manytomany.unidirectional.AuthorResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*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 { Author searchObject = new Author(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.manytomany.unidirectional.Author", searchObject); String id = ""; if (results != null && results.size() > 0) { Author obj = (Author) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Author/" + 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("Author" + "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.manytoone.unidirectional.RestaurantResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from w ww. j a v a2 s . co m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Restaurant searchObject = new Restaurant(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.manytoone.unidirectional.Restaurant", searchObject); String id = ""; if (results != null && results.size() > 0) { Restaurant obj = (Restaurant) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Restaurant/" + 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("Restaurant" + "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.manytoone.unidirectional.withjoin.AlbumResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w w w . j a va 2 s . co m*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Album searchObject = new Album(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.manytoone.unidirectional.withjoin.Album", searchObject); String id = ""; if (results != null && results.size() > 0) { Album obj = (Album) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Album/" + 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("Album" + "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.onetomany.unidirectional.LatchKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w w w . j a v a2 s.c om*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { LatchKey searchObject = new LatchKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.onetomany.unidirectional.LatchKey", searchObject); String id = ""; if (results != null && results.size() > 0) { LatchKey obj = (LatchKey) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/LatchKey/" + 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("LatchKey" + "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.onetomany.unidirectional.withjoin.ButtonResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from w w w .j ava2 s .com*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Button searchObject = new Button(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.onetomany.unidirectional.withjoin.Button", searchObject); String id = ""; if (results != null && results.size() > 0) { Button obj = (Button) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Button/" + 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("Button" + "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.onetoone.multipleassociation.ParentResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*ww w . j a v a2s . co m*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { Parent searchObject = new Parent(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.onetoone.multipleassociation.Parent", searchObject); String id = ""; if (results != null && results.size() > 0) { Parent obj = (Parent) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/Parent/" + 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("Parent" + "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.onetoone.multipleassociation.withjoin.InLawResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//w ww .ja v a 2s.c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { InLaw searchObject = new InLaw(); Collection results = getApplicationService().search( "gov.nih.nci.cacoresdk.domain.onetoone.multipleassociation.withjoin.InLaw", searchObject); String id = ""; if (results != null && results.size() > 0) { InLaw obj = (InLaw) ((List) results).get(0); id = obj.getId().getExtension(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/InLaw/" + 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("InLaw" + "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; } }