@Before public void setUp() throws IOException { restCaller = new ZanataRestCaller(); // generate a properties source Properties properties = new Properties(); properties.setProperty("hello", "hello world"); properties.setProperty("greeting", "this is from Huston"); properties.setProperty("hey", "hey hey"); File propertiesSource = new File(tempDir, "test.properties"); properties.store(new FileWriter(propertiesSource), "comment"); }
@Test public void canPushAndPullProperties() throws IOException, InterruptedException { restCaller.createProjectAndVersion("properties-test", "master", "properties"); // generate a zanata.xml TestFileGenerator.generateZanataXml( new File(tempDir, "zanata.xml"), "properties-test", "master", "properties", Lists.newArrayList("pl")); List<String> output = client.callWithTimeout( tempDir, "mvn -B org.zanata:zanata-maven-plugin:push -Dzanata.srcDir=. -Dzanata.userConfig=" + userConfigPath); assertThat(client.isPushSuccessful(output), Matchers.equalTo(true)); EditorPage editorPage = verifyPushedToEditor().setSyntaxHighlighting(false); editorPage = editorPage .translateTargetAtRowIndex(2, "translation updated approved") .approveTranslationAtRow(2); editorPage.translateTargetAtRowIndex(1, "translation updated fuzzy").saveAsFuzzyAtRow(1); output = client.callWithTimeout( tempDir, "mvn -B org.zanata:zanata-maven-plugin:pull -Dzanata.userConfig=" + userConfigPath); assertThat(client.isPushSuccessful(output), Matchers.is(true)); File transFile = new File(tempDir, "test_pl.properties"); assertThat(transFile.exists(), Matchers.is(true)); Properties translations = new Properties(); translations.load(new FileReader(transFile)); assertThat(translations.size(), Matchers.is(1)); assertThat(translations.getProperty("hey"), Matchers.equalTo("translation updated approved")); // change on client side translations.setProperty("greeting", "translation updated on client"); translations.store(new FileWriter(transFile), null); // push again client.callWithTimeout( tempDir, "mvn -B org.zanata:zanata-maven-plugin:push -Dzanata.pushType=trans -Dzanata.srcDir=. -Dzanata.userConfig=" + userConfigPath); final EditorPage editor = new BasicWorkFlow() .goToPage( String.format( BasicWorkFlow.EDITOR_TEMPLATE, "properties-test", "master", "pl", "test"), EditorPage.class); assertThat( editor.getMessageTargetAtRowIndex(1), Matchers.equalTo("translation updated on client")); }