mvn package 构建 FakeSMTP failure

1. 下载源码

git clone git@github.com:Nilhcem/FakeSMTP.git

2. mvn package

错误可能如下:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project fakesmtp: There are test failures

Tests in error:
  testInvalidHost(com.nilhcem.fakesmtp.model.UIModelTest): Unexpected exception, expected<com.nilhcem.fakesmtp.core.exception.InvalidHostException> but was<java.lang.IllegalStateException

FakeSMTP (master) ✔ mvn package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.nilhcem.fakesmtp:fakesmtp:jar:2.1-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter. @ line 149, column 20
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -------------------< com.nilhcem.fakesmtp:fakesmtp >--------------------
[INFO] Building Fake SMTP 2.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fakesmtp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ fakesmtp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 45 source files to /Users/luoyu/Tech/K8S/FakeSMTP/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fakesmtp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/luoyu/Tech/K8S/FakeSMTP/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ fakesmtp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /Users/luoyu/Tech/K8S/FakeSMTP/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ fakesmtp ---
[INFO] Surefire report directory: /Users/luoyu/Tech/K8S/FakeSMTP/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.nilhcem.fakesmtp.core.server.SMTPServerHandlerTest
11 二月 2022 17:51:11 INFO  org.subethamail.smtp.server.SMTPServer - SMTP server *:9999999 starting
11 二月 2022 17:51:11 ERROR com.nilhcem.fakesmtp.server.SMTPServerHandler - Port 9999999 out of range.
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.28 sec
Running com.nilhcem.fakesmtp.core.server.MailServerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.017 sec
Running com.nilhcem.fakesmtp.core.I18nTest
11 二月 2022 17:51:11 ERROR com.nilhcem.fakesmtp.core.I18n - Can't find resource for bundle java.util.PropertyResourceBundle, key this.key.doesnt.exist
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Running com.nilhcem.fakesmtp.core.ConfigurationTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec
Running com.nilhcem.fakesmtp.model.UIModelTest
11 二月 2022 17:51:11 INFO  org.subethamail.smtp.server.SMTPServer - SMTP server *:2626 starting
11 二月 2022 17:51:11 INFO  org.subethamail.smtp.server.ServerThread - SMTP server *:2626 started
11 二月 2022 17:51:13 INFO  org.subethamail.smtp.server.SMTPServer - SMTP server INVALID/30.8.56.34:2626 starting
11 二月 2022 17:51:13 ERROR com.nilhcem.fakesmtp.server.SMTPServerHandler -
java.lang.IllegalStateException: SMTPServer can only be started once
	at org.subethamail.smtp.server.SMTPServer.start(SMTPServer.java:281) ~[subethasmtp-3.1.7.jar:June 16 2012]
	at com.nilhcem.fakesmtp.server.SMTPServerHandler.startServer(SMTPServerHandler.java:43) ~[classes/:na]
	at com.nilhcem.fakesmtp.model.UIModel.toggleButton(UIModel.java:64) [classes/:na]
	at com.nilhcem.fakesmtp.model.UIModelTest.testInvalidHost(UIModelTest.java:33) [test-classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_271]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_271]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_271]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_271]
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) [surefire-junit4-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) [surefire-junit4-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) [surefire-junit4-2.12.4.jar:2.12.4]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_271]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_271]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_271]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_271]
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) [surefire-api-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) [surefire-booter-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) [surefire-booter-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) [surefire-booter-2.12.4.jar:2.12.4]
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) [surefire-booter-2.12.4.jar:2.12.4]
Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.107 sec <<< FAILURE!
testInvalidHost(com.nilhcem.fakesmtp.model.UIModelTest)  Time elapsed: 1.08 sec  <<< ERROR!
java.lang.Exception: Unexpected exception, expected<com.nilhcem.fakesmtp.core.exception.InvalidHostException> but was<java.lang.IllegalStateException>
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.IllegalStateException: SMTPServer can only be started once
	at org.subethamail.smtp.server.SMTPServer.start(SMTPServer.java:281)
	at com.nilhcem.fakesmtp.server.SMTPServerHandler.startServer(SMTPServerHandler.java:43)
	at com.nilhcem.fakesmtp.model.UIModel.toggleButton(UIModel.java:64)
	at com.nilhcem.fakesmtp.model.UIModelTest.testInvalidHost(UIModelTest.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19)
	... 21 more


