Package org.openengsb.core.api.context

Examples of org.openengsb.core.api.context.ContextHolder


        // mock auth context
        AuthenticationContext authenticationContext = mock(AuthenticationContext.class);
        when(authenticationContext.getAuthenticatedPrincipal()).thenReturn("testUser");

        // mock context
        ContextHolder contextHolder = ContextHolder.get();
        contextHolder.setCurrentContextId("testContext");

        // commit converter
        converter = new CommitConverter(authenticationContext, contextHolder);
    }
View Full Code Here


public class ContextHolderTest {

    @Test
    public void testContextHolderHasInitialContext_contextShouldBeNotNull() throws Exception {
        ContextHolder context = ContextHolder.get();
        assertThat(context, notNullValue());
    }
View Full Code Here

        assertThat(context, notNullValue());
    }

    @Test
    public void testGetContext_shouldReturnCurrentContext() throws Exception {
        ContextHolder context = ContextHolder.get();
        context.setCurrentContextId("foo");
        String contextId = context.getCurrentContextId();
        assertThat(contextId, is("foo"));
    }
View Full Code Here

        assertThat(contextId, is("foo"));
    }

    @Test
    public void testContextIsNotModifiedByChildThread_contextShouldBeUnchanged() throws Exception {
        ContextHolder context = ContextHolder.get();
        context.setCurrentContextId("foo");
        Callable<String> task = new Callable<String>() {
            @Override
            public String call() throws Exception {
                ContextHolder.get().setCurrentContextId("bar");
                return ContextHolder.get().getCurrentContextId();
            }
        };
        String result = Executors.newSingleThreadExecutor().submit(task).get();
        assertThat(result, is("bar"));
        assertThat(context.getCurrentContextId(), is("foo"));
    }
View Full Code Here

        assertThat(context.getCurrentContextId(), is("foo"));
    }

    @Test
    public void testContextIsAccessibleFromChildThread_shouldGetUnchangedContext() throws Exception {
        ContextHolder context = ContextHolder.get();
        context.setCurrentContextId("foo");
        Callable<String> task = new Callable<String>() {
            @Override
            public String call() throws Exception {
                return ContextHolder.get().getCurrentContextId();
            }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.context.ContextHolder

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.