private boolean checkInterest(IInteractionContext activeContext, String id) { boolean found = false; for (IInteractionElement elem : activeContext.getAllElements()) { assertEquals(elem.getContentType(), "ecore"); // $NON-NLS-1$ if (elem.getHandleIdentifier().equals(id)) { found = true; } assertTrue(elem.getInterest().isInteresting()); } return found; }
/** For testing */ public void writeContext( IInteractionContext context, ZipOutputStream outputStream, IInteractionContextWriter writer) throws IOException { String handleIdentifier = context.getHandleIdentifier(); String encoded = URLEncoder.encode(handleIdentifier, InteractionContextManager.CONTEXT_FILENAME_ENCODING); ZipEntry zipEntry = new ZipEntry(encoded + InteractionContextManager.CONTEXT_FILE_EXTENSION_OLD); outputStream.putNextEntry(zipEntry); outputStream.setMethod(ZipOutputStream.DEFLATED); writer.setOutputStream(outputStream); writer.writeContextToStream(context); outputStream.flush(); outputStream.closeEntry(); addAdditionalInformation(outputStream); }
/** * Public for testing. * * @throws IOException if writing of context fails */ public void writeContextToXml( IInteractionContext context, File file, IInteractionContextWriter writer) throws IOException { if (context.getInteractionHistory().isEmpty()) { return; } FileOutputStream fileOutputStream = new FileOutputStream(file); try { ZipOutputStream outputStream = new ZipOutputStream(fileOutputStream); try { writeContext(context, outputStream, writer); } finally { outputStream.close(); } } finally { fileOutputStream.close(); } }