@Test public void testContainerAssignmentOfMultipleFiles() { System.out.println(Constants.TESTCASE_LIMITER); System.out.println(this.getClass().getSimpleName() + ": " + name.getMethodName()); int id1 = 1001; int id2 = 1002; int id3 = 2000; int shareRelationID = 4444; // Create FileInfo FileInfoEncrypt textFileInfo1 = new FileInfoEncrypt(id1, textFile.getAbsolutePath(), shareRelationID); FileInfoEncrypt textFileInfo2 = new FileInfoEncrypt(id2, textFile.getAbsolutePath(), shareRelationID); FileInfoEncrypt textFileInfoBigger = new FileInfoEncrypt(id3, textFileBigger.getAbsolutePath(), shareRelationID); // create FileInfoList List<FileInfoEncrypt> fileInfoList = new ArrayList<FileInfoEncrypt>(); fileInfoList.add(textFileInfo1); fileInfoList.add(textFileInfo2); fileInfoList.add(textFileInfoBigger); // set Max Container Size containerManager.setMaxContainerSize(textFile.length() * 2 + 1); // get the gerated File Infos containerManager.assignContainerID(fileInfoList); assertFalse(fileInfoList.isEmpty()); // not Empty // check if both textfiles are in the same container assertTrue( fileInfoList.get(fileInfoList.indexOf(textFileInfo1)).getContainerInfo().getContainerID() == fileInfoList .get(fileInfoList.indexOf(textFileInfo2)) .getContainerInfo() .getContainerID()); // Check Size of these container assertTrue( fileInfoList .get(fileInfoList.indexOf(textFileInfo1)) .getContainerInfo() .getEstimatedContainerSize() == (textFile.length() * 2)); // check if the Bigger File is in another container assertFalse( fileInfoList.get(fileInfoList.indexOf(textFileInfo1)).getContainerInfo().getContainerID() == fileInfoList .get(fileInfoList.indexOf(textFileInfoBigger)) .getContainerInfo() .getContainerID()); // Check Size of this container assertTrue( fileInfoList .get(fileInfoList.indexOf(textFileInfoBigger)) .getContainerInfo() .getEstimatedContainerSize() == textFileBigger.length()); }
/* * (non-Javadoc) * * @see * cc.kune.core.server.content.CreationService#createFolder(cc.kune.domain * .Group, java.lang.Long, java.lang.String, cc.kune.domain.I18nLanguage, * java.lang.String) */ @Override public Container createFolder( final Group group, final Long parentFolderId, final String name, final I18nLanguage language, final String typeId) { final Container parent = containerManager.find(parentFolderId); final String toolName = parent.getToolName(); tools.get(toolName).checkTypesBeforeContainerCreation(parent.getTypeId(), typeId); final Container child = containerManager.createFolder(group, parent, name, language, typeId); tools.get(toolName).onCreateContainer(child, parent); return child; }
@Test public void testExistingContainerID() { System.out.println(Constants.TESTCASE_LIMITER); System.out.println(this.getClass().getSimpleName() + ": " + name.getMethodName()); int id = 2222; int shareRelationID = 4444; int contId = 9999; // Create FileInfo FileInfoEncrypt fie = new FileInfoEncrypt(id, textFile.getAbsolutePath(), shareRelationID); fie.getContainerInfo().setContainerID(contId); List<FileInfoEncrypt> fileInfoList = new ArrayList<FileInfoEncrypt>(); fileInfoList.add(fie); // get the gerated File Infos containerManager.assignContainerID(fileInfoList); assertFalse(fileInfoList.isEmpty()); // not Empty // check Container ID assertTrue(fileInfoList.get(0).getContainerInfo().getContainerID() == contId); // Check Path assertEquals( fie.getContainerInfo().getShareRelationID(), fileInfoList.get(0).getContainerInfo().getShareRelationID()); // Check Size // assertTrue(fileInfoList.get(0).getContainerInfo().getEstimatedContainerSize() == // textFile.length()); }
public ContainerManagerTest() { containerManager = ContainerManager.getInstance(); // initalize the config TConfig config = TConfig.get(); // Configure custom application file format. TArchiveDetector tad = KeyManager1.getArchiveDetector( Constants.CONTAINER_EXTENTION, Constants.TEST_PASSWORD_1.toCharArray()); config.setArchiveDetector(tad); }
/* * (non-Javadoc) * * @see * cc.kune.core.server.content.CreationService#createRootFolder(cc.kune.domain * .Group, java.lang.String, java.lang.String, java.lang.String) */ @Override public Container createRootFolder( final Group group, final String name, final String rootName, final String typeRoot) { // FIXME Check that does not exist yet return containerManager.createRootFolder(group, name, rootName, typeRoot); }