Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
5e0c6ab6
Kaydet (Commit)
5e0c6ab6
authored
Şub 20, 2012
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make ridljar JunitTests work
üst
73da209a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
233 additions
and
233 deletions
+233
-233
JunitTest_typedesc.mk
ridljar/JunitTest_typedesc.mk
+4
-1
JunitTest_uno.mk
ridljar/JunitTest_uno.mk
+6
-1
JunitTest_util.mk
ridljar/JunitTest_util.mk
+4
-0
TypeDescription_Test.java
...t/com/sun/star/lib/uno/typedesc/TypeDescription_Test.java
+58
-56
WeakMap_Test.java
ridljar/test/com/sun/star/lib/util/WeakMap_Test.java
+24
-27
Any_Test.java
ridljar/test/com/sun/star/uno/Any_Test.java
+12
-17
Type_Test.java
ridljar/test/com/sun/star/uno/Type_Test.java
+80
-73
UnoRuntime_Test.java
ridljar/test/com/sun/star/uno/UnoRuntime_Test.java
+45
-58
No files found.
ridljar/JunitTest_typedesc.mk
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -28,7 +28,6 @@
$(eval $(call gb_JunitTest_JunitTest,ridljar_typedesc))
$(eval $(call gb_JunitTest_add_jars,ridljar_typedesc,\
$(OUTDIR)/bin/OOoRunnerLight.jar \
$(OUTDIR)/bin/ridl.jar \
))
...
...
@@ -36,4 +35,8 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_typedesc,\
ridljar/test/com/sun/star/lib/uno/typedesc/TypeDescription_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_typedesc,\
com.sun.star.lib.uno.typedesc.TypeDescription_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
ridljar/JunitTest_uno.mk
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -28,7 +28,6 @@
$(eval $(call gb_JunitTest_JunitTest,ridljar_uno))
$(eval $(call gb_JunitTest_add_jars,ridljar_uno,\
$(OUTDIR)/bin/OOoRunnerLight.jar \
$(OUTDIR)/bin/ridl.jar \
))
...
...
@@ -38,4 +37,10 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_uno,\
ridljar/test/com/sun/star/uno/UnoRuntime_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_uno,\
com.sun.star.uno.Any_Test \
com.sun.star.uno.Type_Test \
com.sun.star.uno.UnoRuntime_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
ridljar/JunitTest_util.mk
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -36,4 +36,8 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_util,\
ridljar/test/com/sun/star/lib/util/WeakMap_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_util,\
com.sun.star.lib.util.WeakMap_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
ridljar/test/com/sun/star/lib/uno/typedesc/TypeDescription_Test.java
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -37,19 +37,11 @@ import com.sun.star.uno.Type;
import
com.sun.star.uno.TypeClass
;
import
com.sun.star.uno.XInterface
;
import
com.sun.star.uno.XNamingService
;
import
complexlib.ComplexTestCase
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
public
final
class
TypeDescription_Test
extends
ComplexTestCase
{
public
String
getTestObjectName
()
{
return
getClass
().
getName
();
}
public
String
[]
getTestMethodNames
()
{
return
new
String
[]
{
"test"
,
"testUnsigned"
,
"testGetMethodDescription"
,
"testSequence"
};
}
public
void
test
()
throws
Exception
{
public
final
class
TypeDescription_Test
{
@Test
public
void
test
()
throws
Exception
{
ITypeDescription
voidTD
=
TypeDescription
.
getTypeDescription
(
void
.
class
);
ITypeDescription
stringTD
=
TypeDescription
.
getTypeDescription
(
...
...
@@ -141,21 +133,23 @@ public final class TypeDescription_Test extends ComplexTestCase {
"com.sun.star.uno.XNamingService"
));
}
public
void
testUnsigned
()
throws
ClassNotFoundException
{
assure
(
"TypeDescription for UNSIGNED LONG"
,
TypeDescription
.
getTypeDescription
(
Type
.
UNSIGNED_LONG
).
getTypeName
().
equals
(
"unsigned long"
));
@Test
public
void
testUnsigned
()
throws
ClassNotFoundException
{
assertEquals
(
"TypeDescription for UNSIGNED LONG"
,
"unsigned long"
,
(
TypeDescription
.
getTypeDescription
(
Type
.
UNSIGNED_LONG
).
getTypeName
()));
}
public
void
testGetMethodDescription
()
{
@Test
public
void
testGetMethodDescription
()
{
TypeDescription
td
=
TypeDescription
.
getTypeDescription
(
XDerived
.
class
);
td
.
getMethodDescription
(
"fn"
);
}
public
void
testSequence
()
throws
ClassNotFoundException
{
assure
(
TypeDescription
.
getTypeDescription
(
"[]unsigned short"
).
getComponentType
().
getTypeName
().
equals
(
"unsigned short"
));
@Test
public
void
testSequence
()
throws
ClassNotFoundException
{
assertEquals
(
"unsigned short"
,
(
TypeDescription
.
getTypeDescription
(
"[]unsigned short"
).
getComponentType
().
getTypeName
()));
}
public
interface
XBase
extends
XInterface
{
...
...
@@ -182,27 +176,31 @@ public final class TypeDescription_Test extends ComplexTestCase {
public
void
test
(
String
prefix
,
int
index
,
IMethodDescription
description
)
{
assure
(
prefix
+
"; getIndex"
,
description
.
getIndex
()
==
index
);
assure
(
prefix
+
"; getMethod"
,
(
description
.
getMethod
()
==
null
)
==
buildIn
);
assure
(
prefix
+
"; isOneway"
,
description
.
isOneway
()
==
oneWay
);
assertEquals
(
prefix
+
"; getIndex"
,
index
,
description
.
getIndex
());
assertEquals
(
prefix
+
"; getMethod"
,
buildIn
,
description
.
getMethod
()
==
null
);
assertEquals
(
prefix
+
"; isOneway"
,
oneWay
,
description
.
isOneway
());
ITypeDescription
[]
in
=
description
.
getInSignature
();
ass
ure
(
prefix
+
"; getInSignature"
,
in
.
length
==
inParameters
.
length
);
ass
ertEquals
(
prefix
+
"; getInSignature"
,
inParameters
.
length
,
in
.
length
);
for
(
int
i
=
0
;
i
<
in
.
length
;
++
i
)
{
ass
ure
(
prefix
+
"; getInSignature "
+
i
,
in
[
i
].
equals
(
inParameters
[
i
])
);
ass
ertEquals
(
prefix
+
"; getInSignature "
+
i
,
inParameters
[
i
],
in
[
i
]
);
}
ITypeDescription
[]
out
=
description
.
getOutSignature
();
ass
ure
(
prefix
+
"; getOutSignature"
,
out
.
length
==
outParameters
.
length
);
ass
ertEquals
(
prefix
+
"; getOutSignature"
,
outParameters
.
length
,
out
.
length
);
for
(
int
i
=
0
;
i
<
out
.
length
;
++
i
)
{
assure
(
prefix
+
"; getOutSignature "
+
i
,
out
[
i
]
==
null
?
outParameters
[
i
]
==
null
:
out
[
i
].
equals
(
outParameters
[
i
]));
assertTrue
(
prefix
+
"; getOutSignature "
+
i
,
(
out
[
i
]
==
null
?
outParameters
[
i
]
==
null
:
out
[
i
].
equals
(
outParameters
[
i
])));
}
assure
(
prefix
+
"; getReturnSignature"
,
description
.
getReturnSignature
().
equals
(
returnValue
));
assertEquals
(
prefix
+
"; getReturnSignature"
,
returnValue
,
description
.
getReturnSignature
());
}
private
final
boolean
buildIn
;
...
...
@@ -230,21 +228,24 @@ public final class TypeDescription_Test extends ComplexTestCase {
public
void
test
(
String
prefix
,
Object
[]
data
,
ITypeDescription
description
)
throws
Exception
{
assure
(
prefix
+
"; getTypeName"
,
description
.
getTypeName
().
equals
(
data
[
0
]));
assure
(
prefix
+
"; equals"
,
description
.
equals
(
TypeDescription
.
getTypeDescription
(
(
String
)
data
[
0
])));
assure
(
prefix
+
"; getArrayTypeName"
,
description
.
getArrayTypeName
().
equals
(
data
[
1
]));
assure
(
prefix
+
"; getZClass"
,
description
.
getZClass
()
==
data
[
2
]);
assure
(
prefix
+
"; getTypeClass"
,
description
.
getTypeClass
()
==
data
[
3
]);
assure
(
prefix
+
"; getComponentType"
,
description
.
getComponentType
()
==
null
);
assertEquals
(
prefix
+
"; getTypeName"
,
data
[
0
],
description
.
getTypeName
());
assertEquals
(
prefix
+
"; equals"
,
TypeDescription
.
getTypeDescription
((
String
)
data
[
0
]),
description
);
assertEquals
(
prefix
+
"; getArrayTypeName"
,
data
[
1
],
description
.
getArrayTypeName
());
assertSame
(
prefix
+
"; getZClass"
,
data
[
2
],
description
.
getZClass
());
assertSame
(
prefix
+
"; getTypeClass"
,
data
[
3
],
description
.
getTypeClass
());
assertNull
(
prefix
+
"; getComponentType"
,
description
.
getComponentType
());
IMethodDescription
[]
mds
=
description
.
getMethodDescriptions
();
ass
ur
e
(
ass
ertTru
e
(
prefix
+
"; getMethodDescriptions"
,
mds
==
null
?
methodSignatures
==
null
...
...
@@ -259,8 +260,9 @@ public final class TypeDescription_Test extends ComplexTestCase {
for
(
int
i
=
0
;
i
<
methodNames
.
length
;
++
i
)
{
IMethodDescription
md
=
description
.
getMethodDescription
(
i
+
methodOffset
);
assure
(
prefix
+
"; getMethodDescription "
+
(
i
+
methodOffset
),
md
!=
null
);
assertNotNull
(
prefix
+
"; getMethodDescription "
+
(
i
+
methodOffset
),
md
);
methodSignatures
[
i
].
test
(
prefix
+
"; getMethodDescription "
+
(
i
+
methodOffset
),
i
+
methodOffset
,
md
);
...
...
@@ -268,15 +270,15 @@ public final class TypeDescription_Test extends ComplexTestCase {
for
(
int
i
=
0
;
i
<
methodNames
.
length
;
++
i
)
{
IMethodDescription
md
=
description
.
getMethodDescription
(
methodNames
[
i
]);
ass
ure
(
prefix
+
"; getMethodDescription "
+
methodNames
[
i
],
md
!=
null
);
ass
ertNotNull
(
prefix
+
"; getMethodDescription "
+
methodNames
[
i
],
md
);
methodSignatures
[
i
].
test
(
prefix
+
"; getMethodDescription "
+
methodNames
[
i
],
i
+
methodOffset
,
md
);
}
IFieldDescription
[]
fds
=
description
.
getFieldDescriptions
();
ass
ur
e
(
ass
ertTru
e
(
prefix
+
"; getFieldDescriptions"
,
fds
==
null
?
fieldSignatures
==
null
...
...
@@ -291,8 +293,8 @@ public final class TypeDescription_Test extends ComplexTestCase {
}
ITypeDescription
supert
=
description
.
getSuperType
();
ass
ure
(
prefix
+
"; getSuperType"
,
(
supert
==
null
)
==
(
data
.
length
<
6
)
);
ass
ertEquals
(
prefix
+
"; getSuperType"
,
data
.
length
<
6
,
supert
==
null
);
if
(
supert
!=
null
&&
data
[
5
]
!=
null
)
{
_superType
.
test
(
prefix
+
"; getSuperType"
,
(
Object
[])
data
[
5
],
supert
);
...
...
ridljar/test/com/sun/star/lib/util/WeakMap_Test.java
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -27,45 +27,42 @@
package
com
.
sun
.
star
.
lib
.
util
;
import
complexlib.ComplexTestCase
;
import
org.junit.Test
;
import
util.WaitUnreachable
;
import
static
org
.
junit
.
Assert
.*;
public
final
class
WeakMap_Test
extends
ComplexTestCase
{
public
String
[]
getTestMethodNames
()
{
return
new
String
[]
{
"test"
};
}
public
void
test
()
{
public
final
class
WeakMap_Test
{
@Test
public
void
test
()
{
WeakMap
m
=
new
WeakMap
();
ass
ure
(
""
,
m
.
size
()
==
0
);
ass
ure
(
""
,
m
.
isEmpty
());
ass
ure
(
""
,
!
m
.
containsKey
(
"key1"
));
ass
ure
(
""
,
!
m
.
containsValue
(
null
));
ass
ertEquals
(
0
,
m
.
size
()
);
ass
ertTrue
(
m
.
isEmpty
());
ass
ertFalse
(
m
.
containsKey
(
"key1"
));
ass
ertFalse
(
m
.
containsValue
(
null
));
WaitUnreachable
u1
=
new
WaitUnreachable
(
new
Object
());
m
.
put
(
"key1"
,
u1
.
get
());
WaitUnreachable
u2
=
new
WaitUnreachable
(
new
Disposable
());
m
.
put
(
"key2"
,
u2
.
get
());
ass
ure
(
""
,
m
.
size
()
==
2
);
ass
ure
(
""
,
!
m
.
isEmpty
());
ass
ure
(
""
,
m
.
containsKey
(
"key1"
));
ass
ure
(
""
,
m
.
containsKey
(
"key2"
));
ass
ure
(
""
,
!
m
.
containsKey
(
"key3"
));
ass
ure
(
""
,
m
.
containsValue
(
m
.
get
(
"key1"
)));
ass
ure
(
""
,
m
.
containsValue
(
m
.
get
(
"key2"
)));
ass
ure
(
""
,
WeakMap
.
getValue
(
m
.
get
(
"key1"
)).
equals
(
u1
.
get
(
)));
ass
ure
(
""
,
WeakMap
.
getValue
(
m
.
get
(
"key2"
)).
equals
(
u2
.
get
(
)));
ass
ure
(
""
,
m
.
values
().
size
()
==
2
);
ass
ure
(
""
,
m
.
values
().
contains
(
m
.
get
(
"key1"
)));
ass
ure
(
""
,
m
.
values
().
contains
(
m
.
get
(
"key2"
)));
ass
ertEquals
(
2
,
m
.
size
()
);
ass
ertFalse
(
m
.
isEmpty
());
ass
ertTrue
(
m
.
containsKey
(
"key1"
));
ass
ertTrue
(
m
.
containsKey
(
"key2"
));
ass
ertFalse
(
m
.
containsKey
(
"key3"
));
ass
ertTrue
(
m
.
containsValue
(
m
.
get
(
"key1"
)));
ass
ertTrue
(
m
.
containsValue
(
m
.
get
(
"key2"
)));
ass
ertEquals
(
u1
.
get
(),
WeakMap
.
getValue
(
m
.
get
(
"key1"
)));
ass
ertEquals
(
u2
.
get
(),
WeakMap
.
getValue
(
m
.
get
(
"key2"
)));
ass
ertEquals
(
2
,
m
.
values
().
size
()
);
ass
ertTrue
(
m
.
values
().
contains
(
m
.
get
(
"key1"
)));
ass
ertTrue
(
m
.
values
().
contains
(
m
.
get
(
"key2"
)));
u1
.
waitUnreachable
();
ass
ure
(
""
,
WeakMap
.
getValue
(
m
.
get
(
"key1"
))
==
null
);
ass
ertNull
(
WeakMap
.
getValue
(
m
.
get
(
"key1"
))
);
((
Disposable
)
u2
.
get
()).
dispose
();
ass
ure
(
""
,
WeakMap
.
getValue
(
m
.
get
(
"key2"
))
==
null
);
ass
ertNull
(
WeakMap
.
getValue
(
m
.
get
(
"key2"
))
);
m
.
clear
();
u2
.
waitUnreachable
();
ass
ure
(
""
,
m
.
size
()
==
0
);
ass
ertEquals
(
0
,
m
.
size
()
);
m
.
put
(
"key2"
,
new
Object
());
ass
ure
(
""
,
m
.
size
()
==
1
);
ass
ertEquals
(
1
,
m
.
size
()
);
}
// This simple class (single listener, no synchronization) exploits
...
...
ridljar/test/com/sun/star/uno/Any_Test.java
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -27,32 +27,27 @@
package
com
.
sun
.
star
.
uno
;
import
complexlib.ComplexTestCase
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
public
final
class
Any_Test
extends
ComplexTestCase
{
public
String
[]
getTestMethodNames
()
{
return
new
String
[]
{
"testAnyAny"
,
"testComplete"
};
}
public
void
testAnyAny
()
{
public
final
class
Any_Test
{
@Test
public
void
testAnyAny
()
{
boolean
caught
=
false
;
try
{
new
Any
(
Type
.
ANY
,
null
);
}
catch
(
IllegalArgumentException
e
)
{
caught
=
true
;
}
ass
ur
e
(
caught
);
ass
ertTru
e
(
caught
);
}
public
void
testComplete
()
{
assure
(
Any
.
complete
(
Any
.
VOID
)
==
Any
.
VOID
);
assure
(
Any
.
complete
(
new
Integer
(
10
)).
equals
(
new
Any
(
Type
.
LONG
,
new
Integer
(
10
))));
assure
(
Any
.
complete
(
null
).
equals
(
new
Any
(
new
Type
(
XInterface
.
class
),
null
)));
@Test
public
void
testComplete
()
{
assertSame
(
Any
.
VOID
,
Any
.
complete
(
Any
.
VOID
));
assertEquals
(
new
Any
(
Type
.
LONG
,
new
Integer
(
10
)),
Any
.
complete
(
new
Integer
(
10
)));
assertEquals
(
new
Any
(
new
Type
(
XInterface
.
class
),
null
),
Any
.
complete
(
null
));
XInterface
x
=
new
XInterface
()
{};
ass
ure
(
Any
.
complete
(
x
).
equals
(
new
Any
(
new
Type
(
XInterface
.
class
),
x
)
));
ass
ertEquals
(
new
Any
(
new
Type
(
XInterface
.
class
),
x
),
Any
.
complete
(
x
));
}
}
ridljar/test/com/sun/star/uno/Type_Test.java
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -27,85 +27,92 @@
package
com
.
sun
.
star
.
uno
;
import
complexlib.ComplexTestCase
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
public
final
class
Type_Test
extends
ComplexTestCase
{
public
String
[]
getTestMethodNames
()
{
return
new
String
[]
{
"testZClass"
,
"testIsSupertypeOf"
};
}
public
void
testZClass
()
{
assure
(
"VOID"
,
new
Type
(
"void"
).
getZClass
()
==
void
.
class
);
assure
(
"BOOLEAN"
,
new
Type
(
"boolean"
).
getZClass
()
==
boolean
.
class
);
assure
(
"BYTE"
,
new
Type
(
"byte"
).
getZClass
()
==
byte
.
class
);
assure
(
"SHORT"
,
new
Type
(
"short"
).
getZClass
()
==
short
.
class
);
assure
(
"UNSIGNED SHORT"
,
new
Type
(
"unsigned short"
).
getZClass
()
==
short
.
class
);
assure
(
"LONG"
,
new
Type
(
"long"
).
getZClass
()
==
int
.
class
);
assure
(
"UNSIGNED LONG"
,
new
Type
(
"unsigned long"
).
getZClass
()
==
int
.
class
);
assure
(
"HYPER"
,
new
Type
(
"hyper"
).
getZClass
()
==
long
.
class
);
assure
(
"UNSIGNED HYPER"
,
new
Type
(
"unsigned hyper"
).
getZClass
()
==
long
.
class
);
assure
(
"FLOAT"
,
new
Type
(
"float"
).
getZClass
()
==
float
.
class
);
assure
(
"DOUBLE"
,
new
Type
(
"double"
).
getZClass
()
==
double
.
class
);
assure
(
"CHAR"
,
new
Type
(
"char"
).
getZClass
()
==
char
.
class
);
assure
(
"STRING"
,
new
Type
(
"string"
).
getZClass
()
==
String
.
class
);
assure
(
"TYPE"
,
new
Type
(
"type"
).
getZClass
()
==
Type
.
class
);
assure
(
"ANY"
,
new
Type
(
"any"
).
getZClass
()
==
Object
.
class
);
assure
(
"sequence of BOOLEAN"
,
new
Type
(
"[]boolean"
,
TypeClass
.
SEQUENCE
).
getZClass
()
==
boolean
[].
class
);
assure
(
"sequence of sequence of XComponentContext"
,
new
Type
(
"[][]com.sun.star.uno.XComponentContext"
,
TypeClass
.
SEQUENCE
).
getZClass
()
==
XComponentContext
[][].
class
);
assure
(
"enum TypeClass"
,
new
Type
(
"com.sun.star.uno.TypeClass"
,
TypeClass
.
ENUM
).
getZClass
()
==
TypeClass
.
class
);
assure
(
"struct Uik"
,
new
Type
(
"com.sun.star.uno.Uik"
,
TypeClass
.
STRUCT
).
getZClass
()
==
Uik
.
class
);
assure
(
"exception Exception"
,
new
Type
(
"com.sun.star.uno.Exception"
,
TypeClass
.
EXCEPTION
).
getZClass
()
==
com
.
sun
.
star
.
uno
.
Exception
.
class
);
assure
(
"exception RuntimeException"
,
new
Type
(
"com.sun.star.uno.RuntimeException"
,
TypeClass
.
EXCEPTION
).
getZClass
()
==
com
.
sun
.
star
.
uno
.
RuntimeException
.
class
);
assure
(
"exception DeploymentException"
,
new
Type
(
"com.sun.star.uno.DeploymentException"
,
TypeClass
.
EXCEPTION
).
getZClass
()
==
DeploymentException
.
class
);
assure
(
"interface XInterface"
,
new
Type
(
"com.sun.star.uno.XInterface"
,
TypeClass
.
INTERFACE
).
getZClass
()
==
XInterface
.
class
);
assure
(
"interface XComponentContext"
,
new
Type
(
"com.sun.star.uno.XComponentContext"
,
TypeClass
.
INTERFACE
).
getZClass
()
==
XComponentContext
.
class
);
public
final
class
Type_Test
{
@Test
public
void
testZClass
()
{
assertSame
(
"VOID"
,
void
.
class
,
new
Type
(
"void"
).
getZClass
());
assertSame
(
"BOOLEAN"
,
boolean
.
class
,
new
Type
(
"boolean"
).
getZClass
());
assertSame
(
"BYTE"
,
byte
.
class
,
new
Type
(
"byte"
).
getZClass
());
assertSame
(
"SHORT"
,
short
.
class
,
new
Type
(
"short"
).
getZClass
());
assertSame
(
"UNSIGNED SHORT"
,
short
.
class
,
new
Type
(
"unsigned short"
).
getZClass
());
assertSame
(
"LONG"
,
int
.
class
,
new
Type
(
"long"
).
getZClass
());
assertSame
(
"UNSIGNED LONG"
,
int
.
class
,
new
Type
(
"unsigned long"
).
getZClass
());
assertSame
(
"HYPER"
,
long
.
class
,
new
Type
(
"hyper"
).
getZClass
());
assertSame
(
"UNSIGNED HYPER"
,
long
.
class
,
new
Type
(
"unsigned hyper"
).
getZClass
());
assertSame
(
"FLOAT"
,
float
.
class
,
new
Type
(
"float"
).
getZClass
());
assertSame
(
"DOUBLE"
,
double
.
class
,
new
Type
(
"double"
).
getZClass
());
assertSame
(
"CHAR"
,
char
.
class
,
new
Type
(
"char"
).
getZClass
());
assertSame
(
"STRING"
,
String
.
class
,
new
Type
(
"string"
).
getZClass
());
assertSame
(
"TYPE"
,
Type
.
class
,
new
Type
(
"type"
).
getZClass
());
assertSame
(
"ANY"
,
Object
.
class
,
new
Type
(
"any"
).
getZClass
());
assertSame
(
"sequence of BOOLEAN"
,
boolean
[].
class
,
new
Type
(
"[]boolean"
,
TypeClass
.
SEQUENCE
).
getZClass
());
assertSame
(
"sequence of sequence of XComponentContext"
,
XComponentContext
[][].
class
,
(
new
Type
(
"[][]com.sun.star.uno.XComponentContext"
,
TypeClass
.
SEQUENCE
).
getZClass
()));
assertSame
(
"enum TypeClass"
,
TypeClass
.
class
,
new
Type
(
"com.sun.star.uno.TypeClass"
,
TypeClass
.
ENUM
).
getZClass
());
assertSame
(
"struct Uik"
,
Uik
.
class
,
new
Type
(
"com.sun.star.uno.Uik"
,
TypeClass
.
STRUCT
).
getZClass
());
assertSame
(
"exception Exception"
,
com
.
sun
.
star
.
uno
.
Exception
.
class
,
(
new
Type
(
"com.sun.star.uno.Exception"
,
TypeClass
.
EXCEPTION
).
getZClass
()));
assertSame
(
"exception RuntimeException"
,
com
.
sun
.
star
.
uno
.
RuntimeException
.
class
,
(
new
Type
(
"com.sun.star.uno.RuntimeException"
,
TypeClass
.
EXCEPTION
).
getZClass
()));
assertSame
(
"exception DeploymentException"
,
DeploymentException
.
class
,
(
new
Type
(
"com.sun.star.uno.DeploymentException"
,
TypeClass
.
EXCEPTION
).
getZClass
()));
assertSame
(
"interface XInterface"
,
XInterface
.
class
,
(
new
Type
(
"com.sun.star.uno.XInterface"
,
TypeClass
.
INTERFACE
).
getZClass
()));
assertSame
(
"interface XComponentContext"
,
XComponentContext
.
class
,
(
new
Type
(
"com.sun.star.uno.XComponentContext"
,
TypeClass
.
INTERFACE
).
getZClass
()));
ass
ure
(
new
Type
(
boolean
.
class
).
getZClass
()
==
boolean
.
class
);
ass
ure
(
new
Type
(
Boolean
.
class
).
getZClass
()
==
boolean
.
class
);
ass
ure
(
new
Type
(
boolean
[].
class
).
getZClass
()
==
boolean
[].
class
);
ass
ure
(
new
Type
(
Boolean
[].
class
).
getZClass
()
==
boolean
[].
class
);
ass
ertSame
(
boolean
.
class
,
new
Type
(
boolean
.
class
).
getZClass
()
);
ass
ertSame
(
boolean
.
class
,
new
Type
(
Boolean
.
class
).
getZClass
()
);
ass
ertSame
(
boolean
[].
class
,
new
Type
(
boolean
[].
class
).
getZClass
()
);
ass
ertSame
(
boolean
[].
class
,
new
Type
(
Boolean
[].
class
).
getZClass
()
);
}
public
void
testIsSupertypeOf
()
{
@Test
public
void
testIsSupertypeOf
()
{
Type
ifc
=
new
Type
(
com
.
sun
.
star
.
uno
.
XInterface
.
class
);
Type
ctx
=
new
Type
(
com
.
sun
.
star
.
uno
.
XComponentContext
.
class
);
Type
exc
=
new
Type
(
com
.
sun
.
star
.
uno
.
RuntimeException
.
class
);
assure
(
"LONG :> LONG"
,
Type
.
LONG
.
isSupertypeOf
(
Type
.
LONG
));
assure
(
"not ANY :> XInterface"
,
!
Type
.
ANY
.
isSupertypeOf
(
ifc
));
assure
(
"ANY :> ANY"
,
Type
.
ANY
.
isSupertypeOf
(
Type
.
ANY
));
assure
(
"not ANY :> LONG"
,
!
Type
.
ANY
.
isSupertypeOf
(
Type
.
LONG
));
assure
(
"not XInterface :> ANY"
,
!
ifc
.
isSupertypeOf
(
Type
.
ANY
));
assure
(
"XInterface :> XInterface"
,
ifc
.
isSupertypeOf
(
ifc
));
assure
(
"XInterface :> XComponentContext"
,
ifc
.
isSupertypeOf
(
ctx
));
assure
(
"not XComponentContext :> XInterface"
,
!
ctx
.
isSupertypeOf
(
ifc
));
assure
(
"XComponentContext :> XComponentContext"
,
ctx
.
isSupertypeOf
(
ctx
));
assure
(
"not XInterface :> RuntimeException"
,
!
ifc
.
isSupertypeOf
(
exc
));
assertTrue
(
"LONG :> LONG"
,
Type
.
LONG
.
isSupertypeOf
(
Type
.
LONG
));
assertFalse
(
"not ANY :> XInterface"
,
Type
.
ANY
.
isSupertypeOf
(
ifc
));
assertTrue
(
"ANY :> ANY"
,
Type
.
ANY
.
isSupertypeOf
(
Type
.
ANY
));
assertFalse
(
"not ANY :> LONG"
,
Type
.
ANY
.
isSupertypeOf
(
Type
.
LONG
));
assertFalse
(
"not XInterface :> ANY"
,
ifc
.
isSupertypeOf
(
Type
.
ANY
));
assertTrue
(
"XInterface :> XInterface"
,
ifc
.
isSupertypeOf
(
ifc
));
assertTrue
(
"XInterface :> XComponentContext"
,
ifc
.
isSupertypeOf
(
ctx
));
assertFalse
(
"not XComponentContext :> XInterface"
,
ctx
.
isSupertypeOf
(
ifc
));
assertTrue
(
"XComponentContext :> XComponentContext"
,
ctx
.
isSupertypeOf
(
ctx
));
assertFalse
(
"not XInterface :> RuntimeException"
,
ifc
.
isSupertypeOf
(
exc
));
}
}
ridljar/test/com/sun/star/uno/UnoRuntime_Test.java
Dosyayı görüntüle @
5e0c6ab6
...
...
@@ -28,68 +28,55 @@
package
com
.
sun
.
star
.
uno
;
import
com.sun.star.beans.Optional
;
import
complexlib.ComplexTestCase
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
public
final
class
UnoRuntime_Test
extends
ComplexTestCase
{
public
String
getTestObjectName
()
{
return
getClass
().
getName
();
}
public
String
[]
getTestMethodNames
()
{
return
new
String
[]
{
"test_generateOid"
,
"test_queryInterface"
,
"test_areSame"
,
"test_completeValue"
,
"test_currentContext"
};
}
public
void
test_generateOid
()
{
public
final
class
UnoRuntime_Test
{
@Test
public
void
test_generateOid
()
{
// Test if UnoRuntime generates an OID for a simple class:
ass
ure
(
"Test1"
,
UnoRuntime
.
generateOid
(
new
Test1
())
!=
null
);
ass
ertNotNull
(
"Test1"
,
UnoRuntime
.
generateOid
(
new
Test1
())
);
// Test if UnoRuntime generates an OID for a class implementing
// IQueryInterface and returning null from getOid:
ass
ure
(
"Test2"
,
UnoRuntime
.
generateOid
(
new
Test2
())
!=
null
);
ass
ertNotNull
(
"Test2"
,
UnoRuntime
.
generateOid
(
new
Test2
())
);
// Test if a delegator object has the same OID as its creator:
Test4
test4
=
new
Test4
();
Ifc
ifc
=
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
test4
);
ass
ure
(
"Test4"
,
UnoRuntime
.
generateOid
(
test4
)
.
equals
(
UnoRuntime
.
generateOid
(
ifc
))
);
ass
ertEquals
(
"Test4"
,
UnoRuntime
.
generateOid
(
ifc
),
UnoRuntime
.
generateOid
(
test4
));
}
public
void
test_queryInterface
()
{
@Test
public
void
test_queryInterface
()
{
// Test if a query for an interface which is not supported returns null:
assure
(
"Test1"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test1
())
==
null
);
assertNull
(
"Test1"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test1
()));
// Test if a query for an interface which is supported through
// IQueryInterface succeeds:
assure
(
"Test2"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test2
())
!=
null
);
assertNotNull
(
"Test2"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test2
()));
// Test if a query for an interface which is directly supported (through
// inheritance) succeeds:
assure
(
"Test3"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test3
())
!=
null
);
assertNotNull
(
"Test3"
,
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
new
Test3
()));
}
public
void
test_areSame
()
{
ass
ur
e
(
@Test
public
void
test_areSame
()
{
ass
ertTru
e
(
UnoRuntime
.
areSame
(
new
Any
(
Type
.
UNSIGNED_LONG
,
new
Integer
(
3
)),
new
Any
(
Type
.
UNSIGNED_LONG
,
new
Integer
(
3
))));
ass
ur
e
(
!
UnoRuntime
.
areSame
(
ass
ertFals
e
(
UnoRuntime
.
areSame
(
new
Any
(
Type
.
UNSIGNED_LONG
,
new
Integer
(
3
)),
new
Integer
(
3
)));
ass
ure
(!
UnoRuntime
.
areSame
(
new
int
[]
{
1
},
new
int
[]
{
1
,
2
}));
ass
ur
e
(
ass
ertFalse
(
UnoRuntime
.
areSame
(
new
int
[]
{
1
},
new
int
[]
{
1
,
2
}));
ass
ertTru
e
(
UnoRuntime
.
areSame
(
TypeClass
.
UNSIGNED_LONG
,
new
Any
(
new
Type
(
TypeClass
.
class
),
TypeClass
.
UNSIGNED_LONG
)));
ass
ur
e
(
ass
ertTru
e
(
UnoRuntime
.
areSame
(
new
Any
(
new
Type
(
"com.sun.star.beans.Optional<unsigned long>"
),
...
...
@@ -97,33 +84,32 @@ public final class UnoRuntime_Test extends ComplexTestCase {
new
Any
(
new
Type
(
"com.sun.star.beans.Optional<unsigned long>"
),
new
Optional
(
false
,
new
Integer
(
0
)))));
ass
ure
(!
UnoRuntime
.
areSame
(
new
Test1
(),
new
Test2
()));
ass
ertFalse
(
UnoRuntime
.
areSame
(
new
Test1
(),
new
Test2
()));
Test2
test2
=
new
Test2
();
ass
ur
e
(
ass
ertTru
e
(
"Test2"
,
UnoRuntime
.
areSame
(
UnoRuntime
.
queryInterface
(
Ifc
.
class
,
test2
),
test2
));
}
public
void
test_completeValue
()
{
assure
(
UnoRuntime
.
completeValue
(
Type
.
UNSIGNED_LONG
,
null
).
equals
(
new
Integer
(
0
)));
@Test
public
void
test_completeValue
()
{
assertEquals
(
new
Integer
(
0
),
UnoRuntime
.
completeValue
(
Type
.
UNSIGNED_LONG
,
null
));
Object
v
=
UnoRuntime
.
completeValue
(
new
Type
(
"[][]unsigned long"
),
null
);
ass
ur
e
(
v
instanceof
int
[][]);
ass
ure
(((
int
[][])
v
).
length
==
0
);
ass
ur
e
(
UnoRuntime
.
completeValue
(
new
Type
(
TypeClass
.
class
),
null
)
==
TypeClass
.
VOID
);
ass
ertTru
e
(
v
instanceof
int
[][]);
ass
ertEquals
(
0
,
((
int
[][])
v
).
length
);
ass
ertSam
e
(
TypeClass
.
VOID
,
UnoRuntime
.
completeValue
(
new
Type
(
TypeClass
.
class
),
null
)
);
v
=
UnoRuntime
.
completeValue
(
new
Type
(
"com.sun.star.beans.Optional<unsigned long>"
),
null
);
ass
ur
e
(
v
instanceof
Optional
);
ass
ure
(!
((
Optional
)
v
).
IsPresent
);
ass
ure
(((
Optional
)
v
).
Value
==
null
);
ass
ertTru
e
(
v
instanceof
Optional
);
ass
ertFalse
(
((
Optional
)
v
).
IsPresent
);
ass
ertNull
(((
Optional
)
v
).
Value
);
}
public
void
test_currentContext
()
throws
InterruptedException
{
@Test
public
void
test_currentContext
()
throws
InterruptedException
{
TestThread
t1
=
new
TestThread
();
TestThread
t2
=
new
TestThread
();
t1
.
start
();
...
...
@@ -132,10 +118,10 @@ public final class UnoRuntime_Test extends ComplexTestCase {
t2
.
join
();
Object
v1
=
t1
.
context
.
getValueByName
(
""
);
Object
v2
=
t2
.
context
.
getValueByName
(
""
);
ass
ure
(
""
,
t1
.
context
!
=
t2
.
context
);
ass
ure
(
""
,
v1
==
t1
);
ass
ure
(
""
,
v2
==
t2
);
ass
ure
(
""
,
v1
!
=
v2
);
ass
ertFalse
(
t1
.
context
=
=
t2
.
context
);
ass
ertTrue
(
v1
==
t1
);
ass
ertTrue
(
v2
==
t2
);
ass
ertFalse
(
v1
=
=
v2
);
}
private
interface
Ifc
extends
XInterface
{}
...
...
@@ -194,13 +180,14 @@ public final class UnoRuntime_Test extends ComplexTestCase {
private
final
class
TestThread
extends
Thread
{
public
void
run
()
{
assure
(
""
,
UnoRuntime
.
getCurrentContext
()
==
null
);
//TODO: JUnit does not notice if these asserts fail:
assertNull
(
UnoRuntime
.
getCurrentContext
());
context
=
new
TestCurrentContext
();
UnoRuntime
.
setCurrentContext
(
context
);
ass
ure
(
""
,
UnoRuntime
.
getCurrentContext
()
==
context
);
ass
ure
(
""
,
context
.
getValueByName
(
""
)
==
this
);
ass
ertSame
(
context
,
UnoRuntime
.
getCurrentContext
()
);
ass
ertSame
(
this
,
context
.
getValueByName
(
""
)
);
UnoRuntime
.
setCurrentContext
(
null
);
ass
ure
(
""
,
UnoRuntime
.
getCurrentContext
()
==
null
);
ass
ertNull
(
UnoRuntime
.
getCurrentContext
()
);
}
public
XCurrentContext
context
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment