You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/08/25 01:29:15 UTC

[GitHub] [shardingsphere] xbkaishui opened a new pull request #7044: Add test case of pg binary value

xbkaishui opened a new pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044


   
   Changes proposed in this pull request:
   -  Add test case pg binary value
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero merged pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#discussion_r476107550



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PostgreSQLDoubleBinaryProtocolValueTest {
+    
+    @Mock
+    private ByteBuf byteBuf;
+    
+    @Test
+    public void assertGetColumnLength() {
+        assertThat(new PostgreSQLDoubleBinaryProtocolValue().getColumnLength(""), is(8));
+    }
+    
+    @Test
+    public void assertRead() {
+        when(byteBuf.readDouble()).thenReturn(1D);
+        assertThat(new PostgreSQLDoubleBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf)), is(1D));
+    }
+    
+    @Test
+    public void assertWrite() {
+        new PostgreSQLDoubleBinaryProtocolValue().write(new PostgreSQLPacketPayload(byteBuf), 1D);
+        verify(byteBuf).writeDouble(1.0d);
+    }
+    

Review comment:
       It is suggested to remove this redundant blank line.

##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
+
+import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.sql.Timestamp;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PostgreSQLDateBinaryProtocolValueTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    public void assertGetColumnLength() {
+        assertThat(new PostgreSQLDateBinaryProtocolValue().getColumnLength(""), is(8));
+    }
+    
+    @Test
+    public void assertRead() {
+        when(payload.readInt8()).thenReturn(1L);
+        assertThat(new PostgreSQLDateBinaryProtocolValue().read(payload), is(1L));
+    }
+    
+    @Test
+    public void assertWrite() {
+        Timestamp data = new Timestamp(System.currentTimeMillis());
+        new PostgreSQLDateBinaryProtocolValue().write(payload, data);
+        verify(payload).writeInt8(data.getTime());
+    }
+    

Review comment:
       It is suggested to remove this redundant blank line.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls commented on pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#issuecomment-679458639


   ## Pull Request Test Coverage Report for [Build 14094](https://coveralls.io/builds/32972891)
   
   * **0** of **0**   changed or added relevant lines in **0** files are covered.
   * No unchanged relevant lines lost coverage.
   * Overall coverage increased (+**0.008%**) to **35.449%**
   
   ---
   
   
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/32972891/badge)](https://coveralls.io/builds/32972891) |
   | :-- | --: |
   | Change from base [Build 14092](https://coveralls.io/builds/32963363): |  0.008% |
   | Covered Lines: | 35637 |
   | Relevant Lines: | 100530 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#discussion_r476192430



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
+
+import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.sql.Timestamp;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PostgreSQLDateBinaryProtocolValueTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    public void assertGetColumnLength() {
+        assertThat(new PostgreSQLDateBinaryProtocolValue().getColumnLength(""), is(8));
+    }
+    
+    @Test
+    public void assertRead() {
+        when(payload.readInt8()).thenReturn(1L);
+        assertThat(new PostgreSQLDateBinaryProtocolValue().read(payload), is(1L));
+    }
+    
+    @Test
+    public void assertWrite() {
+        Timestamp data = new Timestamp(System.currentTimeMillis());
+        new PostgreSQLDateBinaryProtocolValue().write(payload, data);
+        verify(payload).writeInt8(data.getTime());
+    }
+    

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#discussion_r476193035



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PostgreSQLDoubleBinaryProtocolValueTest {
+    
+    @Mock
+    private ByteBuf byteBuf;
+    
+    @Test
+    public void assertGetColumnLength() {
+        assertThat(new PostgreSQLDoubleBinaryProtocolValue().getColumnLength(""), is(8));
+    }
+    
+    @Test
+    public void assertRead() {
+        when(byteBuf.readDouble()).thenReturn(1D);
+        assertThat(new PostgreSQLDoubleBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf)), is(1D));
+    }
+    
+    @Test
+    public void assertWrite() {
+        new PostgreSQLDoubleBinaryProtocolValue().write(new PostgreSQLPacketPayload(byteBuf), 1D);
+        verify(byteBuf).writeDouble(1.0d);
+    }
+    

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#issuecomment-679458639


   ## Pull Request Test Coverage Report for [Build 14100](https://coveralls.io/builds/32976853)
   
   * **0** of **0**   changed or added relevant lines in **0** files are covered.
   * **78** unchanged lines in **2** files lost coverage.
   * Overall coverage increased (+**0.01%**) to **35.453%**
   
   ---
   
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingRouteDecorator.java](https://coveralls.io/builds/32976853/source?filename=shardingsphere-features%2Fshardingsphere-sharding%2Fshardingsphere-sharding-route%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsharding%2Froute%2Fengine%2FShardingRouteDecorator.java#L87) | 4 | 93.44% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/util/TableExtractUtils.java](https://coveralls.io/builds/32976853/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-statement%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Futil%2FTableExtractUtils.java#L51) | 74 | 0% |
   <!-- | **Total:** | **78** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/32976853/badge)](https://coveralls.io/builds/32976853) |
   | :-- | --: |
   | Change from base [Build 14092](https://coveralls.io/builds/32963363): |  0.01% |
   | Covered Lines: | 35648 |
   | Relevant Lines: | 100551 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xbkaishui commented on a change in pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
xbkaishui commented on a change in pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#discussion_r476191740



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java
##########
@@ -65,6 +65,7 @@ public void assertDecode() {
         List<Object> out = new LinkedList<>();
         new PostgreSQLPacketCodecEngine().decode(context, byteBuf, out, 54);
         assertThat(out.size(), is(1));
+        assertThat(out.size(), is(1));

Review comment:
       fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on a change in pull request #7044: Add test case of pg binary value

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on a change in pull request #7044:
URL: https://github.com/apache/shardingsphere/pull/7044#discussion_r476128919



##########
File path: shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java
##########
@@ -65,6 +65,7 @@ public void assertDecode() {
         List<Object> out = new LinkedList<>();
         new PostgreSQLPacketCodecEngine().decode(context, byteBuf, out, 54);
         assertThat(out.size(), is(1));
+        assertThat(out.size(), is(1));

Review comment:
       Is it a duplicated line?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org