001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Vladimir Pasquier <vpasquier@nuxeo.com> 016 */ 017package org.nuxeo.ecm.automation.test.repository; 018 019import java.io.File; 020import java.io.Serializable; 021 022import org.nuxeo.common.utils.FileUtils; 023import org.nuxeo.ecm.core.api.Blobs; 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.core.api.impl.blob.FileBlob; 027import org.nuxeo.ecm.core.test.DefaultRepositoryInit; 028import org.nuxeo.runtime.transaction.TransactionHelper; 029 030/** 031 * @since 7.3 032 */ 033public class AutomationRepositoryInit extends DefaultRepositoryInit { 034 035 @Override 036 public void populate(CoreSession session) { 037 super.populate(session); 038 DocumentModel doc = session.createDocumentModel("/", "testBlob", "File"); 039 doc.setPropertyValue("file:content", (Serializable) Blobs.createBlob("one")); 040 session.createDocument(doc); 041 File docFile = FileUtils.getResourceFileFromContext("hello.doc"); 042 DocumentModel doc2 = session.createDocumentModel("/", "testBlob2", "File"); 043 doc2.setPropertyValue("file:content", new FileBlob(docFile)); 044 session.createDocument(doc2); 045 TransactionHelper.commitOrRollbackTransaction(); 046 TransactionHelper.startTransaction(); 047 } 048}