@Test public void testGetPath () throws Exception { Globals globals = new Globals (); JaqyInterpreter interpreter = new JaqyInterpreter (globals, null, null); AzurePathHandler handler = new AzurePathHandler (); AzureUtils.setAccount ("devstoreaccount1", interpreter); AzureUtils.setKey ("Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", interpreter); AzureUtils.setEndPoint ("http: CloudBlobClient client = AzureUtils.getBlobClient (interpreter, "devstoreaccount1"); CloudBlobContainer container = client.getContainerReference ("testcontainer"); container.create (); Path path = handler.getPath ("wasb: Assert.assertNotNull (path); OutputStream os = path.getOutputStream (); os.write ("Hello World".getBytes ("utf-8")); os.close (); path = handler.getPath ("wasbs: Assert.assertNotNull (path); Assert.assertTrue (path.exists ()); Assert.assertEquals (11, path.length ()); Assert.assertTrue (path.isFile ()); InputStream is = path.getInputStream (); BufferedReader r = new BufferedReader (new InputStreamReader (is, "utf-8")); String line = r.readLine (); Assert.assertEquals ("Hello World", line); is.close (); container.delete (); }
@Override public Path getPath (String path, JaqyInterpreter interpreter) throws IOException { AzurePathInfo info = AzureUtils.getPathInfo (path); if ("wasb".equals (info.protocol) || "wasbs".equals (info.protocol)) { CloudBlobContainer container = AzureUtils.getContainer (info.account, info.container, interpreter); try { if (!container.exists ()) { throw new IOException ("Invalid Azure path: " + path); } } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } return new WasbPath (container, info.file, interpreter); } throw new IOException ("Invalid Azure path: " + path); }
AzurePathHandler implements PathHandler { @Override public Path getPath (String path, JaqyInterpreter interpreter) throws IOException { AzurePathInfo info = AzureUtils.getPathInfo (path); if ("wasb".equals (info.protocol) || "wasbs".equals (info.protocol)) { CloudBlobContainer container = AzureUtils.getContainer (info.account, info.container, interpreter); try { if (!container.exists ()) { throw new IOException ("Invalid Azure path: " + path); } } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } return new WasbPath (container, info.file, interpreter); } throw new IOException ("Invalid Azure path: " + path); } }
AzurePathHandler implements PathHandler { @Override public Path getPath (String path, JaqyInterpreter interpreter) throws IOException { AzurePathInfo info = AzureUtils.getPathInfo (path); if ("wasb".equals (info.protocol) || "wasbs".equals (info.protocol)) { CloudBlobContainer container = AzureUtils.getContainer (info.account, info.container, interpreter); try { if (!container.exists ()) { throw new IOException ("Invalid Azure path: " + path); } } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } return new WasbPath (container, info.file, interpreter); } throw new IOException ("Invalid Azure path: " + path); }  }
AzurePathHandler implements PathHandler { @Override public Path getPath (String path, JaqyInterpreter interpreter) throws IOException { AzurePathInfo info = AzureUtils.getPathInfo (path); if ("wasb".equals (info.protocol) || "wasbs".equals (info.protocol)) { CloudBlobContainer container = AzureUtils.getContainer (info.account, info.container, interpreter); try { if (!container.exists ()) { throw new IOException ("Invalid Azure path: " + path); } } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } return new WasbPath (container, info.file, interpreter); } throw new IOException ("Invalid Azure path: " + path); }  @Override Path getPath(String path, JaqyInterpreter interpreter); @Override boolean canHandle(String path); }
AzurePathHandler implements PathHandler { @Override public Path getPath (String path, JaqyInterpreter interpreter) throws IOException { AzurePathInfo info = AzureUtils.getPathInfo (path); if ("wasb".equals (info.protocol) || "wasbs".equals (info.protocol)) { CloudBlobContainer container = AzureUtils.getContainer (info.account, info.container, interpreter); try { if (!container.exists ()) { throw new IOException ("Invalid Azure path: " + path); } } catch (IOException ex) { throw ex; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } return new WasbPath (container, info.file, interpreter); } throw new IOException ("Invalid Azure path: " + path); }  @Override Path getPath(String path, JaqyInterpreter interpreter); @Override boolean canHandle(String path);  }