001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Vladimir Pasquier <[email protected]> 018 */ 019package org.nuxeo.ecm.automation.test.repository; 020 021import java.io.File; 022import java.io.Serializable; 023 024import org.nuxeo.common.utils.FileUtils; 025import org.nuxeo.ecm.core.api.Blobs; 026import org.nuxeo.ecm.core.api.CoreSession; 027import org.nuxeo.ecm.core.api.DocumentModel; 028import org.nuxeo.ecm.core.api.impl.blob.FileBlob; 029import org.nuxeo.ecm.core.test.DefaultRepositoryInit; 030import org.nuxeo.runtime.transaction.TransactionHelper; 031 032/** 033 * @since 7.3 034 */ 035public class AutomationRepositoryInit extends DefaultRepositoryInit { 036 037 @Override 038 public void populate(CoreSession session) { 039 super.populate(session); 040 DocumentModel doc = session.createDocumentModel("/", "testBlob", "File"); 041 doc.setPropertyValue("file:content", (Serializable) Blobs.createBlob("one")); 042 session.createDocument(doc); 043 File docFile = FileUtils.getResourceFileFromContext("hello.doc"); 044 DocumentModel doc2 = session.createDocumentModel("/", "testBlob2", "File"); 045 doc2.setPropertyValue("file:content", new FileBlob(docFile)); 046 session.createDocument(doc2); 047 TransactionHelper.commitOrRollbackTransaction(); 048 TransactionHelper.startTransaction(); 049 } 050}