Statistics
| Revision:

root / branches / 0.8 / linshare / src / test / java / org / linagora / linShare / dao / jackrabbit / TestJackRabbit.java @ 194

History | View | Annotate | Download (3.4 KB)

1
/*
2
 *    This file is part of Linshare.
3
 *
4
 *   Linshare is free software: you can redistribute it and/or modify
5
 *   it under the terms of the GNU Affero General Public License as
6
 *   published by the Free Software Foundation, either version 3 of
7
 *   the License, or (at your option) any later version.
8
 *
9
 *   Linshare is distributed in the hope that it will be useful,
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *   GNU Affero General Public License for more details.
13
 *
14
 *   You should have received a copy of the GNU Affero General Public
15
 *   License along with Foobar.  If not, see
16
 *                                    <http://www.gnu.org/licenses/>.
17
 *
18
 *   (c) 2008 Groupe Linagora - http://linagora.org
19
 *
20
*/
21
package org.linagora.linShare.dao.jackrabbit;
22
23
import java.io.BufferedReader;
24
import java.io.IOException;
25
import java.io.InputStream;
26
import java.io.InputStreamReader;
27
28
import org.junit.Assert;
29
import org.junit.Before;
30
import org.junit.Test;
31
import org.linagora.linShare.core.dao.FileSystemDao;
32
import org.springframework.beans.factory.annotation.Autowired;
33
import org.springframework.test.annotation.DirtiesContext;
34
import org.springframework.test.context.ContextConfiguration;
35
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
36
37
38
@ContextConfiguration(locations={"classpath:springContext-jackRabbit.xml","classpath:springContext-test.xml"})
39
public class TestJackRabbit extends AbstractJUnit4SpringContextTests{
40
41
        
42
        
43
        @Autowired
44
        private FileSystemDao fileRepository;
45
        private InputStream inputStream;
46
        
47
        @Before
48
        public void setUp() throws Exception {
49
                
50
                this.inputStream=Thread.currentThread().getContextClassLoader().getResourceAsStream("linShare-default.properties");
51
                
52
        }
53
54
        @Test
55
        @DirtiesContext
56
        public void testInsertFile(){
57
                
58
                
59
                String uuid=this.fileRepository.insertFile("user1", inputStream, 0, "linShare-default.properties", "txt");
60
                try {
61
                        this.inputStream.close();
62
                } catch (IOException e1) {
63
                        // TODO Auto-generated catch block
64
                        e1.printStackTrace();
65
                }
66
                this.inputStream=Thread.currentThread().getContextClassLoader().getResourceAsStream("linShare-default.properties");
67
                
68
                BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
69
                BufferedReader out=new BufferedReader(new InputStreamReader(this.fileRepository.getFileContentByUUID(uuid)));
70
                String first=null;
71
                String second=null;
72
                try{
73
                while( (first=bufferedReader.readLine())!=null && ((second=out.readLine()) !=null) ){
74
                        if(!first.equals(second)){
75
                                break;
76
                        }
77
                }
78
                
79
                if(null==first && null==second){
80
                        Assert.assertTrue(true);
81
                }
82
                }catch(Exception e){
83
                        e.printStackTrace();
84
                        Assert.assertFalse(true);
85
                }
86
                
87
                
88
                
89
        }
90
        
91
//
92
//        @Test
93
//        public void testGetFile(){
94
//                //this.fileRepository.insertFile("user1", inputStream, "txt");
95
//                InputStream stream=this.fileRepository.getFile("user1/user1/");
96
//                BufferedReader reader=new BufferedReader(new InputStreamReader(stream));
97
//                String dd="";
98
//                try {
99
//                        while(( dd=reader.readLine())!=null){
100
//                                System.out.println(dd);
101
//                        }
102
//                } catch (IOException e) {
103
//                        // TODO Auto-generated catch block
104
//                        e.printStackTrace();
105
//                }
106
//                if(this.inputStream.equals(stream)){
107
//                        Assert.assertTrue(true);
108
//                }
109
//        }
110
//
111
//        
112
//        @Test
113
//        public void getPath(){
114
//                
115
//                for(String current:this.fileRepository.getAllPath()){
116
//                        System.out.println(current);
117
//                }
118
//        }
119
//        
120
}