Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: More common tests moved to correct module #10133

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform-sdk/swirlds-common/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
com.swirlds.signingtool;
exports com.swirlds.common.crypto.internal to
com.swirlds.platform.core,
com.swirlds.common.test.fixtures,
com.swirlds.common.testing;
exports com.swirlds.common.notification.internal to
com.swirlds.common.testing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.swirlds.common.test.metrics.extensions;
package com.swirlds.common.metrics.extensions;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -25,7 +25,6 @@
import com.swirlds.base.test.fixtures.time.FakeTime;
import com.swirlds.common.metrics.IntegerPairAccumulator;
import com.swirlds.common.metrics.Metrics;
import com.swirlds.common.metrics.extensions.CountPerSecond;
import com.swirlds.common.metrics.platform.DefaultIntegerPairAccumulator;
import com.swirlds.common.time.IntegerEpochTime;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
* limitations under the License.
*/

package com.swirlds.common.test.metrics.extensions;
package com.swirlds.common.metrics.extensions;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.swirlds.base.test.fixtures.time.FakeTime;
import com.swirlds.common.metrics.extensions.FractionalTimer;
import com.swirlds.common.metrics.extensions.NoOpFractionalTimer;
import com.swirlds.common.metrics.extensions.StandardFractionalTimer;
import java.time.Duration;
import java.time.Instant;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package com.swirlds.common.test.metrics.extensions;
package com.swirlds.common.metrics.extensions;

import static com.swirlds.common.test.metrics.extensions.TestPhases.BAR;
import static com.swirlds.common.test.metrics.extensions.TestPhases.BAZ;
import static com.swirlds.common.test.metrics.extensions.TestPhases.FOO;
import static com.swirlds.common.metrics.extensions.TestPhases.BAR;
import static com.swirlds.common.metrics.extensions.TestPhases.BAZ;
import static com.swirlds.common.metrics.extensions.TestPhases.FOO;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -38,8 +38,6 @@
import com.swirlds.common.metrics.MetricConfig;
import com.swirlds.common.metrics.Metrics;
import com.swirlds.common.metrics.RunningAverageMetric;
import com.swirlds.common.metrics.extensions.PhaseTimer;
import com.swirlds.common.metrics.extensions.PhaseTimerBuilder;
import com.swirlds.common.units.TimeUnit;
import com.swirlds.test.framework.context.TestPlatformContextBuilder;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

package com.swirlds.common.test.metrics.extensions;

import com.swirlds.common.metrics.extensions.PhaseTimer;
package com.swirlds.common.metrics.extensions;

