xref: /AOO42X/test/testuno/source/fvt/uno/sd/file/CheckFileProperties.java (revision 25e09e76c1fa80a58bc663d44347c3329a042a1b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 /**
22  *
23  */
24 package fvt.uno.sd.file;
25 import static org.junit.Assert.*;
26 
27 import org.junit.After;
28 import org.junit.AfterClass;
29 import org.junit.Before;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.openoffice.test.uno.UnoApp;
33 import org.openoffice.test.common.FileUtil;
34 import org.openoffice.test.common.Testspace;
35 
36 import com.sun.star.beans.IllegalTypeException;
37 import com.sun.star.beans.Property;
38 import com.sun.star.beans.PropertyAttribute;
39 import com.sun.star.beans.PropertyExistException;
40 import com.sun.star.beans.PropertyValue;
41 import com.sun.star.beans.UnknownPropertyException;
42 import com.sun.star.beans.XPropertyContainer;
43 import com.sun.star.beans.XPropertySet;
44 import com.sun.star.beans.XPropertySetInfo;
45 import com.sun.star.container.XNameAccess;
46 import com.sun.star.document.XDocumentProperties;
47 import com.sun.star.document.XDocumentPropertiesSupplier;
48 import java.util.Calendar;
49 import com.sun.star.util.DateTime;
50 import com.sun.star.util.Date;
51 import com.sun.star.util.Duration;
52 import com.sun.star.lang.IllegalArgumentException;
53 import com.sun.star.lang.WrappedTargetException;
54 import com.sun.star.lang.XComponent;
55 import com.sun.star.lang.XMultiServiceFactory;
56 import com.sun.star.uno.UnoRuntime;
57 
58 /**
59  * @author LouQL
60  *
61  */
62 public class CheckFileProperties {
63 
64     private static final UnoApp app = new UnoApp();
65 
66     private XComponent m_xSDComponent = null;
67     private static String m_filePath = null;
68 
69     @Before
70     public void setUpDocument() throws Exception {
71         if (FileUtil.fileExists(m_filePath)) {//load
72             m_xSDComponent = app.loadDocument(m_filePath);
73         } else {//new
74             m_xSDComponent = (XComponent) UnoRuntime.queryInterface(
75                     XComponent.class, app.newDocument("simpress"));
76         }
77     }
78 
79     private String getUserName() throws com.sun.star.uno.Exception
80     {
81         Object configurationProvider = app.getServiceFactory().
82                 createInstance("com.sun.star.configuration.ConfigurationProvider");
83 
84         XMultiServiceFactory msFac = (XMultiServiceFactory)UnoRuntime.queryInterface(
85                 XMultiServiceFactory.class, configurationProvider);
86 
87         PropertyValue[] propValue = new PropertyValue[1];
88         propValue[0] = new PropertyValue();
89         propValue[0].Name = "nodepath";
90         propValue[0].Value = "/org.openoffice.UserProfile/Data";
91 
92         Object configurationAccess = msFac.createInstanceWithArguments(
93                 "com.sun.star.configuration.ConfigurationAccess", propValue);
94         XNameAccess nameAcc = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, configurationAccess);
95         String givenname = (String)nameAcc.getByName("givenname");
96         String sn = (String)nameAcc.getByName("sn");
97         String name = null;
98         if(givenname.length() == 0) name = sn;
99         else    name = givenname+" "+sn;
100 
101         return name;
102     }
103 
104     private XDocumentProperties getDocumentProperties(){
105         XDocumentPropertiesSupplier xDocumentProSupplier = (XDocumentPropertiesSupplier)UnoRuntime.queryInterface(
106                 XDocumentPropertiesSupplier.class, this.m_xSDComponent);
107         return xDocumentProSupplier.getDocumentProperties();
108     }
109 
110     @After
111     public void tearDownDocument() {
112         app.closeDocument(m_xSDComponent);
113         m_filePath = Testspace.getPath("temp/CheckFileProperties.odp");
114         FileUtil.deleteFile(m_filePath);
115 
116     }
117 
118     @BeforeClass
119     public static void setUpConnection() throws Exception {
120         app.start();
121         m_filePath = Testspace.getPath("temp/CheckFileProperties.odp");
122         FileUtil.deleteFile(m_filePath);
123     }
124 
125     @AfterClass
126     public static void tearDownConnection() throws InterruptedException,
127             Exception {
128         app.close();
129     }
130 
131     /*
132      * UI entry: File->Properties->General->Created*/
133     @Test
134     public void testGeneralAuthor() throws Exception {
135         String author = getUserName();
136         XDocumentProperties xDocPro = getDocumentProperties();
137         xDocPro.setAuthor(author);
138 
139         app.saveDocument(m_xSDComponent, m_filePath);
140         app.closeDocument(m_xSDComponent);
141         m_xSDComponent = app.loadDocument(m_filePath);
142         XDocumentProperties xDocPro2 = getDocumentProperties();
143         assertEquals("Author should be "+ author, author, xDocPro2.getAuthor());
144     }
145 
146     private boolean DateTimeEquals(DateTime datetime1, DateTime datetime2){
147 
148         if(datetime1.Seconds == datetime2.Seconds &&
149                 datetime1.Minutes == datetime2.Minutes &&
150                 datetime1.Hours == datetime2.Hours &&
151                 datetime1.Day == datetime2.Day &&
152                 datetime1.Month == datetime2.Month &&
153                 datetime1.Year == datetime2.Year)
154             return true;
155         else
156             return false;
157     }
158 
159     private boolean DateEquals(Date date1, Date date2){
160 
161         if(date1.Day == date2.Day &&
162            date1.Month == date2.Month &&
163             date1.Year == date2.Year)
164             return true;
165         else
166             return false;
167     }
168 
169     private boolean DurationEquals(Duration d1, Duration d2){
170 
171         if(d1.Seconds == d2.Seconds &&
172                 d1.Minutes == d2.Minutes &&
173                 d1.Hours == d2.Hours &&
174                 d1.Days == d2.Days &&
175                 d1.Months == d2.Months &&
176                 d1.Years == d2.Years)
177             return true;
178         else
179             return false;
180     }
181 
182     private DateTime getCurrentDateTime(){
183         Calendar ca = Calendar.getInstance();
184         DateTime currentDateTime = new DateTime();
185         currentDateTime.Year = (short)ca.get(Calendar.YEAR);
186         // java.util.Calendar's months start at 0=January.
187         currentDateTime.Month = (short)(ca.get(Calendar.MONTH) + 1);
188         currentDateTime.Day = (short)ca.get(Calendar.DATE);
189         currentDateTime.Minutes = (short)ca.get(Calendar.MINUTE);
190         currentDateTime.Hours = (short)ca.get(Calendar.HOUR);
191         currentDateTime.Seconds = (short)ca.get(Calendar.SECOND);
192 
193         return currentDateTime;
194     }
195 
196     private Date getCurrentDate(){
197         Calendar ca = Calendar.getInstance();
198         Date currentDate = new Date();
199         currentDate.Year = (short)ca.get(Calendar.YEAR);
200         // java.util.Calendar's months start at 0=January.
201         currentDate.Month = (short)(ca.get(Calendar.MONTH) + 1);
202         currentDate.Day = (short)ca.get(Calendar.DATE);
203 
204         return currentDate;
205     }
206 
207     /*
208      * UI entry: File->Properties->General->Created*/
209     @Test
210     public void testGeneralCreationDate() throws Exception {
211         DateTime creationDate = getCurrentDateTime();
212 
213         XDocumentProperties xDocPro = getDocumentProperties();
214 
215         xDocPro.setCreationDate(creationDate);
216 
217         app.saveDocument(m_xSDComponent, m_filePath);
218         app.closeDocument(m_xSDComponent);
219         m_xSDComponent = app.loadDocument(m_filePath);
220         XDocumentProperties xDocPro2 = getDocumentProperties();
221         DateTime result = xDocPro2.getCreationDate();
222         assertTrue("CreationDate should be the same as set", this.DateTimeEquals(creationDate, result));
223     }
224 
225     /*
226      * UI entry: File->Properties->General->Modified*/
227     @Test
228     //ModifiedBy will be set each time the file loaded. The value is the one set in Tools->options->User data->Last name
229     public void testGeneralModifiedBy() throws Exception {
230         String modifiedBy = this.getUserName();
231         XDocumentProperties xDocPro = getDocumentProperties();
232         xDocPro.setModifiedBy(modifiedBy);
233 
234 
235         app.saveDocument(m_xSDComponent, m_filePath);
236         app.closeDocument(m_xSDComponent);
237         m_xSDComponent = app.loadDocument(m_filePath);
238         XDocumentProperties xDocPro2 = getDocumentProperties();
239         assertEquals("The file is modified by "+ modifiedBy, modifiedBy, xDocPro2.getModifiedBy());
240     }
241 
242     /*
243      * UI entry: File->Properties->General->Modified*/
244     @Test
245     public void testGeneralModificationDate() throws Exception {
246         //modification date will be set each time the file saved, so I don't save after set.
247         DateTime modificationDate = getCurrentDateTime();
248 
249         XDocumentProperties xDocPro = getDocumentProperties();
250 
251         xDocPro.setModificationDate(modificationDate);
252 
253         DateTime result = xDocPro.getModificationDate();
254         assertTrue("ModificationDate should be the same as set", this.DateTimeEquals(modificationDate, result));
255     }
256 
257     /*
258      * UI entry: File->Properties->General->Last printed*/
259     @Test
260     public void testGeneralPrintBy() throws Exception {
261         String printBy = "PrintBy";
262         XDocumentProperties xDocPro = getDocumentProperties();
263 
264         xDocPro.setPrintedBy(printBy);
265 
266         app.saveDocument(m_xSDComponent, m_filePath);
267         app.closeDocument(m_xSDComponent);
268         m_xSDComponent = app.loadDocument(m_filePath);
269         XDocumentProperties xDocPro2 = getDocumentProperties();
270         assertEquals("This document is printed by "+ printBy, printBy, xDocPro2.getPrintedBy());
271     }
272 
273     /*
274      * UI entry: File->Properties->General->Last printed*/
275     @Test
276     public void testGeneralPrintDate() throws Exception {
277         DateTime printDate = getCurrentDateTime();
278 
279         XDocumentProperties xDocPro = getDocumentProperties();
280 
281         xDocPro.setPrintDate(printDate);
282 
283         app.saveDocument(m_xSDComponent, m_filePath);
284         app.closeDocument(m_xSDComponent);
285         m_xSDComponent = app.loadDocument(m_filePath);
286         XDocumentProperties xDocPro2 = getDocumentProperties();
287         DateTime result = xDocPro2.getPrintDate();
288         assertTrue("PrintDate should be the same as set", this.DateTimeEquals(printDate, result));
289     }
290 
291     /*
292      * UI entry: File->Properties->General->Total editing time*/
293     @Test
294     public void testGeneralEditingDuration() throws Exception {
295         int editingDuration = 60;
296 
297         XDocumentProperties xDocPro = getDocumentProperties();
298 
299         xDocPro.setEditingDuration(editingDuration);
300 
301         app.saveDocument(m_xSDComponent, m_filePath);
302         app.closeDocument(m_xSDComponent);
303         m_xSDComponent = app.loadDocument(m_filePath);
304         XDocumentProperties xDocPro2 = getDocumentProperties();
305         assertEquals("Totally editing time should be "+ editingDuration, editingDuration, xDocPro2.getEditingDuration());
306     }
307 
308     /*
309      * UI entry: File->Properties->General->Revision number*/
310     @Test
311     public void testGeneralRevisionNumber() throws Exception {
312         short revisionNumber = 10;
313 
314         XDocumentProperties xDocPro = getDocumentProperties();
315 
316         xDocPro.setEditingCycles(revisionNumber);
317 
318         app.saveDocument(m_xSDComponent, m_filePath);
319         app.closeDocument(m_xSDComponent);
320         m_xSDComponent = app.loadDocument(m_filePath);
321         XDocumentProperties xDocPro2 = getDocumentProperties();
322         assertEquals("Revision number should be "+ revisionNumber+1, revisionNumber+1, xDocPro2.getEditingCycles());
323     }
324 
325     /*
326      * UI entry: File->Properties->General->template*/
327     @Test
328     public void testGeneralTemplateName() throws Exception {
329         String templateName = "I'm a template";
330 
331         XDocumentProperties xDocPro = getDocumentProperties();
332 
333         xDocPro.setTemplateName(templateName);
334 
335         app.saveDocument(m_xSDComponent, m_filePath);
336         app.closeDocument(m_xSDComponent);
337         m_xSDComponent = app.loadDocument(m_filePath);
338         XDocumentProperties xDocPro2 = getDocumentProperties();
339         assertEquals("Template name should be "+ templateName, templateName, xDocPro2.getTemplateName());
340     }
341 
342     /*
343      * UI entry: File->Properties->General->Reset*/
344     @Test
345     public void testGeneralReset() throws Exception {
346         String author = "ResetAuthor";
347         XDocumentProperties xDocPro = getDocumentProperties();
348         xDocPro.resetUserData(author);
349 
350         assertEquals("Author should be "+ author, author, xDocPro.getAuthor());
351         assertEquals("Modified should be empty", "", xDocPro.getModifiedBy());
352         assertTrue("ModificationDate should be empty",
353                 DateTimeEquals(new DateTime(), xDocPro.getModificationDate()));
354         assertEquals("PrintBy should be empty", "", xDocPro.getPrintedBy());
355         assertTrue("PrintDate should be empty",
356                 DateTimeEquals(new DateTime(), xDocPro.getPrintDate()));
357         assertEquals("Totally editing time should be empty", 0, xDocPro.getEditingDuration());
358         assertEquals("Revision number should be empty", 1, xDocPro.getEditingCycles());
359     }
360 
361     // UI entry: File->Properties->General->Apply user data
362 
363     // UI entry: File->Properties->General->digital signature
364 
365     //Description begin
366     /*
367      * UI entry: File->Properties->Description->Title*/
368     @Test
369     public void testDescriptionTitle() throws Exception{
370         String title = "titleForTest";
371         XDocumentProperties xDocPro = getDocumentProperties();
372         xDocPro.setTitle(title);
373 
374         app.saveDocument(m_xSDComponent, m_filePath);
375         app.closeDocument(m_xSDComponent);
376         m_xSDComponent = app.loadDocument(m_filePath);
377         XDocumentProperties xDocPro2 = getDocumentProperties();
378         assertEquals("Title should be "+ title, title, xDocPro2.getTitle());
379     }
380 
381     /*
382      * UI entry: File->Properties->Description->Subject*/
383     @Test
384     public void testDescriptionSubject() throws Exception{
385         String subject = "subjectForTest";
386         XDocumentProperties xDocPro = getDocumentProperties();
387         xDocPro.setSubject(subject);
388 
389         app.saveDocument(m_xSDComponent, m_filePath);
390         app.closeDocument(m_xSDComponent);
391         m_xSDComponent = app.loadDocument(m_filePath);
392         XDocumentProperties xDocPro2 = getDocumentProperties();
393         assertEquals("Subject should be "+ subject, subject, xDocPro2.getSubject());
394     }
395 
396     /*
397      * UI entry: File->Properties->Description->Keywords*/
398     @Test
399     public void testDescriptionKeywords() throws Exception{
400         String[] keywords = {"keyword1", "keyword2"};
401         XDocumentProperties xDocPro = getDocumentProperties();
402         xDocPro.setKeywords(keywords);
403 
404         app.saveDocument(m_xSDComponent, m_filePath);
405         app.closeDocument(m_xSDComponent);
406 
407         m_xSDComponent = app.loadDocument(m_filePath);
408         XDocumentProperties xDocPro2 = getDocumentProperties();
409         String[] keywordsResult = xDocPro2.getKeywords();
410         assertEquals("There should be 2 Keywords", 2, keywordsResult.length);
411         for(int i=0;i<keywordsResult.length;i++)
412         {
413             String num = Integer.toString(i+1);
414             assertEquals("The keywords should be keyword"+num, "keyword"+num, keywordsResult[i]);
415         }
416     }
417 
418     /*
419      * UI entry: File->Properties->Description->Comments*/
420     @Test
421     public void testDescriptionComments() throws Exception{
422         String comments = "This is the comment.";
423         XDocumentProperties xDocPro = getDocumentProperties();
424         xDocPro.setDescription(comments);
425 
426         app.saveDocument(m_xSDComponent, m_filePath);
427         app.closeDocument(m_xSDComponent);
428 
429         m_xSDComponent = app.loadDocument(m_filePath);
430         XDocumentProperties xDocPro2 = getDocumentProperties();
431 
432         assertEquals("Comments should be "+comments, comments, xDocPro2.getDescription());
433     }
434     //Description end
435 
436     //custom properties begin
437     //UI entry: File->Properties->Custom properties
438         private void addCustomPro(String propertyName, Object value) throws PropertyExistException, IllegalTypeException, IllegalArgumentException{
439             XDocumentProperties xDocPro = getDocumentProperties();
440             XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
441             proContainer.addProperty(propertyName, PropertyAttribute.REMOVEABLE, value);
442         }
443 
444         private Object getCustomPro(String propertyName) throws UnknownPropertyException, WrappedTargetException{
445             XDocumentProperties xDocPro = getDocumentProperties();
446             XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
447             XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
448                     XPropertySet.class, proContainer);
449 
450             return xProSet.getPropertyValue(propertyName);
451         }
452 
453         @Test
454         public void testCustomAddPro_Text() throws Exception{
455             String addedProName = "TextPro";
456             String addedProDefaultValue = "testUser";
457 
458             addCustomPro(addedProName, addedProDefaultValue);
459 
460             app.saveDocument(m_xSDComponent, m_filePath);
461             app.closeDocument(m_xSDComponent);
462 
463             m_xSDComponent = app.loadDocument(m_filePath);
464 
465             String result = (String)getCustomPro(addedProName);
466 
467             assertTrue("added Text property \""+addedProName+"\" should exist", result != null);
468             assertEquals("value of added property should be "+addedProDefaultValue,
469                     addedProDefaultValue, result);
470         }
471 
472         @Test
473         public void testCustomAddPro_DateTime() throws Exception{
474             String addedProName = "DateTimePro";
475             DateTime addedProDefaultValue = getCurrentDateTime();
476 
477             addCustomPro(addedProName, addedProDefaultValue);
478 
479             app.saveDocument(m_xSDComponent, m_filePath);
480             app.closeDocument(m_xSDComponent);
481 
482             m_xSDComponent = app.loadDocument(m_filePath);
483 
484             DateTime result = (DateTime)getCustomPro(addedProName);
485             assertTrue("added DateTime property \""+addedProName+"\" should exist", result != null);
486             assertTrue("value of added property should be the same as set",
487                     this.DateTimeEquals(result, addedProDefaultValue));
488         }
489 
490         @Test
491         public void testCustomAddPro_Date() throws Exception{
492             String addedProName = "DatePro";
493             Date addedProDefaultValue = getCurrentDate();
494 
495             addCustomPro(addedProName, addedProDefaultValue);
496 
497             app.saveDocument(m_xSDComponent, m_filePath);
498             app.closeDocument(m_xSDComponent);
499 
500             m_xSDComponent = app.loadDocument(m_filePath);
501 
502             Date result = (Date)getCustomPro(addedProName);
503             assertTrue("added Date property \""+addedProName+"\" should exist", result != null);
504             assertTrue("value of added property should be the same as set",
505                     this.DateEquals(result, addedProDefaultValue));
506         }
507 
508         @Test
509         public void testCustomAddPro_Duration() throws Exception{
510             String addedProName = "DurationPro";
511             Duration addedProDefaultValue = new Duration();
512             addedProDefaultValue.Days = 1;
513 
514             addCustomPro(addedProName, addedProDefaultValue);
515 
516             app.saveDocument(m_xSDComponent, m_filePath);
517             app.closeDocument(m_xSDComponent);
518 
519             m_xSDComponent = app.loadDocument(m_filePath);
520 
521             Duration result = (Duration)getCustomPro(addedProName);
522             assertTrue("added Date property \""+addedProName+"\" should exist", result != null);
523             assertTrue("value of added property should the same as set", DurationEquals(addedProDefaultValue, result));
524         }
525 
526         @Test
527         public void testCustomAddPro_Number() throws Exception{
528             String addedProName = "NumberPro";
529             Double addedProDefaultValue = (double)10;
530 
531             addCustomPro(addedProName, addedProDefaultValue);
532 
533             app.saveDocument(m_xSDComponent, m_filePath);
534             app.closeDocument(m_xSDComponent);
535 
536             m_xSDComponent = app.loadDocument(m_filePath);
537 
538             Object oResult = getCustomPro(addedProName);
539 
540             Double result = (Double)oResult;
541             assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null);
542             assertEquals("value of added property should be "+Double.toString(addedProDefaultValue),
543                     addedProDefaultValue, result);
544         }
545 
546         @Test
547         public void testCustomAddPro_Boolean() throws Exception{
548             String addedProName = "BooleanPro";
549             Boolean addedProDefaultValue = true;
550 
551             addCustomPro(addedProName, addedProDefaultValue);
552 
553             app.saveDocument(m_xSDComponent, m_filePath);
554             app.closeDocument(m_xSDComponent);
555 
556             m_xSDComponent = app.loadDocument(m_filePath);
557 
558             Object oResult = getCustomPro(addedProName);
559 
560             boolean result = (Boolean)oResult;
561             assertTrue("added Number property \""+addedProName+"\" should exist", oResult != null);
562             assertEquals("value of added property should be "+Boolean.toString(addedProDefaultValue),
563                     addedProDefaultValue, result);
564         }
565 
566         @Test
567         public void testCustomRemovePro() throws Exception{
568             addCustomPro("testPro", "value");
569             XDocumentProperties xDocPro = getDocumentProperties();
570             XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
571             XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
572                     XPropertySet.class, proContainer);
573             XPropertySetInfo xproSetInfo = xProSet.getPropertySetInfo();
574             Property[] pros = xproSetInfo.getProperties();
575 
576             for(int i=0; i< pros.length;i++)
577             {
578                 proContainer.removeProperty(pros[i].Name);
579             }
580 
581             app.saveDocument(m_xSDComponent, m_filePath);
582             app.closeDocument(m_xSDComponent);
583 
584             m_xSDComponent = app.loadDocument(m_filePath);
585 
586             XDocumentProperties xDocPro2 = getDocumentProperties();
587             XPropertyContainer proContainer2 = xDocPro2.getUserDefinedProperties();
588             XPropertySet xProSet2 = (XPropertySet)UnoRuntime.queryInterface(
589                     XPropertySet.class, proContainer2);
590             XPropertySetInfo xproSetInfo2 = xProSet2.getPropertySetInfo();
591             Property[] pros2 = xproSetInfo2.getProperties();
592 
593             assertEquals("number of custom property should be zero ",
594                     0, pros2.length);
595         }
596     //custom properties end
597 
598         //Internet begin
599         private void setAutoLoad(String URL, int secs) throws IllegalArgumentException
600         {
601             XDocumentProperties xDocPro = getDocumentProperties();
602             xDocPro.setAutoloadURL(URL);
603             xDocPro.setAutoloadSecs(secs);
604             xDocPro.setDefaultTarget("_blank");
605         }
606 
607         @Test
608         public void testNoRefresh() throws Exception{
609             String autoLoadURL = "";
610             int autoLoadSecs = 0;
611             setAutoLoad(autoLoadURL, autoLoadSecs);
612 
613             app.saveDocument(m_xSDComponent, m_filePath);
614             app.closeDocument(m_xSDComponent);
615 
616             m_xSDComponent = app.loadDocument(m_filePath);
617             XDocumentProperties xDocPro2 = getDocumentProperties();
618 
619             assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
620             assertEquals("AutoLoadSecs should be 0", autoLoadSecs, xDocPro2.getAutoloadSecs());
621         }
622 
623         @Test
624         public void testRefreshEvery60Secs() throws Exception{
625             String autoLoadURL = "";
626             int autoLoadSecs = 60;
627             setAutoLoad(autoLoadURL, autoLoadSecs);
628 
629             app.saveDocument(m_xSDComponent, m_filePath);
630             app.closeDocument(m_xSDComponent);
631 
632             m_xSDComponent = app.loadDocument(m_filePath);
633             XDocumentProperties xDocPro2 = getDocumentProperties();
634 
635             assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
636             assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs());
637         }
638 
639         @Test
640         public void testRedirect() throws Exception{
641             String autoLoadURL = "http://www.openoffice.com/";
642             int autoLoadSecs = 5;
643             setAutoLoad(autoLoadURL, autoLoadSecs);
644 
645             app.saveDocument(m_xSDComponent, m_filePath);
646             app.closeDocument(m_xSDComponent);
647 
648             m_xSDComponent = app.loadDocument(m_filePath);
649             XDocumentProperties xDocPro2 = getDocumentProperties();
650 
651             assertEquals("AutoLoadURL should be empty", autoLoadURL, xDocPro2.getAutoloadURL());
652             assertEquals("AutoLoadSecs should be "+Integer.toString(autoLoadSecs), autoLoadSecs, xDocPro2.getAutoloadSecs());
653         }
654         //Internet end
655 }
656