@@ -0,0 +1,2335 @@
+/*******************************************************************************%0A *  Copyright (c) 2016 Obeo. %0A *  All rights reserved. This program and the accompanying materials%0A *  are made available under the terms of the Eclipse Public License v1.0%0A *  which accompanies this distribution, and is available at%0A *  http://www.eclipse.org/legal/epl-v10.html%0A *   %0A *   Contributors:%0A *       Obeo - initial API and implementation%0A *  %0A *******************************************************************************/%0Apackage org.obeonetwork.wgen.generator.test;%0A%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.math.BigInteger;%0A%0Aimport org.apache.poi.openxml4j.exceptions.InvalidFormatException;%0Aimport org.apache.poi.openxml4j.opc.OPCPackage;%0Aimport org.apache.poi.xwpf.usermodel.XWPFDocument;%0Aimport org.junit.Test;%0Aimport org.obeonetwork.wgen.generator.DocumentGenerationException;%0Aimport org.obeonetwork.wgen.parser.DocumentParserException;%0Aimport org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;%0Aimport org.openxmlformats.schemas.wordprocessingml.x2006.main.CTMarkupRange;%0A%0Apublic class BookmarkTest %7B%0A%0A%09public BookmarkTest() %7B%0A%09%09// TODO Auto-generated constructor stub%0A%09%7D%0A%0A%09@Test%0A%09public void testStaticFragmentWithFieldProcessing()%0A%09%09%09throws InvalidFormatException, IOException, DocumentParserException, DocumentGenerationException %7B%0A%09%09FileInputStream is = new FileInputStream(%22templates/test2.docx%22);%0A%09%09OPCPackage oPackage = OPCPackage.open(is);%0A%09%09XWPFDocument document = new XWPFDocument(oPackage);%0A%09%09// insert some static content.%0A%09%09document.createParagraph().createRun().setText(%22static part that will not contain any link%22);%0A%09%09CTBookmark bookmark = document.getDocument().getBody().addNewBookmarkStart();%0A%09%09bookmark.setName(%22bookmark1%22);%0A%09%09bookmark.setId(new BigInteger(%2266%22));%0A%09%09document.createParagraph().createRun().setText(%22bookmarked part%22);%0A%09%09CTMarkupRange range = document.getDocument().getBody().addNewBookmarkEnd();%0A%09%09range.setId(new BigInteger(%2266%22));%0A%09%09document.createParagraph().createRun().setText(%22another static part that will not contain any link%22);%0A%09%09// save the document in another file%0A%09%09FileOutputStream fos = new FileOutputStream(%22results/bookmarkTest.docx%22);%0A%09%09document.write(fos);%0A%09%09document.close();%0A%09%09fos.close();%0A%09%7D%0A%0A%7D%0A

test the bookmark mecanism