EndpointReplacer extends AbstractTestLifeCycleElement { public void changeDeployment(IDeployment d, TestSuite testSuite) throws DeploymentException { List<String> partnerTrackNames = getPartnerTrackNames(testSuite); for (IBPELProcess p : d.getBPELProcesses()) { List<String> partnerLinkNames = getPartnerLinkNamesWithPartnerRole(p .getProcessModel()); partnerLinkNames.retainAll(partnerTrackNames); for (String partnerLinkName : partnerLinkNames) { p.changePartnerEndpoint(partnerLinkName, getEndpointForPartnerTrack(testSuite, partnerLinkName)); } } }  @Override void doPrepareProcesses(IBPELUnitContext context); void changeDeployment(IDeployment d, TestSuite testSuite);  }
@Test public void testReplacementAllPartnersAreMockedSingleProcess() throws Exception { TestSuite ts = createTestSuite(); addPartnerTrack(ts, "Provider"); addPartnerTrack(ts, "Provider2"); DeploymentMock deployment = new DeploymentMock("tc1.bpel"); endpointReplacer.changeDeployment(deployment, ts); BPELProcessMock process = deployment.getBPELProcesses().get(0); Map<String, String> changedEndpoints = process.getChangedEndpoints(); assertEquals(2, changedEndpoints.size()); assertEquals("http: assertEquals("http: }
@Test public void testReplacementNotAllPartnersAreMockedSingleProcess() throws Exception { TestSuite ts = createTestSuite(); addPartnerTrack(ts, "Provider"); addPartnerTrack(ts, "Provider2"); addPartnerTrack(ts, "ProviderUnused"); DeploymentMock deployment = new DeploymentMock("tc1.bpel"); endpointReplacer.changeDeployment(deployment, ts); BPELProcessMock process = deployment.getBPELProcesses().get(0); Map<String, String> changedEndpoints = process.getChangedEndpoints(); assertEquals(2, changedEndpoints.size()); assertEquals("http: assertEquals("http: }
@Test public void testReplacementNotAllPartnerLinksAreMockedSingleProcess() throws Exception { TestSuite ts = createTestSuite(); addPartnerTrack(ts, "Provider"); DeploymentMock deployment = new DeploymentMock("tc1.bpel"); endpointReplacer.changeDeployment(deployment, ts); BPELProcessMock process = deployment.getBPELProcesses().get(0); Map<String, String> changedEndpoints = process.getChangedEndpoints(); assertEquals(1, changedEndpoints.size()); assertEquals("http: }
@Test public void testReplacementAllPartnersAreMockedTwoProcesses() throws Exception { TestSuite ts = createTestSuite(); addPartnerTrack(ts, "Provider"); addPartnerTrack(ts, "Provider2"); DeploymentMock deployment = new DeploymentMock("tc1.bpel", "tc1.bpel"); endpointReplacer.changeDeployment(deployment, ts); BPELProcessMock process = deployment.getBPELProcesses().get(0); Map<String, String> changedEndpoints = process.getChangedEndpoints(); assertEquals(2, changedEndpoints.size()); assertEquals("http: assertEquals("http: process = deployment.getBPELProcesses().get(1); changedEndpoints = process.getChangedEndpoints(); assertEquals(2, changedEndpoints.size()); assertEquals("http: assertEquals("http: }