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

Fixes #232 Add go struct refer to java.util.UUID #256

Merged
merged 24 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2c6c772
add license checker
Mar 28, 2020
384263a
dd javaProject java8time test code and add go hessian/java8_time strc…
zhangymPerson Jul 4, 2020
bb39912
alter author and error word
zhangymPerson Jul 4, 2020
22adeb6
Merge pull request #3 from zhangymPerson/feature/issue193
willson-chen Jul 6, 2020
93c2a43
Merge remote-tracking branch 'origin/master'
zhangymPerson Jan 23, 2021
24eef7f
Merge branch 'feature/AddLicenseChcker' of https://github.com/willson…
zhangymPerson Jan 23, 2021
2c799ac
Merge branch 'master' of https://github.com/apache/dubbo-go-hessian2
zhangymPerson Jan 23, 2021
9588106
add java.util.UUID encode
zhangymPerson Jan 23, 2021
2558a8d
Revert "reset go.mod after go fmt"
zhangymPerson Jan 27, 2021
c509ac4
add UUID test
zhangymPerson Jan 27, 2021
661738a
alter .travis.yml
zhangymPerson Jan 27, 2021
088ee6c
alter code
zhangymPerson Jan 27, 2021
2bf9f0c
add license
zhangymPerson Jan 27, 2021
7a9bd56
shift count type int, must be unsigned integer
zhangymPerson Jan 31, 2021
b869609
alter file name and delete test file
zhangymPerson Mar 5, 2021
9367cc2
alter file name
zhangymPerson Mar 5, 2021
079fd68
delete file
zhangymPerson Mar 5, 2021
7705871
alter file name
zhangymPerson Mar 5, 2021
fb1378c
alter file name
zhangymPerson Mar 5, 2021
20ec0e1
add uuid struct info and split import block.
zhangymPerson Mar 11, 2021
cab32a4
add java UUID encode and uuid.toString() equals go uuid.ToString() te…
zhangymPerson Mar 12, 2021
06613ee
alter ToString() -> String()
zhangymPerson Mar 12, 2021
3d81e3b
Merge branch 'master' into java.util
wongoo Mar 13, 2021
dae1b38
fix code review
wongoo Mar 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	java8_time.go
#	java8_time/year.go
#	java8_time_test.go
#	test_hessian/src/main/java/test/Hessian.java
#	test_hessian/src/main/java/test/TestJava8Time.java
  • Loading branch information
zhangymPerson committed Jan 23, 2021
commit 93c2a43b6a2df8e2280fcbf69ae067919d51b24d
13 changes: 13 additions & 0 deletions java8_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@ import (

func init() {
RegisterPOJO(&java8_time.Year{Year: 2020})
RegisterPOJO(&java8_time.YearMonth{Month: 2020, Year: 6})
RegisterPOJO(&java8_time.Period{Years: 2020, Months: 6, Days: 6})
RegisterPOJO(&java8_time.LocalDate{Year: 2020, Month: 6, Day: 6})
RegisterPOJO(&java8_time.LocalTime{Hour: 6, Minute: 6, Second: 0, Nano: 0})
RegisterPOJO(&java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}})
RegisterPOJO(&java8_time.MonthDay{Month: 6, Day: 6})
RegisterPOJO(&java8_time.Duration{Second: 0, Nano: 0})
RegisterPOJO(&java8_time.Instant{Seconds: 100, Nanos: 0})
RegisterPOJO(&java8_time.ZoneOffSet{Seconds: 0})
RegisterPOJO(&java8_time.OffsetDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: -64800}})
RegisterPOJO(&java8_time.OffsetTime{LocalTime: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}, ZoneOffset: java8_time.ZoneOffSet{Seconds: -64800}})
RegisterPOJO(&java8_time.ZonedDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: 0}, ZoneId: "Z"})

}
3 changes: 2 additions & 1 deletion java8_time/year.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package java8_time

//java8-time java.time.Year
type Year struct {
Year int32 `hessian:"year"`
}
Expand All @@ -25,5 +26,5 @@ func (Year) JavaClassName() string {
}

func (Year) Error() string {
return "encode year error"
return "encode Year error"
}
30 changes: 15 additions & 15 deletions java8_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ package hessian

import (
"github.com/apache/dubbo-go-hessian2/java8_time"
"github.com/stretchr/testify/assert"
"testing"
)

