OpenStack Cinder general cleanup. Prefer ByteSourcePayload.

This commit is contained in:
Jeremy Daggett 2014-08-06 11:44:13 -07:00 committed by Jeremy Daggett
parent 59462747e7
commit 23d5290526
15 changed files with 63 additions and 25 deletions

View File

@ -1 +1,18 @@
org.jclouds.openstack.cinder.v1.CinderApiMetadata
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
org.jclouds.openstack.cinder.v1.CinderApiMetadata

View File

@ -17,8 +17,8 @@
package org.jclouds.openstack.cinder.v1.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
@ -29,6 +29,7 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.jclouds.openstack.cinder.v1.domain.Snapshot;
import org.jclouds.openstack.cinder.v1.domain.Volume;
import org.jclouds.openstack.cinder.v1.internal.BaseCinderApiExpectTest;
@ -39,6 +40,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteSource;
/**
* Tests SnapshotApi Guice wiring and parsing
@ -144,7 +146,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
.build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_create_response.json")).build()
).getSnapshotApiForZone("RegionOne");
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
.name("jclouds-test-snapshot")
.description("jclouds test snapshot")
@ -166,7 +168,7 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
.build(),
HttpResponse.builder().statusCode(404).build()
).getSnapshotApiForZone("RegionOne");
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
.name("jclouds-test-snapshot")
.description("jclouds test snapshot")
@ -187,10 +189,12 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
.build(),
HttpResponse.builder()
.statusCode(400)
.payload("{\"badRequest\": {\"message\": \"Invalid volume: must be available\", \"code\": 400}}")
.payload(Payloads.newByteSourcePayload(ByteSource
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: must be available\", \"code\": 400}}"
.getBytes())))
.build()
).getSnapshotApiForZone("RegionOne");
CreateSnapshotOptions options = CreateSnapshotOptions.Builder
.name("jclouds-test-snapshot")
.description("jclouds test snapshot")
@ -266,7 +270,9 @@ public class SnapshotApiExpectTest extends BaseCinderApiExpectTest {
authenticatedGET().endpoint(endpoint).method("DELETE").build(),
HttpResponse.builder()
.statusCode(400)
.payload("{\"badRequest\": {\"message\": \"Invalid volume: Volume Snapshot status must be available or error\", \"code\": 400}}")
.payload(Payloads.newByteSourcePayload(ByteSource
.wrap("{\"badRequest\": {\"message\": \"Invalid volume: Volume Snapshot status must be available or error\", \"code\": 400}}"
.getBytes())))
.build()
).getSnapshotApiForZone("RegionOne");

View File

@ -1,6 +1,8 @@
{"quota_set": {
"gigabytes": 1000,
"volumes": 10,
"snapshots": 20,
"id": "demo"
}}
{
"quota_set": {
"gigabytes": 1000,
"volumes": 10,
"snapshots": 20,
"id": "demo"
}
}

View File

@ -1 +1,8 @@
{"snapshot":{"display_name":"jclouds-test-snapshot","volume_id":"ea6f70ef-2784-40b9-9d14-d7f33c507c3f","display_description":"jclouds test snapshot","force":"true"}}
{
"snapshot": {
"display_name": "jclouds-test-snapshot",
"volume_id": "ea6f70ef-2784-40b9-9d14-d7f33c507c3f",
"display_description": "jclouds test snapshot",
"force": "true"
}
}

View File

@ -8,4 +8,4 @@
"id": "67d03df1-ce5d-4ba7-adbe-492ceb80170b",
"size": 1
}
}
}

View File

@ -10,4 +10,4 @@
"id": "67d03df1-ce5d-4ba7-adbe-492ceb80170b",
"size": 1
}
}
}

View File

@ -12,4 +12,4 @@
"size": 1
}
]
}
}

View File

@ -10,4 +10,4 @@
"size": 1
}
]
}
}

View File

@ -1 +1,7 @@
{"volume":{"display_name":"jclouds-test-volume","display_description":"description of test volume","size":1}}
{
"volume": {
"display_name": "jclouds-test-volume",
"display_description": "description of test volume",
"size": 1
}
}

View File

@ -12,4 +12,4 @@
"id": "60761c60-0f56-4499-b522-ff13e120af10",
"size": 1
}
}
}

View File

@ -19,4 +19,4 @@
"id": "60761c60-0f56-4499-b522-ff13e120af10",
"size": 1
}
}
}

View File

@ -21,4 +21,4 @@
"size": 1
}
]
}
}

View File

@ -21,4 +21,4 @@
"size": 1
}
]
}
}

View File

@ -11,4 +11,4 @@
"deleted_at": null,
"id": 1
}
}
}

View File

@ -13,4 +13,4 @@
"id": 1
}
]
}
}