Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: optimize workflow for 2.x #5268

Merged
merged 10 commits into from
Jan 29, 2023
Prev Previous commit
Next Next commit
add test
Signed-off-by: slievrly <slievrly@163.com>
  • Loading branch information
slievrly committed Jan 29, 2023
commit 91e777b4bbb0de316fd7112c9889163f6f74dc50
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
*/
package io.seata.serializer.kryo;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.Map;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import io.seata.core.exception.TransactionExceptionCode;
import io.seata.core.model.BranchStatus;
import io.seata.core.model.BranchType;
Expand Down Expand Up @@ -82,4 +90,31 @@ public void testBranchCommitResponse() {

}

@Test
public void testKryoBasic() {
Kryo kryo = new Kryo();
kryo.setReferences(true);
kryo.setRegistrationRequired(false);
//kryo.register(HashMap.class);

long beginMills=System.currentTimeMillis();
for (int i = 0; i < 1; i++) {
Map<String, String> map = new HashMap<>();
map.put(String.valueOf(i), "test");

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Output output = new Output(outputStream);
kryo.writeClassAndObject(output, map);
output.close();
byte[] outByte = outputStream.toByteArray();

ByteArrayInputStream inputStream = new ByteArrayInputStream(outByte);
Input input = new Input(inputStream);
input.close();
Map result = (HashMap)kryo.readClassAndObject(input);
assertThat(result).isEqualTo(map);
}
//System.out.println(System.currentTimeMillis()-beginMills);
}

}