public boolean testCase4()

in java/src/org/apache/qetest/trax/TransformerAPITest.java [767:919]


    public boolean testCase4()
    {
        reporter.testCaseInit("Negative tests of Transformer.set/getOutputProperty/ies()");
        TransformerFactory factory = null;
        Templates outputTemplates = null;
        Transformer outputTransformer = null;
        Transformer identityTransformer = null;
        try
        {
            factory = TransformerFactory.newInstance();
            factory.setErrorListener(new DefaultErrorHandler());
            identityTransformer = factory.newTransformer();
            identityTransformer.setErrorListener(new DefaultErrorHandler());
            outputTemplates = factory.newTemplates(new StreamSource(outputFormatTest.inputName));
        }
        catch (Throwable t)
        {
            reporter.checkFail("Problem creating Templates; cannot continue");
            reporter.logThrowable(reporter.ERRORMSG, t, 
                                  "Problem creating Templates; cannot continue");
            return true;
        }

        GetOutputPropertyTestlet testlet = new GetOutputPropertyTestlet();
        reporter.logTraceMsg("Using GetOutputPropertyTestlet for negative tests");
        testlet.setLogger(reporter);

        // Negative tests of getOutputProperty()
        GetOutputPropertyDatalet datalet = new GetOutputPropertyDatalet();
        reporter.logTraceMsg("Using GetOutputPropertyDatalet for negative tests");

        try
        {
            datalet.transformer = identityTransformer;
            datalet.propName = "bogus-name";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("bogus-name identityTransformer throws IllegalArgumentException");
            testlet.execute(datalet);
            
            datalet.transformer = identityTransformer;
            datalet.propName = "bogus-{name}";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("bogus-{name} throws IllegalArgumentException");
            testlet.execute(datalet);

            datalet.transformer = identityTransformer;
            datalet.propName = "{bogus-name";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("{bogus-name throws IllegalArgumentException (bracket not closed)");
            testlet.execute(datalet); 
            
            datalet.transformer = identityTransformer;
            datalet.propName = "{some-namespace}bogus-name";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{some-namespace}bogus-name returns null");
            testlet.execute(datalet);

            datalet.transformer = identityTransformer;
            datalet.propName = "{just-some-namespace}";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{just-some-namespace}bogus-name returns null");
            testlet.execute(datalet);

            datalet.transformer = identityTransformer;
            datalet.propName = "{}no-namespace-at-all";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{}no-namespace-at-all returns null (is this correct?)");
            testlet.execute(datalet);

            datalet.transformer = identityTransformer;
            datalet.propName = OutputKeys.METHOD;
            datalet.expectedValue = "xml";
            datalet.expectedException = null;
            datalet.setDescription(OutputKeys.METHOD + " returns xml on identity transformer (is this really correct?)");
            testlet.execute(datalet);
            
        }
        catch (Throwable t)
        {
            reporter.logThrowable(reporter.STATUSMSG, t, "Problem(1) with negative identityTransformer getOutputProperty");
            reporter.checkErr("Problem(1) with negative identityTransformer getOutputProperty: " + t.toString());
        }
        try
        {
            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "bogus-name";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("bogus-name regular transformer throws IllegalArgumentException");
            testlet.execute(datalet);
            
            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "bogus-{name}";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("bogus-{name} throws IllegalArgumentException");
            testlet.execute(datalet);

            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "{bogus-name";
            datalet.expectedValue = null;
            datalet.expectedException = "java.lang.IllegalArgumentException";
            datalet.setDescription("{bogus-name throws IllegalArgumentException (bracket not closed)");
            /* testlet.execute(datalet); comment out 10-May-01 -sc Bugzilla 890 */
            /* This is a fairly unimportant bug that may well be 
               fixed in the javadoc, so I'm commenting this case 
               out so we can run this test in the smoketest and 
               get more regular coverage of it! */

            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "{some-namespace}bogus-name";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{some-namespace}bogus-name returns null");
            testlet.execute(datalet);

            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "{just-some-namespace}";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{just-some-namespace}bogus-name returns null");
            testlet.execute(datalet);

            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = "{}no-namespace-at-all";
            datalet.expectedValue = datalet.NULL_VALUE_EXPECTED;
            datalet.expectedException = null;
            datalet.setDescription("{}no-namespace-at-all returns null (is this correct?)");
            testlet.execute(datalet);

            datalet.transformer = outputTemplates.newTransformer();
            datalet.propName = OutputKeys.METHOD;
            datalet.expectedValue = METHOD_VALUE;
            datalet.expectedException = null;
            datalet.setDescription(OutputKeys.METHOD + " returns " + METHOD_VALUE + " on transformer");
            testlet.execute(datalet);
            
        }
        catch (Throwable t)
        {
            reporter.logThrowable(reporter.STATUSMSG, t, "Problem(2) with negative transformer getOutputProperty");
            reporter.checkErr("Problem(2) with negative transformer getOutputProperty: " + t.toString());
        }

        reporter.testCaseClose();
        return true;
    } // end testCase4