@Test public void testDeleteConfValue_3() throws Exception { String propertyName = ""; String file = "abcde.xml"; boolean result = xmlManipulator.deleteConfValue(file, propertyName); FileUtils.deleteQuietly(new File(file)); assertEquals(false, result); }
@Override public boolean deleteConfValue(String file, String propertyName) { try { JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File confFile = new File(file); Configuration configuration = (Configuration) unmarshaller .unmarshal(confFile); boolean status = false; List<Property> propertyList = configuration.getProperty(); for (Iterator<Property> iterator = propertyList.iterator(); iterator .hasNext();) { Property property = iterator.next(); if (property.getName().equals(propertyName)) { status = configuration.getProperty().remove(property); break; } } if (status) { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(configuration, confFile); return true; } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }
XMLManipulator implements Manipulatable { @Override public boolean deleteConfValue(String file, String propertyName) { try { JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File confFile = new File(file); Configuration configuration = (Configuration) unmarshaller .unmarshal(confFile); boolean status = false; List<Property> propertyList = configuration.getProperty(); for (Iterator<Property> iterator = propertyList.iterator(); iterator .hasNext();) { Property property = iterator.next(); if (property.getName().equals(propertyName)) { status = configuration.getProperty().remove(property); break; } } if (status) { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(configuration, confFile); return true; } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; } }
XMLManipulator implements Manipulatable { @Override public boolean deleteConfValue(String file, String propertyName) { try { JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File confFile = new File(file); Configuration configuration = (Configuration) unmarshaller .unmarshal(confFile); boolean status = false; List<Property> propertyList = configuration.getProperty(); for (Iterator<Property> iterator = propertyList.iterator(); iterator .hasNext();) { Property property = iterator.next(); if (property.getName().equals(propertyName)) { status = configuration.getProperty().remove(property); break; } } if (status) { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(configuration, confFile); return true; } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }  }
XMLManipulator implements Manipulatable { @Override public boolean deleteConfValue(String file, String propertyName) { try { JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File confFile = new File(file); Configuration configuration = (Configuration) unmarshaller .unmarshal(confFile); boolean status = false; List<Property> propertyList = configuration.getProperty(); for (Iterator<Property> iterator = propertyList.iterator(); iterator .hasNext();) { Property property = iterator.next(); if (property.getName().equals(propertyName)) { status = configuration.getProperty().remove(property); break; } } if (status) { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(configuration, confFile); return true; } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }  @Override boolean deleteConfValue(String file, String propertyName); @Override boolean editConfValue(String file, String propertyName,
			String newPropertyValue); @Override boolean writeConfValue(String file, String propertyName,
			String propertyValue); @Override String readConfValue(String file, String propertyName); }
XMLManipulator implements Manipulatable { @Override public boolean deleteConfValue(String file, String propertyName) { try { JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File confFile = new File(file); Configuration configuration = (Configuration) unmarshaller .unmarshal(confFile); boolean status = false; List<Property> propertyList = configuration.getProperty(); for (Iterator<Property> iterator = propertyList.iterator(); iterator .hasNext();) { Property property = iterator.next(); if (property.getName().equals(propertyName)) { status = configuration.getProperty().remove(property); break; } } if (status) { Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(configuration, confFile); return true; } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }  @Override boolean deleteConfValue(String file, String propertyName); @Override boolean editConfValue(String file, String propertyName,
			String newPropertyValue); @Override boolean writeConfValue(String file, String propertyName,
			String propertyValue); @Override String readConfValue(String file, String propertyName);  }