Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
8f41fdb1
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f41fdb1
编写于
3月 17, 2020
作者:
Z
Zhou Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改
@test
上级
4c167540
变更
45
隐藏空白更改
内联
并排
Showing
45 changed file
with
1 addition
and
1620 deletion
+1
-1620
o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/Describe.java
...ain/java/com/x/base/core/project/annotation/Describe.java
+0
-6
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CheckCore.java
...rc/main/java/com/x/base/core/project/build/CheckCore.java
+0
-10
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/CreateSample.java
...ain/java/com/x/base/core/project/config/CreateSample.java
+0
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ExtractTextTools.java
.../java/com/x/base/core/project/tools/ExtractTextTools.java
+0
-6
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/JarTools.java
...src/main/java/com/x/base/core/project/tools/JarTools.java
+0
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
.../main/java/com/x/base/core/project/tools/StringTools.java
+0
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/URLTools.java
...src/main/java/com/x/base/core/project/tools/URLTools.java
+0
-1
o2server/x_base_core_project/src/test/java/com/x/base/core/project/gson/TestClient.java
...rc/test/java/com/x/base/core/project/gson/TestClient.java
+0
-37
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/ASCII.java
...ect/src/test/java/com/x/base/core/project/test/ASCII.java
+0
-164
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/CryptoClass.java
...c/test/java/com/x/base/core/project/test/CryptoClass.java
+0
-144
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/CryptoTest.java
...rc/test/java/com/x/base/core/project/test/CryptoTest.java
+0
-58
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/JarTestClient.java
...test/java/com/x/base/core/project/test/JarTestClient.java
+0
-22
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/LockTestClient.java
...est/java/com/x/base/core/project/test/LockTestClient.java
+0
-79
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/LockTestClient2.java
...st/java/com/x/base/core/project/test/LockTestClient2.java
+0
-21
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/OCRTest.java
...t/src/test/java/com/x/base/core/project/test/OCRTest.java
+0
-20
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/RsaTestClient.java
...test/java/com/x/base/core/project/test/RsaTestClient.java
+0
-15
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/T1.java
...roject/src/test/java/com/x/base/core/project/test/T1.java
+0
-27
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/T2.java
...roject/src/test/java/com/x/base/core/project/test/T2.java
+0
-26
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestOver.java
.../src/test/java/com/x/base/core/project/test/TestOver.java
+0
-54
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestXGsonBuilder.java
...t/java/com/x/base/core/project/test/TestXGsonBuilder.java
+0
-21
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/Foo.java
.../src/test/java/com/x/base/core/project/test/gson/Foo.java
+0
-41
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/GsonTools.java
...est/java/com/x/base/core/project/test/gson/GsonTools.java
+0
-86
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/TestClient.java
...st/java/com/x/base/core/project/test/gson/TestClient.java
+0
-24
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/package-info.java
.../java/com/x/base/core/project/test/gson/package-info.java
+0
-1
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/hanlp/TestClient.java
...t/java/com/x/base/core/project/test/hanlp/TestClient.java
+0
-55
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/javapoet/package-info.java
...a/com/x/base/core/project/test/javapoet/package-info.java
+0
-8
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Bar.java
...rc/test/java/com/x/base/core/project/test/lambda/Bar.java
+0
-9
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Book.java
...c/test/java/com/x/base/core/project/test/lambda/Book.java
+0
-40
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Foo.java
...rc/test/java/com/x/base/core/project/test/lambda/Foo.java
+0
-9
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/TestClient.java
.../java/com/x/base/core/project/test/lambda/TestClient.java
+0
-63
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/TestClient2.java
...java/com/x/base/core/project/test/lambda/TestClient2.java
+0
-52
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/list/TestClient.java
...st/java/com/x/base/core/project/test/list/TestClient.java
+0
-39
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/metadata/TestClient.java
...ava/com/x/base/core/project/test/metadata/TestClient.java
+0
-10
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/metadata/package-info.java
...a/com/x/base/core/project/test/metadata/package-info.java
+0
-8
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/poi/TestClient.java
...est/java/com/x/base/core/project/test/poi/TestClient.java
+0
-25
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/socket/TimeClient.java
.../java/com/x/base/core/project/test/socket/TimeClient.java
+0
-30
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/socket/TimeServer.java
.../java/com/x/base/core/project/test/socket/TimeServer.java
+0
-37
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/string/TestClient.java
.../java/com/x/base/core/project/test/string/TestClient.java
+0
-47
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/tika/TestClient.java
...st/java/com/x/base/core/project/test/tika/TestClient.java
+0
-20
o2server/x_base_core_project/src/test/java/test/com/x/base/connection/Foo.java
...project/src/test/java/test/com/x/base/connection/Foo.java
+0
-30
o2server/x_base_core_project/src/test/java/test/com/x/base/connection/TestClient.java
.../src/test/java/test/com/x/base/connection/TestClient.java
+0
-83
o2server/x_base_core_project/src/test/java/test/com/x/base/core/project/HeapDumper.java
...rc/test/java/test/com/x/base/core/project/HeapDumper.java
+0
-66
o2server/x_base_core_project/src/test/java/test/com/x/base/core/project/TestClient.java
...rc/test/java/test/com/x/base/core/project/TestClient.java
+0
-99
o2server/x_base_core_project/src/test/java/text.txt
o2server/x_base_core_project/src/test/java/text.txt
+0
-22
o2server/x_jpush_assemble_control/.gitignore
o2server/x_jpush_assemble_control/.gitignore
+1
-0
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/annotation/Describe.java
浏览文件 @
8f41fdb1
...
...
@@ -37,7 +37,6 @@ import org.apache.commons.lang3.reflect.FieldUtils;
import
org.apache.commons.lang3.reflect.MethodUtils
;
import
org.glassfish.jersey.media.multipart.FormDataContentDisposition
;
import
org.glassfish.jersey.media.multipart.FormDataParam
;
import
org.junit.Test
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.bean.WrapCopier
;
...
...
@@ -757,9 +756,4 @@ public class Describe {
}
@Test
public
void
test1
()
{
Describe
o
=
new
Describe
();
o
.
scan
(
"d:/x/x_processplatform_assemble_surface/describe"
,
"x_processplatform_assemble_surface"
);
}
}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CheckCore.java
浏览文件 @
8f41fdb1
...
...
@@ -17,7 +17,6 @@ import org.apache.commons.lang3.BooleanUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.openjpa.persistence.jdbc.ContainerTable
;
import
org.junit.Test
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.annotation.ContainerEntity
;
...
...
@@ -65,7 +64,6 @@ public class CheckCore {
/*
* 检查数据库字段名是否是ColumnNamePrefix + fieldName
*/
@Test
public
static
void
checkColumnName
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getAllFieldsList
(
cls
);
...
...
@@ -84,7 +82,6 @@ public class CheckCore {
/*
* 检查是否有将Lob类型字段增加索引
*/
@Test
public
static
void
checkLobIndex
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getAllFieldsList
(
cls
);
...
...
@@ -121,7 +118,6 @@ public class CheckCore {
* @CheckPersist(allowEmpty = true, citationExists = @CitationExist(type =
* Person.class)) private List<String> personList;
*/
@Test
public
static
void
checkListFieldContainerTableName
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getAllFieldsList
(
cls
);
...
...
@@ -145,7 +141,6 @@ public class CheckCore {
/*
* 检查是否将@FieldDescribe注解到static字段上,如果是意味着上下行搞错了
*/
@Test
public
static
void
checkFieldDescribeOnStatic
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getFieldsListWithAnnotation
(
cls
,
FieldDescribe
.
class
);
...
...
@@ -161,7 +156,6 @@ public class CheckCore {
/*
* 检查约束名中的table名称和entity类中的TABLE名称是否一致
*/
@Test
public
static
void
checkTableNameUniqueConstraintName
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
Table
table
=
cls
.
getAnnotation
(
Table
.
class
);
...
...
@@ -181,7 +175,6 @@ public class CheckCore {
/*
* 检查类中是否有在createTime,updateTime和sequence上的索引,这几个索引已经用约束在类上了
*/
@Test
public
static
void
checkIdCreateTimeUpdateTimeSequenceIndex
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
Field
idField
=
FieldUtils
.
getField
(
cls
,
JpaObject
.
id_FIELDNAME
,
true
);
...
...
@@ -200,7 +193,6 @@ public class CheckCore {
/*
* 检查entity是否有重复的字段
*/
@Test
public
static
void
checkEnum
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getFieldsListWithAnnotation
(
cls
,
FieldDescribe
.
class
);
...
...
@@ -219,7 +211,6 @@ public class CheckCore {
}
/* 检查是否有对String lob 之外的字段设定长度 */
@Test
public
static
void
checkColumnLength
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
List
<
Field
>
fields
=
FieldUtils
.
getFieldsListWithAnnotation
(
cls
,
Column
.
class
);
...
...
@@ -235,7 +226,6 @@ public class CheckCore {
}
}
@Test
public
static
void
checkIdUnique
(
List
<
Class
<?>>
classes
)
throws
Exception
{
for
(
Class
<?>
cls
:
classes
)
{
Field
idField
=
FieldUtils
.
getField
(
cls
,
JpaObject
.
id_FIELDNAME
,
true
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/CreateSample.java
浏览文件 @
8f41fdb1
...
...
@@ -15,7 +15,6 @@ import org.apache.commons.beanutils.MethodUtils;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.junit.Test
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.entity.StorageProtocol
;
...
...
@@ -31,7 +30,6 @@ public class CreateSample {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CreateSample
.
class
);
@Test
public
void
test
()
throws
Exception
{
List
<
Class
<?>>
classes
=
new
ArrayList
<
Class
<?>>();
classes
.
add
(
AppStyle
.
class
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ExtractTextTools.java
浏览文件 @
8f41fdb1
...
...
@@ -16,7 +16,6 @@ import org.apache.pdfbox.pdfparser.PDFParser;
import
org.apache.pdfbox.pdmodel.PDDocument
;
import
org.apache.pdfbox.text.PDFTextStripper
;
import
org.apache.tika.Tika
;
import
org.junit.Test
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.logger.Logger
;
...
...
@@ -169,9 +168,4 @@ public class ExtractTextTools {
return
tika
;
}
@Test
public
void
test1
()
throws
Exception
{
System
.
out
.
println
(
word
(
FileUtils
.
readFileToByteArray
(
new
File
(
"d:/1.html"
))));
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/JarTools.java
浏览文件 @
8f41fdb1
...
...
@@ -14,9 +14,7 @@ import java.util.jar.JarInputStream;
import
java.util.jar.JarOutputStream
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
public
class
JarTools
{
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
浏览文件 @
8f41fdb1
...
...
@@ -26,7 +26,6 @@ import org.apache.commons.io.IOUtils;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.junit.Test
;
import
org.slf4j.helpers.MessageFormatter
;
public
class
StringTools
{
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/URLTools.java
浏览文件 @
8f41fdb1
package
com.x.base.core.project.tools
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
public
class
URLTools
{
...
...
o2server/x_base_core_project/src/test/java/com/x/base/core/project/gson/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.gson
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.Crypto
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
System
.
out
.
println
(
Crypto
.
encrypt
(
"张学良#"
+
(
new
Date
()).
getTime
(),
"12345678"
));
}
@Test
public
void
test1
()
throws
Exception
{
System
.
out
.
println
(
String
.
class
.
getTypeName
());
}
@Test
public
void
test2
()
throws
Exception
{
List
<
String
>
aaa
=
new
ArrayList
<>();
aaa
.
add
(
"abc"
);
aaa
.
add
(
"efg"
);
aaa
.
add
(
"hij"
);
System
.
out
.
println
(
aaa
);
aaa
.
remove
(
0
);
for
(
String
s
:
aaa
)
{
System
.
out
.
println
(
s
);
}
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/ASCII.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
javax.imageio.ImageIO
;
import
javax.swing.JDialog
;
import
javax.swing.JFileChooser
;
import
javax.swing.JOptionPane
;
import
javax.swing.JScrollPane
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingUtilities
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.StringTools
;
/*Copyright (c) 2011 Aravind Rao
Modifications by Sam Barnum, 360Works 2012
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
public
final
class
ASCII
{
boolean
negative
;
public
ASCII
()
{
this
(
false
);
}
public
ASCII
(
final
boolean
negative
)
{
this
.
negative
=
negative
;
}
public
String
convert
(
final
BufferedImage
image
)
{
StringBuilder
sb
=
new
StringBuilder
((
image
.
getWidth
()
+
1
)
*
image
.
getHeight
());
for
(
int
y
=
0
;
y
<
image
.
getHeight
();
y
++)
{
if
(
sb
.
length
()
!=
0
)
sb
.
append
(
"\n"
);
for
(
int
x
=
0
;
x
<
image
.
getWidth
();
x
++)
{
Color
pixelColor
=
new
Color
(
image
.
getRGB
(
x
,
y
));
double
gValue
=
(
double
)
pixelColor
.
getRed
()
*
0.2989
+
(
double
)
pixelColor
.
getBlue
()
*
0.5870
+
(
double
)
pixelColor
.
getGreen
()
*
0.1140
;
final
char
s
=
negative
?
returnStrNeg
(
gValue
)
:
returnStrPos
(
gValue
);
sb
.
append
(
s
);
}
}
return
sb
.
toString
();
}
/**
* Create a new string and assign to it a string based on the grayscale value.
* If the grayscale value is very high, the pixel is very bright and assign
* characters such as . and , that do not appear very dark. If the grayscale
* value is very lowm the pixel is very dark, assign characters such as # and @
* which appear very dark.
*
* @param g
* grayscale
* @return char
*/
private
char
returnStrPos
(
double
g
)
// takes the grayscale value as parameter
{
final
char
str
;
if
(
g
>=
230.0
)
{
str
=
' '
;
}
else
if
(
g
>=
200.0
)
{
str
=
'.'
;
}
else
if
(
g
>=
180.0
)
{
str
=
'*'
;
}
else
if
(
g
>=
160.0
)
{
str
=
':'
;
}
else
if
(
g
>=
130.0
)
{
str
=
'o'
;
}
else
if
(
g
>=
100.0
)
{
str
=
'&'
;
}
else
if
(
g
>=
70.0
)
{
str
=
'8'
;
}
else
if
(
g
>=
50.0
)
{
str
=
'#'
;
}
else
{
str
=
'@'
;
}
return
str
;
// return the character
}
/**
* Same method as above, except it reverses the darkness of the pixel. A dark
* pixel is given a light character and vice versa.
*
* @param g
* grayscale
* @return char
*/
private
char
returnStrNeg
(
double
g
)
{
final
char
str
;
if
(
g
>=
230.0
)
{
str
=
'@'
;
}
else
if
(
g
>=
200.0
)
{
str
=
'#'
;
}
else
if
(
g
>=
180.0
)
{
str
=
'8'
;
}
else
if
(
g
>=
160.0
)
{
str
=
'&'
;
}
else
if
(
g
>=
130.0
)
{
str
=
'o'
;
}
else
if
(
g
>=
100.0
)
{
str
=
':'
;
}
else
if
(
g
>=
70.0
)
{
str
=
'*'
;
}
else
if
(
g
>=
50.0
)
{
str
=
'.'
;
}
else
{
str
=
' '
;
}
return
str
;
}
public
static
void
main
(
String
[]
args
)
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setFileFilter
(
new
FileNameExtensionFilter
(
"Images"
,
"jpg"
,
"gif"
,
"png"
));
while
(
fileChooser
.
showOpenDialog
(
null
)
==
JFileChooser
.
APPROVE_OPTION
)
{
try
{
File
f
=
fileChooser
.
getSelectedFile
();
final
BufferedImage
image
=
ImageIO
.
read
(
f
);
if
(
image
==
null
)
throw
new
IllegalArgumentException
(
f
+
" is not a valid image."
);
final
String
ascii
=
new
ASCII
().
convert
(
image
);
final
JTextArea
textArea
=
new
JTextArea
(
ascii
,
image
.
getHeight
(),
image
.
getWidth
());
textArea
.
setFont
(
new
Font
(
"Monospaced"
,
Font
.
BOLD
,
5
));
textArea
.
setEditable
(
false
);
final
JDialog
dialog
=
new
JOptionPane
(
new
JScrollPane
(
textArea
),
JOptionPane
.
PLAIN_MESSAGE
)
.
createDialog
(
ASCII
.
class
.
getName
());
dialog
.
setResizable
(
true
);
dialog
.
setVisible
(
true
);
}
catch
(
Exception
e
)
{
JOptionPane
.
showMessageDialog
(
null
,
e
.
toString
(),
"Error"
,
JOptionPane
.
ERROR_MESSAGE
);
}
}
System
.
exit
(
0
);
}
});
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/CryptoClass.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
import
java.security.SecureRandom
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.Date
;
import
javax.crypto.Cipher
;
import
javax.crypto.SecretKey
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.DESKeySpec
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
public
class
CryptoClass
{
private
static
final
String
utf8
=
"UTF-8"
;
private
final
static
String
DES
=
"DES"
;
private
final
static
String
cipher_init
=
"DES"
;
private
final
static
String
RSA
=
"RSA"
;
public
static
String
encrypt
(
String
data
,
String
key
)
throws
Exception
{
byte
[]
bt
=
encrypt
(
data
.
getBytes
(),
key
.
getBytes
());
//String str = Base64.encodeBase64URLSafeString(bt);
String
str
=
Base64
.
encodeBase64URLSafeString
(
bt
);
return
URLEncoder
.
encode
(
str
,
utf8
);
}
public
static
byte
[]
encrypt
(
byte
[]
data
,
byte
[]
key
)
throws
Exception
{
// 生成一个可信任的随机数源
SecureRandom
sr
=
new
SecureRandom
();
// 从原始密钥数据创建DESKeySpec对象
DESKeySpec
dks
=
new
DESKeySpec
(
key
);
// 创建一个密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
DES
);
SecretKey
securekey
=
keyFactory
.
generateSecret
(
dks
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
cipher_init
);
// 用密钥初始化Cipher对象
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
securekey
,
sr
);
return
cipher
.
doFinal
(
data
);
}
public
static
String
decrypt
(
String
data
,
String
key
)
throws
IOException
,
Exception
{
if
(
StringUtils
.
isEmpty
(
data
))
{
return
null
;
}
String
str
=
URLDecoder
.
decode
(
data
,
utf8
);
byte
[]
buf
=
Base64
.
decodeBase64
(
str
);
byte
[]
bt
=
decrypt
(
buf
,
key
.
getBytes
());
return
new
String
(
bt
);
}
public
static
byte
[]
decrypt
(
byte
[]
data
,
byte
[]
key
)
throws
Exception
{
// 生成一个可信任的随机数源
SecureRandom
sr
=
new
SecureRandom
();
// 从原始密钥数据创建DESKeySpec对象
DESKeySpec
dks
=
new
DESKeySpec
(
key
);
// 创建一个密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
DES
);
SecretKey
securekey
=
keyFactory
.
generateSecret
(
dks
);
// Cipher对象实际完成解密操作
Cipher
cipher
=
Cipher
.
getInstance
(
cipher_init
);
// 用密钥初始化Cipher对象
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
securekey
,
sr
);
return
cipher
.
doFinal
(
data
);
}
public
static
PublicKey
rsaPublicKey
(
String
publicKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
publicKey
);
X509EncodedKeySpec
keySpec
=
new
X509EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
RSA
);
return
keyFactory
.
generatePublic
(
keySpec
);
}
public
static
PrivateKey
rsaPrivateKey
(
String
privateKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
privateKey
);
PKCS8EncodedKeySpec
keySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
RSA
);
return
keyFactory
.
generatePrivate
(
keySpec
);
}
public
static
String
rsaEncrypt
(
String
content
,
String
publicKey
)
throws
Exception
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
rsaPublicKey
(
publicKey
));
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
byte
[]
bytes
=
content
.
getBytes
();
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
+=
100
)
{
baos
.
write
(
cipher
.
doFinal
(
ArrayUtils
.
subarray
(
bytes
,
i
,
i
+
100
)));
}
return
Base64
.
encodeBase64URLSafeString
(
baos
.
toByteArray
());
}
}
public
static
String
rsaDecrypt
(
String
content
,
String
privateKey
)
throws
Exception
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
rsaPrivateKey
(
privateKey
));
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
byte
[]
bytes
=
Base64
.
decodeBase64
(
content
);
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
+=
128
)
{
baos
.
write
(
cipher
.
doFinal
(
ArrayUtils
.
subarray
(
bytes
,
i
,
i
+
128
)));
}
return
new
String
(
baos
.
toByteArray
());
}
}
public
static
final
String
TEST_PUBLIC_KEY
=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWcVZIS57VeOUzi8c01WKvwJK9uRe6hrGTUYmF6J/pI6/UvCbdBWCoErbzsBZOElOH8Sqal3vsNMVLjPYClfoDyYDaUlakP3ldfnXJzAFJVVubF53KadG+fwnh9ZMvxdh7VXVqRL3IQBDwGgzX4rmSK+qkUJjc3OkrNJPB7LLD8QIDAQAB"
;
public
static
final
String
TEST_PRIVATE_KEY
=
"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJZxVkhLntV45TOLxzTVYq/Akr25F7qGsZNRiYXon+kjr9S8Jt0FYKgStvOwFk4SU4fxKpqXe+w0xUuM9gKV+gPJgNpSVqQ/eV1+dcnMAUlVW5sXncpp0b5/CeH1ky/F2HtVdWpEvchAEPAaDNfiuZIr6qRQmNzc6Ss0k8HsssPxAgMBAAECgYAWtRy05NUgm5Lc6Og0jVDL/mEnydxPBy2ectwzHh2k7wIHNi8XhUxFki2TMqzrM9Dv3/LySpMl4AE3mhs34LNPy6F+MwyF5X7j+2Y6MflJyeb9HNyT++viysQneoOEiOk3ghxF2/GPjpiEF79wSp+1YKTxRAyq7ypV3t35fGOOEQJBANLDPWl8b5c3lrcz/dTamMjHbVamEyX43yzQOphzkhYsz4pruATzTxU+z8/zPdEqHcWWV39CP3xu3EYNcAhxJW8CQQC2u7PF5Xb1xYRCsmIPssFxil64vvdUadSxl7GLAgjQ9ULyYWB24KObCEzLnPcT8Pf2Q0YQOixxa/78FuzmgbyfAkA7ZFFV/H7lugB6t+f7p24OhkRFep9CwBMD6dnZRBgSr6X8d8ZvfrD2Z7DgBMeSva+OEoOtlNmXExZ3lynO9zN5AkAVczEmIMp3DSl6XtAuAZC9kD2QODJ2QToLYsAfjiyUwsWKCC43piTuVOoW2KUUPSwOR1VZIEsJQWEcHGDQqhgHAkAeZ7a6dVRZFdBwKA0ADjYCufAW2cIYiVDQBJpgB+kiLQflusNOCBK0FT3lg8BdUSy2D253Ih6l3lbaM/4M7DFQ"
;
@Test
public
void
test1
()
throws
Exception
{
System
.
out
.
println
(
decrypt
(
"erG1+eWJCWI="
,
"xplatform"
));
}
@Test
public
void
test2
()
throws
Exception
{
Long
l
=
(
new
Date
()).
getTime
();
System
.
out
.
println
(
encrypt
(
"13336173316#"
+
l
,
"12345678"
));
}
@Test
public
void
testrsa
()
throws
Exception
{
File
s
=
new
File
(
"e:/1.war"
);
byte
[]
ss
=
FileUtils
.
readFileToByteArray
(
s
);
String
value
=
rsaEncrypt
(
Base64
.
encodeBase64String
(
ss
),
TEST_PUBLIC_KEY
);
byte
[]
ds
=
Base64
.
decodeBase64
(
rsaDecrypt
(
value
,
TEST_PRIVATE_KEY
));
FileUtils
.
writeByteArrayToFile
(
new
File
(
"e:/2.war"
),
ds
);
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/CryptoTest.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.util.Random
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.SecretKeySpec
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.ClassUtils
;
import
org.junit.Test
;
public
class
CryptoTest
{
@Test
public
void
test
()
throws
Exception
{
System
.
out
.
println
(
CryptoClass
.
encrypt
(
"password"
,
"12345678"
));
}
public
static
void
main
(
String
[]
args
)
{
String
javaType
=
"List<WorkStatus>"
;
String
className
=
javaType
.
substring
(
javaType
.
indexOf
(
"<"
)+
1
,
javaType
.
indexOf
(
">"
));
System
.
out
.
println
(
className
);
Class
clazz
=
null
;
try
{
//clazz = Class.forName(className);
Class
<?>
ss
=
ClassUtils
.
getClass
(
className
);
System
.
out
.
println
(
ss
);
}
catch
(
ClassNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
System
.
out
.
println
(
clazz
);
}
@Test
public
void
test1
()
throws
Exception
{
System
.
out
.
println
(
CryptoClass
.
decrypt
(
"imXg6AUytfr+uVm31GQvyw=="
,
"12345678"
));
}
// 加密
public
static
String
EncryptTest
(
String
sSrc
,
String
sKey
)
throws
Exception
{
if
(
sKey
==
null
)
{
System
.
out
.
print
(
"Key为空null"
);
return
null
;
}
// // 判断Key是否为16位
// if (sKey.length() != 16) {
// System.out.print("Key长度不是16位");
// return null;
// }
byte
[]
raw
=
sKey
.
getBytes
(
"utf-8"
);
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/ECB/PKCS5Padding"
);
// "算法/模式/补码方式"
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
);
byte
[]
encrypted
=
cipher
.
doFinal
(
sSrc
.
getBytes
(
"utf-8"
));
return
Base64
.
encodeBase64URLSafeString
(
encrypted
);
// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/JarTestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.JarTools
;
public
class
JarTestClient
{
@Test
public
void
test
()
throws
Exception
{
List
<
File
>
files
=
new
ArrayList
<>();
files
.
add
(
new
File
(
"d:/aaa"
));
files
.
add
(
new
File
(
"e:/bbb"
));
FileUtils
.
writeByteArrayToFile
(
new
File
(
"e:/11.zip"
),
JarTools
.
jar
(
files
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/LockTestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
org.junit.Test
;
public
class
LockTestClient
{
@Test
public
void
test1
()
throws
Exception
{
Object
lock
=
new
Object
();
Thread
thread1
=
new
Thread
()
{
@Override
public
void
run
()
{
synchronized
(
lock
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
System
.
out
.
println
(
"我是T1线程,我准备等待被其他人唤醒."
);
try
{
lock
.
wait
();
System
.
out
.
println
(
"我是T1线程,我被人唤醒了."
);
Thread
.
sleep
(
1000
);
System
.
out
.
println
(
"我是T1线程,我干了1秒钟的活,后面我就调用了notifyAll()."
);
lock
.
notifyAll
();
System
.
out
.
println
(
"我是T1线程,我已经调用了notifyAll()."
);
Thread
.
sleep
(
1000
);
System
.
out
.
println
(
"我是T1线程,我"
+
i
+
"次循环完成了."
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
}
};
Thread
thread2
=
new
Thread
()
{
@Override
public
void
run
()
{
synchronized
(
lock
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
System
.
out
.
println
(
"我是T2线程,我准备等待被其他人唤醒."
);
try
{
lock
.
wait
();
System
.
out
.
println
(
"我是T2线程,我被人唤醒了."
);
Thread
.
sleep
(
1000
);
System
.
out
.
println
(
"我是T2线程,我干了1秒钟的活,后面我就调用了notifyAll()."
);
lock
.
notifyAll
();
System
.
out
.
println
(
"我是T2线程,我已经调用了notifyAll()."
);
Thread
.
sleep
(
1000
);
System
.
out
.
println
(
"我是T2线程,我"
+
i
+
"次循环完成了."
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
}
};
Thread
thread3
=
new
Thread
()
{
@Override
public
void
run
()
{
synchronized
(
lock
)
{
System
.
out
.
println
(
"我是T3线程,我唤醒了别人."
);
lock
.
notifyAll
();
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"唤醒后我就完成了."
);
}
}
};
thread1
.
start
();
thread2
.
start
();
Thread
.
sleep
(
1000L
);
thread3
.
start
();
Thread
.
sleep
(
30000L
);
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/LockTestClient2.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
org.junit.Test
;
public
class
LockTestClient2
{
@Test
public
void
test1
()
throws
Exception
{
Object
lock
=
new
Object
();
Thread
thread1
=
new
Thread
(
new
T1
(
lock
));
Thread
thread2
=
new
Thread
(
new
T2
(
lock
));
thread1
.
start
();
Thread
.
sleep
(
3000L
);
thread2
.
start
();
Thread
.
sleep
(
30000L
);
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/OCRTest.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.io.File
;
import
org.junit.Test
;
public
class
OCRTest
{
@Test
public
void
test
()
throws
Exception
{
File
imageFile
=
new
File
(
"d:/download.png"
);
// Tesseract instance = Tesseract.getInstance();
// instance.setDatapath("D:\\Coding\\Tess4J\\tessdata");// 设置训练库的位置
// instance.setLanguage("chi_sim");// 中文识别
// String result = instance.doOCR(imageFile);
// System.out.println(result);
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/RsaTestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.Crypto
;
public
class
RsaTestClient
{
@Test
public
void
test1
()
throws
Exception
{
String
aaa
=
"s3ZeJFvJVi5IHlMweNyqBOGxuGvuDBzV"
;
System
.
out
.
println
(
Crypto
.
decrypt
(
aaa
,
"thisistheway"
));
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/T1.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
public
class
T1
implements
Runnable
{
private
Object
lock
;
public
T1
(
Object
object
)
{
this
.
lock
=
object
;
}
@Override
public
void
run
()
{
synchronized
(
lock
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
System
.
out
.
println
(
"我是T1线程,我准备等待被其他人唤醒."
);
try
{
lock
.
notifyAll
();
lock
.
wait
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"我是T1线程,我被人唤醒了."
);
}
}
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/T2.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
public
class
T2
implements
Runnable
{
private
Object
lock
;
public
T2
(
Object
object
)
{
this
.
lock
=
object
;
}
@Override
public
void
run
()
{
synchronized
(
lock
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
System
.
out
.
println
(
"我是T2线程,我准备等待被其他人唤醒."
);
try
{
lock
.
notifyAll
();
lock
.
wait
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"我是T2线程,我被人唤醒了."
);
}
}
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestOver.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
public
class
TestOver
{
public
void
exe
(
Integer
i
)
{
System
.
out
.
println
(
"exe integer:"
+
i
);
}
public
void
exe
(
Number
n
)
{
System
.
out
.
println
(
"exe number:"
+
n
);
}
public
void
exe
(
Double
d
)
{
System
.
out
.
println
(
"exe double:"
+
d
);
}
@Test
public
void
test2
()
{
String
str
=
"aaa{},bbb{},ccc."
;
System
.
out
.
println
(
StringUtils
.
replaceEachRepeatedly
(
str
,
new
String
[]
{
"{}"
},
new
String
[]
{
"111"
}));
}
@Test
public
void
test1
()
{
System
.
out
.
println
(
com
.
x
.
base
.
core
.
entity
.
JpaObject
.
createId
());
}
@Test
public
void
test3
()
{
String
str
=
"com.x.processplatform.core.entity.log.Work"
;
String
aaa
=
"com.x.processplatform.core.entity.*"
;
System
.
out
.
println
(
StringUtils
.
substringBeforeLast
(
aaa
,
"*"
));
System
.
out
.
println
(
StringUtils
.
startsWith
(
str
,
StringUtils
.
substringBeforeLast
(
aaa
,
"*"
)));
}
@Test
public
void
test4
()
{
Pattern
test
=
Pattern
.
compile
(
"^(\\S+)\\@(\\S+)\\@P$"
);
String
str
=
"杭州111@1124@P"
;
Matcher
matcher
=
test
.
matcher
(
str
);
if
(
matcher
.
find
())
{
System
.
out
.
println
(
matcher
.
group
(
0
));
System
.
out
.
println
(
matcher
.
group
(
1
));
System
.
out
.
println
(
matcher
.
group
(
2
));
}
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/TestXGsonBuilder.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test
;
import
org.junit.Test
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.gson.XGsonBuilder
;
public
class
TestXGsonBuilder
{
@Test
public
void
test
()
throws
Exception
{
String
str
=
"{\"city\": {\"name\":\"杭州\",\"address\":\"wenerlu\"},\"name\":\"字典\"}"
;
JsonElement
json
=
XGsonBuilder
.
instance
().
fromJson
(
str
,
JsonElement
.
class
);
System
.
out
.
println
(
json
);
System
.
out
.
println
(
XGsonBuilder
.
extractString
(
json
,
"name"
));
System
.
out
.
println
(
XGsonBuilder
.
extractString
(
json
,
"city.name"
));
System
.
out
.
println
(
XGsonBuilder
.
extractString
(
json
,
"city.we"
));
System
.
out
.
println
(
XGsonBuilder
.
extractString
(
json
,
"city.name.name"
));
System
.
out
.
println
(
XGsonBuilder
.
extractString
(
json
,
"city"
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/Foo.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.gson
;
import
java.lang.reflect.InvocationTargetException
;
import
org.apache.commons.beanutils.PropertyUtils
;
import
org.junit.Test
;
import
com.google.gson.annotations.SerializedName
;
public
class
Foo
{
@SerializedName
(
"bbb"
)
public
String
getBbb
()
{
return
bbb
+
"ttt"
;
}
public
String
aaa
=
"aaa"
;
private
String
bbb
=
"bbb"
;
public
String
getAaa
()
{
return
aaa
;
}
public
void
setAaa
(
String
aaa
)
{
this
.
aaa
=
aaa
;
}
public
void
setBbb
(
String
bbb
)
{
this
.
bbb
=
bbb
;
}
@Test
public
void
test
()
throws
IllegalAccessException
,
InvocationTargetException
,
NoSuchMethodException
{
Foo
foo
=
new
Foo
();
System
.
out
.
println
(
PropertyUtils
.
isReadable
(
foo
,
"aaaaa"
));
//System.out.println(PropertyUtils.getProperty(foo, "aaaaa"));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/GsonTools.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.gson
;
import
java.lang.reflect.InvocationTargetException
;
import
org.apache.commons.beanutils.PropertyUtils
;
import
org.junit.Test
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
java.util.Map
;
public
class
GsonTools
{
public
static
enum
ConflictStrategy
{
THROW_EXCEPTION
,
PREFER_FIRST_OBJ
,
PREFER_SECOND_OBJ
,
PREFER_NON_NULL
;
}
public
static
class
JsonObjectExtensionConflictException
extends
Exception
{
public
JsonObjectExtensionConflictException
(
String
message
)
{
super
(
message
);
}
}
public
static
void
extendJsonObject
(
JsonObject
destinationObject
,
ConflictStrategy
conflictResolutionStrategy
,
JsonObject
...
objs
)
throws
JsonObjectExtensionConflictException
{
for
(
JsonObject
obj
:
objs
)
{
extendJsonObject
(
destinationObject
,
obj
,
conflictResolutionStrategy
);
}
}
private
static
void
extendJsonObject
(
JsonObject
leftObj
,
JsonObject
rightObj
,
ConflictStrategy
conflictStrategy
)
throws
JsonObjectExtensionConflictException
{
for
(
Map
.
Entry
<
String
,
JsonElement
>
rightEntry
:
rightObj
.
entrySet
())
{
String
rightKey
=
rightEntry
.
getKey
();
JsonElement
rightVal
=
rightEntry
.
getValue
();
if
(
leftObj
.
has
(
rightKey
))
{
//conflict
JsonElement
leftVal
=
leftObj
.
get
(
rightKey
);
if
(
leftVal
.
isJsonArray
()
&&
rightVal
.
isJsonArray
())
{
JsonArray
leftArr
=
leftVal
.
getAsJsonArray
();
JsonArray
rightArr
=
rightVal
.
getAsJsonArray
();
//concat the arrays -- there cannot be a conflict in an array, it's just a collection of stuff
for
(
int
i
=
0
;
i
<
rightArr
.
size
();
i
++)
{
leftArr
.
add
(
rightArr
.
get
(
i
));
}
}
else
if
(
leftVal
.
isJsonObject
()
&&
rightVal
.
isJsonObject
())
{
//recursive merging
extendJsonObject
(
leftVal
.
getAsJsonObject
(),
rightVal
.
getAsJsonObject
(),
conflictStrategy
);
}
else
{
//not both arrays or objects, normal merge with conflict resolution
handleMergeConflict
(
rightKey
,
leftObj
,
leftVal
,
rightVal
,
conflictStrategy
);
}
}
else
{
//no conflict, add to the object
leftObj
.
add
(
rightKey
,
rightVal
);
}
}
}
private
static
void
handleMergeConflict
(
String
key
,
JsonObject
leftObj
,
JsonElement
leftVal
,
JsonElement
rightVal
,
ConflictStrategy
conflictStrategy
)
throws
JsonObjectExtensionConflictException
{
{
switch
(
conflictStrategy
)
{
case
PREFER_FIRST_OBJ:
break
;
//do nothing, the right val gets thrown out
case
PREFER_SECOND_OBJ:
leftObj
.
add
(
key
,
rightVal
);
//right side auto-wins, replace left val with its val
break
;
case
PREFER_NON_NULL:
//check if right side is not null, and left side is null, in which case we use the right val
if
(
leftVal
.
isJsonNull
()
&&
!
rightVal
.
isJsonNull
())
{
leftObj
.
add
(
key
,
rightVal
);
}
//else do nothing since either the left value is non-null or the right value is null
break
;
case
THROW_EXCEPTION:
throw
new
JsonObjectExtensionConflictException
(
"Key "
+
key
+
" exists in both objects and the conflict resolution strategy is "
+
conflictStrategy
);
default
:
throw
new
UnsupportedOperationException
(
"The conflict strategy "
+
conflictStrategy
+
" is unknown and cannot be processed"
);
}
}
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.gson
;
import
java.util.Date
;
import
org.junit.Test
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.gson.XGsonBuilder
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
String
aaa
=
"{'aaa':'bbbddd','a1':['11','22','33'],'a2':['a','b','c'],'c':{'1':'11','2':'22','3':'33'}}"
;
String
bbb
=
"{'aaa':'bbb','a2':['a','b','e','f'],'c':{'4':'44','5':'55'}}"
;
JsonElement
a
=
XGsonBuilder
.
instance
().
fromJson
(
aaa
,
JsonElement
.
class
);
JsonElement
b
=
XGsonBuilder
.
instance
().
fromJson
(
bbb
,
JsonElement
.
class
);
System
.
out
.
println
(
XGsonBuilder
.
merge
(
a
,
b
));
}
@Test
public
void
test1
()
throws
Exception
{
Date
date
=
new
Date
();
System
.
out
.
println
(
date
.
getTime
());
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/gson/package-info.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.gson
;
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/hanlp/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.hanlp
;
import
java.io.File
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.junit.Test
;
import
com.hankcs.hanlp.HanLP
;
import
com.x.base.core.project.tools.DefaultCharset
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
String
value
=
FileUtils
.
readFileToString
(
new
File
(
"d:/aaa.txt"
),
DefaultCharset
.
charset_utf_8
);
List
<
String
>
list
=
HanLP
.
extractSummary
(
value
,
10
);
System
.
out
.
println
(
list
);
}
// @Test
// public void test1() throws Exception {
// String value = FileUtils.readFileToString(new File("d:/aaa.txt"), DefaultCharset.charset_utf_8);
// String str = HanLP.extractKeyword(document, size)(value, 10);
// System.out.println(str);
// }
@Test
public
void
test2
()
throws
Exception
{
String
value
=
FileUtils
.
readFileToString
(
new
File
(
"d:/aaa.txt"
),
DefaultCharset
.
charset_utf_8
);
List
<
String
>
list
=
HanLP
.
extractKeyword
(
value
,
10
);
System
.
out
.
println
(
list
);
}
@Test
public
void
test3
()
throws
Exception
{
String
value
=
FileUtils
.
readFileToString
(
new
File
(
"d:/aaa.txt"
),
DefaultCharset
.
charset_utf_8
);
List
<
String
>
list
=
HanLP
.
extractPhrase
(
value
,
10
);
System
.
out
.
println
(
list
);
}
@Test
public
void
test4
()
throws
Exception
{
String
value
=
FileUtils
.
readFileToString
(
new
File
(
"d:/aaa.txt"
),
DefaultCharset
.
charset_utf_8
);
List
<
String
>
list
=
HanLP
.
extractSummary
(
value
,
10
);
System
.
out
.
println
(
list
);
}
@Test
public
void
test5
()
throws
Exception
{
String
value
=
FileUtils
.
readFileToString
(
new
File
(
"d:/aaa.txt"
),
DefaultCharset
.
charset_utf_8
);
System
.
out
.
println
(
HanLP
.
getSummary
(
value
,
10
,
" "
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/javapoet/package-info.java
已删除
100644 → 0
浏览文件 @
4c167540
/**
*
*/
/**
* @author zhour
*
*/
package
com.x.base.core.project.test.javapoet
;
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Bar.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.lambda
;
public
class
Bar
{
public
String
get
()
{
return
"bar"
;
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Book.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.lambda
;
import
org.junit.Test
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
public
class
Book
extends
GsonPropertyObject
{
public
Book
(
String
name
,
Integer
sn
)
{
this
.
name
=
name
;
this
.
sn
=
sn
;
}
private
String
name
;
private
Integer
sn
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getSn
()
{
return
sn
;
}
public
void
setSn
(
Integer
sn
)
{
this
.
sn
=
sn
;
}
@Test
public
void
test
()
{
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/Foo.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.lambda
;
public
class
Foo
{
public
String
get
()
{
return
"foo"
;
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.lambda
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.IntStream
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
public
class
TestClient
{
@Test
public
void
test3
()
{
Map
<
String
,
List
<
Book
>>
map
=
new
ConcurrentHashMap
<>();
List
<
Book
>
list
=
new
ArrayList
<>();
IntStream
.
rangeClosed
(
1
,
100
).
forEach
(
i
->
{
IntStream
.
rangeClosed
(
1
,
100
).
forEach
(
j
->
{
int
x
=
(
i
+
j
);
Book
book
=
new
Book
(
x
+
""
,
x
);
list
.
add
(
book
);
});
});
list
.
parallelStream
().
peek
(
b
->
{
List
<
Book
>
bs
=
map
.
get
(
b
.
getName
());
if
(
null
==
bs
)
{
bs
=
new
CopyOnWriteArrayList
<
Book
>();
map
.
put
(
b
.
getName
(),
bs
);
}
bs
.
add
(
b
);
}).
anyMatch
(
b
->
false
);
map
.
entrySet
().
stream
().
peek
(
e
->
{
System
.
out
.
println
(
e
.
getKey
()
+
":"
+
e
.
getValue
().
size
());
}).
anyMatch
(
b
->
false
);
System
.
out
.
println
(
map
.
values
().
stream
().
mapToInt
(
List:
:
size
).
sum
());
}
@Test
public
void
test4
()
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"aaa"
);
list
.
add
(
"bbb"
);
list
.
add
(
"ccc"
);
list
.
add
(
"ddd"
);
list
.
add
(
"eee"
);
Optional
<
String
>
obj
=
list
.
stream
().
filter
(
o
->
{
return
StringUtils
.
equals
(
o
,
"ddd11"
);
}).
findFirst
();
System
.
out
.
println
(
obj
.
orElse
(
null
));
}
@Test
public
void
test
()
{
List
<
String
>
list
=
new
ArrayList
<>();
System
.
out
.
println
(
"allMatch:"
+
list
.
stream
().
allMatch
(
o
->
StringUtils
.
length
(
o
)
>
1
));
System
.
out
.
println
(
"noneMatch:"
+
list
.
stream
().
noneMatch
(
o
->
StringUtils
.
length
(
o
)
>
1
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/lambda/TestClient2.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.lambda
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentSkipListMap
;
import
org.junit.Test
;
import
com.x.base.core.project.gson.XGsonBuilder
;
public
class
TestClient2
{
@Test
public
void
test1
()
{
HashMap
<
String
,
Integer
>
hash
=
new
HashMap
<>();
ConcurrentSkipListMap
<
String
,
Integer
>
map
=
new
ConcurrentSkipListMap
<>();
hash
.
put
(
"AAA"
,
9
);
hash
.
put
(
"DDD"
,
8
);
hash
.
put
(
"BBB"
,
7
);
hash
.
put
(
"CCC"
,
6
);
hash
.
entrySet
().
stream
().
sorted
((
o1
,
o2
)
->
{
return
o1
.
getValue
()
-
o2
.
getValue
();
}).
forEachOrdered
(
o
->
{
System
.
out
.
println
(
"key:"
+
o
.
getKey
());
map
.
put
(
o
.
getKey
(),
o
.
getValue
());
});
System
.
out
.
println
(
XGsonBuilder
.
toJson
(
map
));
List
<
String
>
list
=
Collections
.
synchronizedList
(
new
ArrayList
<
String
>());
list
.
add
(
"aaa"
);
list
.
add
(
"ccc"
);
list
.
add
(
"bbb"
);
Iterator
<
String
>
i
=
list
.
iterator
();
// Must be in synchronized block
while
(
i
.
hasNext
())
{
System
.
out
.
println
(
i
.
next
());
}
}
@Test
public
void
test2
()
{
List
<
String
>
aa
=
new
ArrayList
<>();
System
.
out
.
println
(
aa
.
stream
().
findFirst
().
orElse
(
null
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/list/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.list
;
import
java.util.TreeMap
;
import
org.junit.Test
;
public
class
TestClient
{
@Test
public
void
test
()
{
String
a1
=
"1"
;
String
a3
=
"3"
;
String
a5
=
"5"
;
String
a7
=
"7"
;
TreeMap
<
Integer
,
String
>
tree
=
new
TreeMap
<>();
int
cursor
=
0
;
cursor
=
cursor
+
Integer
.
parseInt
(
a1
);
tree
.
put
(
cursor
,
a1
);
cursor
=
cursor
+
Integer
.
parseInt
(
a3
);
tree
.
put
(
cursor
,
a3
);
cursor
=
cursor
+
Integer
.
parseInt
(
a5
);
tree
.
put
(
cursor
,
a5
);
cursor
=
cursor
+
Integer
.
parseInt
(
a7
);
tree
.
put
(
cursor
,
a7
);
System
.
out
.
println
(
tree
.
tailMap
(
1
,
true
).
firstEntry
().
getValue
());
}
@Test
public
void
test1
()
{
Integer
a
=
1
;
Integer
b
=
2
;
System
.
out
.
println
(
a
.
compareTo
(
b
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/metadata/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.metadata
;
import
org.apache.openjpa.ant.MetaDataToolTask
;
import
org.junit.Test
;
public
class
TestClient
{
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/metadata/package-info.java
已删除
100644 → 0
浏览文件 @
4c167540
/**
*
*/
/**
* @author zhour
*
*/
package
com.x.base.core.project.test.metadata
;
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/poi/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.poi
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.junit.Test
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
byte
[]
bs
=
FileUtils
.
readFileToByteArray
(
new
File
(
"e:/1.html"
));
try
(
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
bs
);
FileOutputStream
fos
=
new
FileOutputStream
(
"e:/1.docx"
))
{
XWPFDocument
docx
=
new
XWPFDocument
(
bais
);
docx
.
write
(
fos
);
}
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/socket/TimeClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.socket
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.net.Socket
;
/**
* This program demonstrates a simple TCP/IP socket client.
*
* @author www.codejava.net
*/
public
class
TimeClient
{
public
static
void
main
(
String
[]
args
)
{
try
(
Socket
socket
=
new
Socket
(
"127.0.0.1"
,
10000
))
{
DataOutputStream
output
=
new
DataOutputStream
(
socket
.
getOutputStream
());
output
.
writeUTF
(
"aaaaa"
);
DataInputStream
input
=
new
DataInputStream
(
socket
.
getInputStream
());
String
time
=
input
.
readUTF
();
System
.
out
.
println
(
time
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/socket/TimeServer.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.socket
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
/**
* This program demonstrates a simple TCP/IP socket server.
*
* @author www.codejava.net
*/
public
class
TimeServer
{
public
static
void
main
(
String
[]
args
)
{
try
(
ServerSocket
serverSocket
=
new
ServerSocket
(
10000
))
{
System
.
out
.
println
(
"Server is listening on port "
+
10000
);
while
(
true
)
{
Socket
socket
=
serverSocket
.
accept
();
socket
.
setKeepAlive
(
true
);
DataInputStream
input
=
new
DataInputStream
(
socket
.
getInputStream
());
System
.
out
.
println
(
input
.
readUTF
());
DataOutputStream
output
=
new
DataOutputStream
(
socket
.
getOutputStream
());
output
.
writeUTF
(
"aaaaabbbbdd"
);
}
}
catch
(
IOException
ex
)
{
System
.
out
.
println
(
"Server exception: "
+
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/string/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.string
;
import
java.util.zip.CRC32
;
import
org.apache.commons.text.StringEscapeUtils
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.StringTools
;
import
junit.framework.Assert
;
public
class
TestClient
{
@Test
public
void
test
()
{
CRC32
c
=
new
CRC32
();
c
.
update
(
""
.
getBytes
());
System
.
out
.
println
(
c
.
getValue
());
}
@Test
public
void
test4
()
{
String
aaa
=
"(var v \\u003d person.getMobile();\\u000a return v.su\\nbstring(v.length - 6);)"
;
System
.
out
.
println
(
aaa
);
System
.
out
.
println
(
StringEscapeUtils
.
unescapeJson
(
aaa
));
}
@Test
public
void
test1
()
{
System
.
out
.
println
(
StringTools
.
matchWildcard
(
null
,
null
));
System
.
out
.
println
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"*ELLO*"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
""
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
""
,
"HELLO WORLD"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"ELLO"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"HELLO"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"*HELLO"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"HELLO WORLD2"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"HELLO WORL"
));
Assert
.
assertFalse
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"hello world"
));
Assert
.
assertTrue
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"*ELLO*"
));
Assert
.
assertTrue
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"HELLO*"
));
Assert
.
assertTrue
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"*LLO*"
));
Assert
.
assertTrue
(
StringTools
.
matchWildcard
(
"HELLO WORLD"
,
"HELLO WORLD"
));
}
}
o2server/x_base_core_project/src/test/java/com/x/base/core/project/test/tika/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
com.x.base.core.project.test.tika
;
import
java.io.File
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.tika.Tika
;
import
org.junit.Test
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
Tika
tika
=
new
Tika
();
byte
[]
bs
=
FileUtils
.
readFileToByteArray
(
new
File
(
"e:/93ccd8d6-e699-4a82-a0b8-c4bd17e63dd8.doc"
));
System
.
out
.
println
(
"!!!dd@@@!w!!!!!!1!! 1!!!!!!!!!!1!!!!"
);
System
.
out
.
println
(
tika
.
detect
(
bs
));
System
.
out
.
println
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
}
}
o2server/x_base_core_project/src/test/java/test/com/x/base/connection/Foo.java
已删除
100644 → 0
浏览文件 @
4c167540
package
test.com.x.base.connection
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.x.base.core.project.tools.ListTools
;
public
class
Foo
{
private
List
<
String
>
list
=
new
ArrayList
<>(
ListTools
.
toList
(
"a"
,
"b"
,
"c"
,
"d"
));
private
String
str
=
"s"
;
public
List
<
String
>
getList
()
{
return
list
;
}
public
void
setList
(
List
<
String
>
list
)
{
this
.
list
=
list
;
}
public
String
getStr
()
{
return
str
;
}
public
void
setStr
(
String
str
)
{
this
.
str
=
str
;
}
}
o2server/x_base_core_project/src/test/java/test/com/x/base/connection/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
test.com.x.base.connection
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.junit.Test
;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.connection.HttpConnection
;
import
com.x.base.core.project.http.HttpToken
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.base.core.project.tools.ListTools
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
String
url
=
"http://dev.o2oa.io:20020/x_organization_assemble_authentication/jaxrs/authentication"
;
List
<
NameValuePair
>
heads
=
new
ArrayList
<>();
heads
.
add
(
new
NameValuePair
(
HttpToken
.
X_Token
,
"TGzu9RzlNSKiKmp0wVDcEedUKdS6M0BL46GBeK0mokkCyEgxqBLr4w"
));
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
Date
date
=
new
Date
();
ActionResponse
response
=
ConnectionAction
.
get
(
url
,
heads
);
long
time
=
new
Date
().
getTime
()
-
date
.
getTime
();
if
(
time
>
20000
)
{
System
.
out
.
println
(
i
+
":"
+
DateTools
.
format
(
date
)
+
"elapsed:"
+
time
);
}
}
}
@Test
public
void
testLocal
()
throws
Exception
{
String
url
=
"http://127.0.0.1:20020/x_organization_assemble_authentication/jaxrs/authentication"
;
List
<
NameValuePair
>
heads
=
new
ArrayList
<>();
heads
.
add
(
new
NameValuePair
(
HttpToken
.
X_Token
,
"_As7di3gCwTimjjL55fuZZXmus9kE3XwlL04Q5jXX4nsmj2nSOtafg"
));
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
Date
date
=
new
Date
();
ActionResponse
response
=
ConnectionAction
.
get
(
url
,
heads
);
long
time
=
new
Date
().
getTime
()
-
date
.
getTime
();
if
(
time
>
20000
)
{
System
.
out
.
println
(
i
+
":"
+
DateTools
.
format
(
date
)
+
"elapsed:"
+
time
);
}
}
}
@Test
public
void
test1
()
throws
Exception
{
String
url
=
"http://127.0.0.1:8080/examples/jsp/test.jsp"
;
List
<
com
.
x
.
base
.
core
.
project
.
bean
.
NameValuePair
>
heads
=
new
ArrayList
<>();
com
.
x
.
base
.
core
.
project
.
bean
.
NameValuePair
pair
=
new
NameValuePair
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
heads
.
add
(
pair
);
String
aaa
=
HttpConnection
.
postAsString
(
url
,
heads
,
"op=2&data=444"
);
System
.
out
.
println
(
aaa
);
}
@Test
public
void
test2
()
throws
Exception
{
String
servercode
=
"qhI8uDxo"
;
String
serverpwd
=
"zRY3juPG"
;
String
srcnum
=
"3139"
;
String
desttype
=
"0"
;
String
dest
=
"18958143015"
;
String
message
=
"abc test你好"
;
String
time
=
com
.
x
.
base
.
core
.
project
.
tools
.
DateTools
.
format
(
new
Date
(),
com
.
x
.
base
.
core
.
project
.
tools
.
DateTools
.
formatCompact_yyyyMMddHHmmss
);
String
sign
=
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
.
md5Hex
(
servercode
+
serverpwd
+
time
);
String
url
=
"http://115.29.3.87/servlet/smsapi?method=send"
;
java
.
util
.
List
<
com
.
x
.
base
.
core
.
project
.
bean
.
NameValuePair
>
heads
=
new
java
.
util
.
ArrayList
<>();
heads
.
add
(
new
com
.
x
.
base
.
core
.
project
.
bean
.
NameValuePair
(
"Content-Type"
,
"application/x-www-form-urlencoded"
));
String
value
=
"servercode="
+
servercode
+
"&time="
+
time
+
"&sign="
+
sign
+
"&srcnum="
+
srcnum
+
"&desttype="
+
desttype
+
"&dest="
+
dest
+
"&message="
+
message
;
com
.
x
.
base
.
core
.
project
.
connection
.
HttpConnection
.
postAsString
(
url
,
heads
,
value
);
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/test/com/x/base/core/project/HeapDumper.java
已删除
100644 → 0
浏览文件 @
4c167540
package
test.com.x.base.core.project
;
import
javax.management.MBeanServer
;
import
java.lang.management.ManagementFactory
;
import
com.sun.management.HotSpotDiagnosticMXBean
;
public
class
HeapDumper
{
// This is the name of the HotSpot Diagnostic MBean
private
static
final
String
HOTSPOT_BEAN_NAME
=
"com.sun.management:type=HotSpotDiagnostic"
;
// field to store the hotspot diagnostic MBean
private
static
volatile
HotSpotDiagnosticMXBean
hotspotMBean
;
static
void
dumpHeap
(
String
fileName
,
boolean
live
)
{
// initialize hotspot diagnostic MBean
initHotspotMBean
();
try
{
hotspotMBean
.
dumpHeap
(
fileName
,
live
);
}
catch
(
RuntimeException
re
)
{
throw
re
;
}
catch
(
Exception
exp
)
{
throw
new
RuntimeException
(
exp
);
}
}
// initialize the hotspot diagnostic MBean field
private
static
void
initHotspotMBean
()
{
if
(
hotspotMBean
==
null
)
{
synchronized
(
HeapDumper
.
class
)
{
if
(
hotspotMBean
==
null
)
{
hotspotMBean
=
getHotspotMBean
();
}
}
}
}
// get the hotspot diagnostic MBean from the
// platform MBean server
private
static
HotSpotDiagnosticMXBean
getHotspotMBean
()
{
try
{
MBeanServer
server
=
ManagementFactory
.
getPlatformMBeanServer
();
HotSpotDiagnosticMXBean
bean
=
ManagementFactory
.
newPlatformMXBeanProxy
(
server
,
HOTSPOT_BEAN_NAME
,
HotSpotDiagnosticMXBean
.
class
);
return
bean
;
}
catch
(
RuntimeException
re
)
{
throw
re
;
}
catch
(
Exception
exp
)
{
throw
new
RuntimeException
(
exp
);
}
}
public
static
void
main
(
String
[]
args
)
{
// default heap dump file name
String
fileName
=
"d:/heap.hprof1"
;
// by default dump only the live objects
boolean
live
=
true
;
// simple command line options
switch
(
args
.
length
)
{
case
2
:
live
=
args
[
1
].
equals
(
"true"
);
case
1
:
fileName
=
args
[
0
];
}
// dump the heap
dumpHeap
(
fileName
,
live
);
}
}
\ No newline at end of file
o2server/x_base_core_project/src/test/java/test/com/x/base/core/project/TestClient.java
已删除
100644 → 0
浏览文件 @
4c167540
package
test.com.x.base.core.project
;
import
java.io.File
;
import
java.lang.reflect.Field
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
javax.script.Bindings
;
import
javax.script.Compilable
;
import
javax.script.CompiledScript
;
import
javax.script.ScriptContext
;
import
javax.script.ScriptEngine
;
import
javax.script.ScriptEngineManager
;
import
javax.script.SimpleScriptContext
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.junit.Test
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.base.core.project.utils.time.ClockStamp
;
import
test.com.x.base.connection.Foo
;
public
class
TestClient
{
@Test
public
void
test
()
throws
Exception
{
Foo
foo
=
new
Foo
();
Field
l
=
FieldUtils
.
getField
(
Foo
.
class
,
"list"
,
true
);
Field
s
=
FieldUtils
.
getField
(
Foo
.
class
,
"str"
,
true
);
StringTools
.
replaceFieldValue
(
foo
,
l
,
"c"
,
"o"
);
StringTools
.
replaceFieldValue
(
foo
,
s
,
"s"
,
"z"
);
System
.
out
.
println
(
FieldUtils
.
readField
(
l
,
foo
,
true
));
System
.
out
.
println
(
FieldUtils
.
readField
(
s
,
foo
,
true
));
}
@Test
public
void
test1
()
throws
Exception
{
String
aaa
=
"d:\\a\\b\\c.d"
;
System
.
out
.
println
(
FilenameUtils
.
getName
(
aaa
));
}
@Test
public
void
test2
()
{
ConcurrentLinkedQueue
<
String
>
queue
=
new
ConcurrentLinkedQueue
<>();
}
@Test
public
void
test3
()
throws
Exception
{
File
file
=
new
File
(
"D:/O2/o2oa/o2server/commons/mooToolsScriptText.js"
);
String
text
=
FileUtils
.
readFileToString
(
file
,
"utf-8"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
ClockStamp
.
INIT
(
i
,
"1"
);
ScriptContext
scriptContext
=
new
SimpleScriptContext
();
ClockStamp
.
STAMP
(
"2"
);
Bindings
bindings
=
scriptContext
.
getBindings
(
ScriptContext
.
ENGINE_SCOPE
);
ClockStamp
.
STAMP
(
"3"
);
ScriptEngineManager
scriptEngineManager
=
new
ScriptEngineManager
();
ClockStamp
.
STAMP
(
"4"
);
//ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");
ScriptEngine
scriptEngine
=
scriptEngineManager
.
getEngineByName
(
"Nashorn"
);
ClockStamp
.
STAMP
(
"5"
);
scriptEngine
.
eval
(
text
,
scriptContext
);
ClockStamp
.
STAMP
(
"6"
);
ClockStamp
.
TRACE
();
}
}
@Test
public
void
test4
()
throws
Exception
{
ClockStamp
.
INIT
(-
1
,
"1"
);
File
file
=
new
File
(
"D:/O2/o2oa/o2server/commons/mooToolsScriptText.js"
);
ClockStamp
.
STAMP
(
"2"
);
String
text
=
FileUtils
.
readFileToString
(
file
,
"utf-8"
);
ClockStamp
.
STAMP
(
"3"
);
ScriptEngineManager
scriptEngineManager
=
new
ScriptEngineManager
();
ClockStamp
.
STAMP
(
"4"
);
// ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript");
ScriptEngine
scriptEngine
=
scriptEngineManager
.
getEngineByName
(
"Nashorn"
);
ClockStamp
.
STAMP
(
"5"
);
CompiledScript
script
=
((
Compilable
)
scriptEngine
).
compile
(
text
);
ClockStamp
.
STAMP
(
"6"
);
ClockStamp
.
TRACE
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
ClockStamp
.
INIT
(
i
,
"1"
);
ScriptContext
scriptContext
=
new
SimpleScriptContext
();
ClockStamp
.
STAMP
(
"2"
);
Bindings
bindings
=
scriptContext
.
getBindings
(
ScriptContext
.
ENGINE_SCOPE
);
ClockStamp
.
STAMP
(
"3"
);
//scriptEngine.eval(text, scriptContext);
script
.
eval
(
scriptContext
);
ClockStamp
.
STAMP
(
"4"
);
ClockStamp
.
TRACE
();
}
}
}
o2server/x_base_core_project/src/test/java/text.txt
已删除
100644 → 0
浏览文件 @
4c167540
{"name" : "x_attendance_assemble_control", "weight" : 100},
{"name" : "x_bbs_assemble_control", "weight" : 100},
{"name" : "x_cms_assemble_control", "weight" : 100},
{"name" : "x_collaboration_assemble_websocket", "weight" : 100},
{"name" : "x_collaboration_service_message", "weight" : 100},
{"name" : "x_collect_service_transmit", "weight" : 100},
{"name" : "x_component_assemble_control", "weight" : 100},
{"name" : "x_file_assemble_control", "weight" : 100},
{"name" : "x_mail_assemble_control", "weight" : 100},
{"name" : "x_meeting_assemble_control", "weight" : 100},
{"name" : "x_meeting_assemble_junction", "weight" : 100},
{"name" : "x_okr_assemble_control", "weight" : 100},
{"name" : "x_organization_assemble_authentication", "weight" : 100},
{"name" : "x_organization_assemble_control", "weight" : 100},
{"name" : "x_organization_assemble_custom", "weight" : 100},
{"name" : "x_organization_assemble_express", "weight" : 100},
{"name" : "x_organization_assemble_personal", "weight" : 100},
{"name" : "x_processplatform_assemble_designer", "weight" : 100},
{"name" : "x_processplatform_assemble_surface", "weight" : 100},
{"name" : "x_processplatform_service_processing_trigger", "weight" : 100},
{"name" : "x_processplatform_service_processing", "weight" : 100},
{"name" : "x_processplatform_service_service", "weight" : 100}
o2server/x_jpush_assemble_control/.gitignore
0 → 100644
浏览文件 @
8f41fdb1
/target/
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录