/**
* Phases for testing the {@link PhaseTimer} class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,14 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

import com.swirlds.common.test.fixtures.stream.CountDownLatchStream;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.system.NodeId;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.stream.ObjectForTestStream;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import com.swirlds.test.framework.context.TestPlatformContextBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -27,10 +27,9 @@
import com.swirlds.common.crypto.CryptographyHolder;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.io.SelfSerializable;
import com.swirlds.common.stream.HashCalculatorForStream;
import com.swirlds.common.stream.QueueThreadObjectStream;
import com.swirlds.common.stream.internal.LinkedObjectStream;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import org.junit.jupiter.api.Test;

class HashCalculatorTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,22 +14,20 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static com.swirlds.common.stream.MultiStream.NEXT_STREAM_NULL;
import static com.swirlds.common.stream.MultiStream.NOT_ENOUGH_NEXT_STREAMS;
import static com.swirlds.common.test.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import com.swirlds.common.crypto.Hash;
import com.swirlds.common.stream.HashCalculatorForStream;
import com.swirlds.common.stream.MultiStream;
import com.swirlds.common.stream.QueueThreadObjectStream;
import com.swirlds.common.stream.internal.LinkedObjectStream;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,13 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.swirlds.common.constructable.ConstructableRegistry;
import com.swirlds.common.test.fixtures.io.SerializationUtils;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import java.time.Instant;
import org.junit.jupiter.api.Test;

Expand All @@ -42,7 +43,7 @@ void toStringTest() {

@Test
void serializeDeserializeTest() throws Exception {
ConstructableRegistry.getInstance().registerConstructables("com.swirlds.common.test.stream");
ConstructableRegistry.getInstance().registerConstructables("com.swirlds.common.test.fixtures.stream");
ObjectForTestStream deserialized = SerializationUtils.serializeDeserialize(object);
assertEquals(object, deserialized, "deserialized object should equal to original object");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.threading.manager.AdHocThreadManager.getStaticThreadManager;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -29,11 +29,10 @@
import com.swirlds.common.crypto.ImmutableHash;
import com.swirlds.common.io.SelfSerializable;
import com.swirlds.common.io.streams.SerializableDataOutputStream;
import com.swirlds.common.stream.HashCalculatorForStream;
import com.swirlds.common.stream.QueueThreadObjectStream;
import com.swirlds.common.stream.QueueThreadObjectStreamConfiguration;
import com.swirlds.common.stream.RunningHashCalculatorForStream;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStreamGenerator;
import com.swirlds.common.test.fixtures.stream.WriteToStreamConsumer;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,9 +14,9 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.test.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static com.swirlds.common.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -26,7 +26,7 @@
import com.swirlds.common.crypto.DigestType;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.crypto.ImmutableHash;
import com.swirlds.common.stream.RunningHashCalculatorForStream;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import org.junit.jupiter.api.Test;

class RunningHashCalculatorTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.io.utility.FileUtils.deleteDirectory;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.generateStreamFileNameFromInstant;
Expand All @@ -28,11 +28,12 @@
import com.swirlds.common.constructable.ConstructableRegistry;
import com.swirlds.common.constructable.ConstructableRegistryException;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.stream.LinkedObjectStreamUtilities;
import com.swirlds.common.stream.StreamType;
import com.swirlds.common.stream.internal.LinkedObjectStreamValidateUtils;
import com.swirlds.common.stream.internal.StreamValidationResult;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.fixtures.stream.StreamFileSigner;
import com.swirlds.common.test.fixtures.stream.StreamObjectWorker;
import com.swirlds.common.test.fixtures.stream.TestStreamType;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,12 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.test.stream.TestStreamType.TEST_STREAM;
import static com.swirlds.common.test.fixtures.stream.TestStreamType.TEST_STREAM;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.swirlds.common.stream.EventStreamType;
import java.io.File;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,8 +14,9 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static com.swirlds.common.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.computeEntireHash;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.computeMetaHash;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.convertInstantToStringWithPadding;
Expand All @@ -26,6 +27,8 @@
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.readFirstIntFromFile;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.readHashesFromStreamFile;
import static com.swirlds.common.stream.LinkedObjectStreamUtilities.readStartRunningHashFromStreamFile;
import static com.swirlds.common.stream.StreamTypeTest.EVENT_FILE_NAME;
import static com.swirlds.common.stream.StreamTypeTest.EVENT_SIG_FILE_NAME;
import static com.swirlds.common.stream.internal.StreamValidationResult.CALCULATED_END_HASH_NOT_MATCH;
import static com.swirlds.common.stream.internal.StreamValidationResult.INVALID_ENTIRE_SIGNATURE;
import static com.swirlds.common.stream.internal.StreamValidationResult.OK;
Expand All @@ -35,11 +38,8 @@
import static com.swirlds.common.stream.internal.StreamValidationResult.STREAM_FILE_EMPTY;
import static com.swirlds.common.stream.internal.StreamValidationResult.STREAM_FILE_MISS_OBJECTS;
import static com.swirlds.common.stream.internal.StreamValidationResult.STREAM_FILE_MISS_START_HASH;
import static com.swirlds.common.test.stream.HashCalculatorTest.PAY_LOAD_SIZE_4;
import static com.swirlds.common.test.stream.ObjectForTestStream.getRandomObjectForTestStream;
import static com.swirlds.common.test.stream.StreamTypeTest.EVENT_FILE_NAME;
import static com.swirlds.common.test.stream.StreamTypeTest.EVENT_SIG_FILE_NAME;
import static com.swirlds.common.test.stream.TestStreamType.TEST_STREAM;
import static com.swirlds.common.test.fixtures.stream.ObjectForTestStream.getRandomObjectForTestStream;
import static com.swirlds.common.test.fixtures.stream.TestStreamType.TEST_STREAM;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -59,15 +59,14 @@
import com.swirlds.common.crypto.RunningHashable;
import com.swirlds.common.crypto.Signature;
import com.swirlds.common.io.SelfSerializable;
import com.swirlds.common.stream.EventStreamType;
import com.swirlds.common.stream.LinkedObjectStreamUtilities;
import com.swirlds.common.stream.StreamType;
import com.swirlds.common.stream.internal.InvalidStreamFileException;
import com.swirlds.common.stream.internal.LinkedObjectStreamValidateUtils;
import com.swirlds.common.stream.internal.SingleStreamIterator;
import com.swirlds.common.stream.internal.StreamValidationResult;
import com.swirlds.common.test.fixtures.RandomUtils;
import com.swirlds.common.test.fixtures.io.InputOutputStream;
import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import com.swirlds.common.test.fixtures.stream.StreamObjectWorker;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Hedera Hashgraph, LLC
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,11 @@
* limitations under the License.
*/

package com.swirlds.common.test.stream;
package com.swirlds.common.stream;

import static org.junit.jupiter.api.Assertions.assertTrue;

import com.swirlds.common.test.fixtures.stream.ObjectForTestStream;
import com.swirlds.common.utility.StopWatch;
import com.swirlds.test.framework.TestQualifierTags;
import java.util.Iterator;
Expand Down
Loading
Loading