Search in sources :

Example 26 with Authenticator

use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.

the class SpeechToTextIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   *
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    this.customizationId = System.getenv("SPEECH_TO_TEXT_CUSTOM_ID");
    this.acousticCustomizationId = System.getenv("SPEECH_TO_TEXT_ACOUSTIC_CUSTOM_ID");
    String apiKey = System.getenv("SPEECH_TO_TEXT_APIKEY");
    String serviceUrl = System.getenv("SPEECH_TO_TEXT_URL");
    if (apiKey == null) {
        apiKey = getProperty("speech_to_text.apikey");
        this.customizationId = getProperty("speech_to_text.customization_id");
        this.acousticCustomizationId = getProperty("speech_to_text.acoustic_customization_id");
        serviceUrl = getProperty("speech_to_text.url");
    }
    assertNotNull("SPEECH_TO_TEXT_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new SpeechToText(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 27 with Authenticator

use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.

the class SpeechToTextTest method constructClientService.

// Constructs an instance of the service to be used by the tests
public void constructClientService() {
    final String serviceName = "testService";
    final Authenticator authenticator = new NoAuthAuthenticator();
    speechToTextService = new SpeechToText(serviceName, authenticator);
    String url = server.url("/").toString();
    speechToTextService.setServiceUrl(url);
}
Also used : NoAuthAuthenticator(com.ibm.cloud.sdk.core.security.NoAuthAuthenticator) NoAuthAuthenticator(com.ibm.cloud.sdk.core.security.NoAuthAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator)

Example 28 with Authenticator

use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.

the class CustomizationsIT method setUp.

/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY");
    String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL");
    if (apiKey == null) {
        apiKey = getProperty("text_to_speech.apikey");
        serviceUrl = getProperty("text_to_speech.url");
    }
    assertNotNull("TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new TextToSpeech(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 29 with Authenticator

use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.

the class TextToSpeechIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY");
    String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL");
    if (apiKey == null) {
        apiKey = getProperty("text_to_speech.apikey");
        serviceUrl = getProperty("text_to_speech.url");
    }
    assertNotNull("TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new TextToSpeech(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
    voiceName = "en-US_MichaelVoice";
    byteArrayOutputStream = new ByteArrayOutputStream();
    returnedTimings = new ArrayList<>();
    returnedMarks = new ArrayList<>();
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 30 with Authenticator

use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.

the class TextToSpeechTest method constructClientService.

// Constructs an instance of the service to be used by the tests
public void constructClientService() {
    final String serviceName = "testService";
    final Authenticator authenticator = new NoAuthAuthenticator();
    textToSpeechService = new TextToSpeech(serviceName, authenticator);
    String url = server.url("/").toString();
    textToSpeechService.setServiceUrl(url);
}
Also used : NoAuthAuthenticator(com.ibm.cloud.sdk.core.security.NoAuthAuthenticator) NoAuthAuthenticator(com.ibm.cloud.sdk.core.security.NoAuthAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator)

Aggregations

Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)58 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)32 Before (org.junit.Before)15 NoAuthAuthenticator (com.ibm.cloud.sdk.core.security.NoAuthAuthenticator)14 Test (org.testng.annotations.Test)8 SpeechRecognitionResults (com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults)5 BasicAuthenticator (com.ibm.cloud.sdk.core.security.BasicAuthenticator)4 BearerTokenAuthenticator (com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator)4 File (java.io.File)4 InputStream (java.io.InputStream)4 CouchDbSessionAuthenticator (com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator)3 HttpConfigOptions (com.ibm.cloud.sdk.core.http.HttpConfigOptions)3 Response (com.ibm.cloud.sdk.core.http.Response)2 MessageInput (com.ibm.watson.assistant.v1.model.MessageInput)2 MessageOptions (com.ibm.watson.assistant.v1.model.MessageOptions)2 MessageResponse (com.ibm.watson.assistant.v1.model.MessageResponse)2 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)2 TranslateOptions (com.ibm.watson.language_translator.v3.model.TranslateOptions)2 TranslationResult (com.ibm.watson.language_translator.v3.model.TranslationResult)2 RecognizeWithWebsocketsOptions (com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions)2