DeploymentIndex { public BeanContext getDeployment(EJBRequest req) throws RemoteException { BeanContext info = null; int deploymentCode = req.getDeploymentCode(); if (deploymentCode > 0 && deploymentCode < deployments.length) { info = deployments[deploymentCode]; req.setDeploymentId((String) info.getDeploymentID()); return info; } if (req.getDeploymentId() == null) { throw new RemoteException(messages.format("invalidDeploymentIdAndCode", req.getDeploymentId(), req.getDeploymentCode())); } int idCode = getDeploymentIndex(req.getDeploymentId()); if (idCode == -1) { throw new RemoteException(messages.format("noSuchDeploymentIdAndCode", req.getDeploymentId(), req.getDeploymentCode())); } req.setDeploymentCode(idCode); if (req.getDeploymentCode() < 0 || req.getDeploymentCode() >= deployments.length) { throw new RemoteException(messages.format("invalidDeploymentIdAndCode", req.getDeploymentId(), req.getDeploymentCode())); } return deployments[req.getDeploymentCode()]; } DeploymentIndex(BeanContext[] beanContexts); BeanContext getDeployment(EJBRequest req); int getDeploymentIndex(BeanContext deployment); int getDeploymentIndex(String deploymentID); BeanContext getDeployment(String deploymentID); BeanContext getDeployment(Integer index); BeanContext getDeployment(int index);  }
@Test public void testGetDeploymentEJBRequest() throws RemoteException { final EJBMetaDataImpl ejbMetadataWithId = new EJBMetaDataImpl(null, null, null, null, null, 1, InterfaceType.BUSINESS_REMOTE, null, null); final EJBRequest request = new EJBRequest(null, ejbMetadataWithId, method, null, null); final BeanContext info = deploymentIndex.getDeployment(request); Assert.assertEquals(beanContext, info); Assert.assertEquals(request.getDeploymentId(), info.getDeploymentID()); }
@Test(expected = RemoteException.class) public void testGetDeploymentEJBRequestRemoteException() throws RemoteException { final EJBMetaDataImpl ejbMetadata = new EJBMetaDataImpl(null, null, null, null, null, 0, InterfaceType.BUSINESS_REMOTE, null, null); final EJBRequest request = new EJBRequest(null, ejbMetadata, method, null, null); deploymentIndex.getDeployment(request); }