Source:
<code>public void testNewView() { IViewPart firstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false); IViewPart sameAsFirstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false); IViewPart secondView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), true); IViewPart failView1 = TmfViewFactory.newView("this.is.a.failing.view.id", false); IViewPart failView2 = TmfViewFactory.newView("this.is.a.failing.view.id", true); assertNotNull("Failed to spawn first view", firstView); assertEquals("Same id returned different instance", sameAsFirstView, firstView); assertNotNull("Failed to open second view with suffix", secondView); assertNull("Expected to fail on dummy view id", failView1); assertNull("Expected to fail on dummy view id with suffix", failView2); IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IViewReference[] viewRefs = page.getViewReferences(); String fullId = null; for (IViewReference view : viewRefs) { if (view.getSecondaryId() != null && view.getId().equals(TmfViewStub.TMF_VIEW_STUB_ID)) { assertTrue("Instanceof a <START> TMfViewStub", <END> view.getView(false) instanceof TmfViewStub); fullId = ((TmfViewStub) view.getView(false)).getViewId(); break; } } assertNotNull(fullId); IViewPart thirdView = TmfViewFactory.newView(fullId, true); assertNotNull("Creation from a view id with suffix failed", fullId); assertFalse("New view from view id with suffix was not created", Arrays.asList(viewRefs).contains(thirdView)); }</code><technical_language>Tmf</technical_language>

Target:
public void testNewView() { IViewPart firstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false); IViewPart sameAsFirstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false); IViewPart secondView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), true); IViewPart failView1 = TmfViewFactory.newView("this.is.a.failing.view.id", false); IViewPart failView2 = TmfViewFactory.newView("this.is.a.failing.view.id", true); assertNotNull("Failed to spawn first view", firstView); assertEquals("Same id returned different instance", sameAsFirstView, firstView); assertNotNull("Failed to open second view with suffix", secondView); assertNull("Expected to fail on dummy view id", failView1); assertNull("Expected to fail on dummy view id with suffix", failView2); IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IViewReference[] viewRefs = page.getViewReferences(); String fullId = null; for (IViewReference view : viewRefs) { if (view.getSecondaryId() != null && view.getId().equals(TmfViewStub.TMF_VIEW_STUB_ID)) { assertTrue("Instanceof a TmfViewStub", view.getView(false) instanceof TmfViewStub); fullId = ((TmfViewStub) view.getView(false)).getViewId(); break; } } assertNotNull(fullId); IViewPart thirdView = TmfViewFactory.newView(fullId, true); assertNotNull("Creation from a view id with suffix failed", fullId); assertFalse("New view from view id with suffix was not created", Arrays.asList(viewRefs).contains(thirdView)); }