-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add NetworkMode setting to MTE (#5037)
- Loading branch information
Showing
8 changed files
with
161 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ain/java/org/terasology/engine/integrationenvironment/jupiter/IntegrationEnvironment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2022 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.engine.integrationenvironment.jupiter; | ||
|
||
import org.terasology.engine.network.NetworkMode; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface IntegrationEnvironment { | ||
NetworkMode networkMode() default NetworkMode.LISTEN_SERVER; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...rc/test/java/org/terasology/engine/integrationenvironment/NetworkModeLocalServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.engine.integrationenvironment; | ||
|
||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.terasology.engine.integrationenvironment.jupiter.IntegrationEnvironment; | ||
import org.terasology.engine.integrationenvironment.jupiter.MTEExtension; | ||
import org.terasology.engine.logic.players.LocalPlayer; | ||
import org.terasology.engine.network.NetworkMode; | ||
import org.terasology.engine.network.NetworkSystem; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@Tag("MteTest") | ||
@ExtendWith(MTEExtension.class) | ||
@IntegrationEnvironment(networkMode = NetworkMode.DEDICATED_SERVER) | ||
public class NetworkModeLocalServerTest { | ||
@Test | ||
void testNetworkMode(NetworkSystem network) { | ||
assertThat(network.getMode()).isEqualTo(NetworkMode.DEDICATED_SERVER); | ||
} | ||
|
||
@Test | ||
void testForLocalPlayer(NetworkSystem network, LocalPlayer player) { | ||
assertThat(network.getPlayers()).hasSize(1); | ||
var client = network.getPlayers().iterator().next(); | ||
assertThat(client.isLocal()).isTrue(); | ||
assertThat(player.isValid()).isTrue(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...tests/src/test/java/org/terasology/engine/integrationenvironment/NetworkModeNoneTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.engine.integrationenvironment; | ||
|
||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.terasology.engine.integrationenvironment.jupiter.IntegrationEnvironment; | ||
import org.terasology.engine.integrationenvironment.jupiter.MTEExtension; | ||
import org.terasology.engine.logic.players.LocalPlayer; | ||
import org.terasology.engine.network.NetworkMode; | ||
import org.terasology.engine.network.NetworkSystem; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@Tag("MteTest") | ||
@ExtendWith(MTEExtension.class) | ||
@IntegrationEnvironment(networkMode = NetworkMode.NONE) | ||
public class NetworkModeNoneTest { | ||
@Test | ||
void testNetworkMode(NetworkSystem network) { | ||
assertThat(network.getMode()).isEqualTo(NetworkMode.NONE); | ||
} | ||
|
||
@Test | ||
void testForLocalPlayer(NetworkSystem network, LocalPlayer player) { | ||
assertThat(network.getPlayers()).hasSize(1); | ||
var client = network.getPlayers().iterator().next(); | ||
assertThat(client.isLocal()).isTrue(); | ||
assertThat(player.isValid()).isTrue(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...sts/src/test/java/org/terasology/engine/integrationenvironment/NetworkModeServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2022 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.engine.integrationenvironment; | ||
|
||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.terasology.engine.integrationenvironment.jupiter.IntegrationEnvironment; | ||
import org.terasology.engine.integrationenvironment.jupiter.MTEExtension; | ||
import org.terasology.engine.logic.players.LocalPlayer; | ||
import org.terasology.engine.network.NetworkMode; | ||
import org.terasology.engine.network.NetworkSystem; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@Tag("MteTest") | ||
@ExtendWith(MTEExtension.class) | ||
@IntegrationEnvironment(networkMode = NetworkMode.LISTEN_SERVER) | ||
public class NetworkModeServerTest { | ||
@Test | ||
void testNetworkMode(NetworkSystem network) { | ||
assertThat(network.getMode()).isEqualTo(NetworkMode.LISTEN_SERVER); | ||
} | ||
|
||
@Test | ||
void testServerHasNoPlayers(NetworkSystem network, LocalPlayer player) { | ||
assertThat(network.getPlayers()).isEmpty(); | ||
assertThat(player.isValid()).isFalse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters