@Test public void testLoadCorrectJbossWeb() throws Exception { final VirtualFile jbossWebxml = mock(VirtualFile.class); when(jbossWebxml.exists()).thenReturn(Boolean.TRUE); when(jbossWebxml.openStream()) .thenReturn( JBossWebParsingDeploymentProcessorTest.class.getResourceAsStream("jboss-web.xml")); final VirtualFile deploymentRoot = mock(VirtualFile.class); when(deploymentRoot.getChild("WEB-INF/jboss-web.xml")).thenReturn(jbossWebxml); final ResourceRoot resourceRoot = mock(ResourceRoot.class); when(resourceRoot.getRoot()).thenReturn(deploymentRoot); when(deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT)) .thenReturn(resourceRoot); processor.deploy(phaseContext); }
@Test public void testLoadIncorrectJbossWeb() throws Exception { expectedException.expect(DeploymentUnitProcessingException.class); expectedException.expectMessage( "JBAS018014: Failed to parse XML descriptor \"/content/basic.war/WEB-INF/jboss-web.xml\" at [4,5]"); final VirtualFile jbossWebxml = mock(VirtualFile.class); when(jbossWebxml.exists()).thenReturn(Boolean.TRUE); when(jbossWebxml.openStream()) .thenReturn( JBossWebParsingDeploymentProcessorTest.class.getResourceAsStream( "jboss-error-web.xml")); when(jbossWebxml.toString()).thenReturn("\"/content/basic.war/WEB-INF/jboss-web.xml\""); final VirtualFile deploymentRoot = mock(VirtualFile.class); when(deploymentRoot.getChild("WEB-INF/jboss-web.xml")).thenReturn(jbossWebxml); final ResourceRoot resourceRoot = mock(ResourceRoot.class); when(resourceRoot.getRoot()).thenReturn(deploymentRoot); when(deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT)) .thenReturn(resourceRoot); processor.deploy(phaseContext); }