@Test public void testEditConfValue_3() throws Exception { String filePath = "test.xml"; String propertyName = "test"; String newPropertyValue = "0123456789"; boolean result = xmlManipulator.editConfValue(filePath, propertyName, newPropertyValue); assertEquals(false, result); }
@Override public boolean editConfValue(String file, String propertyName, String newPropertyValue) { try { File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); return false; } JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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) { return marshallObject(propertyName, newPropertyValue, jaxbContext, confFile, configuration); } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }
XMLManipulator implements Manipulatable { @Override public boolean editConfValue(String file, String propertyName, String newPropertyValue) { try { File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); return false; } JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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) { return marshallObject(propertyName, newPropertyValue, jaxbContext, confFile, configuration); } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; } }
XMLManipulator implements Manipulatable { @Override public boolean editConfValue(String file, String propertyName, String newPropertyValue) { try { File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); return false; } JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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) { return marshallObject(propertyName, newPropertyValue, jaxbContext, confFile, configuration); } else { return false; } } catch (JAXBException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }  }
XMLManipulator implements Manipulatable { @Override public boolean editConfValue(String file, String propertyName, String newPropertyValue) { try { File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); return false; } JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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) { return marshallObject(propertyName, newPropertyValue, jaxbContext, confFile, configuration); } 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 editConfValue(String file, String propertyName, String newPropertyValue) { try { File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); return false; } JAXBContext jaxbContext = JAXBContext .newInstance("com.impetus.ankush.agent.action.impl"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 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) { return marshallObject(propertyName, newPropertyValue, jaxbContext, confFile, configuration); } 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);  }