Author: adietish
Date: 2011-01-10 11:13:52 -0500 (Mon, 10 Jan 2011)
New Revision: 28045
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/HardwareProfileDomUnmarshallingTest.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/HardwareProfileResponseFakes.java
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudTestSuite.launch
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltaCloudTestSuite.java
Log:
[JBIDE-7935] added tests to unmarshalling hardware profiles
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudTestSuite.launch
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudTestSuite.launch 2011-01-10
16:13:00 UTC (rev 28044)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/DeltaCloudTestSuite.launch 2011-01-10
16:13:52 UTC (rev 28045)
@@ -12,7 +12,7 @@
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation"
value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/>
-<stringAttribute key="deselected_workspace_plugins"
value="org.jboss.tools.deltacloud.integration,org.jboss.tools.tests,org.jboss.tools.deltacloud.docs,org.jboss.tools.deltacloud.ui"/>
+<stringAttribute key="deselected_workspace_plugins"
value="org.jboss.ide.eclipse.as.wtp.ui,org.jboss.tools.ui.bot.ext,org.jboss.ide.eclipse.as.core,org.jboss.tools.common.projecttemplates,org.jboss.ide.eclipse.as.rse.core,org.jboss.tools.tests.performance,org.jboss.tools.common.el.core,org.jboss.ide.eclipse.as.ui.mbeans,org.jboss.tools.common.gef,org.jboss.ide.eclipse.as.archives.integration.test,org.jboss.tools.common.verification.test,org.jboss.ide.eclipse.archives.core,org.jboss.tools.common.verification,org.jboss.ide.eclipse.archives.jdt.integration,org.jboss.tools.jmx.core.test,org.jboss.tools.common.model,org.jboss.ide.eclipse.as.classpath.core,org.jboss.ide.eclipse.archives.test,org.jboss.ide.eclipse.as.classpath.ui,org.jboss.tools.deltacloud.integration,org.jboss.tools.common.ui,org.jboss.tools.usage,org.jboss.tools.usage.test,org.jboss.tools.common.text.ext,org.jboss.tools.jmx.ui,org.jboss.tools.ui.bot.ext.test,org.jboss.tools.common.el.core.test,org.jboss.tools.co!
mmon.model.ui.test,org.jboss.tools.tests,org.jboss.tools.common.text.xml,org.jboss.ide.eclipse.as.ui.test,org.jboss.tools.common.meta.ui,org.jboss.ide.eclipse.archives.webtools,org.jboss.tools.deltacloud.docs,org.jboss.tools.common.verification.ui.test,org.jboss.ide.eclipse.as.rse.ui,com.jboss.jbds.usage.branding,org.jboss.tools.common.verification.ui,org.jboss.ide.eclipse.as.wtp.core,org.jboss.tools.common.test,org.jboss.tools.deltacloud.ui,org.jboss.tools.gwt.ui,org.jboss.tools.common.model.ui.capabilities,org.jboss.tools.common.resref.core,org.eclipse.jsch.ui,org.jboss.ide.eclipse.archives.ui,org.jboss.ide.eclipse.as.test,org.jboss.tools.common.el.ui,org.jboss.tools.gwt.core,org.jboss.tools.jmx.ui.test,org.jboss.ide.eclipse.as.ssh,org.jboss.tools.common.resref.ui,org.jboss.ide.eclipse.as.ui,org.jboss.ide.eclipse.archives.ui.test,org.jboss.ide.eclipse.as.doc.user,org.jboss.tools.jmx.core,org.jboss.tools.common.model.ui,org.jboss.tools.common.model.test"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location"
value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
@@ -38,8 +38,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
-<stringAttribute key="selected_target_plugins"
value="org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.ui.views@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.core.variables@default:default,org.eclipse.ui.forms@default:default,org.eclipse.osgi@-1:true,org.eclipse.wst.common.uriresolver@default:default,org.eclipse.core.runtime@default:true,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.jem.util@default:default,org.eclipse.osgi.util@default:default,org.eclipse.wst.common.emf@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.ecf@default:default,org.eclipse.core.jobs@default:default,org.eclipse.wst.sse.core@default:default,javax.servlet@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.jdt.core@default:default,org.eclipse.equinox.p!
2.metadata.repository@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.wst.common.emfworkbench.integration@default:default,org.eclipse.debug.ui@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ui.editors@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.ui@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.databinding@default:default,org.apache.commons.logging*1.0.4.v201005080501@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.hamcrest.core@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.apache.xml.resolver@default:default,org.eclipse.debug.core@default:default,org.eclipse.jdt.ui@default:default,org.apache.xerces@default:default,org.eclipse.u!
i.ide@default:default,org.eclipse.jface@default:default,org.ec!
lipse.jd
t.debug@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.osgi.services@default:default,org.apache.commons.httpclient*3.1.0.v201005080502@default:default,org.apache.commons.codec*1.3.0.v20100518-1140@default:default,org.eclipse.wst.common.frameworks@default:default,com.ibm.icu@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.equinox.common@2:true,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.text@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.help@default:default,org.eclipse.compare@default:default,org.eclipse.core.net@default:default,org.eclipse.emf.edit@default:default,org.eclipse.equinox.app@default:default,org.eclipse.team.ui@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.emf.common@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.equinox.p2.repository@default:de!
fault,javax.xml@default:default,org.eclipse.wst.validation@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.core.commands@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.search@default:default,org.eclipse.core.expressions@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.team.core@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.eclipse.ui.console@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.swt@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.wst.xml.core@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.!
wst.common.core@default:default,org.eclipse.equinox.concurrent!
@default
:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.ant.core@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.runtime.compatibility.registry@default:false"/>
-<stringAttribute key="selected_workspace_plugins"
value="org.jboss.tools.common.model.ui.test@default:default,org.jboss.ide.eclipse.as.ui.mbeans@default:default,org.jboss.ide.eclipse.archives.ui.test@default:default,org.jboss.ide.eclipse.archives.webtools@default:default,org.jboss.ide.eclipse.as.classpath.core@default:default,org.jboss.tools.common.el.ui@default:default,org.jboss.tools.deltacloud.core@default:default,org.jboss.tools.common.text.ext@default:default,org.jboss.tools.ui.bot.ext.test@default:default,org.jboss.ide.eclipse.as.core@default:default,org.jboss.ide.eclipse.as.archives.integration.test@default:default,org.jboss.tools.common.meta.ui@default:default,org.jboss.tools.common.verification.ui.test@default:default,org.jboss.tools.ui.bot.ext@default:default,org.jboss.tools.common.resref.ui@default:default,org.jboss.tools.common.gef@default:default,org.jboss.ide.eclipse.as.wtp.ui@default:default,org.jboss.tools.common.model.ui@default:default,org.jboss.ide.eclips!
e.archives.ui@default:default,org.jboss.tools.jmx.core.test@default:default,org.jboss.ide.eclipse.as.rse.core@default:default,org.jboss.tools.common.model.test@default:default,org.jboss.tools.common.ui@default:default,org.jboss.tools.common.model.ui.capabilities@default:default,org.jboss.tools.jmx.ui@default:default,org.jboss.tools.common.el.core@default:default,org.jboss.ide.eclipse.as.wtp.core@default:default,org.jboss.tools.common.verification@default:default,org.jboss.tools.common.text.xml@default:default,org.jboss.ide.eclipse.archives.jdt.integration@default:default,org.jboss.ide.eclipse.as.rse.ui@default:default,org.jboss.tools.tests.performance@default:default,org.jboss.ide.eclipse.as.test@default:default,org.jboss.ide.eclipse.as.ui.test@default:default,org.jboss.tools.deltacloud.test@default:default,org.jboss.tools.common.projecttemplates@default:default,org.jboss.tools.common.model@default:default,org.jboss.ide.eclipse.as.doc.user@default:default,org.jboss.ide.ecli!
pse.archives.core@default:default,org.jboss.tools.common.test@!
default:
default,org.jboss.tools.common.verification.ui@default:default,org.jboss.tools.jmx.ui.test@default:default,org.jboss.tools.common@default:default,org.jboss.ide.eclipse.as.ssh@default:default,org.jboss.tools.common.verification.test@default:default,org.jboss.ide.eclipse.archives.test@default:default,org.jboss.tools.jmx.core@default:default,org.jboss.tools.common.resref.core@default:default,org.jboss.ide.eclipse.as.ui@default:default,org.jboss.ide.eclipse.as.classpath.ui@default:default,org.jboss.tools.common.el.core.test@default:default"/>
+<stringAttribute key="selected_target_plugins"
value="org.eclipse.ui.navigator@default:default,org.apache.commons.codec*1.3.0.v20100518-1140@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.wst.common.emf@default:default,com.ibm.icu@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.equinox.p2.core@default:default,javax.servlet@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.jface.databinding@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.debug@default:default,org.eclipse.ui@default:default,org.eclipse.search@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.compare.core@default:default,org.eclipse!
.core.runtime.compatibility.auth@default:default,org.eclipse.core.net@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.databinding@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.core.resources@default:default,org.eclipse.wst.common.uriresolver@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.equinox.p2.metadata@default:default,org.apache.commons.httpclient*3.1.0.v201005080502@default:default,org.eclipse.wst.xml.core@default:default,org.apache.xerces@default:default,org.eclipse.osgi,org.eclipse.core.filebuffers@default:default,org.junit*4.8.1.v4_8_1_v20100427-1100@default:default,org.eclipse.wst.common.core@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.debug.core@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.core.variables@default:default,org.eclipse.jf!
ace.text@default:default,org.eclipse.emf.edit@default:default,!
org.ecli
pse.help@default:default,org.eclipse.wst.common.frameworks@default:default,org.eclipse.team.ui@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.ui.console@default:default,org.eclipse.core.contenttype@default:default,org.hamcrest.core@default:default,org.eclipse.jdt.core@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.wst.common.emfworkbench.integration@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.equinox.common@default:default,org.eclipse.core.jobs@default:default,org.apache.commons.logging*1.0.4.v201005080501@default:default,org.eclipse.ui.editors@default:default,org.eclipse.ui.navigator.resources@default:default,org.apache.xml.serializer@default:default,org.eclipse.compare@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ui.views@default:default,org.eclipse.swt@default:default,org.eclipse.ui.ide@default:default,org.eclipse.equinox.preferences@default:default,org.eclip!
se.osgi.services@default:default,org.eclipse.ecf.identity@default:default,javax.xml@default:default,org.eclipse.osgi.util@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.wst.validation@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.wst.sse.core@default:default,org.eclipse.text@default:default,org.eclipse.debug.ui@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.ui.workbench@default:default,org.eclipse.jem.util@default:default,org.eclipse.ecf@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.eclipse.ecf.ssl@default:false,org.eclipse.core.runtime@default:true,org.eclipse.jface@default:default,org.eclipse.jdt.core.manipulation@default:default,org!
.eclipse.core.runtime.compatibility.registry@default:false,org!
.eclipse
.equinox.security@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.team.core@default:default,org.eclipse.ant.core@default:default,org.apache.xml.resolver@default:default"/>
+<stringAttribute key="selected_workspace_plugins"
value="org.jboss.tools.common@default:default,org.jboss.tools.deltacloud.test@default:default,org.jboss.tools.deltacloud.core@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltaCloudTestSuite.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltaCloudTestSuite.java 2011-01-10
16:13:00 UTC (rev 28044)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/DeltaCloudTestSuite.java 2011-01-10
16:13:52 UTC (rev 28045)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.test;
+import
org.jboss.tools.internal.deltacloud.test.core.client.HardwareProfileDomUnmarshallingTest;
import
org.jboss.tools.internal.deltacloud.test.core.client.InstanceDomUnmarshallingTest;
import org.jboss.tools.internal.deltacloud.test.core.client.KeyDomUnmarshallingTest;
import org.jboss.tools.internal.deltacloud.test.core.job.CloudSchedulingRulesTest;
@@ -23,6 +24,7 @@
@Suite.SuiteClasses({
CloudSchedulingRulesTest.class,
KeyDomUnmarshallingTest.class,
- InstanceDomUnmarshallingTest.class})
+ InstanceDomUnmarshallingTest.class,
+ HardwareProfileDomUnmarshallingTest.class})
public class DeltaCloudTestSuite {
}
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/HardwareProfileDomUnmarshallingTest.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/HardwareProfileDomUnmarshallingTest.java
(rev 0)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/HardwareProfileDomUnmarshallingTest.java 2011-01-10
16:13:52 UTC (rev 28045)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.test.core.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.net.MalformedURLException;
+
+import javax.xml.bind.JAXBException;
+
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.jboss.tools.deltacloud.core.client.HardwareProfile;
+import org.jboss.tools.deltacloud.core.client.Property;
+import org.jboss.tools.deltacloud.core.client.unmarshal.HardwareProfileUnmarshaller;
+import
org.jboss.tools.internal.deltacloud.test.fakes.HardwareProfileResponseFakes.HardwareProfile1Response;
+import
org.jboss.tools.internal.deltacloud.test.fakes.HardwareProfileResponseFakes.HardwareProfile2Response;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileDomUnmarshallingTest {
+
+ @Test
+ public void fixedPropertyHardwareProfileMayBeUnmarshalled() throws
MalformedURLException, JAXBException,
+ DeltaCloudClientException {
+ HardwareProfile profile = new HardwareProfile();
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(HardwareProfile1Response.response.getBytes());
+ new HardwareProfileUnmarshaller().unmarshall(inputStream, profile);
+ assertNotNull(profile);
+ assertEquals(HardwareProfile1Response.id, profile.getId());
+ assertEquals(HardwareProfile1Response.propMemValue + ' ' +
HardwareProfile1Response.propMemUnit,
+ profile.getMemory());
+ assertEquals(HardwareProfile1Response.propStorageValue + ' ' +
HardwareProfile1Response.propStorageUnit,
+ profile.getStorage());
+ assertEquals(HardwareProfile1Response.propCPUValue, profile.getCPU());
+ assertEquals(HardwareProfile1Response.propArchValue, profile.getArchitecture());
+ }
+
+ @Test
+ public void mixedPropertiesHardwareProfileMayBeUnmarshalled() throws
MalformedURLException, JAXBException,
+ DeltaCloudClientException {
+ HardwareProfile profile = new HardwareProfile();
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(HardwareProfile2Response.response.getBytes());
+ new HardwareProfileUnmarshaller().unmarshall(inputStream, profile);
+ assertNotNull(profile);
+ assertEquals(HardwareProfile2Response.id, profile.getId());
+ assertEquals(HardwareProfile2Response.propMemValue + ' ' +
HardwareProfile2Response.propMemUnit,
+ profile.getMemory());
+ Property property = profile.getNamedProperty(Property.Names.MEMORY);
+ assertNotNull(property);
+ assertEquals(HardwareProfile2Response.propMemRangeFirst,
property.getRange().getFirst());
+ assertEquals(HardwareProfile2Response.propMemRangeLast,
property.getRange().getLast());
+ assertEquals(HardwareProfile2Response.propStorageValue + ' ' +
HardwareProfile2Response.propStorageUnit,
+ profile.getStorage());
+ property = profile.getNamedProperty(Property.Names.STORAGE);
+ assertNotNull(property);
+ assertNotNull(property.getEnums());
+ assertEquals(2, property.getEnums().size());
+ assertEquals(HardwareProfile2Response.propStorageEnum1, property.getEnums().get(0));
+ assertEquals(HardwareProfile2Response.propStorageEnum2, property.getEnums().get(1));
+ assertEquals(HardwareProfile2Response.propCPUValue, profile.getCPU());
+ assertEquals(HardwareProfile2Response.propArchValue, profile.getArchitecture());
+ }
+
+}
Property changes on:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/HardwareProfileDomUnmarshallingTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/HardwareProfileResponseFakes.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/HardwareProfileResponseFakes.java
(rev 0)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/HardwareProfileResponseFakes.java 2011-01-10
16:13:52 UTC (rev 28045)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.test.fakes;
+
+import org.jboss.tools.deltacloud.core.client.Property;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileResponseFakes {
+
+ public static enum Units {
+ GB, MB, COUNT, LABEL
+ };
+
+ public static class PropertyResponse {
+
+ }
+
+ public static class HardwareProfile1Response {
+ public static final String id = "m1-small";
+ public static final String propMemKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propMemUnit = Units.MB.name();
+ public static final String propMemValue = "1740.8";
+ public static final String propStorageKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propStorageUnit = Units.GB.name();
+ public static final String propStorageValue = "160";
+ public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propCPUUnit = Units.COUNT.name().toLowerCase();
+ public static final String propCPUValue = "1";
+ public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propArchUnit = Units.LABEL.name().toLowerCase();
+ public static final String propArchValue = "i386";
+
+ public static final String response = getHardwareProfileResponseXML(
+ id,
+ new String[] {
+ getFixedPropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit,
propMemValue),
+ getFixedPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+ propStorageValue),
+ getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit,
propCPUValue),
+ getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(),
propArchUnit,
+ propArchValue)
+ });
+ }
+
+ public static class HardwareProfile2Response {
+ public static final String id = "m1-large";
+ public static final String propMemKind = Property.Kind.RANGE.name().toLowerCase();
+ public static final String propMemUnit = Units.MB.name();
+ public static final String propMemValue = "10240";
+ public static final String propMemRangeFirst = "7680.0";
+ public static final String propMemRangeLast = "15360";
+ public static final String propStorageKind = Property.Kind.ENUM.name().toLowerCase();
+ public static final String propStorageUnit = Units.GB.name();
+ public static final String propStorageValue = "160";
+ public static final String propStorageEnum1 = "850";
+ public static final String propStorageEnum2 = "1024";
+ public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propCPUUnit = Units.COUNT.name().toLowerCase();
+ public static final String propCPUValue = "2";
+ public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propArchUnit = Units.LABEL.name().toLowerCase();
+ public static final String propArchValue = "x86_64";
+
+ public static final String response = getHardwareProfileResponseXML(
+ id,
+ new String[] {
+ getRangePropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit,
propMemValue,
+ propMemRangeFirst, propMemRangeLast),
+ getEnumPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+ propStorageValue, propStorageEnum1, propStorageEnum2),
+ getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit,
propCPUValue),
+ getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(),
propArchUnit,
+ propArchValue)
+ });
+ }
+
+ public static class HardwareProfilesResponse {
+
+ }
+
+ private static final String getHardwareProfileResponseXML(String id, String[]
properties) {
+ StringBuilder builder = new StringBuilder();
+ for (String propertyString : properties) {
+ builder.append(propertyString);
+ }
+ return getHardwareProfileResponseXML(id, builder.toString());
+ }
+
+ private static final String getHardwareProfileResponseXML(String id, String properties)
{
+ return new StringBuilder()
+ .append("<hardware_profile href=\"fakeUrl\"
id=\"").append(id).append("\">")
+ .append("<name>fakeName</name>")
+ .append(properties)
+ .append("</hardware_profile>")
+ .toString();
+ }
+
+ private static String getFixedPropertyXML(String name, String unit, String value) {
+ return getPropertyXML(name, "fixed", unit, value)
+ + getClodingPropertyTag();
+ }
+
+ private static String getRangePropertyXML(String name, String unit, String value, String
first, String last) {
+ return getPropertyXML(name, "range", unit, value)
+ + "<range first='" + first + "' last='" + last +
"'/>"
+ + getClodingPropertyTag();
+ }
+
+ private static String getEnumPropertyXML(String name, String unit, String value,
String... enumValues) {
+ StringBuilder builder = new StringBuilder(getPropertyXML(name, "enum", unit,
value));
+ builder.append("<enum>");
+ for (String enumValue : enumValues) {
+ builder.append("<entry value='").append(enumValue).append("'
/>");
+ }
+ builder.append("</enum>");
+ builder.append(getClodingPropertyTag());
+ return builder.toString();
+ }
+
+ private static String getPropertyXML(String name, String kind, String unit, String
value) {
+ return "<property kind=\"" + kind + "\" name=\""
+ name + "\" unit=\"" + unit + "\" value=\"" +
value + "\">";
+ }
+
+ private static String getClodingPropertyTag() {
+ return "</property>";
+
+ }
+
+}
Property changes on:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/HardwareProfileResponseFakes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain