From f9beed6a8916324ef944a09ea6f6f25049d0f2a4 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 29 Sep 2021 16:01:36 +0400 Subject: [PATCH] Dev: clear pom files, fixed wrong test packages and scope, added zip tests; --- Mage.Client/pom.xml | 21 +---- Mage.Server.Plugins/Mage.Player.AI/pom.xml | 1 - .../Mage.Player.AIMCTS/pom.xml | 1 - .../Mage.Player.AIMinimax/pom.xml | 1 - Mage.Server/pom.xml | 6 -- Mage.Sets/pom.xml | 1 - Mage.Tests/pom.xml | 15 ++-- .../test/decks/exporter}/DeckFormatsTest.java | 3 +- .../exporter/MtgArenaDeckExporterTest.java | 4 +- .../test/utils/ZipFilesReadWriteTest.java | 76 ++++++++++++++++++ Mage.Tests/src/test/resources/images.zip | Bin 0 -> 1636 bytes Mage.Verify/pom.xml | 1 - Mage/pom.xml | 1 - .../ConditionalContinuousEffect.java | 7 +- pom.xml | 18 +++++ 15 files changed, 115 insertions(+), 41 deletions(-) rename {Mage/src/main/java/mage/cards/decks => Mage.Tests/src/test/java/org/mage/test/decks/exporter}/DeckFormatsTest.java (96%) rename {Mage/src/main/java/mage/cards => Mage.Tests/src/test/java/org/mage/test}/decks/exporter/MtgArenaDeckExporterTest.java (92%) create mode 100644 Mage.Tests/src/test/java/org/mage/test/utils/ZipFilesReadWriteTest.java create mode 100644 Mage.Tests/src/test/resources/images.zip diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index 0ff115a187..57b9da979e 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -43,6 +43,10 @@ org.slf4j slf4j-log4j12 + + net.java.truevfs + truevfs-profile-base + @@ -88,7 +92,6 @@ junit junit - jar test @@ -112,22 +115,6 @@ jsoup 1.14.2 - - truevfs-profile-base - net.java.truevfs - jar - 0.11.1 - - - truevfs-access-swing - net.java.truevfs - - - truecommons-key-swing - net.java.truecommons - - - diff --git a/Mage.Server.Plugins/Mage.Player.AI/pom.xml b/Mage.Server.Plugins/Mage.Player.AI/pom.xml index b6b558e6e8..48086d621f 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/pom.xml +++ b/Mage.Server.Plugins/Mage.Player.AI/pom.xml @@ -18,7 +18,6 @@ log4j log4j - jar ${project.groupId} diff --git a/Mage.Server.Plugins/Mage.Player.AIMCTS/pom.xml b/Mage.Server.Plugins/Mage.Player.AIMCTS/pom.xml index 8435f3ea3e..ece840b665 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMCTS/pom.xml +++ b/Mage.Server.Plugins/Mage.Player.AIMCTS/pom.xml @@ -18,7 +18,6 @@ log4j log4j - jar ${project.groupId} diff --git a/Mage.Server.Plugins/Mage.Player.AIMinimax/pom.xml b/Mage.Server.Plugins/Mage.Player.AIMinimax/pom.xml index 3b773ba2ea..5e43462cba 100644 --- a/Mage.Server.Plugins/Mage.Player.AIMinimax/pom.xml +++ b/Mage.Server.Plugins/Mage.Player.AIMinimax/pom.xml @@ -18,7 +18,6 @@ log4j log4j - jar ${project.groupId} diff --git a/Mage.Server/pom.xml b/Mage.Server/pom.xml index 79e1f17a73..7af167954c 100644 --- a/Mage.Server/pom.xml +++ b/Mage.Server/pom.xml @@ -233,37 +233,31 @@ org.apache.shiro shiro-core 1.8.0 - jar com.google.api-client google-api-client 1.31.1 - jar com.google.apis google-api-services-gmail v1-rev20210614-1.32.1 - jar com.google.oauth-client google-oauth-client-java6 1.31.0 - jar com.google.oauth-client google-oauth-client-jetty 1.31.2 - jar javax.mail mail 1.5.0-b01 - jar com.sun.jersey diff --git a/Mage.Sets/pom.xml b/Mage.Sets/pom.xml index 4dac5f304e..ad724706d4 100644 --- a/Mage.Sets/pom.xml +++ b/Mage.Sets/pom.xml @@ -24,7 +24,6 @@ log4j log4j - jar diff --git a/Mage.Tests/pom.xml b/Mage.Tests/pom.xml index 5e39abef7d..1f54378e9d 100644 --- a/Mage.Tests/pom.xml +++ b/Mage.Tests/pom.xml @@ -34,11 +34,6 @@ mage-server ${mage-version} - - junit - junit - test - ${project.groupId} mage-game-twoplayerduel @@ -52,10 +47,14 @@ compile + + junit + junit + test + log4j log4j - jar ${project.groupId} @@ -73,6 +72,10 @@ jaxb-runtime 3.0.2 + + net.java.truevfs + truevfs-profile-base + diff --git a/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java b/Mage.Tests/src/test/java/org/mage/test/decks/exporter/DeckFormatsTest.java similarity index 96% rename from Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java rename to Mage.Tests/src/test/java/org/mage/test/decks/exporter/DeckFormatsTest.java index 6dfe1d612f..47c85e69c9 100644 --- a/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/decks/exporter/DeckFormatsTest.java @@ -1,5 +1,6 @@ -package mage.cards.decks; +package org.mage.test.decks.exporter; +import mage.cards.decks.DeckFormats; import org.junit.Assert; import org.junit.Test; diff --git a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java b/Mage.Tests/src/test/java/org/mage/test/decks/exporter/MtgArenaDeckExporterTest.java similarity index 92% rename from Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java rename to Mage.Tests/src/test/java/org/mage/test/decks/exporter/MtgArenaDeckExporterTest.java index af7666a45d..9a40ab631c 100644 --- a/Mage/src/main/java/mage/cards/decks/exporter/MtgArenaDeckExporterTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/decks/exporter/MtgArenaDeckExporterTest.java @@ -1,7 +1,9 @@ -package mage.cards.decks.exporter; +package org.mage.test.decks.exporter; import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardLists; +import mage.cards.decks.exporter.DeckExporter; +import mage.cards.decks.exporter.MtgArenaDeckExporter; import org.junit.Test; import java.io.ByteArrayOutputStream; diff --git a/Mage.Tests/src/test/java/org/mage/test/utils/ZipFilesReadWriteTest.java b/Mage.Tests/src/test/java/org/mage/test/utils/ZipFilesReadWriteTest.java new file mode 100644 index 0000000000..a88497f360 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/utils/ZipFilesReadWriteTest.java @@ -0,0 +1,76 @@ +package org.mage.test.utils; + +import net.java.truevfs.access.TFile; +import net.java.truevfs.access.TFileReader; +import net.java.truevfs.access.TFileWriter; +import net.java.truevfs.access.TVFS; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Paths; +import java.util.Arrays; + +/** + * @author JayDi85 + */ +public class ZipFilesReadWriteTest { + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Test + public void test_Read() { + // exists + TFile fileZip = new TFile(Paths.get("src", "test", "resources", "images.zip").toString()); + Assert.assertTrue(fileZip.exists()); + TFile fileZipDir = new TFile(Paths.get("src", "test", "resources", "images.zip", "SET").toString()); + Assert.assertTrue(fileZipDir.exists()); + TFile fileZipFile = new TFile(Paths.get("src", "test", "resources", "images.zip", "SET", "image1.png").toString()); + Assert.assertTrue(fileZipFile.exists()); + + // not exists + TFile fileNotZip = new TFile(Paths.get("src", "test", "resources", "images-FAIL.zip").toString()); + Assert.assertFalse(fileNotZip.exists()); + TFile fileNotZipDir = new TFile(Paths.get("src", "test", "resources", "images.zip", "SET-FAIL").toString()); + Assert.assertFalse(fileNotZipDir.exists()); + TFile fileNotZipFile = new TFile(Paths.get("src", "test", "resources", "images.zip", "SET", "image1-FAIL.png").toString()); + Assert.assertFalse(fileNotZipFile.exists()); + + // reading + Assert.assertEquals(3, fileZipDir.list().length); + Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image1.png")); + Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image2.png")); + Assert.assertTrue(Arrays.asList(fileZipDir.list()).contains("image3.png")); + } + + @Test + public void test_write() { + try { + String zipPath = tempFolder.newFolder().getAbsolutePath(); + TFile fileWriteZip = new TFile(Paths.get(zipPath, "temp-images.zip", "DIR", "test.txt").toString()); + Assert.assertFalse(fileWriteZip.exists()); + + Writer writer = new TFileWriter(fileWriteZip); + try { + writer.write("test text"); + writer.close(); + Assert.assertTrue(fileWriteZip.exists()); + + TFileReader reader = new TFileReader(fileWriteZip); + BufferedReader br = new BufferedReader(reader); + Assert.assertEquals(br.readLine(), "test text"); + reader.close(); + } finally { + TVFS.umount(); + } + } catch (IOException e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } +} diff --git a/Mage.Tests/src/test/resources/images.zip b/Mage.Tests/src/test/resources/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..4453745230d28aad2abcd4fb9fed6bffd0a2b4d2 GIT binary patch literal 1636 zcmWIWW@h1H00Et4Ho;&9lwbkU!LA|t0YDWZKsEE3SN(hnU8dl?xRb^tLSR7GZP zVtT5fUO`?u;|@mmf1Lq-?z~)5AX9lgJzRo-G!F=KumQ=i(wOH!inG8YvKVN>5fEma zs?8_Oz`&U0>EaloaXxjDZI^VQK+9`e-iSs6=1Z()2f3LPTb{G*IvVG|_H_0uwtdaP zs{2|+Eha=x;XIu8CWBQde_7oBJ-#+h$9U&nbq_ZcEiiulwaR6ar{>+c=hL_3{`M-` zfBUW8-epV;XVZkw=1dIwwQAL80VmmHmWIh4GHIJ{PVTUg?|1KKa435CE}Frc;jzFW zh64--Bo17ar8 zB({9()Z(^|1zwtanJiibj=keEZtjRVYOA269$LH7<6Y=ihJ;A3mw*3>$GPyOZR2M! znCoZ1`}eiG_FonAH&6JJo7VsCUp50nY3%>NtMV%H9(5`|8&ed2PAmSGnHKM*d7i;* z$J%2lMv^ll7q9wWZ~r+dt-5@F*kjqOV?+UZxVff?cCd*e@Fkx{fZ5DJ|Dd0&AI;4%_VEa(wDpVeBThUZr|tcJX^2p zYVjSr_UPzpULUjYPu2BevqNr`A1aD>|F>6tm*Zv~U0d-zgFpUe|}Dsaq3@o<*m z?IkNGe($^g)u^;W_0;9UbBj$M-h4aFc4b`I|Lt>lEjBckpLAL_?XKI^=|xA@O0Bay z!=iO_qt(-O=WntLZpuBl{?w;EzKdomU4J&Wi&!U5wot*9WhC{y>=9L9q z%qeEpzVhzdFaD&}R}|-{%;LKKK|ZHDXlpKy2jhtlfv}aE|F4h8{2RaR!jt_j%k(xS z3G^jS&^GL5oXJ+i#L;|1;pn8BzZ@=`8k#mV@uh4nnI|aGd?R79q3HkiY8jCdh4YQJ z9k0?-_Q=b5Da^gF;PBEPmToZ)rf-j@8MP(pNF^_ja8_h^z`b@&dXAm*#(D1*(1(dg!* orbT4)Q<#y=2d7MI=0`k)m=B`^yjekoJOc|5mI2fE4Hgg&02y^-6aWAK literal 0 HcmV?d00001 diff --git a/Mage.Verify/pom.xml b/Mage.Verify/pom.xml index df584fd29b..5f2e558c01 100644 --- a/Mage.Verify/pom.xml +++ b/Mage.Verify/pom.xml @@ -48,7 +48,6 @@ log4j log4j - jar diff --git a/Mage/pom.xml b/Mage/pom.xml index 261fa2208f..714e344652 100644 --- a/Mage/pom.xml +++ b/Mage/pom.xml @@ -22,7 +22,6 @@ log4j log4j - jar diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java index 357d41588e..d4904a82f6 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java @@ -9,7 +9,6 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffectImpl; import mage.constants.*; import mage.game.Game; -import org.junit.Assert; import java.util.*; @@ -48,13 +47,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl { // checks for compatibility EffectType needType = EffectType.CONTINUOUS; if (effect.getEffectType() != needType) { - Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString()); + throw new IllegalArgumentException("ConditionalContinuousEffect supports only " + needType + " but found " + effect.getEffectType().toString()); } if (otherwiseEffect != null && otherwiseEffect.getEffectType() != needType) { - Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString()); + throw new IllegalArgumentException("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString()); } if (otherwiseEffect != null && effect.getEffectType() != otherwiseEffect.getEffectType()) { - Assert.fail("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString()); + throw new IllegalArgumentException("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString()); } } diff --git a/pom.xml b/pom.xml index 45a31a6691..f498f2ca3b 100644 --- a/pom.xml +++ b/pom.xml @@ -156,11 +156,13 @@ + junit junit 4.13.1 + test log4j @@ -192,6 +194,22 @@ commons-lang3 3.11 + + + net.java.truevfs + truevfs-profile-base + 0.11.1 + + + net.java.truevfs + truevfs-access-swing + + + net.java.truecommons + truecommons-key-swing + + +