Kaydet (Commit) 92f4e245 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS qadev18 (1.3.62); FILE MERGED

2004/06/18 16:33:33 sg 1.3.62.1: #112549#CHG: updated tests after cfgapi cws
üst eb31bbf7
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ORootElementValueSetUpdateAccess.java,v $ * $RCSfile: ORootElementValueSetUpdateAccess.java,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change:$Date: 2003-12-11 11:55:32 $ * last change:$Date: 2004-07-23 10:46:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -70,13 +70,19 @@ import util.utils; ...@@ -70,13 +70,19 @@ import util.utils;
import com.sun.star.beans.PropertyState; import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNameReplace; import com.sun.star.container.XNameReplace;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import com.sun.star.util.XChangesBatch; import com.sun.star.util.XChangesBatch;
/**
* Check the ORootElementValueSetUpdateAccess service.
* For this, the ExternalApss layer is used. Since this layer is empty (since
* cws cfgapi), some own values are created and written to the current user
* layer. The tests are then executed on these values.
*/
public class ORootElementValueSetUpdateAccess extends TestCase { public class ORootElementValueSetUpdateAccess extends TestCase {
/** Called to create an instance of <code>TestEnvironment</code> with an /** Called to create an instance of <code>TestEnvironment</code> with an
* object to test and related objects. <br> * object to test and related objects. <br>
...@@ -129,24 +135,26 @@ public class ORootElementValueSetUpdateAccess extends TestCase { ...@@ -129,24 +135,26 @@ public class ORootElementValueSetUpdateAccess extends TestCase {
TestEnvironment tEnv = new TestEnvironment(oObj); TestEnvironment tEnv = new TestEnvironment(oObj);
String[] pNames = new String[] { String[] pNames = new String[] {
"file", "ftp", "http", "https", "mailto" "file", "ftp", "dummy", "http"
}; };
String[] pTypes = new String[] { String[] pTypes = new String[] {
"String", "String", "String", "String", "String" "String", "String", "String", "String"
}; };
createSomeEntries(oObj);
tEnv.addObjRelation("INSTANCE1", "NewOne1"); tEnv.addObjRelation("INSTANCE1", "NewOne1");
tEnv.addObjRelation("NAMEREPLACE", pNames[1]); tEnv.addObjRelation("NAMEREPLACE", pNames[0]);
// for XContainer // for XContainer
tEnv.addObjRelation("INSTANCE", "NewOne2"); tEnv.addObjRelation("INSTANCE", "NewOne2");
tEnv.addObjRelation("XChangesBatch.PropertyName", pNames[1]); tEnv.addObjRelation("XChangesBatch.PropertyName", pNames[0]);
tEnv.addObjRelation("XChangesBatch.ChangeElement", "NewOne3"); tEnv.addObjRelation("XChangesBatch.ChangeElement", "NewOne3");
tEnv.addObjRelation("XChangesBatch.NameReplace", (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, oObj)); tEnv.addObjRelation("XChangesBatch.NameReplace", (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, oObj));
tEnv.addObjRelation("XChangesNotifier.PropertyName", pNames[1]); tEnv.addObjRelation("XChangesNotifier.PropertyName", pNames[0]);
tEnv.addObjRelation("XChangesNotifier.ChangeElement", "NewOne4"); tEnv.addObjRelation("XChangesNotifier.ChangeElement", "NewOne4");
tEnv.addObjRelation("XChangesNotifier.ChangesBatch" , (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, oObj)); tEnv.addObjRelation("XChangesNotifier.ChangesBatch" , (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, oObj));
tEnv.addObjRelation("XChangesNotifier.NameReplace", (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, oObj)); tEnv.addObjRelation("XChangesNotifier.NameReplace", (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, oObj));
...@@ -158,8 +166,62 @@ public class ORootElementValueSetUpdateAccess extends TestCase { ...@@ -158,8 +166,62 @@ public class ORootElementValueSetUpdateAccess extends TestCase {
tEnv.addObjRelation("ElementName","http"); tEnv.addObjRelation("ElementName","http");
tEnv.addObjRelation("TemplateName", "cfg:value/cfg:any"); tEnv.addObjRelation("TemplateName", "cfg:value/cfg:any");
tEnv.addObjRelation("expectedName","mailto"); tEnv.addObjRelation("expectedName","http");
return tEnv; return tEnv;
} }
/**
* Create entries in the ExternalApps layer, so there is something to test
* @param oObj The test object: used to create some entries.
*/
private void createSomeEntries(XInterface oObj) {
XNameContainer xCont = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, oObj);
insertOrUpdate(xCont, "file", "just");
insertOrUpdate(xCont, "ftp", "some");
insertOrUpdate(xCont, "dummy", "arbitrary");
insertOrUpdate(xCont, "http", "value");
// write the changes into the user layer.
XChangesBatch xBatch = (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, oObj);
try {
xBatch.commitChanges();
}
catch(com.sun.star.lang.WrappedTargetException e) {
// ignore: bug will be found with the interface test
}
}
/**
* Insert a value in a name container or else update it
* @param xCont The name conationer to insert or update.
* @param name The name of the value.
* @param value The value itself.
*/
private void insertOrUpdate(XNameContainer xCont, String name, String value) {
boolean update = false;
try {
xCont.insertByName(name, value);
}
catch(com.sun.star.lang.IllegalArgumentException e) {
// ignore: bug will be found with the interface test
}
catch(com.sun.star.lang.WrappedTargetException e) {
// ignore: bug will be found with the interface test
}
catch(com.sun.star.container.ElementExistException e) {
update = true;
}
try {
if (update)
xCont.replaceByName(name, value);
}
catch(com.sun.star.lang.IllegalArgumentException e) {
// ignore: bug will be found with the interface test
}
catch(com.sun.star.container.NoSuchElementException e) {
// ignore: bug will be found with the interface test
}
catch(com.sun.star.lang.WrappedTargetException e) {
// ignore: bug will be found with the interface test
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment