Skip to content

Commit

Permalink
Merge pull request #12 from utastudents/_SaadsBranch
Browse files Browse the repository at this point in the history
Added GameTest.java
  • Loading branch information
saadkhairullah authored Apr 25, 2024
2 parents 47aa0a7 + 283de04 commit cd2f1ec
Show file tree
Hide file tree
Showing 27 changed files with 396 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dgl'as
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
origin/HEAD -> origin/main
origin/_SaadsBranch
origin/backupbranch1
origin/backupbranch2
origin/backupbranch3
origin/backupleaderboard
origin/branchRecover
origin/branch_for_css
origin/leaderboard
origin/main
origin/mainBackup
origin/new
origin/new2
origin/saads_branch_backup
origin/working_on_game_check
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<version>1.5.4</version>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>

<build>
Expand All @@ -59,6 +65,18 @@
<mainClass>${mainClass}</mainClass>
</configuration>
</plugin>
<!-- runs test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> <!-- Adjust version as needed -->
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions src/main/java/uta/cse3310/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private int getColIncrement(int orientation, int i) {
}

// Attempts to place a single word in the grid randomly

private boolean placeWordInGrid(String word) {
int orientation = random.nextInt(8); // Updated for 8 orientations
for (int attempts = 0; attempts < 100; attempts++) {
Expand Down Expand Up @@ -422,6 +423,9 @@ public String getLobbyName() {
public String roomID() {
return roomId;
}
public Map<String, Boolean> getWordsPlaced() {
return wordsPlaced;
}

public void startGame() {
initializeGrid(); // first fill with dashes
Expand Down
33 changes: 33 additions & 0 deletions src/test/java/uta/cse3310/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package uta.cse3310;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

public void testApp()
{


}
}
72 changes: 72 additions & 0 deletions src/test/java/uta/cse3310/GameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package uta.cse3310;
import java.util.ArrayList;
import java.util.List;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class GameTest
extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public GameTest(String testName) {
super(testName);
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(GameTest.class);
}

public void testCase(){

Game g = new Game("TestLobby", "TestRoom"); // New test Room
Player p1 = new Player("josh", null); // new player named josh
Player p2 = new Player("adam", null); // new player named adam

//adding players to game
g.addPlayer(p1);
g.addPlayer(p1);
g.setPlayer1(p1);
g.setPlayer2(p2);

//checkking to see if game is full, adn ready to start
assertTrue(g.isReadyToStart());
assertEquals(g.getCurrentNumberOfPlayers(),"2");

//insert 3 word into the words placed function
List<String> wordList = new ArrayList<>();
for (String word : g.getWordsPlaced().keySet()) {
// Add each word to the list
wordList.add(word);
}


//check to see if words can be correctly chosen by players
assertTrue(g.checkWord(p1.getUsername(), wordList.get(0)));// test to see if player josh can find first word in grid
g.checkWord(p1.getUsername(),wordList.get(0)); // josh finds first word
g.checkWord(p2.getUsername(), wordList.get(1)); // adam finds second word
g.checkWord(p2.getUsername(), wordList.get(2)); // adam finds third word


// retrieve player scores
String string = String.valueOf(g.getPlayerScores());
assertEquals(string, "{adam=2, josh=1}"); // check player scores.

// reset game and kick players out
g.reset();

//make sure there are no players left in the lobby
assertEquals(g.getCurrentNumberOfPlayers(),"0");

}
}
Binary file added target/WordSearch-1.0-SNAPSHOT.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions target/classes/META-INF/maven/archetype.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<archetype>
<id>WordSearch</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>
15 changes: 15 additions & 0 deletions target/classes/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>$org.example</groupId>
<artifactId>$WordSearch</artifactId>
<version>$1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
13 changes: 13 additions & 0 deletions target/classes/archetype-resources/src/main/java/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package $org.example;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
38 changes: 38 additions & 0 deletions target/classes/archetype-resources/src/test/java/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package $org.example;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
Binary file added target/classes/uta/cse3310/App.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Chat.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Game.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/HttpServer$1.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/HttpServer.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Player.class
Binary file not shown.
5 changes: 5 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Thu Apr 25 11:30:25 CDT 2024
groupId=org.example
artifactId=WordSearch
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
uta/cse3310/App.class
uta/cse3310/Player.class
uta/cse3310/HttpServer.class
uta/cse3310/Chat.class
uta/cse3310/HttpServer$1.class
uta/cse3310/Game.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/App.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/HttpServer.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Game.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Chat.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uta/cse3310/AppTest.class
uta/cse3310/GameTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/home/vboxuser/cse3310_sp24_group_18/src/test/java/uta/cse3310/AppTest.java
/home/vboxuser/cse3310_sp24_group_18/src/test/java/uta/cse3310/GameTest.java
55 changes: 55 additions & 0 deletions target/surefire-reports/TEST-uta.cse3310.AppTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="uta.cse3310.AppTest" time="0.02" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property name="java.specification.version" value="17"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="java.vm.vendor" value="Private Build"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.vendor.url" value="Unknown"/>
<property name="os.name" value="Linux"/>
<property name="java.vm.specification.version" value="17"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="user.country" value="US"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
<property name="sun.java.command" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar /home/vboxuser/cse3310_sp24_group_18/target/surefire 2024-04-25T11-30-21_685-jvmRun1 surefire14035829568187834566tmp surefire_04664733525063810608tmp"/>
<property name="jdk.debug" value="release"/>
<property name="surefire.test.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/vboxuser"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.version.date" value="2023-10-17"/>
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
<property name="file.separator" value="/"/>
<property name="basedir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="line.separator" value="&#10;"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="surefire.real.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="user.name" value="vboxuser"/>
<property name="path.separator" value=":"/>
<property name="os.version" value="6.5.0-17-generic"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="localRepository" value="/home/vboxuser/.m2/repository"/>
<property name="java.vendor.url.bug" value="Unknown"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="java.version" value="17.0.9"/>
<property name="user.dir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.vendor" value="Private Build"/>
<property name="java.vm.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="61.0"/>
</properties>
<testcase name="testApp" classname="uta.cse3310.AppTest" time="0"/>
</testsuite>
Loading

0 comments on commit cd2f1ec

Please sign in to comment.