summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javaunohelper/JunitTest_juh.mk3
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java2376
2 files changed, 1204 insertions, 1175 deletions
diff --git a/javaunohelper/JunitTest_juh.mk b/javaunohelper/JunitTest_juh.mk
index 0aaaa3a3a50c..fc289ca589b5 100644
--- a/javaunohelper/JunitTest_juh.mk
+++ b/javaunohelper/JunitTest_juh.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_JunitTest_add_sourcefiles,juh,\
javaunohelper/com/sun/star/lib/uno/helper/ComponentBase \
javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer \
javaunohelper/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer \
+ javaunohelper/com/sun/star/lib/uno/helper/PropertySet \
javaunohelper/com/sun/star/lib/uno/helper/WeakAdapter \
javaunohelper/com/sun/star/lib/uno/helper/WeakBase \
javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test \
@@ -36,6 +37,7 @@ $(eval $(call gb_JunitTest_add_sourcefiles,juh,\
javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test \
javaunohelper/test/com/sun/star/lib/uno/helper/InterfaceContainer_Test \
javaunohelper/test/com/sun/star/lib/uno/helper/MultiTypeInterfaceContainer_Test \
+ javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test \
javaunohelper/test/com/sun/star/lib/uno/helper/ProxyProvider \
javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test \
))
@@ -45,6 +47,7 @@ $(eval $(call gb_JunitTest_add_classes,juh,\
com.sun.star.lib.uno.helper.ComponentBase_Test \
com.sun.star.lib.uno.helper.InterfaceContainer_Test \
com.sun.star.lib.uno.helper.MultiTypeInterfaceContainer_Test \
+ com.sun.star.lib.uno.helper.PropertySet_Test \
com.sun.star.lib.uno.helper.WeakBase_Test \
))
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java
index 88956b7f88b3..9ceb74d46027 100644
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/PropertySet_Test.java
@@ -38,1013 +38,1009 @@ import com.sun.star.beans.XPropertiesChangeListener;
import java.util.logging.Level;
import java.util.logging.Logger;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
public class PropertySet_Test
{
private static final Logger logger = Logger.getLogger(PropertySet_Test.class.getName());
- public boolean convertPropertyValue()
+ @Test public void convertPropertyValue() throws Exception
{
logger.log(Level.INFO, "PropertySet.convertPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- r[i++]= cl.test_convertPropertyValue();
- }catch(java.lang.Exception e){
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ cl.test_convertPropertyValue();
}
- public boolean setPropertyValueNoBroadcast()
+ @Test public void setPropertyValueNoBroadcast() throws Exception
{
logger.log(Level.INFO, "PropertySet.setValueNoBroadcast");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- r[i++]= cl.test_setPropertyValueNoBroadcast();
- }catch(java.lang.Exception e){
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ cl.test_setPropertyValueNoBroadcast();
}
- public boolean setPropertyValue()
+ @Test public void setPropertyValue() throws Exception
{
logger.log(Level.INFO, "PropertySet.setPropertyValue");
- boolean[] r= new boolean[150];
- int i= 0;
-
TestClass cl= new TestClass();
+ cl.resetPropertyMembers();
+ Object value;
+ Object ret;
+
+ value= Boolean.TRUE;
+ cl.setPropertyValue("PropBoolA", value);
+ assertEquals((Boolean) cl.getPropertyValue("PropBoolA"), value);
+
+ value= new Character('A');
+ cl.setPropertyValue("PropCharA",value);
+ assertEquals((Character) cl.getPropertyValue("PropCharA"), value);
+
+ value= Byte.valueOf((byte) 111);
+ cl.setPropertyValue("PropByteA",value);
+ assertEquals((Byte) cl.getPropertyValue("PropByteA"), value);
+
+ value= Short.valueOf((short)112);
+ cl.setPropertyValue("PropShortA", value);
+ assertEquals((Short) cl.getPropertyValue("PropShortA"), value);
+
+ value= Integer.valueOf(113);
+ cl.setPropertyValue("PropIntA", value);
+ assertEquals((Integer) cl.getPropertyValue("PropIntA"), value);
+
+ value= Long.valueOf(115);
+ cl.setPropertyValue("PropLongA", value);
+ assertEquals((Long) cl.getPropertyValue("PropLongA"), value);
+
+ value= new Float(3.14);
+ cl.setPropertyValue("PropFloatA", value);
+ assertEquals((Float) cl.getPropertyValue("PropFloatA"), value);
+
+ value= new Double(3.145);
+ cl.setPropertyValue("PropDoubleA",value);
+ assertEquals((Double) cl.getPropertyValue("PropDoubleA"), value);
+
+ value= "string";
+ cl.setPropertyValue("PropStringA",value);
+ assertEquals((String) cl.getPropertyValue("PropStringA"), value);
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropXInterfaceA",value);
+ assertEquals((XInterface) cl.getPropertyValue("PropXInterfaceA"), value);
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropXWeakA",value);
+ assertEquals((XWeak) cl.getPropertyValue("PropXWeakA"), value);
+
+ value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
+ cl.setPropertyValue("PropEnum",value);
+ assertSame(cl.getPropertyValue("PropEnum"), value);
+
+ value= new byte[]{1,2,3};
+ cl.setPropertyValue("PropArrayByteA", value);
+ assertEquals((byte[]) cl.getPropertyValue("PropArrayByteA"), value);
+
+ value= new Type(String.class);
+ cl.setPropertyValue("PropTypeA", value);
+ assertEquals((Type) cl.getPropertyValue("PropTypeA"), value);
+
+ // test protected,package,private members
+ value= Boolean.TRUE;
+ cl.setPropertyValue("PropBoolB", value);
+ assertEquals((Boolean) cl.getPropertyValue("PropBoolB"), value);
+
+ cl.setPropertyValue("PropBoolC", value);
+ assertEquals((Boolean) cl.getPropertyValue("PropBoolC"), value);
+
try {
- cl.resetPropertyMembers();
- Object value;
- Object ret;
- value= Boolean.TRUE;
- cl.setPropertyValue("PropBoolA", value);
- ret= cl.getPropertyValue("PropBoolA");
- r[i++]= ((Boolean) ret).equals( value);
- value= new Character('A');
- cl.setPropertyValue("PropCharA",value);
- ret= cl.getPropertyValue("PropCharA");
- r[i++]= ((Character) ret).equals(value);
- value= Byte.valueOf((byte) 111);
- cl.setPropertyValue("PropByteA",value);
- ret= cl.getPropertyValue("PropByteA");
- r[i++]= ((Byte) ret).equals(value);
- value= Short.valueOf((short)112);
- cl.setPropertyValue("PropShortA", value);
- ret= cl.getPropertyValue("PropShortA");
- r[i++]= ((Short) ret).equals(value);
- value= Integer.valueOf(113);
- cl.setPropertyValue("PropIntA", value);
- ret= cl.getPropertyValue("PropIntA");
- r[i++]= ((Integer) ret).equals(value);
- value= Long.valueOf(115);
- cl.setPropertyValue("PropLongA", value);
- ret= cl.getPropertyValue("PropLongA");
- r[i++]= ((Long) ret).equals(value);
- value= new Float(3.14);
- cl.setPropertyValue("PropFloatA", value);
- ret= cl.getPropertyValue("PropFloatA");
- r[i++]= ((Float) ret).equals(value);
- value= new Double(3.145);
- cl.setPropertyValue("PropDoubleA",value);
- ret= cl.getPropertyValue("PropDoubleA");
- r[i++]= ((Double) ret).equals(value);
- value= "string";
- cl.setPropertyValue("PropStringA",value);
- ret= cl.getPropertyValue("PropStringA");
- r[i++]= ((String) ret).equals(value);
- value= new ComponentBase();
- cl.setPropertyValue("PropXInterfaceA",value);
- ret= cl.getPropertyValue("PropXInterfaceA");
- r[i++]= ((XInterface) ret).equals(value);
- value= new ComponentBase();
- cl.setPropertyValue("PropXWeakA",value);
- ret= cl.getPropertyValue("PropXWeakA");
- r[i++]= ((XWeak) ret).equals(value);
- value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
- cl.setPropertyValue("PropEnum",value);
- ret= cl.getPropertyValue("PropEnum");
- r[i++]= ret == value;
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropArrayByteA", value);
- ret= cl.getPropertyValue("PropArrayByteA");
- r[i++]= ((byte[]) ret).equals(value);
- value= new Type(String.class);
- cl.setPropertyValue("PropTypeA", value);
- ret= cl.getPropertyValue("PropTypeA");
- r[i++]= ((Type) ret).equals(value);
-
- // test protected,package,private members
- value= Boolean.TRUE;
- cl.setPropertyValue("PropBoolB", value);
- ret= cl.getPropertyValue("PropBoolB");
- r[i++]= ((Boolean) ret).equals(value);
- cl.setPropertyValue("PropBoolC", value);
- ret= cl.getPropertyValue("PropBoolC");
- r[i++]= ((Boolean) ret).equals(value);
-
- try{
- cl.setPropertyValue("PropBoolD", value);
- i++;
- }catch (Exception e)
- {
- r[i++]= true;
- }
- cl.resetPropertyMembers();
-
- value= Boolean.TRUE;
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Boolean) ret).equals(value);
- value= new Character('A');
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Character) ret).equals(value);
- value= Byte.valueOf((byte) 111);
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Byte) ret).equals(value);
- value= Short.valueOf((short)112);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Short) ret).equals(value);
- value= Integer.valueOf(113);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Integer) ret).equals(value);
- value= Long.valueOf(115);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Long) ret).equals(value);
- value= new Float(3.14);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Float) ret).equals(value);
- value= new Double(3.145);
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Double) ret).equals(value);
- value= "string";
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((String) ret).equals(value);
- value= new ComponentBase();
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((XInterface) ret).equals(value);
- value= new ComponentBase();
- cl.setPropertyValue("PropObjectA",value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((XWeak) ret).equals(value);
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((byte[]) ret).equals(value);
- value= new Type(String.class);
- cl.setPropertyValue("PropObjectA", value);
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Type) ret).equals(value);
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), Byte.valueOf((byte)1)));
- ret= cl.getPropertyValue("PropObjectA");
- r[i++]= ((Byte) ret).byteValue() == 1;
-
- cl.resetPropertyMembers();
- value= Boolean.TRUE;
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Character('A');
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= Byte.valueOf((byte) 111);
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= Short.valueOf((short)112);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= Integer.valueOf(113);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= Long.valueOf(115);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Float(3.14);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Double(3.145);
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= "string";
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new ComponentBase();
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new ComponentBase();
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new byte[]{1,2,3};
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Type(String.class);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), Boolean.TRUE);
- cl.setPropertyValue("PropBoolA", value);
- ret= cl.getPropertyValue("PropBoolA");
- r[i++]= ret instanceof Boolean && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropCharA",value);
- ret= cl.getPropertyValue("PropCharA");
- r[i++]= ret instanceof Character && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
- cl.setPropertyValue("PropByteA",value);
- ret= cl.getPropertyValue("PropByteA");
- r[i++]= ret instanceof Byte && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), Short.valueOf((short)112));
- cl.setPropertyValue("PropShortA", value);
- ret= cl.getPropertyValue("PropShortA");
- r[i++]= ret instanceof Short && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), Integer.valueOf(113));
- cl.setPropertyValue("PropIntA", value);
- ret= cl.getPropertyValue("PropIntA");
- r[i++]= ret instanceof Integer && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), Long.valueOf(115));
- cl.setPropertyValue("PropLongA", value);
- ret= cl.getPropertyValue("PropLongA");
- r[i++]= ret instanceof Long && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropFloatA", value);
- ret= cl.getPropertyValue("PropFloatA");
- r[i++]= ret instanceof Float && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropDoubleA",value);
- ret= cl.getPropertyValue("PropDoubleA");
- r[i++]= ret instanceof Double && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), "string");
- cl.setPropertyValue("PropStringA",value);
- ret= cl.getPropertyValue("PropStringA");
- r[i++]= ret instanceof String && util.anyEquals(value, ret);
- value= new Any(new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropXInterfaceA",value);
- ret= cl.getPropertyValue("PropXInterfaceA");
- r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret);
- value= new Any( new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropXWeakA",value);
- ret= cl.getPropertyValue("PropXWeakA");
- r[i++]= ret instanceof ComponentBase && util.anyEquals(value, ret);
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- cl.setPropertyValue("PropArrayByteA", value);
- ret= cl.getPropertyValue("PropArrayByteA");
- r[i++]= ret instanceof byte[] && util.anyEquals(value, ret);
- value= new Any(new Type(Type.class), new Type(String.class));
- cl.setPropertyValue("PropTypeA", value);
- ret= cl.getPropertyValue("PropTypeA");
- r[i++]= ret instanceof Type && util.anyEquals(value, ret);
-
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), Boolean.TRUE);
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), Short.valueOf((short)112));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), Integer.valueOf(113));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), Long.valueOf(115));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), "string");
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any( new Type(ComponentBase.class), new ComponentBase());
- cl.setPropertyValue("PropAnyA",value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
- value= new Any(new Type(Type.class), new Type(String.class));
- cl.setPropertyValue("PropAnyA", value);
- ret= cl.getPropertyValue("PropAnyA");
- r[i++]= ret instanceof Any && util.anyEquals(value, ret);
-
-
-
- cl.resetPropertyMembers();
- value= Boolean.TRUE;
- cl.setPropertyValue("PropBoolClass", value);
- ret= cl.getPropertyValue("PropBoolClass");
- r[i++]= ((Boolean) ret).equals( value);
- value= new Character('A');
- cl.setPropertyValue("PropCharClass",value);
- ret= cl.getPropertyValue("PropCharClass");
- r[i++]= ((Character) ret).equals(value);
- value= Byte.valueOf((byte) 111);
- cl.setPropertyValue("PropByteClass",value);
- ret= cl.getPropertyValue("PropByteClass");
- r[i++]= ((Byte) ret).equals(value);
- value= Short.valueOf((short)112);
- cl.setPropertyValue("PropShortClass", value);
- ret= cl.getPropertyValue("PropShortClass");
- r[i++]= ((Short) ret).equals(value);
- value= Integer.valueOf(113);
- cl.setPropertyValue("PropIntClass", value);
- ret= cl.getPropertyValue("PropIntClass");
- r[i++]= ((Integer) ret).equals(value);
- value= Long.valueOf(115);
- cl.setPropertyValue("PropLongClass", value);
- ret= cl.getPropertyValue("PropLongClass");
- r[i++]= ((Long) ret).equals(value);
- value= new Float(3.14);
- cl.setPropertyValue("PropFloatClass", value);
- ret= cl.getPropertyValue("PropFloatClass");
- r[i++]= ((Float) ret).equals(value);
- value= new Double(3.145);
- cl.setPropertyValue("PropDoubleClass",value);
- ret= cl.getPropertyValue("PropDoubleClass");
- r[i++]= ((Double) ret).equals(value);
-
- cl.resetPropertyMembers();
-
- cl.resetPropertyMembers();
- value= new Any(new Type(boolean.class), Boolean.TRUE);
- cl.setPropertyValue("PropBoolClass", value);
- ret= cl.getPropertyValue("PropBoolClass");
- r[i++]= ret instanceof Boolean && util.anyEquals(value, ret);
- value= new Any (new Type(char.class), new Character('A'));
- cl.setPropertyValue("PropCharClass",value);
- ret= cl.getPropertyValue("PropCharClass");
- r[i++]= ret instanceof Character && util.anyEquals(value, ret);
- value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
- cl.setPropertyValue("PropByteClass",value);
- ret= cl.getPropertyValue("PropByteClass");
- r[i++]= ret instanceof Byte && util.anyEquals(value, ret);
- value= new Any(new Type(short.class), Short.valueOf((short)112));
- cl.setPropertyValue("PropShortClass", value);
- ret= cl.getPropertyValue("PropShortClass");
- r[i++]= ret instanceof Short && util.anyEquals(value, ret);
- value= new Any(new Type(int.class), Integer.valueOf(113));
- cl.setPropertyValue("PropIntClass", value);
- ret= cl.getPropertyValue("PropIntClass");
- r[i++]= ret instanceof Integer && util.anyEquals(value, ret);
- value= new Any(new Type(long.class), Long.valueOf(115));
- cl.setPropertyValue("PropLongClass", value);
- ret= cl.getPropertyValue("PropLongClass");
- r[i++]= ret instanceof Long && util.anyEquals(value, ret);
- value= new Any(new Type(float.class), new Float(3.14));
- cl.setPropertyValue("PropFloatClass", value);
- ret= cl.getPropertyValue("PropFloatClass");
- r[i++]= ret instanceof Float && util.anyEquals(value, ret);
- value= new Any(new Type(double.class),new Double(3.145));
- cl.setPropertyValue("PropDoubleClass",value);
- ret= cl.getPropertyValue("PropDoubleClass");
- r[i++]= ret instanceof Double && util.anyEquals(value, ret);
- value= new Any(new Type(String.class), "string");
-
-
-
- // PropertyAttribute.READONLY
- cl.propBoolA.Attributes= PropertyAttribute.READONLY;
- try{
- cl.setPropertyValue("PropBoolA", Boolean.TRUE);
- i++;
- }catch (com.sun.star.beans.PropertyVetoException e)
- {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= 0;
+ cl.setPropertyValue("PropBoolD", value);
+ fail("com.sun.star.lang.WrappedTargetException expected");
+ } catch(com.sun.star.lang.WrappedTargetException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
+ }
- // MAYBEVOID
- cl.resetPropertyMembers();
- // first MAYBEVOID not set
+ cl.resetPropertyMembers();
+
+ value= Boolean.TRUE;
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Boolean) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new Character('A');
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((Character) cl.getPropertyValue("PropObjectA"), value);
+
+ value= Byte.valueOf((byte) 111);
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((Byte) cl.getPropertyValue("PropObjectA"), value);
+
+ value= Short.valueOf((short)112);
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Short) cl.getPropertyValue("PropObjectA"), value);
+
+ value= Integer.valueOf(113);
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Integer) cl.getPropertyValue("PropObjectA"), value);
+
+ value= Long.valueOf(115);
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Long) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new Float(3.14);
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Float) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new Double(3.145);
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((Double) cl.getPropertyValue("PropObjectA"), value);
+
+ value= "string";
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((String) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((XInterface) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropObjectA",value);
+ assertEquals((XWeak) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new byte[]{1,2,3};
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((byte[]) cl.getPropertyValue("PropObjectA"), value);
+
+ value= new Type(String.class);
+ cl.setPropertyValue("PropObjectA", value);
+ assertEquals((Type) cl.getPropertyValue("PropObjectA"), value);
+
+ cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), Byte.valueOf((byte)1)));
+ assertEquals(((Byte) cl.getPropertyValue("PropObjectA")).byteValue(), 1);
+
+ cl.resetPropertyMembers();
+
+ value= Boolean.TRUE;
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Character('A');
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= Byte.valueOf((byte) 111);
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= Short.valueOf((short)112);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= Integer.valueOf(113);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= Long.valueOf(115);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Float(3.14);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Double(3.145);
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= "string";
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new ComponentBase();
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new byte[]{1,2,3};
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Type(String.class);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ cl.resetPropertyMembers();
+
+ value= new Any(new Type(boolean.class), Boolean.TRUE);
+ cl.setPropertyValue("PropBoolA", value);
+ ret= cl.getPropertyValue("PropBoolA");
+ assertTrue(ret instanceof Boolean);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any (new Type(char.class), new Character('A'));
+ cl.setPropertyValue("PropCharA",value);
+ ret= cl.getPropertyValue("PropCharA");
+ assertTrue(ret instanceof Character);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
+ cl.setPropertyValue("PropByteA",value);
+ ret= cl.getPropertyValue("PropByteA");
+ assertTrue(ret instanceof Byte);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(short.class), Short.valueOf((short)112));
+ cl.setPropertyValue("PropShortA", value);
+ ret= cl.getPropertyValue("PropShortA");
+ assertTrue(ret instanceof Short);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(int.class), Integer.valueOf(113));
+ cl.setPropertyValue("PropIntA", value);
+ ret= cl.getPropertyValue("PropIntA");
+ assertTrue(ret instanceof Integer);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(long.class), Long.valueOf(115));
+ cl.setPropertyValue("PropLongA", value);
+ ret= cl.getPropertyValue("PropLongA");
+ assertTrue(ret instanceof Long);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(float.class), new Float(3.14));
+ cl.setPropertyValue("PropFloatA", value);
+ ret= cl.getPropertyValue("PropFloatA");
+ assertTrue(ret instanceof Float);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(double.class),new Double(3.145));
+ cl.setPropertyValue("PropDoubleA",value);
+ ret= cl.getPropertyValue("PropDoubleA");
+ assertTrue(ret instanceof Double);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(String.class), "string");
+ cl.setPropertyValue("PropStringA",value);
+ ret= cl.getPropertyValue("PropStringA");
+ assertTrue(ret instanceof String);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(ComponentBase.class), new ComponentBase());
+ cl.setPropertyValue("PropXInterfaceA",value);
+ ret= cl.getPropertyValue("PropXInterfaceA");
+ assertTrue(ret instanceof ComponentBase);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any( new Type(ComponentBase.class), new ComponentBase());
+ cl.setPropertyValue("PropXWeakA",value);
+ ret= cl.getPropertyValue("PropXWeakA");
+ assertTrue(ret instanceof ComponentBase);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(byte[].class), new byte[]{1,2,3});
+ cl.setPropertyValue("PropArrayByteA", value);
+ ret= cl.getPropertyValue("PropArrayByteA");
+ assertTrue(ret instanceof byte[]);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(Type.class), new Type(String.class));
+ cl.setPropertyValue("PropTypeA", value);
+ ret= cl.getPropertyValue("PropTypeA");
+ assertTrue(ret instanceof Type);
+ assertTrue(util.anyEquals(value, ret));
+
+ cl.resetPropertyMembers();
+
+ value= new Any(new Type(boolean.class), Boolean.TRUE);
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any (new Type(char.class), new Character('A'));
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(short.class), Short.valueOf((short)112));
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(int.class), Integer.valueOf(113));
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(long.class), Long.valueOf(115));
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(float.class), new Float(3.14));
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(double.class),new Double(3.145));
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(String.class), "string");
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(ComponentBase.class), new ComponentBase());
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any( new Type(ComponentBase.class), new ComponentBase());
+ cl.setPropertyValue("PropAnyA",value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(byte[].class), new byte[]{1,2,3});
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(Type.class), new Type(String.class));
+ cl.setPropertyValue("PropAnyA", value);
+ ret= cl.getPropertyValue("PropAnyA");
+ assertTrue(ret instanceof Any);
+ assertTrue(util.anyEquals(value, ret));
+
+ cl.resetPropertyMembers();
+
+ value= Boolean.TRUE;
+ cl.setPropertyValue("PropBoolClass", value);
+ assertEquals((Boolean) cl.getPropertyValue("PropBoolClass"), value);
+
+ value= new Character('A');
+ cl.setPropertyValue("PropCharClass",value);
+ assertEquals((Character) cl.getPropertyValue("PropCharClass"), value);
+
+ value= Byte.valueOf((byte) 111);
+ cl.setPropertyValue("PropByteClass",value);
+ assertEquals((Byte) cl.getPropertyValue("PropByteClass"), value);
+
+ value= Short.valueOf((short)112);
+ cl.setPropertyValue("PropShortClass", value);
+ assertEquals((Short) cl.getPropertyValue("PropShortClass"), value);
+
+ value= Integer.valueOf(113);
+ cl.setPropertyValue("PropIntClass", value);
+ assertEquals((Integer) cl.getPropertyValue("PropIntClass"), value);
+
+ value= Long.valueOf(115);
+ cl.setPropertyValue("PropLongClass", value);
+ assertEquals((Long) cl.getPropertyValue("PropLongClass"), value);
+
+ value= new Float(3.14);
+ cl.setPropertyValue("PropFloatClass", value);
+ assertEquals((Float) cl.getPropertyValue("PropFloatClass"), value);
+
+ value= new Double(3.145);
+ cl.setPropertyValue("PropDoubleClass",value);
+ assertEquals((Double) cl.getPropertyValue("PropDoubleClass"), value);
+
+ cl.resetPropertyMembers();
+
+ cl.resetPropertyMembers();
+
+ value= new Any(new Type(boolean.class), Boolean.TRUE);
+ cl.setPropertyValue("PropBoolClass", value);
+ ret= cl.getPropertyValue("PropBoolClass");
+ assertTrue(ret instanceof Boolean);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any (new Type(char.class), new Character('A'));
+ cl.setPropertyValue("PropCharClass",value);
+ ret= cl.getPropertyValue("PropCharClass");
+ assertTrue(ret instanceof Character);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(byte.class), Byte.valueOf((byte) 111));
+ cl.setPropertyValue("PropByteClass",value);
+ ret= cl.getPropertyValue("PropByteClass");
+ assertTrue(ret instanceof Byte);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(short.class), Short.valueOf((short)112));
+ cl.setPropertyValue("PropShortClass", value);
+ ret= cl.getPropertyValue("PropShortClass");
+ assertTrue(ret instanceof Short);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(int.class), Integer.valueOf(113));
+ cl.setPropertyValue("PropIntClass", value);
+ ret= cl.getPropertyValue("PropIntClass");
+ assertTrue(ret instanceof Integer);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(long.class), Long.valueOf(115));
+ cl.setPropertyValue("PropLongClass", value);
+ ret= cl.getPropertyValue("PropLongClass");
+ assertTrue(ret instanceof Long);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(float.class), new Float(3.14));
+ cl.setPropertyValue("PropFloatClass", value);
+ ret= cl.getPropertyValue("PropFloatClass");
+ assertTrue(ret instanceof Float);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(double.class),new Double(3.145));
+ cl.setPropertyValue("PropDoubleClass",value);
+ ret= cl.getPropertyValue("PropDoubleClass");
+ assertTrue(ret instanceof Double);
+ assertTrue(util.anyEquals(value, ret));
+
+ value= new Any(new Type(String.class), "string");
+
+ // PropertyAttribute.READONLY
+ cl.propBoolA.Attributes= PropertyAttribute.READONLY;
+ try {
+ cl.setPropertyValue("PropBoolA", Boolean.TRUE);
+ fail("com.sun.star.beans.PropertyVetoException expected");
+ } catch (com.sun.star.beans.PropertyVetoException e) {
+ logger.log(Level.FINE, "com.sun.star.beans.PropertyVetoException caught");
+ }
+ cl.propBoolA.Attributes= 0;
- //primitive members: must not work
+ // MAYBEVOID
+ cl.resetPropertyMembers();
+ // first MAYBEVOID not set
- cl.boolPropA= false;
- try {
- cl.setPropertyValue("PropBoolA", null); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- try {
- cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null)); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID;
- try{
- cl.setPropertyValue("PropBoolA", null); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.propBoolA.Attributes= 0;
-
- cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID;
- cl.boolClassProp= null;
- cl.setPropertyValue("PropBoolClass", null);
- r[i++]= cl.boolClassProp == null;
- // the returned value must be a void any
- Object objAny= cl.getPropertyValue("PropBoolClass");
- r[i++]= util.isVoidAny( objAny);
-
- cl.boolClassProp= Boolean.TRUE;
- cl.setPropertyValue("PropBoolClass", null);
- r[i++]= cl.boolClassProp == null;
- cl.boolClassProp= Boolean.FALSE;
- cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null));
- r[i++]= cl.boolClassProp == null;
-
- cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID;
- cl.setPropertyValue("PropXWeakA", null);
- r[i++]= util.isVoidAny(cl.getPropertyValue("PropXWeakA"));
- cl.propXWeakA.Attributes= 0;
-
- cl.anyPropA= null;
- try{
- cl.setPropertyValue("PropAnyA", null); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e) {
- r[i++]= true;
- }
- cl.anyPropA= null;
- cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID;
+ //primitive members: must not work
- Type _t= new Type(Object.class);
- cl.setPropertyValue("PropAnyA", null);
- r[i++]= cl.anyPropA.getType().equals(new Type(void.class)) &&
- cl.anyPropA.getObject() == null;
+ cl.boolPropA= false;
+ try {
+ cl.setPropertyValue("PropBoolA", null);
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
- cl.anyPropA= new Any(new Type(byte.class),Byte.valueOf((byte) 111));
- cl.setPropertyValue("PropAnyA", null);
- r[i++]= cl.anyPropA.getType().equals(new Type(byte.class)) &&
- cl.anyPropA.getObject() == null;
+ try {
+ cl.setPropertyValue("PropBoolA", new Any(new Type(boolean.class), null));
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
- cl.anyPropA= null;
- try{
- cl.setPropertyValue("PropAnyA", new Object()); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
+ cl.propBoolA.Attributes= PropertyAttribute.MAYBEVOID;
+ try {
+ cl.setPropertyValue("PropBoolA", null);
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
- cl.propObjectA.Attributes= 0;
- try{
- cl.setPropertyValue("PropObjectA", null); i++;
- }catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
- try{
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null)); i++;
- } catch (com.sun.star.lang.IllegalArgumentException e)
- {
- r[i++]= true;
- }
+ cl.propBoolA.Attributes= 0;
- cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID;
- cl.propObjectA= null;
- cl.setPropertyValue("PropObjectA", null);
- r[i++]= cl.propObjectA == null;
+ cl.propBoolClass.Attributes= PropertyAttribute.MAYBEVOID;
+ cl.boolClassProp= null;
+ cl.setPropertyValue("PropBoolClass", null);
+ assertNull(cl.boolClassProp);
- cl.propObjectA= null;
- cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
- r[i++]= cl.propObjectA == null;
+ // the returned value must be a void any
+ Object objAny= cl.getPropertyValue("PropBoolClass");
+ assertTrue(util.isVoidAny( objAny));
+
+ cl.boolClassProp= Boolean.TRUE;
+ cl.setPropertyValue("PropBoolClass", null);
+ assertNull(cl.boolClassProp);
+ cl.boolClassProp= Boolean.FALSE;
+ cl.setPropertyValue("PropBoolClass", new Any(new Type(boolean.class),null));
+ assertNull(cl.boolClassProp);
+ cl.propXWeakA.Attributes= PropertyAttribute.MAYBEVOID;
+ cl.setPropertyValue("PropXWeakA", null);
+ assertTrue(util.isVoidAny(cl.getPropertyValue("PropXWeakA")));
+
+ cl.propXWeakA.Attributes= 0;
+
+ cl.anyPropA= null;
+ try {
+ cl.setPropertyValue("PropAnyA", null);
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
+ cl.anyPropA= null;
+ cl.propAnyA.Attributes= PropertyAttribute.MAYBEVOID;
+
+ Type _t= new Type(Object.class);
+ cl.setPropertyValue("PropAnyA", null);
+ assertEquals(cl.anyPropA.getType(), new Type(void.class));
+ assertNull(cl.anyPropA.getObject());
+
+ cl.anyPropA= new Any(new Type(byte.class),Byte.valueOf((byte) 111));
+ cl.setPropertyValue("PropAnyA", null);
+ assertEquals(cl.anyPropA.getType(), new Type(byte.class));
+ assertNull(cl.anyPropA.getObject());
+
+ cl.anyPropA= null;
+ try {
+ cl.setPropertyValue("PropAnyA", new Object());
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ }catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
+ cl.propObjectA.Attributes= 0;
+ try {
+ cl.setPropertyValue("PropObjectA", null);
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
+ }
- }catch(java.lang.Exception e){
- i++;
+ try {
+ cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
+ fail("com.sun.star.lang.IllegalArgumentException expected");
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.IllegalArgumentException caught");
}
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+
+ cl.propObjectA.Attributes= PropertyAttribute.MAYBEVOID;
+ cl.propObjectA= null;
+ cl.setPropertyValue("PropObjectA", null);
+ assertNull(cl.propObjectA);
+
+ cl.propObjectA= null;
+ cl.setPropertyValue("PropObjectA", new Any( new Type(byte.class), null));
+ assertNull(cl.propObjectA);
}
- public boolean addPropertyChangeListener()
+ @Test public void addPropertyChangeListener() throws Exception
{
logger.log(Level.INFO, "PropertySet.addPropertyChangeListener,\n" +
"PropertySet.removePropertChangeListener," +
"PropertySet.addVetoableChangeListener, \n" +
"PropertySet.removeVetoableChangeListener" +
"Notification of listeners");
- boolean[] r= new boolean[50];
- int i= 0;
+ TestClass cl= new TestClass();
+ Listener li= new Listener();
+
+ cl.addPropertyChangeListener("PropByteA", li);
+ Byte val1= Byte.valueOf((byte)115);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+
+ cl.propByteA.Attributes = PropertyAttribute.BOUND;
+ cl.addPropertyChangeListener("PropByteA", li);
+ Byte val2= Byte.valueOf((byte)116);
+ cl.setPropertyValue("PropByteA", val2);
+ assertEquals(li.nChangeCalled, 1);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li.evt.OldValue, val1);
+ assertEquals(li.evt.NewValue, val2);
+ assertSame(li.evt.Source, cl);
+
+ li.reset();
+ Listener li2= new Listener();
+ cl.addPropertyChangeListener("PropByteA", li2);
+ Byte val3= Byte.valueOf((byte) 117);
+ cl.setPropertyValue("PropByteA", val3);
+ assertEquals(li.nChangeCalled, 1);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 1);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li.evt.OldValue, val2);
+ assertEquals(li.evt.NewValue,val3);
+ assertSame(li.evt.Source, cl);
+ assertEquals(li2.evt.OldValue, val2);
+ assertEquals(li2.evt.NewValue, val3);
+ assertSame(li2.evt.Source, cl);
+
+ li.reset();
+ li2.reset();
+ Listener li3= new Listener();
+ val1= Byte.valueOf((byte)118);
+ cl.addPropertyChangeListener("", li3);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 1);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 1);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 1);
+ assertEquals(li3.nVetoCalled, 0);
+ assertEquals(li.evt.OldValue, val3);
+ assertEquals(li.evt.NewValue, val1);
+ assertSame(li.evt.Source, cl);
+ assertEquals(li2.evt.OldValue, val3);
+ assertEquals(li2.evt.NewValue, val1);
+ assertSame(li2.evt.Source, cl);
+ assertEquals(li3.evt.OldValue, val3);
+ assertEquals(li3.evt.NewValue, val1);
+ assertSame(li3.evt.Source, cl);
+
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.removePropertyChangeListener("PropByteA",li);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 1);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 1);
+ assertEquals(li3.nVetoCalled, 0);
+
+ cl.removePropertyChangeListener("PropByteA", li2);
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 1);
+ assertEquals(li3.nVetoCalled, 0);
+
+ cl.removePropertyChangeListener("", li3);
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.setPropertyValue("PropByteA", val2);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 0);
+ assertEquals(li3.nVetoCalled, 0);
+
+ cl.addPropertyChangeListener("PropByteA", li);
+ cl.addPropertyChangeListener("PropByteA", li2);
+ cl.addPropertyChangeListener("", li3);
+ cl.dispose();
+ li.reset();
+ li2.reset();
+ li3.reset();
try {
- TestClass cl= new TestClass();
- Listener li= new Listener();
- cl.addPropertyChangeListener("PropByteA", li);
- Byte val1= Byte.valueOf((byte)115);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0;
- cl.propByteA.Attributes = PropertyAttribute.BOUND;
- cl.addPropertyChangeListener("PropByteA", li);
- Byte val2= Byte.valueOf((byte)116);
- cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl;
-
- li.reset();
- Listener li2= new Listener();
- cl.addPropertyChangeListener("PropByteA", li2);
- Byte val3= Byte.valueOf((byte) 117);
- cl.setPropertyValue("PropByteA", val3);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl
- && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- Listener li3= new Listener();
- val1= Byte.valueOf((byte)118);
- cl.addPropertyChangeListener("", li3);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 1 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
- r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl;
- r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl;
- r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.removePropertyChangeListener("PropByteA",li);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 1 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
- cl.removePropertyChangeListener("PropByteA", li2);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 1 && li3.nVetoCalled == 0;
-
- cl.removePropertyChangeListener("", li3);
- li.reset();
- li2.reset();
- li3.reset();
cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 0;
-
- cl.addPropertyChangeListener("PropByteA", li);
- cl.addPropertyChangeListener("PropByteA", li2);
- cl.addPropertyChangeListener("", li3);
- cl.dispose();
- li.reset();
- li2.reset();
- li3.reset();
- try {
- cl.setPropertyValue("PropByteA", val2); i++;
- }catch (DisposedException e)
- {
- r[i++]= true;
- }
+ fail("DisposedException expected");
+ } catch (DisposedException e) {
+ logger.log(Level.FINE, "DisposedException caught");
+ }
- //Vetoable tests
- cl= new TestClass();
- li.reset();
- li2.reset();
- li3.reset();
- cl.addVetoableChangeListener("PropByteA", li);
- val1= Byte.valueOf((byte)115);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0;
- cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED;
- cl.addVetoableChangeListener("PropByteA", li);
- val2= Byte.valueOf((byte)116);
- li.reset();
+ //Vetoable tests
+ cl= new TestClass();
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.addVetoableChangeListener("PropByteA", li);
+ val1= Byte.valueOf((byte)115);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+
+ cl.propByteA.Attributes = PropertyAttribute.CONSTRAINED;
+ cl.addVetoableChangeListener("PropByteA", li);
+ val2= Byte.valueOf((byte)116);
+ li.reset();
+ cl.setPropertyValue("PropByteA", val2);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 1);
+ assertEquals(li.evt.OldValue, val1);
+ assertEquals(li.evt.NewValue, val2);
+ assertSame(li.evt.Source, cl);
+
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.addVetoableChangeListener("PropByteA", li2);
+ val3= Byte.valueOf((byte) 117);
+ cl.setPropertyValue("PropByteA", val3);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 1);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 1);
+ assertEquals(li.evt.OldValue, val2);
+ assertEquals(li.evt.NewValue, val3);
+ assertSame(li.evt.Source, cl);
+ assertEquals(li2.evt.OldValue, val2);
+ assertEquals(li2.evt.NewValue, val3);
+ assertSame(li2.evt.Source, cl);
+
+ li.reset();
+ li2.reset();
+ li3.reset();
+ val1= Byte.valueOf((byte)118);
+ cl.addVetoableChangeListener("", li3);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 1);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 1);
+ assertEquals(li3.nChangeCalled, 0);
+ assertEquals(li3.nVetoCalled, 1);
+ assertEquals(li.evt.OldValue, val3);
+ assertEquals(li.evt.NewValue, val1);
+ assertSame(li.evt.Source, cl);
+ assertEquals(li2.evt.OldValue, val3);
+ assertEquals(li2.evt.NewValue, val1);
+ assertSame(li2.evt.Source, cl);
+ assertEquals(li3.evt.OldValue, val3);
+ assertEquals(li3.evt.NewValue, val1);
+ assertSame(li3.evt.Source, cl);
+
+ li.reset();
+ li2.reset();
+ li3.reset();
+ // Test Veto Exception
+ cl.setPropertyValue("PropByteA", val1);
+ li.bVeto= true;
+ try {
cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val1) && li.evt.NewValue.equals(val2) && li.evt.Source == cl;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.addVetoableChangeListener("PropByteA", li2);
- val3= Byte.valueOf((byte) 117);
- cl.setPropertyValue("PropByteA", val3);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val2) && li.evt.NewValue.equals(val3) && li.evt.Source == cl
- && li2.evt.OldValue.equals(val2) && li2.evt.NewValue.equals(val3) && li2.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- val1= Byte.valueOf((byte)118);
- cl.addVetoableChangeListener("", li3);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 1
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
- r[i++]= li.evt.OldValue.equals(val3) && li.evt.NewValue.equals(val1) && li.evt.Source == cl;
- r[i++]= li2.evt.OldValue.equals(val3) && li2.evt.NewValue.equals(val1) && li2.evt.Source == cl;
- r[i++]= li3.evt.OldValue.equals(val3) && li3.evt.NewValue.equals(val1) && li3.evt.Source == cl ;
-
- li.reset();
- li2.reset();
- li3.reset();
- // Test Veto Exception
- cl.setPropertyValue("PropByteA", val1);
- li.bVeto= true;
- try {
- cl.setPropertyValue("PropByteA", val2);i++;
- } catch (PropertyVetoException e)
- {
- r[i++]= true;
- }
- r[i++]= cl.bytePropA == val1.byteValue();
- li.bVeto= false;
-
- li.reset();
- li2.reset();
- li3.reset();
- cl.removeVetoableChangeListener("PropByteA",li);
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 1
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
- cl.removeVetoableChangeListener("PropByteA", li2);
- li.reset();
- li2.reset();
- li3.reset();
- cl.setPropertyValue("PropByteA", val1);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 1;
-
- cl.removeVetoableChangeListener("", li3);
- li.reset();
- li2.reset();
- li3.reset();
+ fail("PropertyVetoException expected");
+ } catch (PropertyVetoException e) {
+ logger.log(Level.FINE, "PropertyVetoException caught");
+ }
+ assertSame(cl.bytePropA, val1.byteValue());
+ li.bVeto= false;
+
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.removeVetoableChangeListener("PropByteA",li);
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 1);
+ assertEquals(li3.nChangeCalled, 0);
+ assertEquals(li3.nVetoCalled, 1);
+
+ cl.removeVetoableChangeListener("PropByteA", li2);
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.setPropertyValue("PropByteA", val1);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 0);
+ assertEquals(li3.nVetoCalled, 1);
+
+ cl.removeVetoableChangeListener("", li3);
+ li.reset();
+ li2.reset();
+ li3.reset();
+ cl.setPropertyValue("PropByteA", val2);
+ assertEquals(li.nChangeCalled, 0);
+ assertEquals(li.nVetoCalled, 0);
+ assertEquals(li2.nChangeCalled, 0);
+ assertEquals(li2.nVetoCalled, 0);
+ assertEquals(li3.nChangeCalled, 0);
+ assertEquals(li3.nVetoCalled, 0);
+
+ cl.addVetoableChangeListener("PropByteA", li);
+ cl.addVetoableChangeListener("PropByteA", li2);
+ cl.addVetoableChangeListener("", li3);
+ cl.dispose();
+ li.reset();
+ li2.reset();
+ li3.reset();
+ try {
cl.setPropertyValue("PropByteA", val2);
- r[i++]= li.nChangeCalled == 0 && li.nVetoCalled == 0
- && li2.nChangeCalled == 0 && li2.nVetoCalled == 0
- && li3.nChangeCalled == 0 && li3.nVetoCalled == 0;
-
- cl.addVetoableChangeListener("PropByteA", li);
- cl.addVetoableChangeListener("PropByteA", li2);
- cl.addVetoableChangeListener("", li3);
- cl.dispose();
- li.reset();
- li2.reset();
- li3.reset();
- try {
- cl.setPropertyValue("PropByteA", val2);
- }catch (DisposedException e)
- {
- r[i++]= true;
- }
- }catch (Exception e)
- {
- i++;
+ fail("DisposedException expected");
+ } catch (DisposedException e) {
+ logger.log(Level.FINE, "DisposedException caught");
}
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
}
- public boolean getPropertySetInfo()
+ @Test public void getPropertySetInfo() throws Exception
{
logger.log(Level.INFO, "PropertySet.getPropertySetInfo");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- XPropertySetInfo info= cl.getPropertySetInfo();
- Property[] arProps= info.getProperties();
- Property[] arRegProps= cl.getRegisteredProperties();
- r[i++]= arProps.length == arRegProps.length;
- for (int j= 0; j < arProps.length; j++)
+ XPropertySetInfo info= cl.getPropertySetInfo();
+ Property[] arProps= info.getProperties();
+ Property[] arRegProps= cl.getRegisteredProperties();
+ assertEquals(arProps.length, arRegProps.length);
+
+ for (int j= 0; j < arProps.length; j++)
+ {
+ boolean bFound= false;
+ for (int k= 0; k < arRegProps.length; k++)
{
- boolean bFound= false;
- for (int k= 0; k < arRegProps.length; k++)
+ if (arProps[j] == arRegProps[k])
{
- if (arProps[j] == arRegProps[k])
- {
- bFound= true;
- break;
- }
+ bFound= true;
+ break;
}
- if ( !bFound)
- r[i++]= false;
- }
-
- for (int j= 0; j < arRegProps.length; j++)
- {
- Property prop= info.getPropertyByName(arRegProps[j].Name);
- if (prop != arRegProps[j])
- r[i++]= false;
- if (! info.hasPropertyByName(arRegProps[j].Name))
- r[i++]= false;
}
-
-
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
+ assertTrue(bFound);
}
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ for (int j= 0; j < arRegProps.length; j++)
+ {
+ Property prop= info.getPropertyByName(arRegProps[j].Name);
+ assertSame(prop, arRegProps[j]);
+ assertTrue(info.hasPropertyByName(arRegProps[j].Name));
+ }
}
- public boolean setFastPropertyValue()
+ @Test public void setFastPropertyValue() throws Exception
{
logger.log(Level.INFO, "PropertySet.setFastPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
+ cl.setFastPropertyValue(5, Integer.valueOf(111));
+ assertEquals(cl.intPropA,111);
try {
- cl.setFastPropertyValue(5, Integer.valueOf(111));
- r[i++]= cl.intPropA == 111;
- try {
- cl.setFastPropertyValue(-1, Integer.valueOf(1)); i++;
- } catch(UnknownPropertyException e)
- {
- r[i++]= true;
- }
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
+ cl.setFastPropertyValue(-1, Integer.valueOf(1));
+ fail("UnknownPropertyException expected");
+ } catch(UnknownPropertyException e) {
+ logger.log(Level.FINE, "UnknownPropertyException caught");
}
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
}
- public boolean getFastPropertyValue()
+ @Test public void getFastPropertyValue() throws Exception
{
logger.log(Level.INFO, "PropertySet.setFastPropertyValue");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- cl.setFastPropertyValue(5, Integer.valueOf(111));
- Integer aInt= (Integer) cl.getFastPropertyValue(5);
- r[i++]= aInt.intValue() == 111;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ cl.setFastPropertyValue(5, Integer.valueOf(111));
+ Integer aInt= (Integer) cl.getFastPropertyValue(5);
+ assertEquals(aInt.intValue(), 111);
}
- public boolean setPropertyValues()
+ @Test public void setPropertyValues() throws Exception
{
logger.log(Level.INFO, "PropertySet.setPropertyValues");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- cl.setPropertyValues(new String[0], new Object[0]);
- String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"};
- Character aChar= new Character('A');
- Integer aInt= Integer.valueOf(111);
- Byte aByte= Byte.valueOf((byte)11);
- Object[] values= new Object[]{aChar, aInt, aByte};
- cl.setPropertyValues(arNames, values);
- r[i++]= cl.charPropA == 'A' && cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11;
-
- arNames= new String[] {"blabla","PropIntClass","PropObjectA"};
- cl.resetPropertyMembers();
- cl.setPropertyValues(arNames, values);
- r[i++]= cl.intClassProp.intValue() == 111 && ((Byte)cl.objectPropA).byteValue() == 11;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ cl.setPropertyValues(new String[0], new Object[0]);
+ String[] arNames= new String[] {"PropCharA","PropIntClass","PropObjectA"};
+ Character aChar= new Character('A');
+ Integer aInt= Integer.valueOf(111);
+ Byte aByte= Byte.valueOf((byte)11);
+ Object[] values= new Object[]{aChar, aInt, aByte};
+ cl.setPropertyValues(arNames, values);
+ assertEquals(cl.charPropA, 'A');
+ assertEquals(cl.intClassProp.intValue(), 111);
+ assertEquals(((Byte)cl.objectPropA).byteValue(), 11);
+
+ arNames= new String[] {"blabla","PropIntClass","PropObjectA"};
+ cl.resetPropertyMembers();
+ cl.setPropertyValues(arNames, values);
+ assertEquals(cl.intClassProp.intValue(), 111);
+ assertEquals(((Byte)cl.objectPropA).byteValue(), 11);
}
- public boolean getPropertyValues()
+ @Test public void getPropertyValues() throws Exception
{
logger.log(Level.INFO, "PropertySet.getPropertyValues");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- cl.charPropA= 'A';
- cl.intClassProp= Integer.valueOf(111);
- cl.objectPropA= Byte.valueOf((byte)11);
- Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"});
-
- r[i++]= ((Character) values[0]).charValue() == 'A' && ((Integer) values[1]).intValue() == 111
- && ((Byte) values[2]).byteValue() == 11;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ cl.charPropA= 'A';
+ cl.intClassProp= Integer.valueOf(111);
+ cl.objectPropA= Byte.valueOf((byte)11);
+ Object[] values= cl.getPropertyValues(new String[] {"PropCharA","PropIntClass","PropObjectA"});
+ assertEquals(((Character) values[0]).charValue(), 'A');
+ assertEquals(((Integer) values[1]).intValue(), 111);
+ assertEquals(((Byte) values[2]).byteValue(), 11);
}
// Currently the listeners are always notified if one of properties has changed.
// The property names in the first argument are ignored.
- public boolean addPropertiesChangeListener()
+ @Test public void addPropertiesChangeListener() throws Exception
{
logger.log(Level.INFO, "PropertySet.addPropertiesChangeListener\n" +
"PropertySet.removePropertiesChangeListener\n" +
"notification of such listeners");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- Listener li1= new Listener();
- Listener li2= new Listener();
- cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1);
- cl.setPropertyValue("PropCharA", new Character('B'));
- r[i++]= li1.nPropertiesChange == 0;
- cl.propCharA.Attributes= PropertyAttribute.BOUND;
- cl.setPropertyValue("PropCharA", new Character('C'));
- r[i++]= li1.nPropertiesChange == 1;
-
- PropertyChangeEvent evt= li1.arEvt[0];
- r[i++]= evt.PropertyName.equals("PropCharA") && ((Character)evt.OldValue).charValue() == 'B'
- && ((Character) evt.NewValue).charValue() == 'C';
- li1.reset();
- cl.removePropertiesChangeListener(li1);
- cl.setPropertyValue("PropCharA", new Character('F'));
- r[i++]= li1.nPropertiesChange == 0;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ Listener li1= new Listener();
+
+ cl.addPropertiesChangeListener(new String[]{"PropCharA"}, li1);
+ cl.setPropertyValue("PropCharA", new Character('B'));
+ assertEquals(li1.nPropertiesChange, 0);
+
+ cl.propCharA.Attributes= PropertyAttribute.BOUND;
+ cl.setPropertyValue("PropCharA", new Character('C'));
+ assertEquals(li1.nPropertiesChange, 1);
+
+ PropertyChangeEvent evt= li1.arEvt[0];
+ assertEquals(evt.PropertyName, "PropCharA");
+ assertEquals(((Character)evt.OldValue).charValue(), 'B');
+ assertEquals(((Character) evt.NewValue).charValue(), 'C');
+
+ li1.reset();
+ cl.removePropertiesChangeListener(li1);
+ cl.setPropertyValue("PropCharA", new Character('F'));
+ assertEquals(li1.nPropertiesChange, 0);
}
- public boolean firePropertiesChangeEvent()
+ @Test public void firePropertiesChangeEvent() throws Exception
{
logger.log(Level.INFO, "PropertySet.firePropertiesChangeEvent");
- boolean[] r= new boolean[50];
- int i= 0;
-
TestClass cl= new TestClass();
- try {
- Listener li1= new Listener();
- cl.intClassProp= Integer.valueOf(111);
- cl.charPropA= 'A';
- cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"}, li1);
- r[i++]= li1.nPropertiesChange == 1;
- PropertyChangeEvent[] arEvt= li1.arEvt;
- r[i++]= arEvt[0].PropertyName.equals("PropCharA")
- && ((Character) arEvt[0].OldValue).charValue() == 'A'
- && ((Character) arEvt[0].NewValue).charValue() == 'A';
- r[i++]= arEvt[1].PropertyName.equals("PropIntClass")
- && ((Integer) arEvt[1].OldValue).intValue() == 111
- && ((Integer) arEvt[1].NewValue).intValue() == 111;
- }catch(java.lang.Exception e){
- System.out.println(e.getMessage());
- i++;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
+ Listener li1= new Listener();
+
+ cl.intClassProp= Integer.valueOf(111);
+ cl.charPropA= 'A';
+ cl.firePropertiesChangeEvent(new String[]{"PropCharA","PropIntClass"}, li1);
+ assertEquals(li1.nPropertiesChange, 1);
+
+ PropertyChangeEvent[] arEvt= li1.arEvt;
+ assertEquals(arEvt[0].PropertyName, "PropCharA");
+ assertEquals(((Character) arEvt[0].OldValue).charValue(), 'A');
+ assertEquals(((Character) arEvt[0].NewValue).charValue(), 'A');
+ assertEquals(arEvt[1].PropertyName, "PropIntClass");
+ assertEquals(((Integer) arEvt[1].OldValue).intValue(), 111);
+ assertEquals(((Integer) arEvt[1].NewValue).intValue(), 111);
}
- public boolean registerProperty1()
+ @Test public void registerProperty1() throws Exception
{
TestClass2 cl= new TestClass2();
- return cl.test_registerProperty1();
+ cl.test_registerProperty1();
}
- public boolean registerProperty2()
+ @Test public void registerProperty2() throws Exception
{
TestClass2 cl= new TestClass2();
- return cl.test_registerProperty2();
- }
-
- public static boolean test()
- {
- PropertySet_Test test= new PropertySet_Test();
- boolean r[]= new boolean[50];
- int i= 0;
- r[i++]= test.convertPropertyValue();
- r[i++]= test.setPropertyValueNoBroadcast();
- r[i++]= test.setPropertyValue();
- r[i++]= test.addPropertyChangeListener();
- r[i++]= test.getPropertySetInfo();
- r[i++]= test.setFastPropertyValue();
- r[i++]= test.getFastPropertyValue();
- r[i++]= test.setPropertyValues();
- r[i++]= test.getPropertyValues();
- r[i++]= test.addPropertiesChangeListener();
- r[i++]= test.firePropertiesChangeEvent();
- r[i++]= test.registerProperty1();
- r[i++]= test.registerProperty2();
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- logger.log(Level.INFO, bOk ? "Ok" : "Failed");
- return bOk;
- }
-
- public static void main(String[] args)
- {
- System.exit( test() ? 0: -1 );
+ cl.test_registerProperty2();
}
}
class TestClass extends PropertySet
{
+ private static final Logger logger = Logger.getLogger(TestClass.class.getName());
+
public Property propBoolA= new Property("PropBoolA", 1, new Type(Boolean.TYPE), (short)0);
public boolean boolPropA;
public Property propCharA= new Property("PropCharA", 2, new Type(Character.TYPE), (short) 0);
@@ -1110,8 +1106,8 @@ class TestClass extends PropertySet
{
super();
-// When adding properties then modify the getRegisteredProperties method
- //registerProperty(String name, int handle, Type type, short attributes, String memberName)
+ // When adding properties then modify the getRegisteredProperties method
+ // registerProperty(String name, int handle, Type type, short attributes, String memberName)
registerProperty(propBoolA, "boolPropA");
registerProperty(propCharA, "charPropA");
registerProperty(propByteA, "bytePropA");
@@ -1156,242 +1152,305 @@ class TestClass extends PropertySet
};
}
- public boolean test_convertPropertyValue()
- {
- boolean[] r= new boolean[150];
- int i= 0;
+ public void test_convertPropertyValue() throws Exception
+ {
resetPropertyMembers();
Object[] outOldVal= new Object[1];
Object[] outNewVal= new Object[1];
Object value= Boolean.TRUE;
- try
- {
- r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value) && outOldVal[0].equals(Boolean.FALSE);
- value= new Character('A');
- r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character((char)0));
- charPropA= 'B';
- r[i++]= convertPropertyValue(propCharA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value) && outOldVal[0].equals(new Character('B'));
- value= Byte.valueOf((byte) 111);
- r[i++]= convertPropertyValue(propByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value);
- value= Short.valueOf((short) 112);
- r[i++]= convertPropertyValue(propShortA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value);
- value= Integer.valueOf( 113);
- r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= Long.valueOf(114);
- r[i++]= convertPropertyValue(propLongA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value);
- value= new Float(3.14);
- r[i++]= convertPropertyValue(propFloatA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value);
- value= new Double(3.145);
- r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value);
- value= "string";
- r[i++]= convertPropertyValue(propStringA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof String && outNewVal[0].equals(value);
- value= new byte[]{1,2,3};
- arBytePropA= null;
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof byte[] && outNewVal[0].equals(value) && outOldVal[0] == null;
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outOldVal[0] == null;
- value= new Type(XInterface.class);
- r[i++]= convertPropertyValue(propTypeA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Type && outNewVal[0].equals(value);
-
- value= new Object(); // TypeClass.VOID
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0].equals(value);
- value= Integer.valueOf(111);
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= new ComponentBase();
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0].equals(value);
- value= Integer.valueOf(111);
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Any && ((Any)outNewVal[0]).getType().equals(new Type(Integer.class))
- && ((Any)outNewVal[0]).getObject().equals(value);
- XWeak oWeak= new ComponentBase();
- value= oWeak;
- // The returned Any must contain an XInterface
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= ((Any) outNewVal[0]).getType().equals(new Type(XInterface.class))
- && ((Any) outNewVal[0]).getObject() == oWeak;
- value= new ComponentBase();
- r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0].equals(value);
- r[i++]= convertPropertyValue(propXWeakA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XWeak && outNewVal[0].equals(value);
-
- value = com.sun.star.beans.PropertyState.DIRECT_VALUE;
- r[i++]= convertPropertyValue(propEnum, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof com.sun.star.uno.Enum && outNewVal[0].equals(value);
-
- // Any arguments ------------------------------------------------------------------
- value= new Any( new Type(Integer.class),Integer.valueOf(111));
- r[i++]= convertPropertyValue(propIntA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && ((Integer)outNewVal[0]).equals( ((Any)value).getObject());
- value= new Any(new Type(Boolean.class), Boolean.TRUE);
- r[i++]= convertPropertyValue(propBoolA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && ((Boolean)outNewVal[0]).equals(((Any) value).getObject());
- //Character, Byte, Short, Long
- // must fail
+ assertTrue(convertPropertyValue(propBoolA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Boolean);
+ assertEquals(outNewVal[0], value);
+ assertEquals(outOldVal[0], Boolean.FALSE);
+
+ value= new Character('A');
+ assertTrue(convertPropertyValue(propCharA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Character);
+ assertEquals(outNewVal[0], value);
+ assertEquals(outOldVal[0], new Character((char)0));
+
+ charPropA= 'B';
+ assertTrue(convertPropertyValue(propCharA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Character);
+ assertEquals(outNewVal[0], value);
+ assertEquals(outOldVal[0], new Character('B'));
+
+ value= Byte.valueOf((byte) 111);
+ assertTrue(convertPropertyValue(propByteA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Byte);
+ assertEquals(outNewVal[0], value);
+
+ value= Short.valueOf((short) 112);
+ assertTrue(convertPropertyValue(propShortA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Short);
+ assertEquals(outNewVal[0], value);
+
+ value= Integer.valueOf( 113);
+ assertTrue(convertPropertyValue(propIntA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Integer);
+ assertEquals(outNewVal[0], value);
+
+ value= Long.valueOf(114);
+ assertTrue(convertPropertyValue(propLongA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Long);
+ assertEquals(outNewVal[0], value);
+
+ value= new Float(3.14);
+ assertTrue(convertPropertyValue(propFloatA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Float);
+ assertEquals(outNewVal[0], value);
+
+ value= new Double(3.145);
+ assertTrue(convertPropertyValue(propDoubleA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Double);
+ assertEquals(outNewVal[0], value);
+
+ value= "string";
+ assertTrue(convertPropertyValue(propStringA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof String);
+ assertEquals(outNewVal[0], value);
+
+ value= new byte[]{1,2,3};
+ arBytePropA= null;
+ assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof byte[]);
+ assertEquals(outNewVal[0], value);
+ assertNull(outOldVal[0]);
+
+ assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
+ assertNull(outOldVal[0]);
+
+ value= new Type(XInterface.class);
+ assertTrue(convertPropertyValue(propTypeA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Type);
+ assertEquals(outNewVal[0], value);
+
+ value= new Object(); // TypeClass.VOID
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertEquals(outNewVal[0], value);
+
+ value= Integer.valueOf(111);
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Integer);
+ assertEquals(outNewVal[0], value);
+
+ value= new ComponentBase();
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertEquals(outNewVal[0], value);
+
+ value= Integer.valueOf(111);
+ assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Any);
+ assertEquals(((Any)outNewVal[0]).getType(), new Type(Integer.class));
+ assertEquals(((Any)outNewVal[0]).getObject(), value);
+
+ XWeak oWeak= new ComponentBase();
+ value= oWeak;
+ // The returned Any must contain an XInterface
+ assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
+ assertEquals(((Any) outNewVal[0]).getType(), new Type(XInterface.class));
+ assertSame(((Any) outNewVal[0]).getObject(), oWeak);
+
+ value= new ComponentBase();
+ assertTrue(convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof XInterface);
+ assertEquals(outNewVal[0], value);
+ assertTrue(convertPropertyValue(propXWeakA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof XWeak);
+ assertEquals(outNewVal[0], value);
+
+ value = com.sun.star.beans.PropertyState.DIRECT_VALUE;
+ assertTrue(convertPropertyValue(propEnum, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof com.sun.star.uno.Enum);
+ assertEquals(outNewVal[0], value);
+
+ // Any arguments ------------------------------------------------------------------
+ value= new Any( new Type(Integer.class),Integer.valueOf(111));
+ assertTrue(convertPropertyValue(propIntA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Integer);
+ assertEquals((Integer) outNewVal[0], ((Any) value).getObject());
+
+ value= new Any(new Type(Boolean.class), Boolean.TRUE);
+ assertTrue(convertPropertyValue(propBoolA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Boolean);
+ assertEquals((Boolean) outNewVal[0], ((Any) value).getObject());
+
+ //Character, Byte, Short, Long
+ // must fail
+ try {
value= new Any(new Type(Object.class), new Object());
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- value= new Any(new Type(Integer.class), Integer.valueOf(111));
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals( ((Any)value).getObject());
- r[i++]= convertPropertyValue(propAnyA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Any && ((Any) outNewVal[0]).getType().equals( ((Any) value).getType())
- && ((Any) outNewVal[0]).getObject().equals( ((Any) value).getObject());
- value= new Any(new Type(XInterface.class), new ComponentBase());
- r[i++]= convertPropertyValue(propObjectA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof XInterface && outNewVal[0] == ((Any) value).getObject();
- r[i++]= convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] == ((Any) value).getObject();
- value= new Any(new Type(byte[].class), new byte[]{1,2,3});
- r[i++]= convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof byte[];
-
-
-
- // test private, protected, package fields
- value= Boolean.TRUE;
- r[i++]= convertPropertyValue(propBoolB, outNewVal, outOldVal, value);
- r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue();
- r[i++]= convertPropertyValue(propBoolC, outNewVal, outOldVal, value);
- r[i++]= ((Boolean)value).booleanValue() == ((Boolean) outNewVal[0]).booleanValue();
- // must fail because the member boolPropD is private
- try{
- convertPropertyValue(propBoolD, outNewVal, outOldVal, value);
- i++;
- }catch (Exception e)
- {
- r[i++]= true;
- }
+ fail("java.lang.IllegalArgumentException expected");
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
+ } catch (java.lang.IllegalArgumentException e) {
+ logger.log(Level.FINE, "java.lang.IllegalArgumentException caught");
+ }
- // Properties member of type Byte,Short etc.
- value= Boolean.TRUE;
- r[i++]= convertPropertyValue(propBoolClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Boolean && outNewVal[0].equals(value);
- value= new Character('A');
- r[i++]= convertPropertyValue(propCharClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Character && outNewVal[0].equals(value);
- value= Byte.valueOf((byte) 111);
- r[i++]= convertPropertyValue(propByteClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Byte && outNewVal[0].equals(value);
- value= Short.valueOf((short) 112);
- r[i++]= convertPropertyValue(propShortClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Short && outNewVal[0].equals(value);
- value= Integer.valueOf( 113);
- r[i++]= convertPropertyValue(propIntClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Integer && outNewVal[0].equals(value);
- value= Long.valueOf(114);
- r[i++]= convertPropertyValue(propLongClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Long && outNewVal[0].equals(value);
- value= new Float(3.14);
- r[i++]= convertPropertyValue(propFloatClass, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Float && outNewVal[0].equals(value);
- value= new Double(3.145);
- r[i++]= convertPropertyValue(propDoubleA, outNewVal, outOldVal, value);
- r[i++]= outNewVal[0] instanceof Double && outNewVal[0].equals(value);
- }catch (com.sun.star.uno.Exception e)
- {
- i++;
+ value= new Any(new Type(Integer.class), Integer.valueOf(111));
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Integer);
+ assertEquals(outNewVal[0], ((Any)value).getObject());
+ assertTrue(convertPropertyValue(propAnyA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Any);
+ assertEquals(((Any) outNewVal[0]).getType(), ((Any) value).getType());
+ assertEquals(((Any) outNewVal[0]).getObject(), ((Any) value).getObject());
+
+ value= new Any(new Type(XInterface.class), new ComponentBase());
+ assertTrue(convertPropertyValue(propObjectA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof XInterface);
+ assertSame(outNewVal[0], ((Any) value).getObject());
+ assertTrue(convertPropertyValue(propXInterfaceA, outNewVal, outOldVal, value));
+ assertSame(outNewVal[0], ((Any) value).getObject());
+
+ value= new Any(new Type(byte[].class), new byte[]{1,2,3});
+ assertTrue(convertPropertyValue(propArrayByteA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof byte[]);
+
+ // test private, protected, package fields
+ value= Boolean.TRUE;
+ assertTrue(convertPropertyValue(propBoolB, outNewVal, outOldVal, value));
+ assertEquals(((Boolean)value).booleanValue(), ((Boolean) outNewVal[0]).booleanValue());
+ assertTrue(convertPropertyValue(propBoolC, outNewVal, outOldVal, value));
+ assertEquals(((Boolean)value).booleanValue(), ((Boolean) outNewVal[0]).booleanValue());
+ // must fail because the member boolPropD is private
+ try{
+ convertPropertyValue(propBoolD, outNewVal, outOldVal, value);
+ fail("com.sun.star.lang.WrappedTargetException expected");
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
}
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- return bOk;
+ // Properties member of type Byte,Short etc.
+ value= Boolean.TRUE;
+ assertTrue(convertPropertyValue(propBoolClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Boolean);
+ assertEquals(outNewVal[0], value);
+
+ value= new Character('A');
+ assertTrue(convertPropertyValue(propCharClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Character);
+ assertEquals(outNewVal[0], value);
+
+ value= Byte.valueOf((byte) 111);
+ assertTrue(convertPropertyValue(propByteClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Byte);
+ assertEquals(outNewVal[0], value);
+
+ value= Short.valueOf((short) 112);
+ assertTrue(convertPropertyValue(propShortClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Short);
+ assertEquals(outNewVal[0], value);
+
+ value= Integer.valueOf(113);
+ assertTrue(convertPropertyValue(propIntClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Integer);
+ assertEquals(outNewVal[0], value);
+
+ value= Long.valueOf(114);
+ assertTrue(convertPropertyValue(propLongClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Long);
+ assertEquals(outNewVal[0], value);
+
+ value= new Float(3.14);
+ assertTrue(convertPropertyValue(propFloatClass, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Float);
+ assertEquals(outNewVal[0], value);
+
+ value= new Double(3.145);
+ assertTrue(convertPropertyValue(propDoubleA, outNewVal, outOldVal, value));
+ assertTrue(outNewVal[0] instanceof Double);
+ assertEquals(outNewVal[0], value);
}
- public boolean test_setPropertyValueNoBroadcast()
+ public void test_setPropertyValueNoBroadcast() throws Exception
{
- boolean[] r= new boolean[150];
- int i= 0;
resetPropertyMembers();
+
+ Object value= Boolean.TRUE;
+ setPropertyValueNoBroadcast(propBoolA, value);
+ assertEquals(boolPropA, ((Boolean) value).booleanValue());
+
+ value= new Character('A');
+ setPropertyValueNoBroadcast(propCharA, value);
+ assertEquals(charPropA, ((Character) value).charValue());
+
+ value= Byte.valueOf((byte) 111);
+ setPropertyValueNoBroadcast(propByteA, value);
+ assertEquals(bytePropA, ((Byte)value).byteValue());
+
+ value= Short.valueOf((short) 112);
+ setPropertyValueNoBroadcast(propShortA, value);
+ assertEquals(shortPropA, ((Short) value).shortValue());
+
+ value= Integer.valueOf( 113);
+ setPropertyValueNoBroadcast(propIntA, value);
+ assertEquals(intPropA, ((Integer) value).intValue());
+
+ value= Long.valueOf(114);
+ setPropertyValueNoBroadcast(propLongA, value);
+ assertEquals(longPropA, ((Long) value).longValue());
+
+ value= new Float(3.14);
+ setPropertyValueNoBroadcast(propFloatA, value);
+ assertEquals(floatPropA, ((Float) value).floatValue(), 0.0f);
+
+ value= new Double(3.145);
+ setPropertyValueNoBroadcast(propDoubleA, value);
+ assertEquals(doublePropA, ((Double) value).doubleValue(), 0.0f);
+
+ value= "string";
+ setPropertyValueNoBroadcast(propStringA, value);
+ assertEquals(stringPropA, value);
+
+ value= new byte[]{1,2,3};
+ setPropertyValueNoBroadcast(propArrayByteA, value);
+ assertEquals(arBytePropA, value);
+
+ value= new Type(XInterface.class);
+ setPropertyValueNoBroadcast(propTypeA, value);
+ assertEquals(typePropA, value);
+
+ value= Integer.valueOf(111);
+ setPropertyValueNoBroadcast(propObjectA, value);
+ assertEquals(objectPropA, value);
+
+ value= new ComponentBase();
+ setPropertyValueNoBroadcast(propObjectA, value);
+ assertEquals(objectPropA, value);
+
+ value= new Any( new Type(Integer.TYPE), Integer.valueOf(111));
+ setPropertyValueNoBroadcast(propAnyA, value);
+ assertTrue(util.anyEquals(anyPropA, value));
+
+ value= new ComponentBase();
+ setPropertyValueNoBroadcast(propXInterfaceA, value);
+ assertTrue(xInterfacePropA instanceof XInterface);
+ assertEquals(xInterfacePropA, value);
+
+ setPropertyValueNoBroadcast(propXWeakA, value);
+ assertTrue(xInterfacePropA instanceof XWeak);
+ assertEquals(xInterfacePropA, value);
+
+ value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
+ setPropertyValueNoBroadcast(propEnum, value);
+ assertSame(enumPropertyState, value);
+
+ value= Boolean.TRUE;
+ setPropertyValueNoBroadcast(propBoolB, value);
+ assertEquals(boolPropB, ((Boolean) value).booleanValue());
+
+ setPropertyValueNoBroadcast(propBoolC, value);
+ assertEquals(boolPropC, ((Boolean) value).booleanValue());
+
+ // must fail because the member boolPropD is private
try {
- Object value= Boolean.TRUE;
- setPropertyValueNoBroadcast(propBoolA, value);
- r[i++]= boolPropA == ((Boolean) value).booleanValue();
- value= new Character('A');
- setPropertyValueNoBroadcast(propCharA, value);
- r[i++]= charPropA == ((Character) value).charValue();
- value= Byte.valueOf((byte) 111);
- setPropertyValueNoBroadcast(propByteA, value);
- r[i++]= bytePropA == ((Byte)value).byteValue();
- value= Short.valueOf((short) 112);
- setPropertyValueNoBroadcast(propShortA, value);
- r[i++]= shortPropA == ((Short) value).shortValue();
- value= Integer.valueOf( 113);
- setPropertyValueNoBroadcast(propIntA, value);
- r[i++]= intPropA == ((Integer) value).intValue();
- value= Long.valueOf(114);
- setPropertyValueNoBroadcast(propLongA, value);
- r[i++]= longPropA == ((Long) value).longValue();
- value= new Float(3.14);
- setPropertyValueNoBroadcast(propFloatA, value);
- r[i++]= floatPropA == ((Float) value).floatValue();
- value= new Double(3.145);
- setPropertyValueNoBroadcast(propDoubleA, value);
- r[i++]= doublePropA == ((Double) value).doubleValue();
- value= "string";
- setPropertyValueNoBroadcast(propStringA, value);
- r[i++]= stringPropA.equals(value);
- value= new byte[]{1,2,3};
- setPropertyValueNoBroadcast(propArrayByteA, value);
- r[i++]= arBytePropA.equals(value);
- value= new Type(XInterface.class);
- setPropertyValueNoBroadcast(propTypeA, value);
- r[i++]= typePropA.equals(value);
- value= Integer.valueOf(111);
- setPropertyValueNoBroadcast(propObjectA, value);
- r[i++]= objectPropA.equals(value);
- value= new ComponentBase();
- setPropertyValueNoBroadcast(propObjectA, value);
- r[i++]= objectPropA.equals(value);
- value= new Any( new Type(Integer.TYPE), Integer.valueOf(111));
- setPropertyValueNoBroadcast(propAnyA, value);
- r[i++]= util.anyEquals(anyPropA, value);
- value= new ComponentBase();
- setPropertyValueNoBroadcast(propXInterfaceA, value);
- r[i++]= xInterfacePropA instanceof XInterface && xInterfacePropA.equals(value);
- setPropertyValueNoBroadcast(propXWeakA, value);
- r[i++]= xInterfacePropA instanceof XWeak && xInterfacePropA.equals(value);
- value = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE;
- setPropertyValueNoBroadcast(propEnum, value);
- r[i++]= enumPropertyState == value;
- value= Boolean.TRUE;
- setPropertyValueNoBroadcast(propBoolB, value);
- r[i++]= boolPropB == ((Boolean) value).booleanValue();
- setPropertyValueNoBroadcast(propBoolC, value);
- r[i++]= boolPropC == ((Boolean) value).booleanValue();
- // must fail because the member boolPropD is private
- try{
setPropertyValueNoBroadcast(propBoolD, value);
- }catch(com.sun.star.lang.WrappedTargetException e)
- {
- r[i++]= true;
- }
- }catch (java.lang.Exception e)
- {
- i++;
+ fail("com.sun.star.lang.WrappedTargetException expected");
+ } catch (com.sun.star.lang.WrappedTargetException e) {
+ logger.log(Level.FINE, "com.sun.star.lang.WrappedTargetException caught");
}
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- return bOk;
}
void resetPropertyMembers()
@@ -1438,11 +1497,8 @@ class TestClass2 extends PropertySet
protected Character charClassB;
Character charClassC;
- boolean test_registerProperty1()
+ void test_registerProperty1() throws Exception
{
- boolean r[]= new boolean[50];
- int i= 0;
-
registerProperty("PropChar", new Type(char.class), (short) 0, "PropChar");
registerProperty("PropInt", new Type(int.class), (short) 0, "PropInt");
registerProperty("PropString", new Type(String.class), (short) 0, "PropString");
@@ -1451,35 +1507,24 @@ class TestClass2 extends PropertySet
Property[] props= info.getProperties();
for (int j= 0; j < props.length; j++)
{
+ boolean result= false;
Property aProp= props[j];
if (aProp.Name.equals("PropChar") && aProp.Type.equals(new Type(char.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("PropInt") && aProp.Type.equals(new Type(int.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("PropString") && aProp.Type.equals(new Type(String.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
- else
- r[i++]= false;
+ result= true;
+ assertTrue(result);
}
-
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (!bOk)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
}
- boolean test_registerProperty2()
+ void test_registerProperty2() throws Exception
{
System.out.println("registerProperty Test 2");
- boolean r[]= new boolean[50];
- int i= 0;
registerProperty("charA", "charA", (short) 0);
registerProperty("charB", "charB", (short) 0);
@@ -1491,53 +1536,34 @@ class TestClass2 extends PropertySet
Property[] props= info.getProperties();
for (int j= 0; j < props.length; j++)
{
+ boolean result= false;
Property aProp= props[j];
if (aProp.Name.equals("charA") && aProp.Type.equals(new Type(char.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("charB") && aProp.Type.equals(new Type(char.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("charC") && aProp.Type.equals(new Type(char.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("charClassB") && aProp.Type.equals(new Type(char.class)) &&
aProp.Attributes == PropertyAttribute.MAYBEVOID)
- r[i++]= true;
+ result= true;
else if (aProp.Name.equals("IntProp") && aProp.Type.equals(new Type(int.class)) &&
aProp.Attributes == 0)
- r[i++]= true;
- else
- r[i++]= false;
+ result= true;
+ assertTrue(result);
}
- Object ret;
Object val= new Character('A');
- try{
- setPropertyValue("charA", val);
- ret= getPropertyValue("charA");
- r[i++]= val.equals(ret);
- setPropertyValue("charClassB",val);
- ret= getPropertyValue("charClassB");
- r[i++]= val.equals(ret);
- val= Integer.valueOf(111);
- setPropertyValue("IntProp",val);
- ret= getPropertyValue("IntProp");
- r[i++]= val.equals(ret);
- }
- catch(Exception e)
- {
- r[i++]=false;
- }
- boolean bOk= true;
- for (int c= 0; c < i; c++)
- bOk= bOk && r[c];
- if (!bOk)
- System.out.println("Failed");
- else
- System.out.println("Ok");
- return bOk;
+ setPropertyValue("charA", val);
+ assertEquals(val, getPropertyValue("charA"));
+ setPropertyValue("charClassB",val);
+ assertEquals(val, getPropertyValue("charClassB"));
+ val= Integer.valueOf(111);
+ setPropertyValue("IntProp",val);
+ assertEquals(val, getPropertyValue("IntProp"));
}
-
}
class util