@Test( expected = KettleException.class ) public void testSendXML() throws Exception { slaveServer.setHostname( "hostNameStub" ); slaveServer.setUsername( "userNAmeStub" ); HttpPost httpPostMock = mock( HttpPost.class ); URI uriMock = new URI( "fake" ); doReturn( uriMock ).when( httpPostMock ).getURI(); doReturn( httpPostMock ).when( slaveServer ).buildSendXMLMethod( any( byte[].class ), anyString() ); slaveServer.sendXML( "", "" ); fail( "Incorrect connection details had been used, but no exception was thrown" ); }
public String sendXML( String xml, String service ) throws Exception { HttpPost method = buildSendXMLMethod( xml.getBytes( Const.XML_ENCODING ), service ); addCredentials( method ); try { HttpResponse httpResponse = getHttpClient().execute( method ); StatusLine statusLine = httpResponse.getStatusLine(); int result = statusLine.getStatusCode(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseStatus", Integer.toString( result ) ) ); } String responseBody = getResponseBodyAsString( httpResponse.getEntity().getContent() ); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseBody", responseBody ) ); } if ( result >= 400 ) { String message; if ( result == NOT_FOUND_ERROR ) { message = String.format( "%s%s%s%s", BaseMessages.getString( PKG, "SlaveServer.Error.404.Title" ), Const.CR, Const.CR, BaseMessages.getString( PKG, "SlaveServer.Error.404.Message" ) ); } else { message = String.format( "HTTP Status %d - %s - %s", result, method.getURI().toString(), statusLine.getReasonPhrase() ); } throw new KettleException( message ); } return responseBody; } finally { method.releaseConnection(); if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "SlaveServer.DETAILED_SentXmlToService", service, environmentSubstitute( hostname ) ) ); } } }
SlaveServer extends ChangedFlag implements Cloneable, SharedObjectInterface, VariableSpace,
  RepositoryElementInterface, XMLInterface { public String sendXML( String xml, String service ) throws Exception { HttpPost method = buildSendXMLMethod( xml.getBytes( Const.XML_ENCODING ), service ); addCredentials( method ); try { HttpResponse httpResponse = getHttpClient().execute( method ); StatusLine statusLine = httpResponse.getStatusLine(); int result = statusLine.getStatusCode(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseStatus", Integer.toString( result ) ) ); } String responseBody = getResponseBodyAsString( httpResponse.getEntity().getContent() ); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseBody", responseBody ) ); } if ( result >= 400 ) { String message; if ( result == NOT_FOUND_ERROR ) { message = String.format( "%s%s%s%s", BaseMessages.getString( PKG, "SlaveServer.Error.404.Title" ), Const.CR, Const.CR, BaseMessages.getString( PKG, "SlaveServer.Error.404.Message" ) ); } else { message = String.format( "HTTP Status %d - %s - %s", result, method.getURI().toString(), statusLine.getReasonPhrase() ); } throw new KettleException( message ); } return responseBody; } finally { method.releaseConnection(); if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "SlaveServer.DETAILED_SentXmlToService", service, environmentSubstitute( hostname ) ) ); } } } }
SlaveServer extends ChangedFlag implements Cloneable, SharedObjectInterface, VariableSpace,
  RepositoryElementInterface, XMLInterface { public String sendXML( String xml, String service ) throws Exception { HttpPost method = buildSendXMLMethod( xml.getBytes( Const.XML_ENCODING ), service ); addCredentials( method ); try { HttpResponse httpResponse = getHttpClient().execute( method ); StatusLine statusLine = httpResponse.getStatusLine(); int result = statusLine.getStatusCode(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseStatus", Integer.toString( result ) ) ); } String responseBody = getResponseBodyAsString( httpResponse.getEntity().getContent() ); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseBody", responseBody ) ); } if ( result >= 400 ) { String message; if ( result == NOT_FOUND_ERROR ) { message = String.format( "%s%s%s%s", BaseMessages.getString( PKG, "SlaveServer.Error.404.Title" ), Const.CR, Const.CR, BaseMessages.getString( PKG, "SlaveServer.Error.404.Message" ) ); } else { message = String.format( "HTTP Status %d - %s - %s", result, method.getURI().toString(), statusLine.getReasonPhrase() ); } throw new KettleException( message ); } return responseBody; } finally { method.releaseConnection(); if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "SlaveServer.DETAILED_SentXmlToService", service, environmentSubstitute( hostname ) ) ); } } } SlaveServer();  SlaveServer( String name, String hostname, String port, String username, String password );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master, boolean ssl );  SlaveServer( Node slaveNode ); }