func TestJava8Time(t *testing.T) {

doTestJava8Time(t, "java8_Year", java8_time.Year{Year: 2020})
doTestTime(t, "java8_Year", &java8_time.Year{Year: 2020})
doTestTime(t, "java8_LocalDate", &java8_time.LocalDate{Year: 2020, Month: 6, Day: 6})
doTestTime(t, "java8_LocalTime", &java8_time.LocalTime{Hour: 6, Minute: 6})
doTestTime(t, "java8_LocalDateTime", &java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}})
doTestTime(t, "java8_MonthDay", &java8_time.MonthDay{Month: 6, Day: 6})
doTestTime(t, "java8_Duration", &java8_time.Duration{Second: 0, Nano: 0})
doTestTime(t, "java8_Instant", &java8_time.Instant{Seconds: 100, Nanos: 0})
doTestTime(t, "java8_YearMonth", &java8_time.YearMonth{Year: 2020, Month: 6})
doTestTime(t, "java8_Period", &java8_time.Period{Years: 2020, Months: 6, Days: 6})
doTestTime(t, "java8_ZoneOffset", &java8_time.ZoneOffSet{Seconds: 0})
doTestTime(t, "java8_OffsetDateTime", &java8_time.OffsetDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: -64800}})
doTestTime(t, "java8_OffsetTime", &java8_time.OffsetTime{LocalTime: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}, ZoneOffset: java8_time.ZoneOffSet{Seconds: -64800}})
doTestTime(t, "java8_ZonedDateTime", &java8_time.ZonedDateTime{DateTime: java8_time.LocalDateTime{Date: java8_time.LocalDate{Year: 2020, Month: 6, Day: 6}, Time: java8_time.LocalTime{Hour: 6, Minute: 6, Second: 6, Nano: 6}}, Offset: java8_time.ZoneOffSet{Seconds: 0}, ZoneId: "Z"})
}

func doTestJava8Time(t *testing.T, method string, pojo POJO) {
e := NewEncoder()
err := e.Encode(pojo)
// go encode
goStr := e.buffer
if err != nil {
panic(err)
}
//java encode
javaStr := getJavaReply(method, "")
assert.Equal(t, goStr, javaStr)

func doTestTime(t *testing.T, method string, expected interface{}) {
testDecodeFramework(t, method, expected)
}
23 changes: 21 additions & 2 deletions test_hessian/src/main/java/test/Hessian.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,34 @@ public static void main(String[] args) throws Exception {
Hessian2Output output = new Hessian2Output(System.out);
output.writeObject(object);
output.flush();
}else if(args[0].startsWith("java8_")){
} else if (args[0].startsWith("java8_")) {
//add java8 java.time Object test
Method method = TestJava8Time.class.getMethod(args[0]);
Object obj = new Object();
Object object =method.invoke(obj);
Object object = method.invoke(obj);

Hessian2Output output = new Hessian2Output(System.out);
output.writeObject(object);
output.flush();
} else if (args[0].startsWith("javaSql_")) {
if (args[0].startsWith("javaSql_encode")) {

Hessian2Input input = new Hessian2Input(System.in);
Object o = input.readObject();

Method method = TestJavaSqlTime.class.getMethod(args[0], Object.class);
TestJavaSqlTime testJavaSqlTime = new TestJavaSqlTime();
System.out.print(method.invoke(testJavaSqlTime, o));
} else {
Method method = TestJavaSqlTime.class.getMethod(args[0]);
TestJavaSqlTime testJavaSqlTime = new TestJavaSqlTime();
Object object = method.invoke(testJavaSqlTime);

Hessian2Output output = new Hessian2Output(System.out);
output.writeObject(object);
output.flush();
}

}
}

Expand Down
32 changes: 20 additions & 12 deletions test_hessian/src/main/java/test/TestJava8Time.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/*
* 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 test;

import java.time.*;

/**
* date 2020/7/2 11:07 <br/>
* description class <br/>
* add java8 package java.time Object method
*
* @author zhangyanmingjiayou@163.com
* @version 1.0
* @since 1.0
*/
public class TestJava8Time {

public static Duration java8_Duration() {
Expand All @@ -26,7 +34,7 @@ public static LocalDate java8_LocalDate() {
}

public static LocalDateTime java8_LocalDateTime() {
return LocalDateTime.of(2020, 6, 6, 6, 6);
return LocalDateTime.of(2020, 6, 6, 6, 6, 6, 6);
}

public static LocalTime java8_LocalTime() {
Expand Down Expand Up @@ -63,11 +71,11 @@ public static ZonedDateTime java8_ZonedDateTime() {
}

public static ZoneId java8_ZoneId() {
return ZoneId.of("1000");
return ZoneId.of("Z");
}

public static ZoneOffset java8_ZoneOffset() {
return ZoneOffset.of("1000");
return ZoneOffset.of("Z");
}

}
You are viewing a condensed version of this merge commit. You can view the full changes here.