AlfrescoSharedResource extends AbstractAlfrescoSharedResource { @Override public String putContent(File file, String mimeType){ try { return createRepositoryAccessSession().putContent(file, mimeType); } catch (RuntimeException e){ if (e.getMessage().equals(PUT_CONTENT_401_MESSAGE)){ logger.debug("401 message on put content, ticket could be expired, retrying"); destroyRepositoryAccessSession(); return createRepositoryAccessSession().putContent(file, mimeType); } else { throw e; } } } AlfrescoSharedResource();  AlfrescoSharedResource(RepositoryAccessFactory repositoryAccessFactory); @Value(value = "#{'${repo.luceneFallback.enabled}'}") void setLuceneFallbackEnabled(boolean luceneFallbackEnabled); @Override String putContent(File file, String mimeType); @Override List<UploadResult> sendBatch(
			final WriteOption docExistsMode, final List<Document> documents); @Override void setACL(final ACL acl); @Override boolean exists(final String remotePath, final String name); @Override void delete(final String remotePath, final String name, final DeleteOption option); @Override boolean fileNameExists(final String name); void clearCaches(); @Override String getDescription(); @Override String getName(); @Override boolean validate(); static final String PUT_CONTENT_401_MESSAGE; }
@Test public void testPutContent(){ String contentUrl = "testContentURL"; RepositoryAccessSession repositoryAccessSession = mock(RepositoryAccessSession.class); when(repositoryAccessSession.putContent(any(File.class), any(String.class))) .thenThrow(new RuntimeException(AlfrescoSharedResource.PUT_CONTENT_401_MESSAGE)) .thenReturn(contentUrl); RepositoryAccess repositoryAccess = mock(RepositoryAccess.class); when(repositoryAccess.createSessionAndRetry()).thenReturn(repositoryAccessSession); RepositoryAccessFactory repositoryAccessFactory = mock(RepositoryAccessFactory.class); when(repositoryAccessFactory.createRepositoryAccess()).thenReturn(repositoryAccess); AlfrescoSharedResource alfrescoSharedResource = new AlfrescoSharedResource(repositoryAccessFactory); String resultContentUrl = alfrescoSharedResource.putContent(mock(File.class), "testMimetype"); assert resultContentUrl == contentUrl; }