Package org.fedorahosted.openprops

Examples of org.fedorahosted.openprops.Properties


        }
        return sb.toString();
    }

    public static String listToHeader(List<HeaderEntry> entries) {
        Properties props = new Properties();
        for (HeaderEntry entry : entries) {
            props.setProperty(entry.getKey(), entry.getValue());
        }
        return propertiesToHeader(props);
    }
View Full Code Here


        // return buffer.substring(newline+lineSep.length());
        return writer.toString();
    }

    public static List<HeaderEntry> headerToList(String entries) {
        Properties props = headerToProperties(entries);
        List<HeaderEntry> result = new ArrayList<HeaderEntry>();
        for (String key : props.keySet()) {
            result.add(new HeaderEntry(key, props.getProperty(key)));
        }
        return result;
    }
View Full Code Here

        }
        return result;
    }

    public static Properties headerToProperties(String entries) {
        Properties result = new Properties();
        try {
            result.load(new StringReader(entries));
        } catch (IOException e) {
            throw new RuntimeException("unexpected IO exception", e);
        }
        return result;
    }
View Full Code Here

    @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");
    }
View Full Code Here

                "-Dzanata.userConfig=" + userConfigPath);

        assertThat(client.isPushSuccessful(output)).isTrue();
        File transFile = new File(tempDir, "test_pl.properties");
        assertThat(transFile.exists()).isTrue();
        Properties translations = new Properties();
        translations.load(new FileReader(transFile));
        assertThat(translations.size()).isEqualTo(1);
        assertThat(translations.getProperty("hey"))
                .isEqualTo("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="
View Full Code Here

        }
    }

    public static void makePropertiesFile(File file,
            Map<String, String> entries) throws IOException {
        Properties resource = new Properties();
        for (Map.Entry<String, String> entry : entries.entrySet()) {
            resource.setProperty(entry.getKey(), entry.getValue());
        }
        resource.store(new FileWriter(file), null);
    }
View Full Code Here

public class PoUtilityTest {
    String lineSep = System.getProperty("line.separator");

    @Test
    public void testHeaderEntriesToString() throws Exception {
        Properties entries = new Properties();
        assertEquals("", PoUtility.propertiesToHeader(entries));
        entries.setProperty("key", "value");
        assertEquals("key=value" + lineSep,
                PoUtility.propertiesToHeader(entries));
        entries.setProperty("key2", "value2");
        assertEquals("key=value" + lineSep + "key2=value2" + lineSep,
                PoUtility.propertiesToHeader(entries));
        entries.keySet().clear();
        entries.setProperty("key with\na newline and spaces", "value");
        assertEquals("key\\ with\\na\\ newline\\ and\\ spaces=value" + lineSep,
                PoUtility.propertiesToHeader(entries));
    }
View Full Code Here

                PoUtility.propertiesToHeader(entries));
    }

    @Test
    public void testStringToHeaderEntries() throws Exception {
        Properties expected = new Properties();
        assertEqual(expected, PoUtility.headerToProperties(""));
        expected.setProperty("key", "value");
        assertEqual(expected, PoUtility.headerToProperties("key=value"));
        expected.setProperty("key2", "value2");
        assertEqual(expected,
                PoUtility.headerToProperties("key=value\nkey2=value2"));
        expected.setProperty("key1", "value1");
        assertEqual(
                expected,
                PoUtility
                        .headerToProperties("key=value\nkey2=value2\nkey1=value1"));
    }
View Full Code Here

TOP

Related Classes of org.fedorahosted.openprops.Properties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.