SlaveServer extends ChangedFlag implements Cloneable, SharedObjectInterface, VariableSpace,
  RepositoryElementInterface, XMLInterface { public String sendXML( String xml, String service ) throws Exception { HttpPost method = buildSendXMLMethod( xml.getBytes( Const.XML_ENCODING ), service ); addCredentials( method ); try { HttpResponse httpResponse = getHttpClient().execute( method ); StatusLine statusLine = httpResponse.getStatusLine(); int result = statusLine.getStatusCode(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseStatus", Integer.toString( result ) ) ); } String responseBody = getResponseBodyAsString( httpResponse.getEntity().getContent() ); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseBody", responseBody ) ); } if ( result >= 400 ) { String message; if ( result == NOT_FOUND_ERROR ) { message = String.format( "%s%s%s%s", BaseMessages.getString( PKG, "SlaveServer.Error.404.Title" ), Const.CR, Const.CR, BaseMessages.getString( PKG, "SlaveServer.Error.404.Message" ) ); } else { message = String.format( "HTTP Status %d - %s - %s", result, method.getURI().toString(), statusLine.getReasonPhrase() ); } throw new KettleException( message ); } return responseBody; } finally { method.releaseConnection(); if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "SlaveServer.DETAILED_SentXmlToService", service, environmentSubstitute( hostname ) ) ); } } } SlaveServer();  SlaveServer( String name, String hostname, String port, String username, String password );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master, boolean ssl );  SlaveServer( Node slaveNode ); static int getBackoffIncrements(); LogChannelInterface getLogChannel(); String getXML(); Object clone(); void replaceMeta( SlaveServer slaveServer ); String toString(); String getServerAndPort(); boolean equals( Object obj ); int hashCode(); String getHostname(); void setHostname( String urlString ); String getPassword(); void setPassword( String password ); String getUsername(); void setUsername( String username ); String getWebAppName(); void setWebAppName( String webAppName ); String getNonProxyHosts(); void setNonProxyHosts( String nonProxyHosts ); String getProxyHostname(); void setProxyHostname( String proxyHostname ); String getProxyPort(); void setProxyPort( String proxyPort ); String getPropertiesMasterName(); boolean isOverrideExistingProperties(); String getPort(); void setPort( String port ); String getPortSpecification(); String constructUrl( String serviceAndArguments ); String sendXML( String xml, String service ); String sendExport( String filename, String type, String load ); void addCredentials( HttpRequestBase method ); boolean isMaster(); void setMaster( boolean master ); String execService( String service, boolean retry ); static long getDelay( int trial ); String execService( String service ); String execService( String service, Map<String, String> headerValues ); SlaveServerStatus getStatus(); List<SlaveServerDetection> getSlaveServerDetections(); SlaveServerTransStatus getTransStatus( String transName, String carteObjectId, int startLogLineNr ); SlaveServerJobStatus getJobStatus( String jobName, String carteObjectId, int startLogLineNr ); WebResult stopTransformation( String transName, String carteObjectId ); WebResult pauseResumeTransformation( String transName, String carteObjectId ); WebResult removeTransformation( String transName, String carteObjectId ); WebResult removeJob( String jobName, String carteObjectId ); WebResult stopJob( String transName, String carteObjectId ); WebResult startTransformation( String transName, String carteObjectId ); WebResult startJob( String jobName, String carteObjectId ); WebResult cleanupTransformation( String transName, String carteObjectId ); WebResult deAllocateServerSockets( String transName, String clusteredRunId ); Properties getKettleProperties(); static SlaveServer findSlaveServer( List<SlaveServer> slaveServers, String name ); static SlaveServer findSlaveServer( List<SlaveServer> slaveServers, ObjectId id ); static String[] getSlaveServerNames( List<SlaveServer> slaveServers ); int allocateServerSocket( String runId, int portRangeStart, String hostname,
                                   String transformationName, String sourceSlaveName,
                                   String sourceStepName, String sourceStepCopy,
                                   String targetSlaveName, String targetStepName, String targetStepCopy ); String getName(); void setName( String name ); boolean isShared(); void setShared( boolean shared ); void copyVariablesFrom( VariableSpace space ); String environmentSubstitute( String aString ); String[] environmentSubstitute( String[] aString ); String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ); VariableSpace getParentVariableSpace(); void setParentVariableSpace( VariableSpace parent ); String getVariable( String variableName, String defaultValue ); String getVariable( String variableName ); boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ); void initializeVariablesFrom( VariableSpace parent ); String[] listVariables(); void setVariable( String variableName, String variableValue ); void shareVariablesWith( VariableSpace space ); void injectVariables( Map<String, String> prop ); ObjectId getObjectId(); void setObjectId( ObjectId id ); RepositoryDirectoryInterface getRepositoryDirectory(); void setRepositoryDirectory( RepositoryDirectoryInterface repositoryDirectory ); RepositoryObjectType getRepositoryElementType(); ObjectRevision getObjectRevision(); void setObjectRevision( ObjectRevision objectRevision ); String getDescription(); void setDescription( String description ); String verifyAndModifySlaveServerName( List<SlaveServer> slaveServers, String oldname ); String sniffStep( String transName, String stepName, String copyNr, int lines, String type ); long getNextSlaveSequenceValue( String slaveSequenceName, long incrementValue ); SlaveServer getClient(); Date getChangedDate(); void setSslMode( boolean sslMode ); boolean isSslMode(); SslConfiguration getSslConfig(); }
