Issue 147: performace improvements to SQS

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2641 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-12 02:18:23 +00:00
parent 2f9d4a8ed8
commit b29521ef41
14 changed files with 498 additions and 52 deletions

View File

@ -92,7 +92,8 @@ public class EC2ComputeService implements ComputeService {
// 32/64 bit
private Map<Profile, InstanceType> profileInstanceTypeMap = ImmutableMap
.<Profile, InstanceType> builder().put(Profile.SMALLEST, InstanceType.M1_SMALL).build();
.<Profile, InstanceType> builder().put(Profile.SMALLEST, InstanceType.M1_SMALL).put(
Profile.MEDIUM, InstanceType.C1_MEDIUM).build();
private static Map<InstanceState, ServerState> instanceToServerState = ImmutableMap
.<InstanceState, ServerState> builder().put(InstanceState.PENDING, ServerState.PENDING)

View File

@ -34,14 +34,14 @@ import org.jclouds.aws.sqs.functions.QueueLocation;
import org.jclouds.aws.sqs.functions.RegionToEndpoint;
import org.jclouds.aws.sqs.options.CreateQueueOptions;
import org.jclouds.aws.sqs.options.ListQueuesOptions;
import org.jclouds.aws.sqs.xml.ListQueuesResponseHandler;
import org.jclouds.aws.sqs.xml.MD5Handler;
import org.jclouds.aws.sqs.xml.QueueHandler;
import org.jclouds.aws.sqs.xml.RegexListQueuesResponseHandler;
import org.jclouds.aws.sqs.xml.RegexMD5Handler;
import org.jclouds.aws.sqs.xml.RegexQueueHandler;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
@ -62,7 +62,7 @@ public interface SQSAsyncClient {
@POST
@Path("/")
@FormParams(keys = ACTION, values = "ListQueues")
@XMLResponseParser(ListQueuesResponseHandler.class)
@ResponseParser(RegexListQueuesResponseHandler.class)
ListenableFuture<? extends Set<Queue>> listQueuesInRegion(
@EndpointParam(parser = RegionToEndpoint.class) Region region,
ListQueuesOptions... options);
@ -73,7 +73,7 @@ public interface SQSAsyncClient {
@POST
@Path("/")
@FormParams(keys = ACTION, values = "CreateQueue")
@XMLResponseParser(QueueHandler.class)
@ResponseParser(RegexQueueHandler.class)
ListenableFuture<Queue> createQueueInRegion(
@EndpointParam(parser = RegionToEndpoint.class) Region region,
@FormParam("QueueName") String queueName, CreateQueueOptions... options);
@ -92,7 +92,7 @@ public interface SQSAsyncClient {
@POST
@Path("/")
@FormParams(keys = ACTION, values = "SendMessage")
@XMLResponseParser(MD5Handler.class)
@ResponseParser(RegexMD5Handler.class)
ListenableFuture<byte[]> sendMessage(@EndpointParam(parser = QueueLocation.class) Queue queue,
@FormParam("MessageBody") String message);

View File

@ -39,7 +39,6 @@ public class MD5Handler extends ParseSax.HandlerWithResult<byte[]> {
@Inject
MD5Handler(EncryptionService encryptionService) {
this.encryptionService = encryptionService;
}
public byte[] getResult() {

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
import org.jclouds.http.HttpResponse;
import org.jclouds.util.Utils;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
@Singleton
public class RegexListQueuesResponseHandler extends BaseRegexQueueHandler implements
Function<HttpResponse, Set<Queue>> {
@Inject
RegexListQueuesResponseHandler(Map<Region, URI> regionMap) {
super(regionMap);
}
@Override
public Set<Queue> apply(HttpResponse response) {
try {
return parse(Utils.toStringAndClose(response.getContent()));
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
response.getContent().close();
} catch (IOException e) {
Throwables.propagate(e);
}
}
}
}

View File

@ -0,0 +1,71 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.HttpResponse;
import org.jclouds.util.Utils;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.inject.Singleton;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html"
* />
* @author Adrian Cole
*/
@Singleton
public class RegexMD5Handler implements Function<HttpResponse, byte[]> {
Pattern pattern = Pattern.compile("<MD5OfMessageBody>([\\S&&[^<]]+)</MD5OfMessageBody>");
private final EncryptionService encryptionService;
@Inject
RegexMD5Handler(EncryptionService encryptionService) {
this.encryptionService = encryptionService;
}
@Override
public byte[] apply(HttpResponse response) {
byte[] value = null;
try {
Matcher matcher = pattern.matcher(Utils.toStringAndClose(response.getContent()));
if (matcher.find()) {
value = encryptionService.fromHexString(matcher.group(1));
}
} catch (IOException e) {
Throwables.propagate(e);
} finally {
try {
response.getContent().close();
} catch (IOException e) {
Throwables.propagate(e);
}
}
return value;
}
}

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
import org.jclouds.http.HttpResponse;
import org.jclouds.util.Utils;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.inject.internal.Iterables;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
@Singleton
public class RegexQueueHandler extends BaseRegexQueueHandler implements
Function<HttpResponse, Queue> {
@Inject
RegexQueueHandler(Map<Region, URI> regionMap) {
super(regionMap);
}
@Override
public Queue apply(HttpResponse response) {
try {
return Iterables.getOnlyElement(parse(Utils.toStringAndClose(response.getContent())));
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
response.getContent().close();
} catch (IOException e) {
Throwables.propagate(e);
}
}
}
}

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml.internal;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Sets;
/**
*
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryListQueues.html"
* />
* @author Adrian Cole
*/
@Singleton
public class BaseRegexQueueHandler {
private final ImmutableBiMap<URI, Region> uriToRegion;
Pattern pattern = Pattern.compile("<QueueUrl>(https://[\\S&&[^<]]+)</QueueUrl>");
@Inject
protected BaseRegexQueueHandler(Map<Region, URI> regionMap) {
this.uriToRegion = ImmutableBiMap.copyOf(regionMap).inverse();
}
public Set<Queue> parse(String in) {
Set<Queue> queues = Sets.newLinkedHashSet();
Matcher matcher = pattern.matcher(in);
while (matcher.find()) {
String uriText = matcher.group(1);
String queueName = uriText.substring(uriText.lastIndexOf('/') + 1);
URI location = URI.create(uriText);
String regionString = uriText.substring(0, uriText.indexOf(".com/") + 4);
URI regionURI = URI.create(regionString);
Region region = uriToRegion.get(regionURI);
queues.add(new Queue(region, queueName, location));
}
return queues;
}
}

View File

@ -33,10 +33,9 @@ import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.reference.AWSConstants;
import org.jclouds.aws.sqs.options.CreateQueueOptions;
import org.jclouds.aws.sqs.options.ListQueuesOptions;
import org.jclouds.aws.sqs.xml.ListQueuesResponseHandler;
import org.jclouds.aws.sqs.xml.QueueHandler;
import org.jclouds.aws.sqs.xml.RegexListQueuesResponseHandler;
import org.jclouds.aws.sqs.xml.RegexQueueHandler;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.rest.RestClientTest;
@ -70,8 +69,8 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
"Content-Length: 36\nContent-Type: application/x-www-form-urlencoded\nHost: default\n");
assertPayloadEquals(httpMethod, "Version=2009-02-01&Action=ListQueues");
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, ListQueuesResponseHandler.class);
assertResponseParserClassEquals(method, httpMethod, RegexListQueuesResponseHandler.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
@ -89,8 +88,8 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
"Content-Length: 59\nContent-Type: application/x-www-form-urlencoded\nHost: default\n");
assertPayloadEquals(httpMethod, "Version=2009-02-01&Action=ListQueues&QueueNamePrefix=prefix");
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, ListQueuesResponseHandler.class);
assertResponseParserClassEquals(method, httpMethod, RegexListQueuesResponseHandler.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
@ -108,8 +107,8 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
"Content-Length: 57\nContent-Type: application/x-www-form-urlencoded\nHost: default\n");
assertPayloadEquals(httpMethod, "Version=2009-02-01&Action=CreateQueue&QueueName=queueName");
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, QueueHandler.class);
assertResponseParserClassEquals(method, httpMethod, RegexQueueHandler.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);
@ -129,8 +128,8 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
assertPayloadEquals(httpMethod,
"Version=2009-02-01&Action=CreateQueue&QueueName=queueName&DefaultVisibilityTimeout=45");
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
assertSaxResponseParserClassEquals(method, QueueHandler.class);
assertResponseParserClassEquals(method, httpMethod, RegexQueueHandler.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpMethod);