Results :

Tests in error:
  testInvalidHost(com.nilhcem.fakesmtp.model.UIModelTest): Unexpected exception, expected<com.nilhcem.fakesmtp.core.exception.InvalidHostException> but was<java.lang.IllegalStateException>

Tests run: 16, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.473 s
[INFO] Finished at: 2022-02-11T17:51:13+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project fakesmtp: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/luoyu/Tech/K8S/FakeSMTP/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

3. 解决

FakeSMTP – Developer FAQ。【感谢大佬】

从错误来看是执行测试用例的时候失败了。哈哈哈,那么最合适的做法就是跳过单元测试

FakeSMTP (master) ✔ mvn package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.nilhcem.fakesmtp:fakesmtp:jar:2.1-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter. @ line 149, column 20
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -------------------< com.nilhcem.fakesmtp:fakesmtp >--------------------
[INFO] Building Fake SMTP 2.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fakesmtp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ fakesmtp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 45 source files to /Users/luoyu/Tech/K8S/FakeSMTP/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ fakesmtp ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ fakesmtp ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ fakesmtp ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ fakesmtp ---
[INFO] Building jar: /Users/luoyu/Tech/K8S/FakeSMTP/target/fakeSMTP-2.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-assembly-plugin:2.5.4:attached (default) @ fakesmtp ---
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-archiver/2.10/plexus-archiver-2.10.pom
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-archiver/2.10/plexus-archiver-2.10.pom (5.4 kB at 1.2 kB/s)
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-io/2.6/plexus-io-2.6.pom
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-io/2.6/plexus-io-2.6.pom (0 B at 0 B/s)
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.pom
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.pom (0 B at 0 B/s)
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.pom
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.pom (0 B at 0 B/s)
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-repository-builder/1.0/maven-repository-builder-1.0.pom
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-repository-builder/1.0/maven-repository-builder-1.0.pom (0 B at 0 B/s)
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-archiver/2.10/plexus-archiver-2.10.jar
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.jar
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-io/2.6/plexus-io-2.6.jar
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
Downloading from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-repository-builder/1.0/maven-repository-builder-1.0.jar
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-io/2.6/plexus-io-2.6.jar (0 B at 0 B/s)
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar (0 B at 0 B/s)
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.jar (0 B at 0 B/s)
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/apache/maven/shared/maven-repository-builder/1.0/maven-repository-builder-1.0.jar (0 B at 0 B/s)
Downloaded from tbmirror-all: http://mvnrepo.alibaba-inc.com/mvn/repository/org/codehaus/plexus/plexus-archiver/2.10/plexus-archiver-2.10.jar (372 kB at 1.1 MB/s)
[WARNING] Artifact: com.nilhcem.fakesmtp:fakesmtp:jar:2.1-SNAPSHOT references the same file as the assembly destination file. Moving it to a temporary location for inclusion.
[INFO] Building jar: /Users/luoyu/Tech/K8S/FakeSMTP/target/fakeSMTP-2.1-SNAPSHOT.jar
[WARNING] Configuration options: 'appendAssemblyId' is set to false, and 'classifier' is missing.
Instead of attaching the assembly file: /Users/luoyu/Tech/K8S/FakeSMTP/target/fakeSMTP-2.1-SNAPSHOT.jar, it will become the file for main project artifact.
NOTE: If multiple descriptors or descriptor-formats are provided for this project, the value of this file will be non-deterministic!
[WARNING] Replacing pre-existing project main-artifact file: /Users/luoyu/Tech/K8S/FakeSMTP/target/archive-tmp/fakeSMTP-2.1-SNAPSHOT.jar
with assembly file: /Users/luoyu/Tech/K8S/FakeSMTP/target/fakeSMTP-2.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.871 s
[INFO] Finished at: 2022-02-11T17:53:16+08:00
[INFO] ------------------------------------------------------------------------

 

4. 启动【完美】

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值