/** * Saves an application descriptor. * @param f the file where the properties will be saved * @param app an application (not null) * @throws IOException if the file could not be written */ public static void save( File f, Application app ) throws IOException { Properties properties = new Properties(); if( ! Utils.isEmptyOrWhitespaces( app.getDisplayName())) properties.setProperty( APPLICATION_NAME, app.getDisplayName()); if( ! Utils.isEmptyOrWhitespaces( app.getDescription())) properties.setProperty( APPLICATION_DESCRIPTION, app.getDescription()); if( app.getTemplate() != null ) { if( ! Utils.isEmptyOrWhitespaces( app.getTemplate().getName())) properties.setProperty( APPLICATION_TPL_NAME, app.getTemplate().getName()); if( ! Utils.isEmptyOrWhitespaces( app.getTemplate().getVersion())) properties.setProperty( APPLICATION_TPL_VERSION, app.getTemplate().getVersion()); } Utils.writePropertiesFile( properties, f ); } }
generator.writeStringField( NAME, app.getName()); if( app.getDisplayName() != null ) generator.writeStringField( DISPLAY_NAME, app.getDisplayName());
@Test public void testSetNameWithAccents() { Application app = new Application( "avé dés àcçents", new TestApplicationTemplate()); Assert.assertEquals( "ave des accents", app.getName()); Assert.assertEquals( "avé dés àcçents", app.getDisplayName()); app.setName( " " ); Assert.assertEquals( "", app.getName()); Assert.assertEquals( "", app.getDisplayName()); app.setName( null ); Assert.assertNull( app.getName()); Assert.assertNull( app.getDisplayName()); app.setName( " âêû éèà " ); Assert.assertEquals( "aeu eea", app.getName()); Assert.assertEquals( "âêû éèà", app.getDisplayName()); } }