### Question:
AnalysisService extends DatasourceService { String getSchemaName( String encoding, InputStream inputStream ) throws XMLStreamException, IOException { String domainId = null; XMLStreamReader reader = null; try { XMLInputFactory factory = getXMLInputFactory(); factory.setProperty( XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false ); factory.setProperty( XMLInputFactory.IS_COALESCING, Boolean.TRUE ); if ( StringUtils.isEmpty( encoding ) ) { reader = factory.createXMLStreamReader( inputStream ); } else { reader = factory.createXMLStreamReader( inputStream, encoding ); } while ( reader.next() != XMLStreamReader.END_DOCUMENT ) { if ( reader.getEventType() == XMLStreamReader.START_ELEMENT && reader.getLocalName().equalsIgnoreCase( "Schema" ) ) { domainId = reader.getAttributeValue( "", "name" ); if ( domainId == null ) { domainId = reader.getAttributeValue( null, "name" ); } return domainId; } } } finally { if ( reader != null ) { reader.close(); } inputStream.reset(); } return domainId; } AnalysisService(); Map<String, InputStream> doGetAnalysisFilesAsDownload( String analysisId ); void removeAnalysis( String analysisId ); List<String> getAnalysisDatasourceIds(); void putMondrianSchema( InputStream dataInputStream, FormDataContentDisposition schemaFileInfo,
                                 String catalogName, // Optional
                                 String origCatalogName, // Optional
                                 String datasourceName, // Optional
                                 boolean overwrite, boolean xmlaEnabledFlag, String parameters,
                                 RepositoryFileAclDto acl ); RepositoryFileAclDto getAnalysisDatasourceAcl( String analysisId ); void setAnalysisDatasourceAcl( String analysisId, RepositoryFileAclDto aclDto ); static final String METADATA_EXT; }### Answer:
@Test public void testGetSchemaName() throws Exception { AnalysisService analysis = Mockito.spy( new AnalysisService() ); String xml = "<Schema name=\"Test4\"></Schema>"; InputStream schema = new ByteArrayInputStream( xml.getBytes() ); doReturn( new com.sun.xml.stream.ZephyrParserFactory() ).when( analysis ).getXMLInputFactory(); String domainId = analysis.getSchemaName( null, schema ); assertEquals( "Test4", domainId); }