use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryJaxwsWebServiceIT method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
String address = "http://localhost:9000/repo";
try {
Endpoint.publish(address, new DefaultUnifiedRepositoryJaxwsWebService(repo));
} catch (Throwable th) {
// ignore
}
Service service = Service.create(new URL("http://localhost:9000/repo?wsdl"), new QName("http://www.pentaho.org/ws/1.0", "unifiedRepository"));
IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort(IUnifiedRepositoryJaxwsWebService.class);
// accept cookies to maintain session on server
((BindingProvider) repoWebService).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
// support streaming binary data
((BindingProvider) repoWebService).getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
SOAPBinding binding = (SOAPBinding) ((BindingProvider) repoWebService).getBinding();
binding.setMTOMEnabled(true);
repo = new UnifiedRepositoryToWebServiceAdapter(repoWebService);
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class RepositoryFileTreeAdapterTest method testBIServer7777.
/**
* Assert empty list in RepositoryFileTree#children survives full jaxb serialization roundtrip
*/
@Test
public void testBIServer7777() throws Exception {
IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
PentahoSystem.registerObject(unifiedRepository);
RepositoryFileAcl acl = new RepositoryFileAcl.Builder("admin").build();
when(unifiedRepository.getAcl(anyString())).thenReturn(acl);
IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
// file tree with empty children
RepositoryFile empty = new RepositoryFile.Builder("empty").build();
RepositoryFileTree emptyDir = new RepositoryFileTree(empty, Collections.<RepositoryFileTree>emptyList());
RepositoryFile root = new RepositoryFile.Builder("rootDir").build();
ArrayList<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>(1);
children.add(emptyDir);
RepositoryFileTree rootDir = new RepositoryFileTree(root, children);
// to DTO
RepositoryFileTreeAdapter adapter = new RepositoryFileTreeAdapter();
RepositoryFileTreeDto dtoThere = adapter.marshal(rootDir);
assertNotNull(dtoThere.getChildren().get(0).getChildren());
// serialize
final JAXBContext jaxbContext = JAXBContext.newInstance(RepositoryFileTreeDto.class);
Marshaller marshaller = jaxbContext.createMarshaller();
StringWriter sw = new StringWriter();
marshaller.marshal(dtoThere, sw);
// and bring it back
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader sr = new StringReader(sw.toString());
RepositoryFileTreeDto dtoBackAgain = (RepositoryFileTreeDto) unmarshaller.unmarshal(sr);
assertNotNull(dtoBackAgain.getChildren().get(0).getChildren());
// unmarshall
RepositoryFileTree rootDir2 = adapter.unmarshal(dtoBackAgain);
assertNotNull(rootDir2.getChildren().get(0).getChildren());
assertEquals(rootDir, rootDir2);
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class DefaultRepositoryVersioningManagerTest method testFullTrue.
/*
* Test a file set to versioningEnable=True, versionCommentsEnabled=true with various combinations
* of the master switch.
*/
@Test
public void testFullTrue() {
IRepositoryVersionManager repositoryVersionManager = defaultRepositoryVersionManagerFullTrue;
assertTrue(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
assertTrue(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerPartialTrue;
assertTrue(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerFalse;
assertFalse(repositoryVersionManager.isVersioningEnabled(FULL_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(FULL_VERSIONING_PATH));
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class DefaultRepositoryVersioningManagerTest method testFalse.
/*
* Test a file set to versioningEnable=false, versionCommentsEnabled=false with various combinations
* of the master switch.
*/
@Test
public void testFalse() {
IRepositoryVersionManager repositoryVersionManager = defaultRepositoryVersionManagerFullTrue;
assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerPartialTrue;
assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
repositoryVersionManager = defaultRepositoryVersionManagerFalse;
assertFalse(repositoryVersionManager.isVersioningEnabled(NO_VERSIONING_PATH));
assertFalse(repositoryVersionManager.isVersionCommentEnabled(NO_VERSIONING_PATH));
}
use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-platform by pentaho.
the class JcrRepositoryFileDaoTest method setUp.
@Before
public void setUp() throws RepositoryException {
Node node = mock(Node.class);
Node nodeParent = mock(Node.class);
when(node.getIdentifier()).thenReturn("");
when(nodeParent.getIdentifier()).thenReturn("");
when(node.getParent()).thenReturn(nodeParent);
when(node.isNodeType("null:pentahoFile")).thenReturn(true);
when(node.isNodeType("null:pentahoVersionable")).thenReturn(true);
VersionManagerImpl versionManager = mock(VersionManagerImpl.class);
Workspace workspace = mock(Workspace.class);
when(workspace.getVersionManager()).thenReturn(versionManager);
Session session = mock(Session.class);
when(session.getWorkspace()).thenReturn(workspace);
when(session.getNodeByIdentifier(anyString())).thenReturn(node);
when(session.getItem(anyString())).thenReturn(node);
pentahoSession = mock(IPentahoSession.class);
PentahoSessionHolder.setSession(pentahoSession);
IRepositoryVersionManager repositoryVersionManager = mock(IRepositoryVersionManager.class);
when(repositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
PentahoSystem.registerObject(repositoryVersionManager);
JcrTemplate jcrTemplate = new JcrTemplate() {
@Override
public Object execute(JcrCallback callback) throws DataAccessException {
try {
return callback.doInJcr(session);
} catch (Exception e) {
// wrapping exception to comply overriding rules
throw new RuntimeException(e);
}
}
};
List<ITransformer<IRepositoryFileData>> transformerList = Collections.emptyList();
IPathConversionHelper pathConversionHelper = new DefaultPathConversionHelper();
IRepositoryFileAclDao aclDao = mock(IRepositoryFileAclDao.class);
accessVoterManager = mock(IRepositoryAccessVoterManager.class);
JcrRepositoryFileDao jcrDao = new JcrRepositoryFileDao(jcrTemplate, transformerList, null, null, pathConversionHelper, aclDao, null, accessVoterManager);
dao = spy(jcrDao);
}
Aggregations