Package org.zanata.util

Examples of org.zanata.util.ZanataRestCaller


    @Feature(summary = "A maintainer user may pull translations from a project",
            tcmsTestPlanIds = 5316, tcmsTestCaseIds = 136564)
    @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
    public void projectMaintainerPullTest() throws IOException {
        ZanataRestCaller restCaller = new ZanataRestCaller("translator",
                PropertiesHolder
                        .getProperty(Constants.zanataTranslatorKey.value()));
        File workDir = Files.createTempDir();
        String projectSlug = "pull-test";
        String iterationSlug = "master";
        String projectType = "properties";
        restCaller.createProjectAndVersion(projectSlug, iterationSlug,
                projectType);
        // generate a properties source
        makePropertiesFile(new File(workDir, "prop1.properties"), ImmutableMap
                .<String, String> builder().put("hello", "hello world").build());
        makePropertiesFile(new File(workDir, "prop2.properties"), ImmutableMap
                .<String, String> builder().put("greeting", "hey buddy")
                .build());

        // copy a pom file
        generateZanataXml(new File(workDir, "zanata.xml"), projectSlug,
                iterationSlug, projectType, Lists.newArrayList("pl"));

        client.callWithTimeout(workDir,
                "mvn -B org.zanata:zanata-maven-plugin:push -Dzanata.userConfig="
                        + translatorConfig);

        // only message1 has translation
        TranslationsResource translationsResource =
                buildTranslationResource(buildTextFlowTarget("hello",
                        "translated"));
        restCaller.postTargetDocResource(projectSlug, iterationSlug, "prop1",
                new LocaleId("pl"), translationsResource, "auto");

        // dryRun creates nothing
        File transDir = Files.createTempDir();
        client.callWithTimeout(workDir,
View Full Code Here


    @DataPoint
    public static String TEST_html = "html";

    @Before
    public void before() {
        zanataRestCaller = new ZanataRestCaller();
        new BasicWorkFlow().goToHome().deleteCookiesAndRefresh();
        assumeFalse(
                "",
                new File(CleanDocumentStorageRule.getDocumentStoragePath()
                        .concat(File.separator).concat("documents")
View Full Code Here

    public void setUp() throws Exception {
        for (LocaleId locale : translatedLocales) {
            SampleDataResourceClient.addLanguage(locale.getId());
        }

        restCaller = new ZanataRestCaller();
        String projectType = ProjectType.Utf8Properties.name().toLowerCase();
        restCaller.createProjectAndVersion(PROJECT_SLUG, "master",
                projectType);
        restCaller.createProjectAndVersion(PROJECT_SLUG, "3.3",
                projectType);
View Full Code Here

    private TestFileGenerator testFileGenerator = new TestFileGenerator();
    private ZanataRestCaller zanataRestCaller;

    @Before
    public void before() {
        zanataRestCaller = new ZanataRestCaller();
        new BasicWorkFlow().goToHome().deleteCookiesAndRefresh();
        assumeFalse(
                "",
                new File(CleanDocumentStorageRule.getDocumentStoragePath()
                        .concat(File.separator).concat("documents")
View Full Code Here

    private String userConfigPath = ClientWorkFlow
            .getUserConfigPath("admin");

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

    @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION)
    public void canLimitConcurrentRestRequestsPerAPIKey() throws Exception {
        // translator creates the project/version
        final String projectSlug = "project";
        final String iterationSlug = "version";
        new ZanataRestCaller(TRANSLATOR, TRANSLATOR_API)
                .createProjectAndVersion(projectSlug, iterationSlug, "gettext");

        ClientRequest clientRequest =
                clientRequestAsAdmin("rest/configurations/"
                        + maxConcurrentPathParam);
        clientRequest.body(MediaType.TEXT_PLAIN_TYPE, "2");

        checkStatusAndReleaseConnection(clientRequest.put());

        // prepare to fire multiple REST requests
        final AtomicInteger atomicInteger = new AtomicInteger(1);

        // requests from translator user
        final int translatorThreads = 3;
        Callable<Integer> translatorTask = new Callable<Integer>() {

            @Override
            public Integer call() {
                return invokeRestService(new ZanataRestCaller(TRANSLATOR,
                        TRANSLATOR_API), projectSlug, iterationSlug,
                        atomicInteger);
            }
        };
        List<Callable<Integer>> translatorTasks =
                Collections.nCopies(translatorThreads, translatorTask);

        // requests from admin user
        int adminThreads = 2;
        Callable<Integer> adminTask = new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return invokeRestService(new ZanataRestCaller(), projectSlug,
                        iterationSlug, atomicInteger);
            }
        };

        List<Callable<Integer>> adminTasks =
View Full Code Here

    @DataPoint
    public static String TEST_ODP = "odp";

    @Before
    public void before() {
        zanataRestCaller = new ZanataRestCaller();
        new BasicWorkFlow().goToHome().deleteCookiesAndRefresh();
        assumeFalse(
                "",
                new File(CleanDocumentStorageRule.getDocumentStoragePath()
                        .concat(File.separator).concat("documents")
View Full Code Here

    public SampleProjectRule rule = new SampleProjectRule();
    private ZanataRestCaller restCaller;

    @Before
    public void setUp() throws Exception {
        restCaller = new ZanataRestCaller();
    }
View Full Code Here

    private TestFileGenerator testFileGenerator = new TestFileGenerator();

    @Before
    public void before() {
        zanataRestCaller = new ZanataRestCaller();
        new BasicWorkFlow().goToHome().deleteCookiesAndRefresh();
        assumeFalse(
                "",
                new File(CleanDocumentStorageRule.getDocumentStoragePath()
                        .concat(File.separator).concat("documents")
View Full Code Here

    @Rule
    public SampleProjectRule sampleProjectRule = new SampleProjectRule();

    @Before
    public void setUp() {
        ZanataRestCaller restCaller = new ZanataRestCaller();
        Resource sourceResource =
                buildSourceResource(document,
                        buildTextFlow("res1", "hello world"),
                        buildTextFlow("res2", "greetings"),
                        buildTextFlow("res3", "hey"));
        restCaller.postSourceDocResource("about-fedora", "master",
                sourceResource, false);
        new LoginWorkFlow().signIn("admin", "admin");
    }
View Full Code Here

TOP

Related Classes of org.zanata.util.ZanataRestCaller

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.