/** * Tests closing all FileSystems * * @throws Exception */ @Ignore("vfs close file system doesn't seem to work properly") @Test public void testCloseFileSystems() throws Exception { logger.info("*************** testCloseFileSystems"); String[] validUrls = server.getVFSRootURLs(); ArrayList<FileObject> fos = new ArrayList<FileObject>(); for (String validUrl : validUrls) { FileObject mounted = VFSMountManagerHelper.mount(validUrl); Assert.assertTrue(mounted.exists()); fos.add(mounted); } VFSMountManagerHelper.closeFileSystems(Arrays.asList(validUrls)); boolean onlyExceptions = true; for (FileObject closedFo : fos) { try { FileObject toto = closedFo.resolveFile("toto"); toto.createFile(); onlyExceptions = false; logger.error(toto.getURL() + " exists : " + toto.exists()); } catch (FileSystemException e) { // this should occur } } Assert.assertTrue("Only Exceptions received", onlyExceptions); }
/** * Tests mounting only one valid FileSystem * * @throws Exception */ @Test public void testMountOk() throws Exception { logger.info("*************** testMountOk"); String[] validUrls = server.getVFSRootURLs(); for (String validUrl : validUrls) { FileObject mounted = VFSMountManagerHelper.mount(validUrl); Assert.assertTrue(mounted.exists()); } }
/** * - Insert a valid file vfs root and a valid proactive vfs root in the list of fake uris - * verifies that mountAny returns the file system corresponding to the valid uri - do that for all * valid uris of the file system server * * @throws Exception */ @Test public void testMountAnyOk() throws Exception { logger.info("*************** testMountAnyOk"); String[] validUris = server.getVFSRootURLs(); for (String validUrl : validUris) { ConcurrentHashMap<String, FileObject> fileSystems = new ConcurrentHashMap<String, FileObject>(); ArrayList<String> uriToMount = new ArrayList<String>(fakeFileUrls); uriToMount.add(spacesDir.toURI().toString()); // adds a valid file uri uriToMount.addAll(fakeUrls); uriToMount.add((int) Math.floor(Math.random() * uriToMount.size()), validUrl); VFSMountManagerHelper.mountAny(uriToMount, fileSystems); logger.info("Content of map : " + fileSystems.toString()); Assert.assertTrue("map contains valid Url", fileSystems.containsKey(validUrl)); } }
/** * Start a PAMR router and a file system server * * @throws Exception */ @BeforeClass public static void setUp() throws Exception { RouterConfig config = new RouterConfig(); config.setPort(PAMRConfig.PA_NET_ROUTER_PORT.getValue()); router = Router.createAndStart(config); protocolsToTest.remove(CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getValue()); StringBuilder apstring = new StringBuilder(); for (String p : protocolsToTest) { apstring.append(p + ","); } apstring.deleteCharAt(apstring.length() - 1); CentralPAPropertyRepository.PA_COMMUNICATION_ADDITIONAL_PROTOCOLS.setValue(apstring.toString()); spacesDir = new File(System.getProperty("java.io.tmpdir"), "ProActive SpaceMountManagerTest"); if (server == null) { server = new FileSystemServerDeployer("inputserver", spacesDir.toString(), true, true); System.out.println("Started File Server at " + Arrays.toString(server.getVFSRootURLs())); } }