老师真的不是查了好久实在没办法了 刚开始是数据库连接不上 我是8.0mysql跟据别人的问题 改了一下 有p3c0有问题 百度之后 解决之后又这样了

来源:2-6 逐层完成SSM的各项配置

qq_慕仰8311381

2020-02-06

二月 06, 2020 2:24:21 下午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
信息: Initializing c3p0 pool… com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 2, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 10000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0ywa86zf99s1ykpcs4|7adda9cc, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.cj.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0ywa86zf99s1ykpcs4|7adda9cc, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:3306/o2o?useSSL=false&characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
14:24:21.951 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@65987993] will not be managed by Spring
14:24:21.957 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - ==> Preparing: SELECT area_id,area_name,priority,create_time,last_edit_time FROM tb_area ORDER BY priority DESC
14:24:21.990 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - > Parameters:
14:24:22.022 [main] DEBUG com.imooc.o2o.dao.AreaDao.queryArea - < Total: 2
14:24:22.029 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5e2c3d18]
二月 06, 2020 2:24:22 下午 org.springframework.context.support.GenericApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@2a2d45ba: startup date [Thu Feb 06 14:24:20 GMT+08:00 2020]; root of context hierarchy
junit信息
java.lang.AssertionError: expected:<2> but was:<[Area [areaId=3, areaName=西园, priority=2, createTime=null, lastEditTime=null], Area [areaId=2, areaName=东晚, priority=1, createTime=null, lastEditTime=null]]>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.imooc.o2o.dao.AreaDaoTest.testQueryArea(AreaDaoTest.java:20)
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.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
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.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

实在想不知道咋办 老师

写回答

2回答

leeeeeem

2020-02-06

我猜是assertEquals函数中的参数有问题

1
1
qq_慕仰8311381
谢谢学长 果然是那个问题 我一直没考虑 我一直觉得是自己mysql版本
2020-02-07
共1条回复

翔仔

2020-02-07

同学好,这个就是ut的目的啊,来验证你的程序是否符合预期,根据你提前设置好的预期,实际值是不符合的,所以会报错

java.lang.AssertionError: expected:<2> but was:<[Area [areaId=3, areaName=西园, priority=2, createTime=null, lastEditTime=null], Area [areaId=2, areaName=东晚, priority=1, createTime=null, lastEditTime=null]]>

并不是程序报了啥异常所以肯定查不到。。

这你的期望值是2,然后实际值你给它指定了一个对象,肯定报错呢,你应该是获取size大小 size是2才能通过验证,你这里是[Area [areaId=3, areaName=西园, priority=2, createTime=null, lastEditTime=null], Area [areaId=2, areaName=东晚, priority=1, createTime=null, lastEditTime=null]] 用一个数组对象来和数字杜比,肯定有问题啊,但是你的数组是两个元素,应该是符合预期的。。建议多看几次视频,理解一下ut是干嘛的。。

0
1
qq_慕仰8311381
谢谢老师 解释的很详细 我直接找到了问题所在 本来还准备重装mysql还好没有卸载
2020-02-07
共1条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程