Skip to content

Commit

Permalink
#24714 small test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizzio-dotCMS committed Apr 26, 2023
1 parent e95d651 commit abfc8a9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dotCMS/src/integration-test/java/com/dotcms/MainSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import com.dotcms.storage.StoragePersistenceAPITest;
import com.dotcms.storage.repository.HashedLocalFileRepositoryManagerTest;
import com.dotcms.translate.GoogleTranslationServiceIntegrationTest;
import com.dotcms.util.ThreadUtilsTest;
import com.dotcms.util.content.json.PopulateContentletAsJSONUtilTest;
import com.dotcms.uuid.shorty.LegacyShortyIdApiTest;
import com.dotcms.variant.VariantAPITest;
Expand Down Expand Up @@ -647,6 +648,7 @@
PopulateContentletAsJSONJobTest.class,
ContentTypeDestroyAPIImplTest.class,
Task230328AddMarkedForDeletionColumnTest.class,
ThreadUtilsTest.class
// AnalyticsAPIImplTest.class,
// AccessTokenRenewJobTest.class,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.dotcms.util;


import com.dotmarketing.util.ThreadUtils;
import graphql.Assert;
import org.junit.Test;

public class ThreadUtilsTest {

@Test
public void Test_Get_Thread_Compare_With_Current_Thread() {
final Thread currentThread = Thread.currentThread();
final Thread byNameThread = ThreadUtils.getThread(currentThread.getName());
assert currentThread == byNameThread;
}

@Test
public void Test_Get_Thread_Non_Existing_Thread_Name() {
final Thread byNameThread = ThreadUtils.getThread("NonExistingThreadName");
Assert.assertNull(byNameThread);
}

@Test
public void Test_Get_Thread_When_Null_Is_Passed() {
final Thread byNameThread = ThreadUtils.getThread(null);
Assert.assertNull(byNameThread);
}

@Test
public void Test_Sleep() {
final long t1 = System.currentTimeMillis();
ThreadUtils.sleep(100L);
final long t2 = System.currentTimeMillis();
assert t2 - t1 >= 100L;
}

}

0 comments on commit abfc8a9

Please sign in to comment.