View File

@ -0,0 +1,165 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.aws.sqs.xml;
import static org.testng.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import javax.ws.rs.ext.RuntimeDelegate;
import org.jclouds.PerformanceTest;
import org.jclouds.aws.domain.Region;
import org.jclouds.aws.sqs.domain.Queue;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.rest.internal.RuntimeDelegateImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.ByteStreams;
import com.google.common.io.InputSupplier;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
/**
* Tests behavior of {@code ListQueuesResponseHandlerr}
*
* @author Adrian Cole
*/
@Test(groups = "unit", sequential = true, testName = "sqs.ListQueuesResponseHandlerrTest")
public class ListQueuesResponseHandlerTest extends PerformanceTest {
private Injector injector;
private Factory factory;
private RegexListQueuesResponseHandler handler;
private InputSupplier<ByteArrayInputStream> supplier;
@BeforeTest
protected void setUpInjector() throws IOException {
LOOP_COUNT = 100000;
THREAD_COUNT = 100;
System.out.printf("queue response handle speed test %d threads %d count%n", THREAD_COUNT,
LOOP_COUNT);
injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
@Override
protected void configure() {
RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
}
@SuppressWarnings("unused")
@Provides
@Singleton
Map<Region, URI> provideRegions() {
return ImmutableMap.<Region, URI> of(Region.EU_WEST_1, URI
.create("https://eu-west-1.queue.amazonaws.com"));
}
});
handler = injector.getInstance(RegexListQueuesResponseHandler.class);
factory = injector.getInstance(ParseSax.Factory.class);
InputStream inputStream = getClass().getResourceAsStream("/sqs/list_queues.xml");
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteStreams.copy(inputStream, out);
supplier = ByteStreams.newInputStreamSupplier(out.toByteArray());
assert factory != null;
}
Set<Queue> expected = ImmutableSet.of(new Queue(Region.EU_WEST_1, "adriancole-sqs1", URI
.create("https://eu-west-1.queue.amazonaws.com/993194456877/adriancole-sqs1")),
new Queue(Region.EU_WEST_1, "adriancole-sqs111", URI
.create("https://eu-west-1.queue.amazonaws.com/993194456877/adriancole-sqs111")));
public void testSax() {
ListQueuesResponseHandler handler = injector.getInstance(ListQueuesResponseHandler.class);
Set<Queue> result;
try {
result = factory.create(handler).parse(supplier.getInput());
assertEquals(result, expected);
} catch (Exception e) {
Throwables.propagate(e);
}
}
public void testRegex() {
try {
assertEquals(handler.apply(new HttpResponse(supplier.getInput())), expected);
} catch (IOException e) {
Throwables.propagate(e);
}
}
@Test()
void testRegexSerialResponseTime() throws IOException {
long now = System.currentTimeMillis();
for (int i = 0; i < LOOP_COUNT; i++)
testRegex();
System.out.println("testRegex serial: " + (System.currentTimeMillis() - now) + "");
}
@Test()
void testRegexParallelResponseTime() throws Throwable {
List<Runnable> tasks = ImmutableList.<Runnable> of(new Runnable() {
public void run() {
testRegex();
}
});
executeMultiThreadedPerformanceTest("testRegexParallelResponseTime", tasks);
}
@Test()
void testSaxSerialResponseTime() throws IOException {
long now = System.currentTimeMillis();
for (int i = 0; i < LOOP_COUNT; i++)
testSax();
System.out.println("testSax serial: " + (System.currentTimeMillis() - now) + "");
}
@Test()
void testSaxParallelResponseTime() throws Throwable {
List<Runnable> tasks = ImmutableList.<Runnable> of(new Runnable() {
public void run() {
testSax();
}
});
executeMultiThreadedPerformanceTest("testSaxParallelResponseTime", tasks);
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0"?>
<ListQueuesResponse xmlns="http://queue.amazonaws.com/doc/2009-02-01/"><ListQueuesResult><QueueUrl>https://eu-west-1.queue.amazonaws.com/993194456877/adriancole-sqs1</QueueUrl><QueueUrl>https://eu-west-1.queue.amazonaws.com/993194456877/adriancole-sqs111</QueueUrl></ListQueuesResult><ResponseMetadata><RequestId>313c81c8-e345-4c75-ad57-ce4d9d5ff35a</RequestId></ResponseMetadata></ListQueuesResponse>

View File

@ -22,5 +22,5 @@ package org.jclouds.compute.domain;
* @author Adrian Cole
*/
public enum Profile {
SMALLEST
SMALLEST, MEDIUM
}

View File

@ -30,6 +30,13 @@ public class HttpResponse extends HttpMessage {
private String message;
private InputStream content;
public HttpResponse() {
}
public HttpResponse(InputStream content) {
this.content = content;
}
public int getStatusCode() {
return statusCode;
}

View File

@ -48,12 +48,42 @@ import com.google.inject.Injector;
public class EncryptionServiceTest extends PerformanceTest {
protected EncryptionService encryptionService;
@BeforeTest
protected void createEncryptionService() {
Injector i = Guice.createInjector();
encryptionService = i.getInstance(EncryptionService.class);
}
public final static Object[][] base64KeyMessageDigest = {
{ Base64.decode("CwsLCwsLCwsLCwsLCwsLCwsLCws="), "Hi There",
"thcxhlUFcmTii8C2+zeMjvFGvgA=" },
{ Base64.decode("SmVmZQ=="), "what do ya want for nothing?",
"7/zfauXrL6LSdBbV8YTfnCWafHk=" },
{ Base64.decode("DAwMDAwMDAwMDAwMDAwMDAwMDAw="), "Test With Truncation",
"TBoDQktV4H/n8nvh1Yu5MkqaWgQ=" },
{
Base64
.decode("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo="),
"Test Using Larger Than Block-Size Key - Hash Key First",
"qkrl4VJy0A6VcFY3zoo7Ve1AIRI=" },
{
Base64
.decode("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo="),
"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
"6OmdD0UjfXhta7qnllx4CLv/GpE=" } };
@DataProvider(name = "hmacsha1")
public Object[][] createData1() {
return base64KeyMessageDigest;
}
@Test(dataProvider = "hmacsha1")
public void testHmacSha1Base64(byte[] key, String message, String base64Digest)
throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException {
String b64 = encryptionService.hmacSha1Base64(message, key);
assertEquals(b64, base64Digest);
}
@Test(dataProvider = "hmacsha1")
void testDigestSerialResponseTime(byte[] key, String message, String base64Digest)
@ -90,35 +120,6 @@ public class EncryptionServiceTest extends PerformanceTest {
{ "dogma", "95eb470e4faee302e9cd3063b1923dab" },
{ "emma", "00a809937eddc44521da9521269e75c6" } };
public final static Object[][] base64KeyMessageDigest = {
{ Base64.decode("CwsLCwsLCwsLCwsLCwsLCwsLCws="), "Hi There",
"thcxhlUFcmTii8C2+zeMjvFGvgA=" },
{ Base64.decode("SmVmZQ=="), "what do ya want for nothing?",
"7/zfauXrL6LSdBbV8YTfnCWafHk=" },
{ Base64.decode("DAwMDAwMDAwMDAwMDAwMDAwMDAw="), "Test With Truncation",
"TBoDQktV4H/n8nvh1Yu5MkqaWgQ=" },
{
Base64
.decode("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo="),
"Test Using Larger Than Block-Size Key - Hash Key First",
"qkrl4VJy0A6VcFY3zoo7Ve1AIRI=" },
{
Base64
.decode("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo="),
"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
"6OmdD0UjfXhta7qnllx4CLv/GpE=" } };
@DataProvider(name = "hmacsha1")
public Object[][] createData1() {
return base64KeyMessageDigest;
}
@Test(dataProvider = "hmacsha1")
public void testHmacSha1Base64(byte[] key, String message, String base64Digest)
throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException {
String b64 = encryptionService.hmacSha1Base64(message, key);
assertEquals(b64, base64Digest);
}
@Test(dataProvider = "eTag")
public void testMD5Digest(String message, String base64Digest) throws NoSuchProviderException,

View File

@ -62,7 +62,7 @@
<target name="create" description="create the server ${jclouds.compute.servername}">
<compute action="create" provider="${jclouds.compute.url}">
<server name="${jclouds.compute.servername}" image="UBUNTU_90" profile="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
<server name="${jclouds.compute.servername}" image="UBUNTU_90" profile="MEDIUM" hostproperty="host" usernameproperty="username" passwordproperty="password" />
</compute>
</target>