SlaveServer extends ChangedFlag implements Cloneable, SharedObjectInterface, VariableSpace,
  RepositoryElementInterface, XMLInterface { public String sendXML( String xml, String service ) throws Exception { HttpPost method = buildSendXMLMethod( xml.getBytes( Const.XML_ENCODING ), service ); addCredentials( method ); try { HttpResponse httpResponse = getHttpClient().execute( method ); StatusLine statusLine = httpResponse.getStatusLine(); int result = statusLine.getStatusCode(); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseStatus", Integer.toString( result ) ) ); } String responseBody = getResponseBodyAsString( httpResponse.getEntity().getContent() ); if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "SlaveServer.DEBUG_ResponseBody", responseBody ) ); } if ( result >= 400 ) { String message; if ( result == NOT_FOUND_ERROR ) { message = String.format( "%s%s%s%s", BaseMessages.getString( PKG, "SlaveServer.Error.404.Title" ), Const.CR, Const.CR, BaseMessages.getString( PKG, "SlaveServer.Error.404.Message" ) ); } else { message = String.format( "HTTP Status %d - %s - %s", result, method.getURI().toString(), statusLine.getReasonPhrase() ); } throw new KettleException( message ); } return responseBody; } finally { method.releaseConnection(); if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "SlaveServer.DETAILED_SentXmlToService", service, environmentSubstitute( hostname ) ) ); } } } SlaveServer();  SlaveServer( String name, String hostname, String port, String username, String password );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master );  SlaveServer( String name, String hostname, String port, String username, String password,
                      String proxyHostname, String proxyPort, String nonProxyHosts, boolean master, boolean ssl );  SlaveServer( Node slaveNode ); static int getBackoffIncrements(); LogChannelInterface getLogChannel(); String getXML(); Object clone(); void replaceMeta( SlaveServer slaveServer ); String toString(); String getServerAndPort(); boolean equals( Object obj ); int hashCode(); String getHostname(); void setHostname( String urlString ); String getPassword(); void setPassword( String password ); String getUsername(); void setUsername( String username ); String getWebAppName(); void setWebAppName( String webAppName ); String getNonProxyHosts(); void setNonProxyHosts( String nonProxyHosts ); String getProxyHostname(); void setProxyHostname( String proxyHostname ); String getProxyPort(); void setProxyPort( String proxyPort ); String getPropertiesMasterName(); boolean isOverrideExistingProperties(); String getPort(); void setPort( String port ); String getPortSpecification(); String constructUrl( String serviceAndArguments ); String sendXML( String xml, String service ); String sendExport( String filename, String type, String load ); void addCredentials( HttpRequestBase method ); boolean isMaster(); void setMaster( boolean master ); String execService( String service, boolean retry ); static long getDelay( int trial ); String execService( String service ); String execService( String service, Map<String, String> headerValues ); SlaveServerStatus getStatus(); List<SlaveServerDetection> getSlaveServerDetections(); SlaveServerTransStatus getTransStatus( String transName, String carteObjectId, int startLogLineNr ); SlaveServerJobStatus getJobStatus( String jobName, String carteObjectId, int startLogLineNr ); WebResult stopTransformation( String transName, String carteObjectId ); WebResult pauseResumeTransformation( String transName, String carteObjectId ); WebResult removeTransformation( String transName, String carteObjectId ); WebResult removeJob( String jobName, String carteObjectId ); WebResult stopJob( String transName, String carteObjectId ); WebResult startTransformation( String transName, String carteObjectId ); WebResult startJob( String jobName, String carteObjectId ); WebResult cleanupTransformation( String transName, String carteObjectId ); WebResult deAllocateServerSockets( String transName, String clusteredRunId ); Properties getKettleProperties(); static SlaveServer findSlaveServer( List<SlaveServer> slaveServers, String name ); static SlaveServer findSlaveServer( List<SlaveServer> slaveServers, ObjectId id ); static String[] getSlaveServerNames( List<SlaveServer> slaveServers ); int allocateServerSocket( String runId, int portRangeStart, String hostname,
                                   String transformationName, String sourceSlaveName,
                                   String sourceStepName, String sourceStepCopy,
                                   String targetSlaveName, String targetStepName, String targetStepCopy ); String getName(); void setName( String name ); boolean isShared(); void setShared( boolean shared ); void copyVariablesFrom( VariableSpace space ); String environmentSubstitute( String aString ); String[] environmentSubstitute( String[] aString ); String fieldSubstitute( String aString, RowMetaInterface rowMeta, Object[] rowData ); VariableSpace getParentVariableSpace(); void setParentVariableSpace( VariableSpace parent ); String getVariable( String variableName, String defaultValue ); String getVariable( String variableName ); boolean getBooleanValueOfVariable( String variableName, boolean defaultValue ); void initializeVariablesFrom( VariableSpace parent ); String[] listVariables(); void setVariable( String variableName, String variableValue ); void shareVariablesWith( VariableSpace space ); void injectVariables( Map<String, String> prop ); ObjectId getObjectId(); void setObjectId( ObjectId id ); RepositoryDirectoryInterface getRepositoryDirectory(); void setRepositoryDirectory( RepositoryDirectoryInterface repositoryDirectory ); RepositoryObjectType getRepositoryElementType(); ObjectRevision getObjectRevision(); void setObjectRevision( ObjectRevision objectRevision ); String getDescription(); void setDescription( String description ); String verifyAndModifySlaveServerName( List<SlaveServer> slaveServers, String oldname ); String sniffStep( String transName, String stepName, String copyNr, int lines, String type ); long getNextSlaveSequenceValue( String slaveSequenceName, long incrementValue ); SlaveServer getClient(); Date getChangedDate(); void setSslMode( boolean sslMode ); boolean isSslMode(); SslConfiguration getSslConfig(); static final String STRING_SLAVESERVER; static final String XML_TAG; static final RepositoryObjectType REPOSITORY_ELEMENT_TYPE; static final String SSL_MODE_TAG; static final int KETTLE_CARTE_RETRIES; static final int KETTLE_CARTE_RETRY_BACKOFF_INCREMENTS; }