diff --git a/.licenserc.yaml b/.licenserc.yaml index a62d76856..0174946b1 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -72,7 +72,6 @@ header: # `header` section is configurations for source codes license header. - 'assembly/**' - '.github/**/*' - '**/target/*' - - '**/util/StringEncoding.java' - '**/go.mod' - '**/go.sum' comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`. diff --git a/LICENSE b/LICENSE index e79807eef..8dada3eda 100644 --- a/LICENSE +++ b/LICENSE @@ -199,12 +199,3 @@ 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. - -======================================================================== -Apache 2.0 licenses -======================================================================== - -The following components are provided under the Apache License. See project link for details. -The text of each license is the standard Apache 2.0 license. - -computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph diff --git a/NOTICE b/NOTICE index a0e7f71c0..42f88212e 100644 --- a/NOTICE +++ b/NOTICE @@ -5,56 +5,3 @@ This product includes software developed at The Apache Software Foundation (http://www.apache.org/). The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021. - ------------------------------------------------------------------------ -This product contains code form the JanusGraph Project: ------------------------------------------------------------------------ -============================================================== - JanusGraph: Distributed Graph Database - Copyright 2012 and onwards JanusGraph Authors -============================================================== - -This product includes software developed by JanusGraph contributors listed -in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt. - -This product is based on Titan, originally developed by Aurelius (acquired by -DataStax) and the following individuals: - - * Matthias Broecheler - * Dan LaRocque - * Marko A. Rodriguez - * Stephen Mallette - * Pavel Yaskevich - -It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing): - - * Apache Cassandra [https://cassandra.apache.org/] - * Apache Commons [https://commons.apache.org/] - * Apache Groovy [http://groovy-lang.org/] - * Apache HBase [https://hbase.apache.org/] - * Apache Hadoop [https://hadoop.apache.org/] - * Apache Kerby [https://github.com/apache/directory-kerby] - * Apache Log4j [https://logging.apache.org/log4j] - * Apache Lucene [https://lucene.apache.org/] - * Apache Solr [https://lucene.apache.org/solr/] - * Apache TinkerPop [https://tinkerpop.apache.org/] - * Astyanax [https://github.com/Netflix/astyanax] - * DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver] - * EasyMock [http://easymock.org/] - * Elasticsearch [https://www.elastic.co/] - * Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client] - * Google Guava [https://github.com/google/guava] - * HPPC [https://labs.carrotsearch.com/hppc.html] - * JUnit [https://www.junit.org/] - * Jackson [https://github.com/FasterXML/jackson] - * Kryo [https://github.com/EsotericSoftware/kryo] - * Metrics [https://metrics.dropwizard.io] - * Mockito [https://site.mockito.org/] - * Noggit [https://github.com/yonik/noggit] - * OpenRDF [http://rdf4j.org/] - * Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below) - * Project Lombok [https://projectlombok.org/] - * Reflections8 [https://github.com/aschoerk/reflections8] - * SLF4J [https://www.slf4j.org/] - * Spatial4j [https://github.com/locationtech/spatial4j] - * Vavr [https://www.vavr.io/] diff --git a/computer-core/src/main/java/org/apache/hugegraph/computer/core/io/StructRandomAccessOutput.java b/computer-core/src/main/java/org/apache/hugegraph/computer/core/io/StructRandomAccessOutput.java index 285a92cf9..16d83ccfe 100644 --- a/computer-core/src/main/java/org/apache/hugegraph/computer/core/io/StructRandomAccessOutput.java +++ b/computer-core/src/main/java/org/apache/hugegraph/computer/core/io/StructRandomAccessOutput.java @@ -20,7 +20,7 @@ import java.io.IOException; import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.testutil.Whitebox; @SuppressWarnings("deprecation") // StringEscapeUtils @@ -67,14 +67,14 @@ public void write(int b) throws IOException { @Override public void write(byte[] b) throws IOException { - this.writeString(StringEncoding.encodeBase64(b)); + this.writeString(StringEncodeUtil.encodeBase64(b)); } @Override public void write(byte[] b, int off, int len) throws IOException { byte[] dest = new byte[len]; System.arraycopy(b, off, dest, 0, len); - this.writeString(StringEncoding.encodeBase64(dest)); + this.writeString(StringEncodeUtil.encodeBase64(dest)); } @Override diff --git a/computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java b/computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java index 9c27f2498..57f35fdb3 100644 --- a/computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java +++ b/computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java @@ -27,7 +27,7 @@ import java.util.List; import org.apache.hugegraph.computer.core.common.exception.ComputerException; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Log; import org.slf4j.Logger; @@ -146,12 +146,12 @@ public static String readString(ByteBuf buf) { } byte[] bytes = new byte[length]; buf.readBytes(bytes); - return StringEncoding.decode(bytes); + return StringEncodeUtil.decode(bytes); } public static void writeString(ByteBuf buf, String value) { E.checkArgumentNotNull(value, "value"); - byte[] encoded = StringEncoding.encode(value); + byte[] encoded = StringEncodeUtil.encode(value); buf.writeInt(encoded.length); buf.writeBytes(encoded); } diff --git a/computer-core/src/main/java/org/apache/hugegraph/computer/core/output/hdfs/HdfsOutput.java b/computer-core/src/main/java/org/apache/hugegraph/computer/core/output/hdfs/HdfsOutput.java index 0cce6e6cc..9d4beece7 100644 --- a/computer-core/src/main/java/org/apache/hugegraph/computer/core/output/hdfs/HdfsOutput.java +++ b/computer-core/src/main/java/org/apache/hugegraph/computer/core/output/hdfs/HdfsOutput.java @@ -31,7 +31,7 @@ import org.apache.hugegraph.computer.core.config.Config; import org.apache.hugegraph.computer.core.graph.vertex.Vertex; import org.apache.hugegraph.computer.core.output.AbstractComputerOutput; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.util.Log; import org.slf4j.Logger; @@ -93,7 +93,7 @@ protected void writeBytes(byte[] bytes) throws IOException { } protected void writeString(String string) throws IOException { - this.writeBytes(StringEncoding.encode(string)); + this.writeBytes(StringEncodeUtil.encode(string)); } protected String constructValueString(Vertex vertex) { diff --git a/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncodeUtil.java b/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncodeUtil.java new file mode 100644 index 000000000..963f86e03 --- /dev/null +++ b/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncodeUtil.java @@ -0,0 +1,52 @@ +/* + * 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.hugegraph.computer.core.util; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +public final class StringEncodeUtil { + + private static final byte[] BYTES_EMPTY = new byte[0]; + + private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder(); + private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder(); + + public static byte[] encode(String value) { + return value.getBytes(StandardCharsets.UTF_8); + } + + public static String decode(byte[] bytes) { + return new String(bytes, StandardCharsets.UTF_8); + } + + public static String decode(byte[] bytes, int offset, int length) { + return new String(bytes, offset, length, StandardCharsets.UTF_8); + } + + public static String encodeBase64(byte[] bytes) { + return BASE64_ENCODER.encodeToString(bytes); + } + + public static byte[] decodeBase64(String value) { + if (value.isEmpty()) { + return BYTES_EMPTY; + } + return BASE64_DECODER.decode(value); + } +} diff --git a/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java b/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java deleted file mode 100644 index 39bbb3ee4..000000000 --- a/computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2017 JanusGraph Authors -// -// Licensed 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.hugegraph.computer.core.util; - -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Base64; -import java.util.UUID; - -import org.apache.hugegraph.computer.core.common.exception.ComputerException; -import org.apache.hugegraph.util.Bytes; -import org.apache.hugegraph.util.E; - -import com.google.common.base.CharMatcher; - -/** - * @author Matthias Broecheler (me@matthiasb.com) - */ -public final class StringEncoding { - - private static final MessageDigest DIGEST; - private static final byte[] BYTES_EMPTY = new byte[0]; - - static { - final String ALG = "SHA-256"; - try { - DIGEST = MessageDigest.getInstance(ALG); - } catch (NoSuchAlgorithmException e) { - throw new ComputerException("Failed to load algorithm %s", e, ALG); - } - } - - private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder(); - private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder(); - - /** Similar to {@link StringSerializer} */ - public static int writeAsciiString(byte[] array, int offset, String value) { - E.checkArgument(CharMatcher.ascii().matchesAllOf(value), - "'%s' must be ASCII string", value); - int len = value.length(); - if (len == 0) { - array[offset++] = (byte) 0x80; - return offset; - } - - int i = 0; - do { - int c = value.charAt(i); - assert c <= 127; - byte b = (byte) c; - if (++i == len) { - // End marker - b |= 0x80; - } - array[offset++] = b; - } while (i < len); - - return offset; - } - - public static String readAsciiString(byte[] array, int offset) { - StringBuilder sb = new StringBuilder(); - int c; - do { - c = 0xFF & array[offset++]; - if (c != 0x80) { - sb.append((char) (c & 0x7F)); - } - } while ((c & 0x80) <= 0); - return sb.toString(); - } - - public static int getAsciiByteLength(String value) { - E.checkArgument(CharMatcher.ascii().matchesAllOf(value), - "'%s' must be ASCII string", value); - return value.isEmpty() ? 1 : value.length(); - } - - public static byte[] encode(String value) { - return value.getBytes(StandardCharsets.UTF_8); - } - - public static String decode(byte[] bytes) { - return new String(bytes, StandardCharsets.UTF_8); - } - - public static String decode(byte[] bytes, int offset, int length) { - return new String(bytes, offset, length, StandardCharsets.UTF_8); - } - - public static String encodeBase64(byte[] bytes) { - return BASE64_ENCODER.encodeToString(bytes); - } - - public static byte[] decodeBase64(String value) { - if (value.isEmpty()) { - return BYTES_EMPTY; - } - return BASE64_DECODER.decode(value); - } - - public static String sha256(String string) { - byte[] stringBytes = encode(string); - DIGEST.reset(); - return StringEncoding.encodeBase64(DIGEST.digest(stringBytes)); - } - - public static String format(byte[] bytes) { - return String.format("%s[0x%s]", decode(bytes), Bytes.toHex(bytes)); - } - - public static UUID uuid(String value) { - E.checkArgument(value != null, "The UUID can't be null"); - try { - if (value.contains("-") && value.length() == 36) { - return UUID.fromString(value); - } - // UUID represented by hex string - E.checkArgument(value.length() == 32, "Invalid UUID string: %s", value); - String high = value.substring(0, 16); - String low = value.substring(16); - return new UUID(Long.parseUnsignedLong(high, 16), - Long.parseUnsignedLong(low, 16)); - } catch (NumberFormatException ignored) { - throw new IllegalArgumentException("Invalid UUID string: " + value); - } - } -} diff --git a/computer-dist/release-docs/LICENSE b/computer-dist/release-docs/LICENSE index 0f8d6f742..c7ae03f9c 100644 --- a/computer-dist/release-docs/LICENSE +++ b/computer-dist/release-docs/LICENSE @@ -400,8 +400,6 @@ The following components are provided under the Apache 2.0 License. (Apache License, Version 2.0) * okio(com.squareup.okio:okio-jvm:3.0.0-https://github.com/square/okio/ ) (Apache License, Version 2.0) * Simple XML (safe)(com.carrotsearch.thirdparty:simple-xml-safe:2.7.1-https://github.com/dweiss/simplexml ) - computer-core/src/main/java/org/apache/hugegraph/computer/core/util/StringEncoding.java files from https://github.com/JanusGraph - ======================================================================== Third party BSD licenses ======================================================================== diff --git a/computer-dist/release-docs/NOTICE b/computer-dist/release-docs/NOTICE index d38658a56..0502f23b1 100644 --- a/computer-dist/release-docs/NOTICE +++ b/computer-dist/release-docs/NOTICE @@ -3807,57 +3807,6 @@ Copyright 2001-2008 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). - -============================================================== - JanusGraph: Distributed Graph Database - Copyright 2012 and onwards JanusGraph Authors -============================================================== - -This product includes software developed by JanusGraph contributors listed -in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt. - -This product is based on Titan, originally developed by Aurelius (acquired by -DataStax) and the following individuals: - - * Matthias Broecheler - * Dan LaRocque - * Marko A. Rodriguez - * Stephen Mallette - * Pavel Yaskevich - -It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing): - - * Apache Cassandra [https://cassandra.apache.org/] - * Apache Commons [https://commons.apache.org/] - * Apache Groovy [http://groovy-lang.org/] - * Apache HBase [https://hbase.apache.org/] - * Apache Hadoop [https://hadoop.apache.org/] - * Apache Kerby [https://github.com/apache/directory-kerby] - * Apache Log4j [https://logging.apache.org/log4j] - * Apache Lucene [https://lucene.apache.org/] - * Apache Solr [https://lucene.apache.org/solr/] - * Apache TinkerPop [https://tinkerpop.apache.org/] - * Astyanax [https://github.com/Netflix/astyanax] - * DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver] - * EasyMock [http://easymock.org/] - * Elasticsearch [https://www.elastic.co/] - * Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client] - * Google Guava [https://github.com/google/guava] - * HPPC [https://labs.carrotsearch.com/hppc.html] - * JUnit [https://www.junit.org/] - * Jackson [https://github.com/FasterXML/jackson] - * Kryo [https://github.com/EsotericSoftware/kryo] - * Metrics [https://metrics.dropwizard.io] - * Mockito [https://site.mockito.org/] - * Noggit [https://github.com/yonik/noggit] - * OpenRDF [http://rdf4j.org/] - * Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below) - * Project Lombok [https://projectlombok.org/] - * Reflections8 [https://github.com/aschoerk/reflections8] - * SLF4J [https://www.slf4j.org/] - * Spatial4j [https://github.com/locationtech/spatial4j] - * Vavr [https://www.vavr.io/] - ======================================================================== kotlin NOTICE diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtilTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtilTest.java index df7f70c4c..f4d50b7ac 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtilTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtilTest.java @@ -19,7 +19,7 @@ import java.net.InetSocketAddress; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.testutil.Assert; import org.junit.Test; @@ -88,7 +88,7 @@ public void testFormatAddress() { @Test public void testReadString() { - byte[] testData = StringEncoding.encode("test data"); + byte[] testData = StringEncodeUtil.encode("test data"); ByteBuf buffer = Unpooled.directBuffer(testData.length); try { buffer.writeInt(testData.length); diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/buffer/NetworkBufferTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/buffer/NetworkBufferTest.java index ac87f1fa0..9c4927196 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/buffer/NetworkBufferTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/buffer/NetworkBufferTest.java @@ -19,7 +19,7 @@ import java.nio.ByteBuffer; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.testutil.Assert; import org.junit.Test; @@ -100,7 +100,7 @@ public void testNettyByteBuffer() { @Test public void testCopyToByteArray() { String testData = "test data"; - byte[] bytesSource = StringEncoding.encode(testData); + byte[] bytesSource = StringEncodeUtil.encode(testData); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(bytesSource.length); byteBuffer = byteBuffer.put(bytesSource); diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyEncodeDecodeHandlerTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyEncodeDecodeHandlerTest.java index 4ecd649d6..77b68db95 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyEncodeDecodeHandlerTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyEncodeDecodeHandlerTest.java @@ -28,7 +28,7 @@ import org.apache.hugegraph.computer.core.network.message.MessageType; import org.apache.hugegraph.computer.core.network.message.StartMessage; import org.apache.hugegraph.computer.core.network.netty.codec.FrameDecoder; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.computer.suite.unit.UnitTestBase; import org.apache.hugegraph.testutil.Assert; import org.junit.Test; @@ -52,7 +52,7 @@ public void testSendMsgWithEncoderExceptionMock() throws IOException { int requestId = 1; int partition = 1; - byte[] bytes = StringEncoding.encode("mock msg"); + byte[] bytes = StringEncodeUtil.encode("mock msg"); ByteBuffer buffer = ByteBuffer.wrap(bytes); NetworkBuffer body = new NioBuffer(buffer); DataMessage dataMessage = new DataMessage(null, requestId, @@ -146,7 +146,7 @@ public void testClientDecodeException() throws IOException { public void testMessageRelease() { int requestId = 99; int partition = 1; - byte[] bytes = StringEncoding.encode("mock msg"); + byte[] bytes = StringEncodeUtil.encode("mock msg"); ByteBuf buf = Unpooled.directBuffer().writeBytes(bytes); try { NettyBuffer managedBuffer = new NettyBuffer(buf); diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyTransportClientTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyTransportClientTest.java index 6d132a83c..fac4046b6 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyTransportClientTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/netty/NettyTransportClientTest.java @@ -38,7 +38,7 @@ import org.apache.hugegraph.computer.core.network.buffer.NetworkBuffer; import org.apache.hugegraph.computer.core.network.message.Message; import org.apache.hugegraph.computer.core.network.message.MessageType; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.computer.suite.unit.UnitTestBase; import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.testutil.Whitebox; @@ -118,9 +118,9 @@ public void testSend() throws IOException { NettyTransportClient client = (NettyTransportClient) this.oneClient(); for (int i = 0; i < 3; i++) { client.startSession(); - client.send(MessageType.MSG, 1, ByteBuffer.wrap(StringEncoding.encode("test1"))); - client.send(MessageType.VERTEX, 2, ByteBuffer.wrap(StringEncoding.encode("test2"))); - client.send(MessageType.EDGE, 3, ByteBuffer.wrap(StringEncoding.encode("test3"))); + client.send(MessageType.MSG, 1, ByteBuffer.wrap(StringEncodeUtil.encode("test1"))); + client.send(MessageType.VERTEX, 2, ByteBuffer.wrap(StringEncodeUtil.encode("test2"))); + client.send(MessageType.EDGE, 3, ByteBuffer.wrap(StringEncodeUtil.encode("test3"))); client.finishSession(); } } @@ -128,9 +128,9 @@ public void testSend() throws IOException { @Test public void testDataUniformity() throws IOException { NettyTransportClient client = (NettyTransportClient) this.oneClient(); - byte[] sourceBytes1 = StringEncoding.encode("test data message"); - byte[] sourceBytes2 = StringEncoding.encode("test data edge"); - byte[] sourceBytes3 = StringEncoding.encode("test data vertex"); + byte[] sourceBytes1 = StringEncodeUtil.encode("test data message"); + byte[] sourceBytes2 = StringEncodeUtil.encode("test data edge"); + byte[] sourceBytes3 = StringEncodeUtil.encode("test data vertex"); Mockito.doAnswer(invocationOnMock -> { MessageType type = invocationOnMock.getArgument(0); @@ -236,7 +236,7 @@ public void testFinishSessionWithSendException() throws IOException { @Test public void testFlowControl() throws IOException { - ByteBuffer buffer = ByteBuffer.wrap(StringEncoding.encode("test data")); + ByteBuffer buffer = ByteBuffer.wrap(StringEncodeUtil.encode("test data")); NettyTransportClient client = (NettyTransportClient) this.oneClient(); client.startSession(); @@ -280,7 +280,7 @@ public void testHandlerException() throws IOException { Mockito.doThrow(new RuntimeException("test exception")).when(serverHandler) .handle(Mockito.any(), Mockito.anyInt(), Mockito.any()); - ByteBuffer buffer = ByteBuffer.wrap(StringEncoding.encode("test data")); + ByteBuffer buffer = ByteBuffer.wrap(StringEncodeUtil.encode("test data")); boolean send = client.send(MessageType.MSG, 1, buffer); Assert.assertTrue(send); diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/session/TransportSessionTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/session/TransportSessionTest.java index 09f4378fe..0e74e70bb 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/session/TransportSessionTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/network/session/TransportSessionTest.java @@ -29,7 +29,7 @@ import org.apache.hugegraph.computer.core.network.message.AbstractMessage; import org.apache.hugegraph.computer.core.network.message.MessageType; import org.apache.hugegraph.computer.core.network.netty.AbstractNetworkTest; -import org.apache.hugegraph.computer.core.util.StringEncoding; +import org.apache.hugegraph.computer.core.util.StringEncodeUtil; import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.testutil.Whitebox; import org.apache.hugegraph.util.ExecutorUtil; @@ -131,7 +131,7 @@ public void testSendAsyncWithException() { ClientSession clientSession = new ClientSession(conf, message -> null); Assert.assertEquals(TransportState.READY, clientSession.state()); - ByteBuffer buffer = ByteBuffer.wrap(StringEncoding.encode("test data")); + ByteBuffer buffer = ByteBuffer.wrap(StringEncodeUtil.encode("test data")); Assert.assertThrows(IllegalArgumentException.class, () -> { clientSession.sendAsync(MessageType.MSG, 1, buffer);