Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken unit tests on CI machine #370

Merged
merged 6 commits into from
Jun 27, 2013
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ private void verifyMediaProcessorInfo(String message, MediaProcessorInfo mediaPr
}

private void verifyMediaProcessorInfo(String message, String id, String name, String description, String sku,
String vendor, String version, MediaProcessorInfo mediaProcessorInfo) {
String vendor, MediaProcessorInfo mediaProcessorInfo) {
assertEquals(message + " id", id, mediaProcessorInfo.getId());
assertEquals(message + " name", name, mediaProcessorInfo.getName());
assertEquals(message + " description", description, mediaProcessorInfo.getDescription());
assertEquals(message + " sku", sku, mediaProcessorInfo.getSku());
assertEquals(message + " vendor", vendor, mediaProcessorInfo.getVendor());
assertEquals(message + " version", version, mediaProcessorInfo.getVersion());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is media services no longer returning version numbers, or is it that they're churning too quickly to keep the test working?

If they change a lot, it might be worth having an assertNotNull on the getVersion call to make sure you got something, even if we can't control/predict what the actual value will be.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good idea to make some validation, I will add a little bit logic to ensure the length of the version element is greater than 0.


@Test
Expand Down Expand Up @@ -73,6 +72,6 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException {
assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size());
MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0);
verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10",
"Storage Decryption", "Storage Decryption", "", "Microsoft", "1.6", mediaProcessorInfo);
"Storage Decryption", "Storage Decryption", "", "Microsoft", mediaProcessorInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss
String configuration = null;
switch (encoderType) {
case WindowsAzureMediaEncoder:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.3");
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER);
// Full list of configurations strings for version 2.1 is at:
// http://msdn.microsoft.com/en-us/library/jj129582.aspx
configuration = "VC1 Broadband SD 4x3";
break;
case StorageDecryption:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.6");
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION);
configuration = null;
break;
default:
Expand All @@ -296,10 +296,9 @@ private String getTaskBody(int inputAssetId, int outputAssetId) {
+ "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>";
}

private String getMediaProcessorIdByName(String processorName, String version) throws ServiceException {
private String getMediaProcessorIdByName(String processorName) throws ServiceException {
EntityListOperation<MediaProcessorInfo> operation = MediaProcessor.list();
operation.getQueryParameters().putSingle("$filter",
"(Name eq '" + processorName + "') and (Version eq '" + version + "')");
operation.getQueryParameters().putSingle("$filter", "(Name eq '" + processorName + "')");
MediaProcessorInfo processor = service.list(operation).get(0);
return processor.getId();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/**
* Copyright Microsoft Corporation
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.microsoft.windowsazure.services.serviceBus.implementation;

import com.microsoft.windowsazure.services.core.Configuration;
import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration;
import static junit.framework.Assert.*;

import org.junit.Test;

import static junit.framework.Assert.*;
import com.microsoft.windowsazure.services.core.Configuration;
import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration;

public class ServiceBusConnectionSettingsTest {

Expand All @@ -31,7 +32,8 @@ public void settingsAreParsedFromConnectionString() throws Exception {

String connectionString = getConnectionString(ns, issuer, secret);

ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(connectionString, null, null, null, null);
ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(connectionString, null, null, null,
null);

assertEquals(String.format("https://%1$s.servicebus.windows.net/", ns), settings.getUri());
assertEquals(String.format("https://%1$s-sb.accesscontrol.windows.net/WRAPv0.9", ns), settings.getWrapUri());
Expand All @@ -41,15 +43,16 @@ public void settingsAreParsedFromConnectionString() throws Exception {

private String getConnectionString(String ns, String issuer, String secret) {
return String.format(
"Endpoint=sb://%1$s.servicebus.windows.net/;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s",
ns, issuer, secret);
"Endpoint=sb://%1$s.servicebus.windows.net/;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s", ns,
issuer, secret);
}

private String getConnectionString(String ns, String stsEndpoint, String issuer, String secret) {
return String.format(
"Endpoint=sb://%1$s.servicebus.windows.net/;StsEndpoint=https://%1$s%4$s;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s",
ns, issuer, secret, stsEndpoint);
return String
.format("Endpoint=sb://%1$s.servicebus.windows.net/;StsEndpoint=https://%1$s%4$s;SharedSecretIssuer=%2$s;SharedSecretValue=%3$s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should the .format be on same line with String?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was auto-formated by Eclipse, I guess when the line is long enough, Eclipse will try to put it into two lines. Even if I change it back, next time we click save, it will be changed into two line format :(

ns, issuer, secret, stsEndpoint);
}

@Test
public void settingsAreUsedFromConnectionStringInConfig() throws Exception {
Configuration config = Configuration.load();
Expand All @@ -68,8 +71,8 @@ public void settingsAreUsedFromConnectionStringInConfig() throws Exception {
public void settingsAreUsedFromIndividualSettingsInConfiguration() throws Exception {
Configuration config = Configuration.load();

ServiceBusConfiguration.configureWithWrapAuthentication(config,
"myNamespace", "owner", "secret", ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9");
ServiceBusConfiguration.configureWithWrapAuthentication(config, "myNamespace", "owner", "secret",
".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9");

ServiceBusConnectionSettings settings = config.create(ServiceBusConnectionSettings.class);

Expand All @@ -83,9 +86,8 @@ public void settingsAreUsedFromIndividualSettingsInConfiguration() throws Except
public void settingsPreferConnectionStringIfBothPresentInConfiguration() throws Exception {
Configuration config = Configuration.load();

ServiceBusConfiguration.configureWithWrapAuthentication(config,
"myIndividualNamespace", "individualowner", "individualsecret",
".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9");
ServiceBusConfiguration.configureWithWrapAuthentication(config, "myIndividualNamespace", "individualowner",
"individualsecret", ".servicebus.windows.net/", "-sb.accesscontrol.windows.net/WRAPv0.9");

ServiceBusConfiguration.configureWithConnectionString(null, config,
getConnectionString("myNamespaceCS", "ownerCS", "secretCS"));
Expand All @@ -100,12 +102,11 @@ public void settingsPreferConnectionStringIfBothPresentInConfiguration() throws

@Test
public void canSetStSEndPointInConnectionString() throws Exception {
ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(
getConnectionString("myNs", "-some.accesscontrol.net", "owner", "secret"),
null, null, null, null);
ServiceBusConnectionSettings settings = new ServiceBusConnectionSettings(getConnectionString("myNs",
"-some.accesscontrol.net", "owner", "secret"), null, null, null, null);

assertEquals("https://myNs.servicebus.windows.net/", settings.getUri());
assertEquals("https://myNs-some.accesscontrol.net", settings.getWrapUri());
assertEquals("https://myNs-some.accesscontrol.net/WRAPv0.9", settings.getWrapUri());
assertEquals("owner", settings.getWrapName());
assertEquals("secret", settings.getWrapPassword());
}
Expand Down