JDK-4984072 : SchemaFactory.newSchema() throws NPE for all sources
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-01-27
  • Updated: 2012-04-24
  • Resolved: 2004-02-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b38Fixed
Related Reports
Duplicate :  
Relates :  
Description
Schema(java.net.URL schema)
// supports and return a valid Schema instance
// Schema is null should throw NPE

  private void checkSchemaFactory13() {   
        try {
            URL url13 = null;
	    SchemaFactory sf13 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema13 = sf13.newSchema(url13);
     	    if (schema13 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory13() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory13() - passed");
//	} catch (MalformedURLException mue){
//	     System.out.println(" MalformedURLException thrown in SchemaFactory01/checkSchemaFactory13() failed ");  
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory13() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory13() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory13() failed");
	}
    } 

// test for getErrorHandler() 
// errorhandler is set to null , should return null

    private void checkSchemaFactory14() {   
        try {
            ErrorHandler eh14 = null;
	    SchemaFactory sf14 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    //System.out.println("ErrorHandler object :"+sf11.getErrorHandler() );
	    sf14.setErrorHandler(eh14);
	    if( sf14.getErrorHandler() == null ){
            System.out.println("SchemaFactory01/checkSchemaFactory14() passed");
            }
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory14() - failed "+e.getMessage());
	}
    } 



// test for get & set ErrorHandler()
// MyErrorHandler is set using setErrorHandler , getErrorHandler should return instance of same

    private void checkSchemaFactory15() {   
        try {
            MyErrorHandler meh15 = new MyErrorHandler();
	    SchemaFactory sf15 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    sf15.setErrorHandler(meh15);
	    //System.out.println("ErrorHandler object :"+sf15.getErrorHandler() );
	    if( sf15.getErrorHandler() == null ){
            System.out.println("SchemaFactory01/checkSchemaFactory15() failed");
            }
            if ( sf15.getErrorHandler() instanceof MyErrorHandler ){
		System.out.println("SchemaFactory01/checkSchemaFactory15() passed ");
	    }
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory15() - failed "+e.getMessage());
	}
    } 

// test for newInstance(null)
// should throw NPE

    private void checkSchemaFactory16() {   
        try {
            String schemaLanguage = null;
	    SchemaFactory sf16 = SchemaFactory.newInstance(schemaLanguage);
            System.out.println("SchemaFactory01/checkSchemaFactory16() failed - Expected NPE not thrown ");
	
	} catch (NullPointerException npe ){ 
	     System.out.println(" Expected NPE thrown in SchemaFactory01/checkSchemaFactory16() - passed ");
	} catch (Exception e ){ 
	     System.out.println(" SchemaFactory01/checkSchemaFactory16() failed - Expected NPE , but thrown "+e.getMessage());
	}
    } 

// test for getErrorHandler() 
// when SchemaFactory is created , initially ErrorHandler is set to null
// getErrorHandler() should return null

    private void checkSchemaFactory17() {   
        try {
	    SchemaFactory sf17 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    if( sf17.getErrorHandler() == null ){
             System.out.println("SchemaFactory01/checkSchemaFactory17() passed");
            }
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory17() - failed "+e.getMessage());
	}
    } 


// test for W3C XML Schema 1.0 - newSchema(Source schema)
// supports and return a valid Schema instance
// SAXSource

  private void checkSchemaFactory18() {   
        try {
	    SchemaFactory sf18 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is18 = new InputSource (new FileInputStream(xmlPath + "test.xsd"));
	    SAXSource saxSource18 = new SAXSource (is18);
	    Schema schema18 = sf18.newSchema(saxSource18);
	    if (schema18 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory18() passed");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" NullPointerException thrown in SchemaFactory01/checkSchemaFactory18() - failed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory18() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory18() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory18() failed");
	}
    } 

 
// test for W3C XML Schema 1.0 - newSchema(Source schema) 
// schema is null - should throw null pointer exception
// SAXSource - schema is null
//SAXSource(null) throws NPE

  private void checkSchemaFactory19() {   
  File f19 = null ;
        try {
	    SchemaFactory sf19 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is19 = new InputSource (new FileInputStream(f19));
	    SAXSource saxSource19 = new SAXSource (is19);
	    Schema schema19 = sf19.newSchema(saxSource19);
	    if (schema19 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory19() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory19() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory19() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory19() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory19() failed");
	}
    } 
   
   
// test for W3C XML Schema 1.0 - newSchema(Source[] schemas)
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// SAXSource[] both valid 

  private void checkSchemaFactory20() {   
        try {
	    SchemaFactory sf20 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is200 = new InputSource (new FileInputStream(xmlPath + "test.xsd"));
	    SAXSource saxSource200 = new SAXSource (is200);
	    InputSource is201 = new InputSource (new FileInputStream(xmlPath + "test1.xsd"));
	    SAXSource saxSource201 = new SAXSource (is201);
	    Schema schema20 = sf20.newSchema(new SAXSource[]{ saxSource200 , saxSource201 });
	    if (schema20 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory20() passed");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" NullPointerException thrown in SchemaFactory01/checkSchemaFactory20() - failed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory20() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory20() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory20() failed");
	}
    } 



 
// test for W3C XML Schema 1.0 - newSchema(Source[] schemas)
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// one schema is null , so should throw NPE
// SAXSource[] - one schema is valid & other null
//SAXSource(null) throws NPE
 
  private void checkSchemaFactory21() {   
  File f21 = null ;
        try {
	    SchemaFactory sf21 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is210 = new InputSource (new FileInputStream(xmlPath + "test.xsd"));
	    SAXSource saxSource210 = new SAXSource (is210);
	    InputSource is211 = new InputSource (new FileInputStream(f21));
	    SAXSource saxSource211 = new SAXSource (is211);
	    Schema schema21 = sf21.newSchema(new SAXSource[]{ saxSource210 , saxSource211 });
	    if (schema21 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory021() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory21() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory21() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory21() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory21() failed");
	}
    } 

// test for W3C XML Schema 1.0 - newSchema(Source schema) 
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// both schemas are null - should throw null pointer exception
// SAXSource[] - both schemas are null
//SAXSource(null) throws NPE

 private void checkSchemaFactory22() {   
  File f220 = null ;
  File f221 = null ;
        try {
	    SchemaFactory sf22 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    InputSource is220 = new InputSource (new FileInputStream(f220));
	    SAXSource saxSource220 = new SAXSource (is220);
	    InputSource is221 = new InputSource (new FileInputStream(f221));
	    SAXSource saxSource221 = new SAXSource (is221);
	    Schema schema22 = sf22.newSchema(new SAXSource[]{ saxSource220 , saxSource221 });
	    if (schema22 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory22() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory22() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory22() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory22() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory22() failed");
	}
    } 



// test for W3C XML Schema 1.0 - newSchema(Source schema)
// supports and return a valid Schema instance
// DOMSource - valid schema

  private void checkSchemaFactory23() {   
        try {
            Document document23 = null;
	    SchemaFactory sf23 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    DocumentBuilderFactory dbf23 = DocumentBuilderFactory.newInstance();
	    dbf23.setNamespaceAware(true);
	    document23 = dbf23.newDocumentBuilder().parse(new File(xmlPath + "test.xsd"));
	    DOMSource domSource23 = new DOMSource(document23);
	    Schema schema23 = sf23.newSchema(domSource23);
	    if (schema23 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory23() passed");
	    }
	
	} catch (NullPointerException npe){
	     System.out.println(" NullPointerException thrown in SchemaFactory01/checkSchemaFactory23() - failed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory23() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory23() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory23() failed");
	}
    } 

 
// test for W3C XML Schema 1.0 - newSchema(Source schema) 
// DOMSource -  null
 
  private void checkSchemaFactory24() {   
  
          try {
     
     	    SchemaFactory sf24 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    DOMSource domSource24 = null ; //new DOMSource(document24);
	    Schema schema24 = sf24.newSchema(domSource24);
	    if (schema24 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory24() failed - expected null pointer exception not thrown ");
	    }
	} catch (IllegalArgumentException iae){
	     System.out.println(" IAE thrown in SchemaFactory01/checkSchemaFactory24() - failed");
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory24() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory24() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory24() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory24() failed");
	}
    } 
   
   

---------------------------------
verified in Tiger 1.5.0-beta2-b44
###@###.### 2004-03-30
---------------------------------
SchemaFactory.newSchema() throws NPE for all sources - (Stream,URL,file, SAXSource,DOMSource)

Sample testcase is attached (SchemaFactory01.java) - tests 4,6,8,12,18,20,23,25 failed .

--------------------------------------------------------------------------------------


import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ErrorHandler; 
import org.xml.sax.SAXParseException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;

import org.w3c.dom.Document;

import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.DocumentBuilderFactory;


import java.io.File;
import java.io.FileInputStream;

import java.net.URL;
import java.net.MalformedURLException;

public class SchemaFactory01 {
 
    String xmlPath = "";
    String testDirPath = "";
   
   // constructor
    SchemaFactory01() {
      
    testDirPath = "/home/sa122568/Jaxp/test";
    xmlPath = testDirPath + "/xmlfiles/";
    
   }
// main()
    public static void main(String[] argv) {
        
        SchemaFactory01 schemaFactory01 = new SchemaFactory01();
        schemaFactory01.checkSchemaFactory01();
        schemaFactory01.checkSchemaFactory02();
        schemaFactory01.checkSchemaFactory03();
        schemaFactory01.checkSchemaFactory04();
        schemaFactory01.checkSchemaFactory05();
        schemaFactory01.checkSchemaFactory06();
        schemaFactory01.checkSchemaFactory07();
        schemaFactory01.checkSchemaFactory08();
        schemaFactory01.checkSchemaFactory09();
        schemaFactory01.checkSchemaFactory10();
        schemaFactory01.checkSchemaFactory11();
        schemaFactory01.checkSchemaFactory12();
        schemaFactory01.checkSchemaFactory13();
        schemaFactory01.checkSchemaFactory14();
        schemaFactory01.checkSchemaFactory15();
        schemaFactory01.checkSchemaFactory16();
        schemaFactory01.checkSchemaFactory17();
        schemaFactory01.checkSchemaFactory18();
        schemaFactory01.checkSchemaFactory19();
        schemaFactory01.checkSchemaFactory20();
        schemaFactory01.checkSchemaFactory21();
        schemaFactory01.checkSchemaFactory22();
        schemaFactory01.checkSchemaFactory23();
        schemaFactory01.checkSchemaFactory24();
        schemaFactory01.checkSchemaFactory25();
        schemaFactory01.checkSchemaFactory26();
        schemaFactory01.checkSchemaFactory27();
        schemaFactory01.checkSchemaFactory28();
        schemaFactory01.checkSchemaFactory29();
        schemaFactory01.checkSchemaFactory30();
        schemaFactory01.checkSchemaFactory31();
        schemaFactory01.checkSchemaFactory32();
        schemaFactory01.checkSchemaFactory33();
        schemaFactory01.checkSchemaFactory34();
        schemaFactory01.checkSchemaFactory35();
    } // end main()
 
 

// test for W3C XML Schema 1.0 - supports

    private void checkSchemaFactory01() {   
        try {
	    SchemaFactory sf1 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
            System.out.println("SchemaFactory01/checkSchemaFactory01() passed");
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory01() - failed ");
	}
    } 
    
// test for RELAX NG 1.0
// does not support so throws IllegalArgumentException

   private void checkSchemaFactory02() {   
        try {
            SchemaFactory sf2 = SchemaFactory.newInstance("http://relaxng.org/ns/structure/1.0");
            System.out.println("SchemaFactory01/checkSchemaFactory02() : failed Expected IllegalArgumentException not thrown");
	} catch (IllegalArgumentException iae ){ 
	     System.out.println("SchemaFactory01/checkSchemaFactory02() : passed Expected IllegalArgumentException thrown ");
	
	} catch (Exception e ){ 
	     System.out.println(" SchemaFactory01/checkSchemaFactory02() : failed  Expected IllegalArgumentException , but thrown "+e.getMessage());
	}
    } 

// test for W3C XML Schema 1.0 - newSchema()
// supports and return a valid Schema instance
 
  private void checkSchemaFactory03() {   
        try {
	    SchemaFactory sf3 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
            Schema schema3 = sf3.newSchema();
            if (schema3 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory03() passed");
	    }
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory03() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory03() failed ");
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory03() failed");
	}
    } 
    
    
// test for W3C XML Schema 1.0 - newSchema(java.io.File schema)
// supports and return a valid Schema instance

  private void checkSchemaFactory04() {   
        try {
	    SchemaFactory sf4 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema4 = sf4.newSchema(new File(xmlPath+"test.xsd"));
            if (schema4 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory04() passed");
	    }
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory04() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory04() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory04() failed");
	}
    } 

    
// test for W3C XML Schema 1.0 - newSchema(java.io.File schema) 
// schema is null - should throw null pointer exception

  private void checkSchemaFactory05() {   
  File f5 = null ;
        try {
	    SchemaFactory sf5 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema5 = sf5.newSchema(f5);
	    if (schema5 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory05() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory05() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory05() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory05() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory05() failed");
	}
    } 
    
    
// test for W3C XML Schema 1.0 - newSchema(Source schema)
// supports and return a valid Schema instance
// StreamSource - valid

  private void checkSchemaFactory06() {   
        try {
	    SchemaFactory sf6 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema6 = sf6.newSchema(new StreamSource (new File(xmlPath+"test.xsd")));
            if (schema6 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory06() passed");
	    }
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory06() ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory06() " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory06() failed");
	}
    } 

 
// test for W3C XML Schema 1.0 - newSchema(Source schema) 
// schema is null - should throw null pointer exception
// StreamSource - null
 
  private void checkSchemaFactory07() {   
  File f7 = null ;
        try {
	    SchemaFactory sf7 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema7 = sf7.newSchema(new StreamSource (f7));
	    if (schema7 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory07() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory07() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory07() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory07() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory07() failed");
	}
    } 
   
   
// test for W3C XML Schema 1.0 - newSchema(Source[] schemas)
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// StreamSource[] - 2 valid schemas

  private void checkSchemaFactory08() {   
        try {
	    SchemaFactory sf8 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema8 = sf8.newSchema(new StreamSource[]{new StreamSource(new File(xmlPath+"test.xsd")),new StreamSource(new File(xmlPath+"test1.xsd")) });
            if (schema8 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory08() passed");
	    }
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory08() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory08() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory08() failed");
	}
    } 



 
// test for W3C XML Schema 1.0 - newSchema(Source[] schemas)
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// one schema is null , so should throw NPE
// StreamSource[] - 1 valid schema and other null
  
  private void checkSchemaFactory09() {   
  File f9 = null ;
        try {
	    SchemaFactory sf9 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema9 = sf9.newSchema(new StreamSource[]{new StreamSource(new File(xmlPath+"test.xsd")),new StreamSource(f9) });
	    if (schema9 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory09() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory09() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory09() ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory09() " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory09() failed");
	}
    } 

// test for W3C XML Schema 1.0 - newSchema(Source schema) 
// supports and returns a valid Schema instance
// read all the Sources and combine them into a single schema 
//( semantics of the combination depends on the schema language that this SchemaFactory object is created for)
// both schemas are null - should throw null pointer exception
// StreamSource[] - both schemas are null
 
 private void checkSchemaFactory10() {   
  File f100 = null ;
  File f101 = null ;
        try {
	    SchemaFactory sf10 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema10 = sf10.newSchema(new StreamSource[]{new StreamSource(f100) , new StreamSource(f101) });
	    if (schema10 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory10() failed - expected null pointer exception not thrown ");
	    }
	} catch (NullPointerException npe){
	     System.out.println(" Expected NullPointerException thrown in SchemaFactory01/checkSchemaFactory10() - passed");
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory10() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory10() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory10() failed");
	}
    } 




// test for getErrorHandler()
// errorhandler is not set , should return null
// by default errorhandler is set to null

    private void checkSchemaFactory11() {   
        try {
	    SchemaFactory sf11 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    //System.out.println("ErrorHandler object :"+sf11.getErrorHandler() );
	    if( sf11.getErrorHandler() == null ){
            System.out.println("SchemaFactory01/checkSchemaFactory11() passed");
            }
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory11() - failed "+e.getMessage());
	}
    } 


// test for W3C XML Schema 1.0 - newSchema(java.net.URL schema)
// supports and return a valid Schema instance

  private void checkSchemaFactory12() {   
        try {
            URL url12 = new URL("http://sqindia.india.sun.com/disk06/tea/sreejith/jaxp/test.xsd");
	    SchemaFactory sf12 = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
	    Schema schema12 = sf12.newSchema(url12);
            if (schema12 instanceof Schema){
		System.out.println("SchemaFactory01/checkSchemaFactory12() passed");
	    }
	} catch (MalformedURLException mue){
	     System.out.println(" MalformedURLException thrown in SchemaFactory01/checkSchemaFactory12() failed ");    
	} catch (UnsupportedOperationException uoe){
	     System.out.println(" UnsupportedOperationException thrown in SchemaFactory01/checkSchemaFactory12() failed ");
	} catch (SAXException saxe){
	     System.out.println(" Operation supported but failed in SchemaFactory01/checkSchemaFactory12() failed " + saxe.getMessage());
	} catch (Exception e ){ 
	     System.out.println(" Exception thrown in SchemaFactory01/checkSchemaFactory12() failed");
	}
    } 



// test for W3C XML Schema 1.0 - new

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b38 tiger-beta2 VERIFIED IN: tiger-beta2
14-06-2004

EVALUATION A recent change to XSDHandler was causing a problem. ###@###.### 2004-01-28
28-01-2004