Line endings.

This commit is contained in:
Andrew Phillips 2010-03-19 12:11:31 +01:00
parent 3b9e961268
commit 83d0b24e53
2 changed files with 138 additions and 138 deletions

View File

@ -1,53 +1,53 @@
/** /**
* *
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com> * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
* *
* ==================================================================== * ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.aws.ec2.compute; package org.jclouds.aws.ec2.compute;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.jclouds.aws.ec2.EC2ContextBuilder; import org.jclouds.aws.ec2.EC2ContextBuilder;
import org.jclouds.aws.ec2.EC2PropertiesBuilder; import org.jclouds.aws.ec2.EC2PropertiesBuilder;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.io.Resources; import com.google.common.io.Resources;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "compute.PropertiesTest") @Test(groups = "unit", testName = "compute.PropertiesTest")
public class PropertiesTest { public class PropertiesTest {
private Properties properties; private Properties properties;
@BeforeTest @BeforeTest
public void setUp() throws IOException { public void setUp() throws IOException {
properties = new Properties(); properties = new Properties();
properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties")) properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties"))
.getInput()); .getInput());
} }
public void testProperties() { public void testProperties() {
assertEquals(properties.getProperty("ec2.contextbuilder"), EC2ContextBuilder.class.getName()); assertEquals(properties.getProperty("ec2.contextbuilder"), EC2ContextBuilder.class.getName());
assertEquals(properties.getProperty("ec2.propertiesbuilder"), EC2PropertiesBuilder.class assertEquals(properties.getProperty("ec2.propertiesbuilder"), EC2PropertiesBuilder.class
.getName()); .getName());
} }
} }

View File

@ -1,85 +1,85 @@
/** /**
* *
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com> * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
* *
* ==================================================================== * ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.aws.ec2.functions; package org.jclouds.aws.ec2.functions;
import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.util.Set; import java.util.Set;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.aws.ec2.compute.functions.ImageParser; import org.jclouds.aws.ec2.compute.functions.ImageParser;
import org.jclouds.aws.ec2.domain.Image; import org.jclouds.aws.ec2.domain.Image;
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler; import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "compute.PropertiesTest") @Test(groups = "unit", testName = "compute.PropertiesTest")
public class ImageParserTest extends BaseHandlerTest { public class ImageParserTest extends BaseHandlerTest {
public void testParseVostokImage() { public void testParseVostokImage() {
InputStream is = getClass().getResourceAsStream("/ec2/vostok.xml"); InputStream is = getClass().getResourceAsStream("/ec2/vostok.xml");
Set<Image> result = parseImages(is); Set<Image> result = parseImages(is);
ImageParser parser = new ImageParser(); ImageParser parser = new ImageParser();
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0)); org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32); assertEquals(image.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
assertEquals(image.getDescription(), assertEquals(image.getDescription(),
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml"); "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getId(), "ami-870de2ee"); assertEquals(image.getId(), "ami-870de2ee");
assertEquals(image.getLocationId(), "default"); assertEquals(image.getLocationId(), "default");
assertEquals(image.getName(), ""); assertEquals(image.getName(), "");
assertEquals(image.getOsDescription(), assertEquals(image.getOsDescription(),
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml"); "vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
assertEquals(image.getOsFamily(), null); assertEquals(image.getOsFamily(), null);
assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner", assertEquals(image.getUserMetadata(), ImmutableMap.<String, String> of("owner",
"133804938231")); "133804938231"));
assertEquals(image.getVersion(), ""); assertEquals(image.getVersion(), "");
} }
private Set<Image> parseImages(InputStream is) { private Set<Image> parseImages(InputStream is) {
DescribeImagesResponseHandler handler = injector DescribeImagesResponseHandler handler = injector
.getInstance(DescribeImagesResponseHandler.class); .getInstance(DescribeImagesResponseHandler.class);
addDefaultRegionToHandler(handler); addDefaultRegionToHandler(handler);
Set<Image> result = factory.create(handler).parse(is); Set<Image> result = factory.create(handler).parse(is);
return result; return result;
} }
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class); GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT }); expect(request.getArgs()).andReturn(new Object[] { Region.DEFAULT });
replay(request); replay(request);
handler.setContext(request); handler.setContext(request);
} }
} }