Java Code Examples for org.alfresco.util.TempFileProvider#getTempDir()
The following examples show how to use
org.alfresco.util.TempFileProvider#getTempDir() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadOnlyFileContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); store = new FileContentStore(ctx, tempDir.getAbsolutePath() + File.separatorChar + getName()); // Put some content into it ContentWriter writer = store.getWriter(new ContentContext(null, null)); writer.putContent("Content for getExistingContentUrl"); this.contentUrl = writer.getContentUrl(); // disallow random access store.setReadOnly(true); }
Example 2
Source File: BufferedResponseTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test that the output stream creates a temp file to cache its content when file size was bigger than its memory threshold ( 5 > 4 MB ) * MNT-19833 */ @Test public void testOutputStream() throws IOException { File bufferTempDirectory = TempFileProvider.getTempDir(TEMP_DIRECTORY_NAME); TempOutputStreamFactory streamFactory = new TempOutputStreamFactory(bufferTempDirectory, MEMORY_THRESHOLD, MAX_CONTENT_SIZE, false,true); BufferedResponse response = new BufferedResponse(null, 0, streamFactory); long countBefore = countFilesInDirectoryWithPrefix(bufferTempDirectory, FILE_PREFIX ); copyFileToOutputStream(response); long countAfter = countFilesInDirectoryWithPrefix(bufferTempDirectory, FILE_PREFIX); response.getOutputStream().close(); Assert.assertEquals(countBefore + 1, countAfter); }
Example 3
Source File: SchemaBootstrap.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Dumps the DB schema to temporary file(s), named similarly to: * <pre> * Alfresco-schema-DialectName-whenDumped-dbPrefix-23498732.xml * </pre> * Where the digits serve to create a unique temp file name. If whenDumped is empty or null, * then the output is similar to: * <pre> * Alfresco-schema-DialectName-dbPrefix-23498732.xml * </pre> * If dbPrefixes is null, then the default list is used (see {@link MultiFileDumper#DEFAULT_PREFIXES}) * The dump files' paths are logged at info level. * * @param whenDumped String * @param dbPrefixes Array of database object prefixes to filter by, e.g. "alf_" * @return List of output files. */ private List<File> dumpSchema(String whenDumped, String[] dbPrefixes) { // Build a string to use as the file name template, // e.g. "Alfresco-schema-MySQLDialect-pre-upgrade-{0}-" StringBuilder sb = new StringBuilder(64); sb.append("Alfresco-schema-"). append(dialect.getClass().getSimpleName()); if (whenDumped != null && whenDumped.length() > 0) { sb.append("-"); sb.append(whenDumped); } sb.append("-{0}-"); File outputDir = TempFileProvider.getTempDir(); String fileNameTemplate = sb.toString(); return dumpSchema(outputDir, fileNameTemplate, dbPrefixes); }
Example 4
Source File: ContentCacheImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void canVisitOldestDirsFirst() { File cacheRoot = new File(TempFileProvider.getTempDir(), GUID.generate()); cacheRoot.deleteOnExit(); contentCache.setCacheRoot(cacheRoot); File f1 = tempfile(createDirs("2000/3/30/17/45/31"), "files-are-unsorted.bin"); File f2 = tempfile(createDirs("2000/3/4/17/45/31"), "another-file.bin"); File f3 = tempfile(createDirs("2010/12/24/23/59/58"), "a-second-before.bin"); File f4 = tempfile(createDirs("2010/12/24/23/59/59"), "last-one.bin"); File f5 = tempfile(createDirs("2000/1/7/2/7/12"), "first-one.bin"); // Check that directories and files are visited in correct order FileHandler handler = Mockito.mock(FileHandler.class); contentCache.processFiles(handler); InOrder inOrder = Mockito.inOrder(handler); inOrder.verify(handler).handle(f5); inOrder.verify(handler).handle(f2); inOrder.verify(handler).handle(f1); inOrder.verify(handler).handle(f3); inOrder.verify(handler).handle(f4); }
Example 5
Source File: RoutingContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { File tempDir = TempFileProvider.getTempDir(); // Create a subdirectory for A File storeADir = new File(tempDir, "A"); storeA = new FileContentStore(ctx, storeADir); // Create a subdirectory for B File storeBDir = new File(tempDir, "B"); storeB = new FileContentStore(ctx, storeBDir); // Create a subdirectory for C File storeCDir = new File(tempDir, "C"); storeC = new DumbReadOnlyFileStore(new FileContentStore(ctx, storeCDir)); // No subdirectory for D storeD = new SupportsNoUrlFormatStore(); // Create the routing store routingStore = new RandomRoutingContentStore(storeA, storeB, storeC, storeD); }
Example 6
Source File: AggregatingContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { File tempDir = TempFileProvider.getTempDir(); // create a primary file store String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate(); primaryStore = new FileContentStore(ctx, storeDir); // create some secondary file stores secondaryStores = new ArrayList<ContentStore>(3); for (int i = 0; i < 4; i++) { storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate(); FileContentStore store = new FileContentStore(ctx, storeDir); secondaryStores.add(store); } // Create the aggregating store aggregatingStore = new AggregatingContentStore(); aggregatingStore.setPrimaryStore(primaryStore); aggregatingStore.setSecondaryStores(secondaryStores); }
Example 7
Source File: ModuleManagementToolTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private String extractToDir(String extension, String location) { File tmpDir = TempFileProvider.getTempDir(); try { TFile zipFile = new TFile(this.getClass().getClassLoader().getResource(location).getPath()); TFile outDir = new TFile(tmpDir.getAbsolutePath()+"/moduleManagementToolTestDir"+System.currentTimeMillis()); outDir.mkdir(); zipFile.cp_rp(outDir); TVFS.umount(zipFile); return outDir.getPath(); } catch (Exception e) { e.printStackTrace(); } return null; }
Example 8
Source File: CachingContentStoreSpringTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { File tempDir = TempFileProvider.getTempDir(); backingStore = new FileContentStore(ctx, tempDir.getAbsolutePath() + File.separatorChar + getName()); cache = new ContentCacheImpl(); cache.setCacheRoot(TempFileProvider.getLongLifeTempDir("cached_content_test")); cache.setMemoryStore(createMemoryStore()); store = new CachingContentStore(backingStore, cache, false); }
Example 9
Source File: ContentCacheImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void willCreateNonExistentCacheRoot() { File cacheRoot = new File(TempFileProvider.getTempDir(), GUID.generate()); cacheRoot.deleteOnExit(); assertFalse("Pre-condition of test is that cacheRoot does not exist", cacheRoot.exists()); contentCache.setCacheRoot(cacheRoot); assertTrue("cacheRoot should have been created", cacheRoot.exists()); }
Example 10
Source File: FileContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); store = new FileContentStore(ctx, tempDir.getAbsolutePath() + File.separatorChar + getName()); store.setDeleteEmptyDirs(true); // Do not need super class's transactions }
Example 11
Source File: NoRandomAccessFileContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { // create a store that uses a subdirectory of the temp directory File tempDir = TempFileProvider.getTempDir(); store = new FileContentStore(ctx, tempDir.getAbsolutePath() + File.separatorChar + getName()); // disallow random access store.setAllowRandomAccess(false); }
Example 12
Source File: ContentDataDAOTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setUp() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); txnHelper = transactionService.getRetryingTransactionHelper(); contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); contentStore = new FileContentStore(ctx, TempFileProvider.getTempDir()); }
Example 13
Source File: DbToXMLTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void execute() { ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); File outFile = new File(TempFileProvider.getTempDir(), getClass().getSimpleName() + ".xml"); System.out.println("Writing to temp file: " + outFile); DbToXML dbToXML = new DbToXML(ctx, outFile); dbToXML.execute(); }
Example 14
Source File: MultiFileDumperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void canDumpSchemaToFiles() { String[] prefixes = new String[] { "a_", "b_", "c_" }; File directory = TempFileProvider.getTempDir(); String fileNamePattern = "SchemaDump-MySQL-{0}-"; MultiFileDumper dumper = new MultiFileDumper(prefixes, directory, fileNamePattern, dbToXMLFactory, null); when(dbToXMLFactory.create(argThat(isFileNameStartingWith("SchemaDump-MySQL-a_-")), eq("a_"))). thenReturn(dbToXMLForA); when(dbToXMLFactory.create(argThat(isFileNameStartingWith("SchemaDump-MySQL-b_-")), eq("b_"))). thenReturn(dbToXMLForB); when(dbToXMLFactory.create(argThat(isFileNameStartingWith("SchemaDump-MySQL-c_-")), eq("c_"))). thenReturn(dbToXMLForC); List<File> files = dumper.dumpFiles(); Iterator<File> it = files.iterator(); assertPathCorrect("SchemaDump-MySQL-a_-", directory, it.next()); assertPathCorrect("SchemaDump-MySQL-b_-", directory, it.next()); assertPathCorrect("SchemaDump-MySQL-c_-", directory, it.next()); verify(dbToXMLForA).execute(); verify(dbToXMLForB).execute(); verify(dbToXMLForC).execute(); }
Example 15
Source File: OpenCmisLocalTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); File tempDir = new File(TempFileProvider.getTempDir(), GUID.generate()); this.streamFactory = TempStoreOutputStreamFactory.newInstance(tempDir, 1024, 1024, false); this.eventPublisher = (EventPublisherForTestingOnly) ctx.getBean("eventPublisher"); }
Example 16
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void setup() { File tempDir = TempFileProvider.getTempDir(); this.tmp = new File(tempDir, "CMISAppend"); if(!this.tmp.exists() && !this.tmp.mkdir()) { throw new AlfrescoRuntimeException("Failed to create CMIS temporary directory"); } }
Example 17
Source File: MultiFileDumperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Test(expected=IllegalArgumentException.class) public void exceptionThrownWhenZeroPrefixesUsed() { // Shouldn't be able to construct a dumper with no prefixes to dump. new MultiFileDumper(new String[] {}, TempFileProvider.getTempDir(), "", dbToXMLFactory, null); }
Example 18
Source File: MultiFileDumperTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Test(expected=IllegalArgumentException.class) public void exceptionThrownWhenNullPrefixListUsed() { // Shouldn't be able to construct a dumper with no prefixes to dump. new MultiFileDumper(null, TempFileProvider.getTempDir(), "", dbToXMLFactory, null); }
Example 19
Source File: RepositoryContainer.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public void setup() { File tempDirectory = TempFileProvider.getTempDir(tempDirectoryName); this.streamFactory = new TempOutputStreamFactory(tempDirectory, memoryThreshold, maxContentSize, encryptTempFiles, false); this.responseStreamFactory = new TempOutputStreamFactory(tempDirectory, memoryThreshold, maxContentSize, encryptTempFiles, true); }
Example 20
Source File: ApiWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public void init() { File tempDirectory = TempFileProvider.getTempDir(tempDirectoryName); this.streamFactory = new TempOutputStreamFactory(tempDirectory, memoryThreshold, maxContentSize, false, false); }