Package com.ettrema.httpclient

Examples of com.ettrema.httpclient.File


                  App.current().view.showDetails( new FolderPanel( (Folder) r ) );
              } catch( Exception ex ) {
                  throw new RuntimeException( ex );
              }
          } else {
              File f = (File) r;
              if( ( f.contentType != null && f.contentType.equals( "text/html" ) ) || f.name.endsWith( "html" ) ) {
                  BareBonesBrowserLaunch.openURL( r.href() );
              } else if( ( f.contentType != null && f.contentType.contains( "image" ) ) || f.name.endsWith( "jpg" ) ) {
                  BareBonesBrowserLaunch.openURL( r.href() );
              } else if( f.contentType != null && f.contentType.contains( "text" ) ) {
View Full Code Here


      List<? extends Resource> children1 = ff1.children();
      List<? extends Resource> children2 = ff2.children();
      assertEquals(1,children1.size());
      assertEquals(1,children2.size());
     
      File r1 = (File)children1.get(0);
      File r2 = (File)children2.get(0);
     
      ByteArrayOutputStream sw1=new ByteArrayOutputStream();
      r1.download(sw1, null);
     
      ByteArrayOutputStream sw2=new ByteArrayOutputStream();
      r2.download(sw2, null);
     
      assertEquals("text1",sw1.toString());
      assertEquals("text2",sw2.toString());
  }
View Full Code Here

      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        Folder wt=(Folder)((Folder)demo.child("wt")).child(ff.getName());
        File wtFile=(File)wt.child("legacy.txt");
        final String newContent="new File content";
        wtFile.setContent(new ByteArrayInputStream(newContent.getBytes()), (long)newContent.getBytes().length);
       
        file = APILocator.getFileAPI().getWorkingFileById(file.getIdentifier(), user, false);
       
        // the file should have the new content
        Assert.assertEquals(newContent, IOUtils.toString(new FileReader(APILocator.getFileAPI().getAssetIOFile(file))));
       
        // testing that webdav returns the same
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        wtFile.download(out, null);
        Assert.assertEquals(newContent,new String(out.toByteArray()));
  }
View Full Code Here

     
      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.copyTo(demo, copyfilename);
        Thread.sleep(1000);
        File f2=(File)demo.child(copyfilename);
        ByteArrayOutputStream out1=new ByteArrayOutputStream(),out2=new ByteArrayOutputStream();
        f1.download(out1, null);
        f2.download(out2, null);
        Assert.assertEquals("this is a test text", out1.toString());
        Assert.assertEquals("this is a test text", out2.toString());
       
        f1.delete();
        f2.delete();
  }
View Full Code Here

       
        final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.delete();
       
        for(Resource rr: demo.children()) {
            if(rr instanceof File) {
                Assert.assertNotSame(filename, ((File)rr).name);
            }
View Full Code Here

       
        java.io.File tmp=java.io.File.createTempFile("filetest", ".txt");
        FileUtils.writeStringToFile(tmp, "this is a test text 888");
       
        try{
          File uploaded = hh.uploadFile(tmp);
        } catch (Exception e){
          //This is expected: User does not have permission to publish contentlets
          Assert.assertTrue(e instanceof InternalServerError);
        }
View Full Code Here

       
        final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.rename(renamefilename);
        Thread.sleep(1000);
        File f2=(File)demo.child(renamefilename);
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        f2.download(out, null);
        Assert.assertEquals("this is a test text", out.toString());
        f2.delete();
  }
View Full Code Here

TOP

Related Classes of com.ettrema.httpclient.File

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.