summaryrefslogtreecommitdiff
path: root/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'filter/qa/complex/filter/misc/FinalizedMandatoryTest.java')
-rw-r--r--filter/qa/complex/filter/misc/FinalizedMandatoryTest.java217
1 files changed, 141 insertions, 76 deletions
diff --git a/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java b/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
index e32b81caa85b..a269afec836d 100644
--- a/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
+++ b/filter/qa/complex/filter/misc/FinalizedMandatoryTest.java
@@ -24,7 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package complex.filter.misc;
import com.sun.star.beans.PropertyValue;
@@ -39,10 +38,18 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.XFlushable;
-import complexlib.ComplexTestCase;
-import util.utils;
-
-
+// import complexlib.ComplexTestCase;
+// import util.utils;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
/**
* This complex test checks the functionality of the properties "Finalized" and "Mandatory" of
@@ -74,7 +81,8 @@ import util.utils;
* <CODE>Mandatory=true</CODE>
* <CODE>Mandatory=false</CODE>
*/
-public class FinalizedMandatoryTest extends ComplexTestCase {
+public class FinalizedMandatoryTest
+{
static XMultiServiceFactory xMSF;
@@ -82,21 +90,21 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* A function to tell the framework, which test functions are available.
* @return All test methods.
*/
- public String[] getTestMethodNames() {
- return new String[]{"checkReadonlySupportFilterFactory",
- "checkReadonlySupportTypeDetection"};
- }
-
+// public String[] getTestMethodNames() {
+// return new String[]{"checkReadonlySupportFilterFactory",
+// "checkReadonlySupportTypeDetection"};
+// }
/** Create the environment for following tests.
* Use either a component loader from desktop or
* from frame
* @throws Exception Exception
*/
- public void before() throws Exception {
+ @Before public void before() throws Exception
+ {
// create TypeDetection
- xMSF = (XMultiServiceFactory)param.getMSF();
- assure("Could not get XMultiServiceFactory", xMSF != null);
+ xMSF = getMSF();
+ assertNotNull("Could not get XMultiServiceFactory", xMSF);
}
@@ -106,14 +114,16 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @throws Exception was thrown if creataion failes
* @return <CODE>XInterface</CODE> of service
*/
- public XInterface getTestObject(String serviceName) throws Exception{
+ private XInterface getTestObject(String serviceName) throws Exception
+ {
Object oInterface = xMSF.createInstance(serviceName);
- if (oInterface == null) {
- failed("Service wasn't created") ;
- throw new Exception("could not create service '"+serviceName+"'");
- }
+ assertNotNull("Service wan't created", oInterface);
+// if (oInterface == null) {
+// failed("Service wasn't created") ;
+// throw new Exception("could not create service '"+serviceName+"'");
+// }
return (XInterface) oInterface;
}
@@ -121,7 +131,8 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* call the function <CODE>checkReadonlySupport</CODE> to test <CODE>com.sun.star.document.FilterFactory</CODE>
* @see com.sun.star.document.FilterFactory
*/
- public void checkReadonlySupportFilterFactory(){
+ @Test public void checkReadonlySupportFilterFactory()
+ {
checkReadonlySupport("com.sun.star.document.FilterFactory");
}
@@ -129,26 +140,30 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* call the function <CODE>checkReadonlySupport</CODE> to test <CODE>com.sun.star.document.TypeDetection</CODE>
* @see com.sun.star.document.TypeDetection
*/
- public void checkReadonlySupportTypeDetection(){
+ @Test public void checkReadonlySupportTypeDetection()
+ {
checkReadonlySupport("com.sun.star.document.TypeDetection");
}
-
/**
* test the given service <CODE>serviceName</CODE>.
* For every filter a new instace was created and the tests started.
* @param serviceName the name of the service to test
*/
- private void checkReadonlySupport(String serviceName){
- log.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- log.println("testing service '" + serviceName + "'");
+ private void checkReadonlySupport(String serviceName)
+ {
+ System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ System.out.println("testing service '" + serviceName + "'");
XInterface oObj = null;
- try{
+ try
+ {
oObj = getTestObject(serviceName);
- log.println("ImplName: "+utils.getImplName(oObj));
- } catch (java.lang.Exception e){
- failed("could not get test object");
+ System.out.println("ImplName: " + util.utils.getImplName(oObj));
+ }
+ catch (java.lang.Exception e)
+ {
+ fail("could not get test object");
}
boolean mandantoryTrue = false;
@@ -157,19 +172,21 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
boolean finalizedFalse = false;
- XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface
- (XNameAccess.class, oObj);
+ XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
String[] filterNames = xNA.getElementNames();
// XNameContainer; XNameReplace
String filterName = filterNames[0];
- Object[] instance = null;;
- for (int i = 0; i < filterNames.length; i++) {
- log.println("------------------------------------------------");
- try{
+ Object[] instance = null;
+
+ for (int i = 0; i < filterNames.length; i++)
+ {
+ System.out.println("------------------------------------------------");
+ try
+ {
PropertyValue instanceProp = new PropertyValue();
filterName = filterNames[i];
- log.println(filterName);
+ System.out.println(filterName);
// testobject must new created for every test.
// We change in a loop the container and try to flush this changes.
@@ -177,16 +194,19 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
// similar to a document which could not be saved beacuse of invalid
// contend. While you don't remove the invalid conted you will never
// be able to save the document. Same here.
- try{
+ try
+ {
oObj = getTestObject(serviceName);
- } catch (java.lang.Exception e){
- failed("could not get test object", CONTINUE);
+ }
+ catch (java.lang.Exception e)
+ {
+ fail("could not get test object");
}
- xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oObj);
- XNameContainer xNC = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oObj);
- XNameReplace xNR = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class, oObj);
- XFlushable xFlush = (XFlushable) UnoRuntime.queryInterface(XFlushable.class, oObj);
+ xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
+ XNameContainer xNC = UnoRuntime.queryInterface(XNameContainer.class, oObj);
+ XNameReplace xNR = UnoRuntime.queryInterface(XNameReplace.class, oObj);
+ XFlushable xFlush = UnoRuntime.queryInterface(XFlushable.class, oObj);
instance = (Object[]) xNA.getByName(filterName);
PropertyValue[] props = (PropertyValue[]) instance;
@@ -204,59 +224,75 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
finalizedFalse |= !isFinalized;
//change the filter
- setPropertyValueValue((PropertyValue[])instance, "UIName", "dummy");
+ setPropertyValueValue((PropertyValue[]) instance, "UIName", "dummy");
// 1a.) try to change the filter in the container
- try{
+ try
+ {
xNR.replaceByName(filterName, instance);
- }catch (IllegalArgumentException e){
- failed("could not replace filter properties ('" + filterName + "')", CONTINUE);
+ }
+ catch (IllegalArgumentException e)
+ {
+ fail("could not replace filter properties ('" + filterName + "')");
}
// 1b.) try to wirte the changed filter to the configuration.
// This must result in a exception if the filter is finalized.
boolean flushError = false;
- try{
+ try
+ {
xFlush.flush();
- } catch (WrappedTargetRuntimeException e){
+ }
+ catch (WrappedTargetRuntimeException e)
+ {
flushError = true;
- assure("Unexpected exception wihle flushing changed filter '"+ filterName + "'", isFinalized,CONTINUE);
+ assertTrue("Unexpected exception wihle flushing changed filter '" + filterName + "'", isFinalized);
}
- assure("Expected exception was not thorwn while flushing changed filter '"+ filterName + "' Finalized:" + isFinalized,
- !(flushError ^ isFinalized), CONTINUE);
+ assertTrue("Expected exception was not thorwn while flushing changed filter '" + filterName + "' Finalized:" + isFinalized,
+ !(flushError ^ isFinalized));
// 2a.) try to remove the filter from the container
- try{
+ try
+ {
xNC.removeByName(filterName);
- }catch (NoSuchElementException e){
- failed("could not remove filter from container ('" + filterName + "')", CONTINUE);
+ }
+ catch (NoSuchElementException e)
+ {
+ fail("could not remove filter from container ('" + filterName + "')");
}
// 1b.) try to wirte the changed filter to the configuration.
// This must result in a exception if the filter is mandatory
flushError = false;
- try{
+ try
+ {
xFlush.flush();
- } catch (WrappedTargetRuntimeException e){
+ }
+ catch (WrappedTargetRuntimeException e)
+ {
flushError = true;
- assure("Unexpected exception wihle flushing removed filter '"+ filterName + "'", isMandatory,CONTINUE);
+ assertTrue("Unexpected exception wihle flushing removed filter '" + filterName + "'", isMandatory);
}
- assure("Expected exception was not thorwn while flushing removed filter '"+ filterName + "' Mandatory:" + isMandatory,
- !(flushError ^ isMandatory), CONTINUE);
+ assertTrue("Expected exception was not thorwn while flushing removed filter '" + filterName + "' Mandatory:" + isMandatory,
+ !(flushError ^ isMandatory));
- } catch (NoSuchElementException e){
- failed("Couldn't get elements from object", true);
- } catch (WrappedTargetException e){
- failed("Couldn't get elements from object", true);
+ }
+ catch (NoSuchElementException e)
+ {
+ fail("Couldn't get elements from object");
+ }
+ catch (WrappedTargetException e)
+ {
+ fail("Couldn't get elements from object");
}
}
String preMsg = "Could not find filter with state ";
String postMsg = " Please check if such filter is installed!";
- assure(preMsg + "'Mandatory=true'" + postMsg ,mandantoryTrue, CONTINUE);
- assure(preMsg + "'Mandatory=false'" + postMsg ,mandantoryFalse, CONTINUE);
- assure(preMsg + "'Finalized=true'" + postMsg ,finalizedTrue, CONTINUE);
- assure(preMsg + "'Finalized=false'" + postMsg ,finalizedFalse, CONTINUE);
+ assertTrue(preMsg + "'Mandatory=true'" + postMsg, mandantoryTrue);
+ assertTrue(preMsg + "'Mandatory=false'" + postMsg, mandantoryFalse);
+ assertTrue(preMsg + "'Finalized=true'" + postMsg, finalizedTrue);
+ assertTrue(preMsg + "'Finalized=false'" + postMsg, finalizedFalse);
}
/**
@@ -265,13 +301,18 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @see com.sun.star.beans.PropertyValue
* @param props Sequenze of PropertyValue
*/
- protected void printPropertyValues(PropertyValue[] props) {
+ protected void printPropertyValues(PropertyValue[] props)
+ {
int i = 0;
- while (i < props.length ) {
- log.println(props[i].Name + ":" + props[i].Value.toString());
+ while (i < props.length)
+ {
+ System.out.println(props[i].Name + ":" + props[i].Value.toString());
i++;
}
- if (i < props.length) log.println(props[i].Name + ":" + props[i].Value.toString());
+ if (i < props.length)
+ {
+ System.out.println(props[i].Name + ":" + props[i].Value.toString());
+ }
}
/**
@@ -280,9 +321,11 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @param pName the name of the property the value shoud be returned
* @return the value of the property
*/
- protected Object getPropertyValueValue(PropertyValue[] props, String pName) {
+ protected Object getPropertyValueValue(PropertyValue[] props, String pName)
+ {
int i = 0;
- while (i < props.length && !props[i].Name.equals(pName)) {
+ while (i < props.length && !props[i].Name.equals(pName))
+ {
i++;
}
return i < props.length ? props[i].Value : null;
@@ -294,14 +337,36 @@ public class FinalizedMandatoryTest extends ComplexTestCase {
* @param pName name of the property which should be changed
* @param pValue the value the property should be assigned
*/
- protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) {
+ protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue)
+ {
int i = 0;
- while (i < props.length && !props[i].Name.equals(pName)) {
+ while (i < props.length && !props[i].Name.equals(pName))
+ {
i++;
}
props[i].Value = pValue;
}
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+ @AfterClass
+ public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+ private static final OfficeConnection connection = new OfficeConnection();
}