Package com.alibaba.mtc.testmodel

Examples of com.alibaba.mtc.testmodel.Call


    @Test
    public void test_MtContextCallable_inSameThread() throws Exception {
        ConcurrentMap<String, MtContextThreadLocal<String>> mtContexts = createTestMtContexts();

        Call call = new Call("1", mtContexts);
        MtContextCallable<String> mtContextCallable = MtContextCallable.<String>get(call);

        // create after new Task, won't see parent value in in task!
        MtContextThreadLocal<String> after = new MtContextThreadLocal<String>();
        after.set(PARENT_AFTER_CREATE_MTC_TASK);
View Full Code Here


    @Test
    public void test_MtContextCallable_withExecutorService() throws Exception {
        ConcurrentMap<String, MtContextThreadLocal<String>> mtContexts = createTestMtContexts();

        Call call = new Call("1", mtContexts);
        MtContextCallable<String> mtContextCallable = MtContextCallable.get(call);

        // create after new Task, won't see parent value in in task!
        MtContextThreadLocal<String> after = new MtContextThreadLocal<String>();
        after.set(PARENT_AFTER_CREATE_MTC_TASK);
View Full Code Here

    @Test
    public void test_testRemove() throws Exception {
        ConcurrentMap<String, MtContextThreadLocal<String>> mtContexts = createTestMtContexts();
        mtContexts.get(PARENT_UNMODIFIED_IN_CHILD).remove();

        Call call = new Call("1", mtContexts);
        MtContextCallable<String> mtContextCallable = MtContextCallable.get(call);

        // create after new Task, won't see parent value in in task!
        MtContextThreadLocal<String> after = new MtContextThreadLocal<String>();
        after.set(PARENT_AFTER_CREATE_MTC_TASK);
View Full Code Here

    @Test
    public void test_releaseMtContextAfterCall() throws Exception {
        ConcurrentMap<String, MtContextThreadLocal<String>> mtContexts = createTestMtContexts();

        Call call = new Call("1", mtContexts);
        MtContextCallable<String> mtContextCallable = MtContextCallable.get(call, true);
        assertSame(call, mtContextCallable.getCallable());

        Future future = executorService.submit(mtContextCallable);
        assertEquals("ok", future.get());
View Full Code Here

        }
    }

    @Test
    public void test_sameCall() throws Exception {
        Call call = new Call("1", null);
        MtContextCallable<String> mtContextCallable = MtContextCallable.get(call);
        assertSame(call, mtContextCallable.getCallable());
    }
View Full Code Here

        assertSame(call, mtContextCallable.getCallable());
    }

    @Test
    public void test_get_idempotent() throws Exception {
        MtContextCallable<String> call = MtContextCallable.get(new Call("1", null));
        try {
            MtContextCallable.get(call);
            fail();
        } catch (IllegalStateException e) {
            assertThat(e.getMessage(), containsString("Already MtContextCallable"));
View Full Code Here

        assertNull(MtContextCallable.get(null));
    }

    @Test
    public void test_gets() throws Exception {
        Callable<String> call1 = new Call("1", null);
        Callable<String> call2 = new Call("1", null);
        Callable<String> call3 = new Call("1", null);

        @SuppressWarnings("unchecked")
        List<MtContextCallable<String>> callList = MtContextCallable.gets(
                Arrays.asList(call1, call2, null, call3));
View Full Code Here

        assertTask1(task.copied);
    }

    @Test
    public void test_submit() throws Exception {
        Call call = new Call("1", mtContexts);

        // create after new Task, won't see parent value in in task!
        setLocalAfter();

        Future future = executorService.submit(call);
View Full Code Here

        assertTask1(task.copied);
    }

    @Test
    public void test_invokeAll() throws Exception {
        Call call1 = new Call("1", mtContexts);
        Call call2 = new Call("2", mtContexts);

        setLocalAfter();

        List<Future<String>> futures = executorService.invokeAll(Arrays.asList(call1, call2));
        for (Future<String> future : futures) {
View Full Code Here

        assertTask2(call2.copied);
    }

    @Test
    public void test_invokeAll_timeout() throws Exception {
        Call call1 = new Call("1", mtContexts);
        Call call2 = new Call("2", mtContexts);

        setLocalAfter();

        List<Future<String>> futures = executorService.invokeAll(Arrays.asList(call1, call2), 10, TimeUnit.SECONDS);
        for (Future<String> future : futures) {
View Full Code Here

TOP

Related Classes of com.alibaba.mtc.testmodel.Call

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.