Permalink
Browse files

RequestMeta: store w & dw values

Neither w or dw were set to the fields writeQuorum or
durableWriteQuorum. Fix w(int) and dw(int) to store to fields.
  • Loading branch information...
1 parent 6a812d0 commit 9811a8a467c705438dc49c4ff42f1ff3502ce224 @russelldb russelldb committed Mar 7, 2011
@@ -46,17 +46,17 @@ public void preparePut(RPB.RpbPutReq.Builder builder) {
}
public RequestMeta returnBody(boolean ret) {
- returnBody = Boolean.valueOf(ret);
+ this.returnBody = Boolean.valueOf(ret);
return this;
}
public RequestMeta w(int w) {
- w = new Integer(w);
+ this.writeQuorum = new Integer(w);
return this;
}
public RequestMeta dw(int dw) {
- dw = new Integer(dw);
+ this.durableWriteQuorum = new Integer(dw);
return this;
}
@@ -0,0 +1,46 @@
+/*
+ * This file is provided 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.
+ */
+package com.trifork.riak;
+
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author russell
+ *
+ */
+@Test(groups = "unit")
+public class TestRequestMeta {
+
+ public void builderIsPopulatedFromSetterValues() {
+ final int dw = 2;
+ final int w = 3;
+ final boolean returnBody = true;
+ final String contentType = "application/json";
+ final RPB.RpbPutReq.Builder builder = RPB.RpbPutReq.newBuilder();
+
+ RequestMeta requestMeta = new RequestMeta();
+ requestMeta.dw(dw).w(w).returnBody(returnBody).contentType(contentType);
+
+ assertEquals(contentType, requestMeta.getContentType().toStringUtf8());
+
+ requestMeta.preparePut(builder);
+
+ assertEquals(dw, builder.getDw());
+ assertEquals(w, builder.getW());
+ assertEquals(returnBody, builder.getReturnBody());
+ }
+
+}

0 comments on commit 9811a8a

Please sign in to comment.