@Test public void testSetup() throws Exception { Project project = initializeJavaProject(); Shell shell = getShell(); shell.execute("i18n setup"); PropertiesFileResource resource = (PropertiesFileResource) project.getFacet(ResourceFacet.class).getResource("messages.properties"); assertTrue(resource.exists()); }
@Test public void testGetProperty() throws Exception { Project project = initializeJavaProject(); Shell shell = getShell(); shell.execute("i18n setup"); PropertiesFileResource resource = (PropertiesFileResource) project.getFacet(ResourceFacet.class).getResource("messages.properties"); shell.execute("i18n put --key mykey --value myvalue"); assertEquals("myvalue", resource.getProperty("mykey")); shell.execute("i18n get --key mykey"); assertTrue(getOutput().contains("myvalue")); }
@Test public void testRemoveProperty() throws Exception { Project project = initializeJavaProject(); Shell shell = getShell(); shell.execute("i18n setup"); shell.execute("i18n put --key mykey --value myvalue"); shell.execute("i18n add-locale --locale pt_BR"); shell.execute("i18n put --key mykey --value meuvalor"); shell.execute("i18n remove --key mykey"); ResourceFacet resourceFacet = project.getFacet(ResourceFacet.class); PropertiesFileResource resource = (PropertiesFileResource) resourceFacet.getResource("messages.properties"); PropertiesFileResource resource_ptBR = (PropertiesFileResource) resourceFacet.getResource("messages_pt_BR.properties"); assertNull(resource.getProperty("mykey")); assertNull(resource_ptBR.getProperty("mykey")); }