mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-06-12 19:41:08 +08:00
separate common
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.maxkey.util.DateUtils;
|
||||
|
||||
public class DateUtilsTest {
|
||||
|
||||
/**
|
||||
* Main method for test.
|
||||
*
|
||||
* @param args
|
||||
* @throws EncryptException
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
String stringValue = "20110610090519";
|
||||
System.out.println(stringValue);
|
||||
// System.out.println("Parse \"" + stringValue
|
||||
// + "\" using format pattern \"" + DateUtils.FORMAT_DATE_DEFAULT
|
||||
// + "\" with method \"DateUtils.parse()\", result: "
|
||||
// + DateUtils.parse(stringValue));
|
||||
// stringValue = "20080506";
|
||||
// System.out.println("Parse \"" + stringValue
|
||||
// + "\" using method \"DateUtils.tryParse()\", result: "
|
||||
// + DateUtils.tryParse(stringValue));
|
||||
// String s = DateUtils.getExchangeFormat(stringValue,FORMAT_DATE_YYYYMMDDHHMMSS,DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS);
|
||||
// System.out.print("--->>>"+s);
|
||||
|
||||
// String str = "2011-08-09";
|
||||
// System.out.println(UserPasswordUtil.decrypt("PVuyeIHtXnXv5oSPwPUug66w=="));
|
||||
// System.out.println(DateUtils.getFormtPattern1ToPattern2(str, DateUtils.FORMAT_DATE_YYYY_MM_DD, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
// str = "aaa\r\nbbb";
|
||||
// List<String> list = StringUtil.strToList(str, "\r\n");
|
||||
// System.out.println(list.size());
|
||||
// System.out.println(StringUtil.listToStr(null, ","));
|
||||
|
||||
// String value = "a,b,,c,,";
|
||||
// System.out.println(value.split("\\,").length);
|
||||
// System.out.println(StringUtil.removeSplit(value, ","));
|
||||
|
||||
// Class clazz = TmEmployeeUserInfo.class;
|
||||
// Field field = clazz.getDeclaredField("spellName");
|
||||
// System.out.println(field.getName());
|
||||
|
||||
// System.out.println(UserPasswordUtil.encrypt("oscwebadmin@163.com"));
|
||||
//System.out.println(JCEnDecrypt.randomDecrypt("2AF5022B2E78478A9761FD3381BB"));
|
||||
// System.out.println(JCEnDecrypt.randomEncrypt("aaa")); 41l2Iw4V
|
||||
// String regEx="[1]{1}[3,5,8,6]{1}[0-9]{9}"; //<2F><>ʾa<CABE><61>f
|
||||
// System.out.println(Pattern.compile(regEx).matcher("18258842633").find());
|
||||
// Date lockoutDate = DateUtils.addDate(new Date(), 0, 30, 0); //解锁时间
|
||||
// System.out.println(DateUtils.format(lockoutDate, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
Date date = new Date();
|
||||
System.out.println(DateUtils.format(DateUtils.addDate(date, 0, 0, 1, 0, 0, 0),DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
|
||||
|
||||
System.out.println(DateUtils.format(DateUtils.addMinutes(new Date(), Integer.parseInt("2")*1000),DateUtils.FORMAT_DATE_ISO_TIMESTAMP));
|
||||
System.out.println(DateUtils.toUtc(date));
|
||||
|
||||
System.out.println(DateUtils.toUtcLocal("2015-11-04T16:00:22.875Z"));
|
||||
System.out.println(DateUtils.toUtcLocal("2015-11-04T23:58:14.286+08:00"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import org.maxkey.util.EthernetAddress;
|
||||
|
||||
public class EthernetAddressTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(EthernetAddress.fromInterface());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
public class IdSequenceTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
long s =System.currentTimeMillis();
|
||||
int k;
|
||||
for(int i=1;i<=10010;i++){
|
||||
k=(i)%10000;
|
||||
System.out.println(k);
|
||||
}
|
||||
System.out.println(System.currentTimeMillis()-s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import org.maxkey.util.MacAddress;
|
||||
|
||||
public class MacAddressTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println(MacAddress.getAllHostMacAddress());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.maxkey.util.ObjectTransformer;
|
||||
|
||||
public class ObjectTransformerTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
HashMap<String, Object> ut=new HashMap<String, Object>();
|
||||
|
||||
ut.put("username","shimingxy");
|
||||
ut.put("password","test");
|
||||
ut.put("department","我的部门");
|
||||
|
||||
String hexString =ObjectTransformer.serialize(ut);
|
||||
|
||||
System.out.println("hexString "+hexString);
|
||||
System.out.println(hexString.length());
|
||||
|
||||
HashMap<String, Object> u2=ObjectTransformer.deserialize(hexString);
|
||||
|
||||
System.out.println("deserialize "+u2.toString());
|
||||
|
||||
System.out.println("{’id’:’be90f66d-95df-4daf-93c1-ece002542702’,’tid’:null,’tname’:null,’description’:null,’status’:0,’sortOrder’:0,’createdBy’:’admin’,’createdDate’:’2014-11-07 21:27:38’,’modifiedBy’:null,’modifiedDate’:null,’startDate’:null,’endDate’:null,’username’:’yyyyy’,’password’:’Pt3dCf6Zad9h3g7q/DI0e7jQ5evO2Jn+tk2TjtdJ0eY=’,’decipherable’:’yaOLYlcdjfF5hFOskBOOxQ==’,’sharedSecret’:null,’sharedCounter’:null,’userType’:’EMPLOYEE’,’windowsAccount’:null,’displayName’:’test’,’nickName’:null,’nameZHSpell’:’test’,’nameZHShortSpell’:’test’,’givenName’:null,’middleName’:null,’familyName’:null,’honorificPrefix’:null,’honorificSuffix’:null,’formattedName’:null,’married’:0,’gender’:1,’birthDate’:null,’idType’:0,’idCardNo’:null,’webSite’:null,’startWorkDate’:null,’authnType’:0,’email’:null,’emailVerified’:0,’mobile’:null,’mobileVerified’:0,’passwordQuestion’:null,’passwordAnswer’:null,’appLoginAuthnType’:0,’appLoginPassword’:null,’protectedApps’:null,’passwordLastSetTime’:’2014-11-07 21:27:38’,’badPasswordCount’:0,’unLockTime’:null,’isLocked’:0,’lastLoginTime’:null,’lastLogoffTime’:null,’passwordSetType’:0,’locale’:’zh_CN’,’timeZone’:’Asia/Shanghai’,’preferredLanguage’:’zh_CN’,’workCountry’:’CHN’,’workRegion’:null,’workLocality’:null,’workStreetAddress’:null,’workAddressFormatted’:null,’workEmail’:null,’workPhoneNumber’:null,’workPostalCode’:null,’workFax’:null,’homeCountry’:’CHN’,’homeRegion’:null,’homeLocality’:null,’homeStreetAddress’:null,’homeAddressFormatted’:null,’homeEmail’:null,’homePhoneNumber’:null,’homePostalCode’:null,’homeFax’:null,’employeeNumber’:null,’costCenter’:null,’organization’:null,’division’:null,’departmentId’:null,’department’:null,’jobTitle’:null,’jobLevel’:null,’managerId’:null,’manager’:null,’assistantId’:null,’assistant’:null,’entryDate’:null,’quitDate’:null,’ims’:’QQ:\r\nWeiXin:\r\nSinaWeibo:\r\nGtalk:\r\nYiXin:\r\nIMessage:\r\nSkype:\r\nYahoo:\r\nMSN:\r\nAim:\r\nICQ :\r\nXmpp :’,’extraAttribute’:null,’extraAttributeName’:null,’extraAttributeValue’:null,’online’:0,’ldapDn’:null}".length());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.PathUtils;
|
||||
|
||||
public class PathUtilsTest {
|
||||
@Test
|
||||
public void test() {
|
||||
//System.out.println(PathUtils.getInstance().getAppPath());
|
||||
//System.out.println(PathUtils.getInstance().getWebInf());
|
||||
//System.out.println(PathUtils.getInstance().getClassPath());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.pretty.PrettyFactory;
|
||||
|
||||
public class SqlPrettyTest {
|
||||
|
||||
public SqlPrettyTest() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSqlFormat() {
|
||||
String sqlString="select * from userinfo where t='111' order by t,s,t";
|
||||
System.out.println(PrettyFactory.getSqlPretty().format(sqlString));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.StringGenerator;
|
||||
|
||||
public class StringGeneratorTest {
|
||||
@Test
|
||||
public void test() {
|
||||
StringGenerator stringGenerator=new StringGenerator();
|
||||
System.out.println(stringGenerator.uuidGenerate());
|
||||
System.out.println(stringGenerator.uuidGenerate().length());
|
||||
System.out.println(stringGenerator.uniqueGenerate());
|
||||
System.out.println(stringGenerator.uniqueGenerate().length());
|
||||
|
||||
System.out.println(StringGenerator.uuidMatches(stringGenerator.uuidGenerate()));
|
||||
System.out.println(StringGenerator.uuidMatches(UUID.randomUUID().toString()));
|
||||
System.out.println(StringGenerator.uuidMatches("408192be-cab9-4b5b-8d41-4cd827cc4091"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import java.util.Date;
|
||||
//import java.util.UUID;
|
||||
|
||||
import org.maxkey.uuid.UUID;
|
||||
import org.junit.Test;
|
||||
import org.maxkey.util.UUIDGenerator;
|
||||
|
||||
public class UUIDGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Date sd=new Date();
|
||||
|
||||
//for(int i=0;i<100000;i++){
|
||||
UUIDGenerator generated=new UUIDGenerator();
|
||||
generated.toString();
|
||||
//System.out.println(generated.toString());
|
||||
|
||||
//}
|
||||
Date ed=new Date();
|
||||
System.out.println("usertime "+(ed.getTime()-sd.getTime()));
|
||||
|
||||
// UUIDGenerator.version(generated);
|
||||
|
||||
|
||||
System.out.println("JDK UUID");
|
||||
Date ssd=new Date();
|
||||
// for(int i=0;i<100000;i++){
|
||||
//UUID.randomUUID().toString();
|
||||
UUID.generate().toString();
|
||||
// System.out.println(UUID.randomUUID().toString());
|
||||
//}
|
||||
Date sed=new Date();
|
||||
System.out.println("usertime "+(sed.getTime()-ssd.getTime()));
|
||||
|
||||
UUIDGenerator.version(new UUIDGenerator(UUID.generate().toString()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
|
||||
*
|
||||
* 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.maxkey.util;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.maxkey.pretty.PrettyFactory;
|
||||
import org.maxkey.pretty.impl.XMLHelper;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSOutput;
|
||||
import org.w3c.dom.ls.LSSerializer;
|
||||
import org.w3c.dom.ls.LSSerializerFilter;
|
||||
|
||||
import net.shibboleth.utilities.java.support.collection.LazyMap;
|
||||
|
||||
public class XMLHelperTest {
|
||||
|
||||
@Test
|
||||
public void testSqlFormat() {
|
||||
String sqlString="<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml><data><name>maxkey</name><age v=\"20\"/></data></xml>";
|
||||
System.out.println(XMLHelper.prettyPrintXML(sqlString));
|
||||
System.out.println(XMLHelper.transformer(sqlString));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user