Package org.jboss.as.server.deployment

Examples of org.jboss.as.server.deployment.SimpleAttachable


    public static DeploymentUnit mockDeploymentUnit() {
        return mockDeploymentUnit("Mock Deployment Unit");
    }

    public static DeploymentUnit mockDeploymentUnit(String duName) {
        final Attachable attachable = new SimpleAttachable();
        final DeploymentUnit deploymentUnit = mock(DeploymentUnit.class);
        when(deploymentUnit.getName()).thenReturn(duName);

        when(deploymentUnit.getAttachment((AttachmentKey<Object>) any())).thenAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                AttachmentKey<?> key = (AttachmentKey<?>) invocation.getArguments()[0];
                return attachable.getAttachment(key);
            }
        });
        when(deploymentUnit.putAttachment((AttachmentKey<Object>) any(), any())).thenAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                AttachmentKey<Object> key = (AttachmentKey<Object>) invocation.getArguments()[0];
                Object value = invocation.getArguments()[1];
                return attachable.putAttachment(key, value);
            }
        });
        ServiceName deploymentUnitServiceName = Services.deploymentUnitName(duName);
        when(deploymentUnit.getServiceName()).thenReturn(deploymentUnitServiceName);
        return deploymentUnit;
View Full Code Here

TOP

Related Classes of org.jboss.as.server.deployment.SimpleAttachable

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.