All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
src.test.java.com.mgnt.utils.StamTest Maven / Gradle / Ivy
package com.mgnt.utils;
import com.mgnt.lifecycle.management.httpclient.HttpClient;
import com.mgnt.lifecycle.management.httpclient.HttpClient.HttpMethod;
import com.mgnt.lifecycle.management.httpclient.HttpClientCommunicationException;
import com.mgnt.lifecycle.management.httpclient.ResponseHolder;
import com.mgnt.utils.entities.TimeInterval;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Created by michaelg on 19/01/2016.
*/
public class StamTest {
public static void main(String[] args) {
// testParsing();
// testEncoderDecoder();
// testSystemPropertyInitializer();
// testParsingStringToTimeInterval();
// testFormatStringToPreserveIndentaitonForHtml();
// testGetStacktrace();
// testTimeInterval();
testHttpClient();
// testJsonParser();
// jsonParserTest();
// testHttpClientBinaryUpload();
// testHttpClientPostWithTextualData();
// timeIntervalCompareTest();
}
private static void testParsing() {
StringBuilder num = new StringBuilder("-92.89");
BigDecimal defaultVal = new BigDecimal(10);
System.out.println(TextUtils.parseStringToBigDecimal(num, defaultVal, null, null));
System.out.println(TextUtils.parseStringToBigDecimal(num, defaultVal));
num = new StringBuilder("-92L");
System.out.println(TextUtils.parseStringToBigDecimal(num, defaultVal, null, null));
System.out.println(TextUtils.parseStringToBigDecimal(num, defaultVal));
System.out.println(TextUtils.parseStringToBigDecimal(num, defaultVal));
}
private static void testEncoderDecoder() {
String helloEncoded = StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence("\\u");
System.out.println(helloEncoded);
String result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString("\\U0048\\U0065\\U006c\\U006c\\U006f");
System.out.println(result);
result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString(" \\u0048\\u0065\\u006c\\u006c \\u006f ");
System.out.println(result);
result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString(" \\u0004\\u0065\\u006c\\u006c \\u006f ");
System.out.println(result);
result = StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence(result);
System.out.println(result);
}
private static void testSystemPropertyInitializer() {
System.out.println("RelevantPackage: " + TextUtils.getRelevantPackage());
TextUtils.setRelevantPackage("com.utils.");
System.out.println("RelevantPackage: " + TextUtils.getRelevantPackage());
}
private static void testParseStringToTimeInterval() {
TimeInterval result = TextUtils.parseStringToTimeInterval("5s");
System.out.println(new Date() + " Waiting for " + result.toMillis());
TimeUtils.sleepFor(result);
System.out.println(new Date() + " wait is over");
}
private static void testFormatStringToPreserveIndentaitonForHtml() {
String rawText = " * This is non-indented line\n" +
" * This is 2 spaces indented line\n" +
" * This is 4 spaces indented line\n";
String result = TextUtils.formatStringToPreserveIndentationForHtml(rawText);
System.out.println(result + "\n" + StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence(result));
}
private static void testGetStacktrace() {
String stacktrace = "com.lib.DigestiveException: Potential stomach upset was detected\r\n" +
" at our.package.util.FoodHacking.washing(FoodHacking.java:391) ~[classes:?]\r\n" +
" at our.package.CustomTool.parseFood(CustomTool.java:307) ~[classes:?]\r\n" +
" at our.package.CustomTool.initTable(CustomTool.java:300) ~[classes:?]\r\n" +
" at our.package.CustomTool.(CustomTool.java:52) ~[classes:?]\r\n" +
" at our.package.CustomToolServlet.doGetOrPost(CustomToolServlet.java:323) ~[classes:?]\r\n" +
" at our.package.CustomToolServlet.doPost(CustomToolServlet.java:261) ~[classes:?]\r\n" +
" at javax.servlet.http.HttpServlet.service(HttpServlet.java:523) ~[jboss-servlet-api.jar]\r\n" +
" at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) ~[jboss-servlet-api.jar]\r\n" +
" at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) ~[undertow-servlet.jar!/:.Final]\r\n" +
" at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) ~[undertow-servlet.jar!/:.Final]\r\n" +
" at our.package.filter.Poison.doFilter(ldskhgoias:59) ~[our.jar:?]\r\n" +
" at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) ~[spring-web]\r\n" +
" at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) ~[spring-web]\r\n" +
" at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) ~[undertow-servlet.jar!/:.Final]\r\n" +
" at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) ~[undertow-servlet.jar!/:.Final]";
System.out.println(TextUtils.getStacktrace(stacktrace, "our.package", "io.undertow."));
String wierdStacktrace = "com.lib.DigestiveException: Potential stomach upset was detected\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.util.FoodHacking.washing(FoodHacking.java:391)\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.CustomTool.parseFood(CustomTool.java:307)\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.CustomTool.initTable(CustomTool.java:300)\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.CustomTool.(CustomTool.java:52)\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.CustomToolServlet.doGetOrPost(CustomToolServlet.java:323)\r\n" +
" at deployment.our-1.0.0.ear.foodlocker-service.war//our.package.CustomToolServlet.doPost(CustomToolServlet.java:261)\r\n" +
" at [email protected] //javax.servlet.http.HttpServlet.service(HttpServlet.java:523)\r\n" +
" at [email protected] //javax.servlet.http.HttpServlet.service(HttpServlet.java:590)\r\n" +
" at [email protected] //io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)\r\n" +
" at [email protected] //io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)\r\n" +
" at deployment.our-1.0.0.ear//our.package.filter.Poison.doFilter(ldskhgoias:59)\r\n" +
" at deployment.our-1.0.0.ear//org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)\r\n" +
" at deployment.our-1.0.0.ear//org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)\r\n" +
" at [email protected] //io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\r\n" +
" at [email protected] //io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)";
System.out.println(TextUtils.getStacktrace(wierdStacktrace, "deployment.our-1.0.0.ear.foodlocker-service.war//our.package"));
stacktrace = "java.lang.Exception: Dumb Stacktrace\n" +
"at com.mot.nsa.errorhandling.TestController.handler(TestController.java:35)\n" +
"at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
"at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" +
"at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" +
"at java.lang.reflect.Method.invoke(Method.java:498)\n" +
"at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)\n" +
"at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)\n" +
"at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)\n" +
"at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:849)\n" +
"at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:760)\n" +
"at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)\n" +
"at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)\n" +
"at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)\n" +
"at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)\n" +
"at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)\n" +
"at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)\n" +
"at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)\n" +
"at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:111)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)\n" +
"at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" +
"at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" +
"at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)\n" +
"at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)\n" +
"at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)\n" +
"at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)\n" +
"at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)\n" +
"at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)\n" +
"at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)\n" +
"at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)\n" +
"at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)\n" +
"at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)\n" +
"at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)\n" +
"at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n" +
"at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n" +
"at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n" +
"at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n" +
"at java.lang.Thread.run(Thread.java:748)\n" +
"Caused by: java.io.IOException: Test controller artificially generated exception\n" +
"at com.mot.nsa.errorhandling.TestController.handler(TestController.java:31)\n" +
"... 66 more";
System.out.println(TextUtils.getStacktrace(stacktrace, "com.mot", "javax.servlet."));
System.out.println(TextUtils.getStacktrace(stacktrace));
TextUtils.setRelevantPackage("com.mot.", "javax.servlet.");
System.out.println(TextUtils.getStacktrace(stacktrace));
}
private static void testTimeInterval() {
TimeInterval oneMilli = new TimeInterval(1L, TimeUnit.MILLISECONDS);
System.out.println("The number of nanoseconds in one millisecond is: " + oneMilli.toNanos());
TimeInterval oneSec = new TimeInterval(1L, TimeUnit.SECONDS);
System.out.println("The number of millisconds in one second is: " + oneSec.toMillis());
System.out.println("The number of nanoseconds in one second is: " + oneSec.toNanos());
}
private static void testHttpClient() {
try {
HttpClient client = new HttpClient();
client.setConnectionUrl("https://www.yahoo.com/");
// client.setConnectionUrl("http://www.israelnationalnews.com/");
// client.setConnectTimeout("1s");
// client.setReadTimeout(1L, TimeUnit.SECONDS);
// client.setConnectionUrl("http://localhost:7789/student/withDynamicSearch");
ResponseHolder result = client.sendHttpRequest(HttpMethod.GET);
client.setRequestProperty("accept", "application/json;charset=UTF-8");
client.setContentType("application/json");
// String result = client.sendHttpRequest(HttpMethod.POST, "{ \"username\": \"adminnpr\", \"password\": \"Adminnpr1234\"}");
System.out.println(result.getResponseContent());
System.out.println("HTTP " + result.getResponseCode() + " " + result.getResponseMessage());
System.out.println("Response headers: " + result.getResponseHeaders());
} catch (HttpClientCommunicationException e) {
System.out.println(TextUtils.getStacktrace(e, "com.mgnt."));
}
}
private static void testHttpClientBinaryUpload() {
try {
byte[] content = Files.readAllBytes(Paths.get("C:\\Michael\\Personal\\pics\\testPic.jpg"));
HttpClient client = new HttpClient();
Integer length = content.length;
Files.write(Paths.get("C:\\Michael\\tmp\\testPicOrig.jpg"), content);
client.setRequestHeader("Content-Length", length.toString());
ResponseHolder result = client.sendHttpRequest("http://localhost:8080/upload", HttpMethod.POST, ByteBuffer.wrap(content));
System.out.println("Upload result: " + result.getResponseContent());
System.out.println("Upload HTTP response: " + result.getResponseCode() + " " + result.getResponseMessage());
ResponseHolder fileContent = client.sendHttpRequestForBinaryResponse("http://localhost:8080/upload", HttpMethod.PUT, ByteBuffer.wrap(content));
Files.write(Paths.get("C:\\Michael\\tmp\\testPicDownloaded.jpg"), fileContent.getResponseContent().array());
System.out.println("Download result: " + fileContent.getResponseContent());
System.out.println("Download HTTP response: " + fileContent.getResponseCode() + " " + fileContent.getResponseMessage());
} catch (Exception e) {
System.out.println(TextUtils.getStacktrace(e, "com.mgnt."));
}
}
private static void testHttpClientPostWithTextualData() {
HttpClient client = new HttpClient();
try {
String myTestData = "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}";
client.clearAllRequestProperties()
.setContentType("application/json; charset=UTF-8")
.setRequestHeader("Content-Length", Integer.valueOf(myTestData.length()).toString())
.setRequestHeader("Test", "test")
.setConnectionUrl("https://jsonplaceholder.typicode.com/posts");
// ByteBuffer bb = ByteBuffer.wrap(myTestData.getBytes(StandardCharsets.UTF_8));
ResponseHolder result = client.sendHttpRequest(HttpClient.HttpMethod.POST, myTestData);
System.out.println(result.getResponseCode() + " " + result.getResponseMessage() + " " + result.getResponseContent());
} catch (HttpClientCommunicationException hcce) {
System.out.println(hcce.getResponseHolder().getResponseCode() + " " + hcce.getResponseHolder().getResponseMessage());
hcce.printStackTrace();
}
}
private static void testJsonParser() {
TextUtils.setRelevantPackage("com.mgnt.");
try {
Map map = new HashMap<>();
map.put("Hello", "World");
map.put("Author", "Michael Gantman");
String json = JsonUtils.writeObjectToJsonString(map);
System.out.println(json);
map = JsonUtils.readObjectFromJsonString(json, Map.class);
System.out.println(map);
TestUser james = new TestUser();
james.setFirstName("James");
james.setLastName("Doe");
TestUser jane = new TestUser();
jane.setFirstName("Jane");
jane.setLastName("Dane");
List users = new ArrayList<>();
users.add(jane);
users.add(james);
UserList myUserList = new UserList();
myUserList.setUsers(users);
json = JsonUtils.writeObjectToJsonString(myUserList, true);
System.out.println(json);
UserList recoveredUsers = JsonUtils.readObjectFromJsonString(json, UserList.class, true);
System.out.println(recoveredUsers.getUsers());
json = JsonUtils.writeObjectToJsonString(users);
System.out.println(json);
Class> clazz = (Class>)users.getClass();
users = JsonUtils.readObjectFromJsonString(json, clazz);
System.out.println(users);
System.out.println(JsonUtils.writeObjectToJsonString(james));
System.out.println(JsonUtils.writeObjectToJsonString(james, true));
} catch (IOException e) {
System.out.println(TextUtils.getStacktrace(e));
}
}
private static void jsonParserTest() {
try {
Map map = JsonUtils.readObjectFromJsonString("{\"a\": \"b\"}", Map.class);
System.out.println(map);
map = JsonUtils.readObjectFromJsonString("{\"a\": \"b\"} foobar{}", Map.class);
System.out.println(map);
map = JsonUtils.readObjectFromJsonString("{\"a\":\"b\"}{\"1\":\"2\"}", Map.class);
System.out.println(map);
map = JsonUtils.readObjectFromJsonString("{\"a\":\"b\"},{\"1\":\"2\"}", Map.class);
System.out.println(map);
map.put("date test", ZonedDateTime.now());
String jsonStr = JsonUtils.writeObjectToJsonString(map);
System.out.println(jsonStr);
map = JsonUtils.readObjectFromJsonString(jsonStr, Map.class);
System.out.println(map);
} catch (IOException e) {
System.out.println(TextUtils.getStacktrace(e, "com.mgnt."));
}
}
private static void timeIntervalCompareTest() {
TimeInterval timeInterval = new TimeInterval(10L, TimeUnit.MINUTES);
TimeInterval timeInterval2 = new TimeInterval();
timeInterval2.setTimeUnit(TimeUnit.HOURS);
int res = timeInterval.compareTo(timeInterval2);
if(res != 1) {
System.err.println(timeInterval.toString() + "should be greater than " + timeInterval2 + " actual result is " + res);
}
timeInterval2.setTimeUnit(TimeUnit.MINUTES);
timeInterval2.setValue(10L);
res = timeInterval.compareTo(timeInterval2);
if(res != 0) {
System.err.println(timeInterval.toString() + " should be equal " + timeInterval2 + " actual result is " + res);
}
timeInterval2.setTimeUnit(TimeUnit.SECONDS);
timeInterval2.setValue(600L);
res = timeInterval.compareTo(timeInterval2);
if(res != 0) {
System.err.println(timeInterval.toString() + " should be equal " + timeInterval2 + " actual result is " + res);
}
if(!timeInterval.equals(timeInterval2)) {
System.err.println(timeInterval.toString() + " should be equal " + timeInterval2 + " but they are not");
}
timeInterval.setTimeUnit(TimeUnit.NANOSECONDS);
timeInterval.setValue(10L);
timeInterval2.setTimeUnit(TimeUnit.NANOSECONDS);
timeInterval2.setValue(9L);
res = timeInterval.compareTo(timeInterval2);
if(res != 1) {
System.err.println(timeInterval.toString() + " should be greater than " + timeInterval2 + " actual result is " + res);
}
timeInterval2.setValue(10L);
if(!timeInterval.equals(timeInterval2)) {
System.err.println(timeInterval.toString() + " should be equal " + timeInterval2 + " but they are not");
}
timeInterval.setValue(2_000_010L);
timeInterval2.setValue(2_000_000L);
res = timeInterval.compareTo(timeInterval2);
if(res != 1) {
System.err.println(timeInterval.toString() + " should be greater than " + timeInterval2 + " actual result is " + res);
}
if(timeInterval.equals(timeInterval2)) {
System.err.println(timeInterval.toString() + " should not be equal " + timeInterval2 + " but they are");
}
}
}