Comments (11)
Jérémy I have tried to import next json file as pakko suggested but completing with missing information and the exception was thrown.
{
"name":"",
"replicationFactor":"",
"strategy":"",
"columnFamilies":[
{
"name":"at_workreq",
"type":"STANDARD",
"keyType":"TimeUUIDType",
"comparatorType":"UTF8Type",
"defaultColumnValueType":"UTF8Type",
"rows":[
{
"key":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5",
"columns":[
{
"name":"WORKREQUEST",
"value":[
{
"name":"device",
"value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F6"
},
{
"name":"timeuuid",
"value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5"
},
{
"name":"workReqTargetList",
"value":[
{
"name":"name",
"value":"989C6E5C-2CC1-11CA-A044-08002B1BB4F6"
},
{
"name":"cfgGUID",
"value":"cfgGUID"
},
{
"name":"fwGUID",
"value":"firmwareGUID"
},
{
"name":"cpu",
"value":"90.0"
}
]
}
]
}
]
}
]
}
]
}
in this case I am going to close the issue opened in nosqlunit about the same thing. If you plan to fix this problem, we can stay connected because I will need to make some modifications too.
from cassandra-unit.
Hi,
as defined in the dataSet you attached, the defaut type for column value is set to utf8 type. So you just have to make a valid string containing a valid json inside.
So :
- surround the json with double quote
- replace inside the json string the double quote with simple quote
it will give something like hat :
"name":"blabla",
"columnFamilies":[
{
"name":"at_workreq",
"type":"STANDARD",
"keyType":"TimeUUIDType",
"comparatorType":"UTF8Type",
"defaultColumnValueType":"UTF8Type",
"rows":[
{
"key":"989C6E5C-2CC1-11CA-A044-08002B1BB4F5",
"columns":[
{
"name":"WORKREQUEST",
"value":"[{'name':'device','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F6'},{'name':'timeuuid','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F5'},{'name':'workReqTargetList','value':[{'name':'name','value':'989C6E5C-2CC1-11CA-A044-08002B1BB4F6'},{'name':'cfgGUID','value':'cfgGUID'},{'name':'fwGUID','value':'firmwareGUID'},{'name':'cpu','value':'90.0'}]}]"
}
]
}
]
}
]
}
from cassandra-unit.
yes you are right I have not seen this as a simple json string, I suppose that pakko means this approach too and I have been confused with some kind of recursive values. Well inthis case all works perfectly, cassandra unit and nosqlunit.
Thanks.
from cassandra-unit.
right. @pakko , tell me if it's ok for you.
from cassandra-unit.
Thanks Jérémy, after revise my test data as your suggestion, it will not throw parser error exception, but a NoSqlAssertion error, maybe it is nosqlunit issue
from cassandra-unit.
nice :-)
from cassandra-unit.
you are right, now the problem is in NoSQLUnit, I will take a look, and see what is returned in each case, I will use the Jérémy approach to test it.
from cassandra-unit.
BTW, when I use expected_workrequest.json as I pasted in @UsingDataSet annotation, it will throw such exception
java.lang.RuntimeException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1017)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.getDeviceResponseById(MonitoringNoSQLDao.java:983)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDaoRemoteCassandraTest.testGetDeviceResponseById_WorkRequest(MonitoringNoSQLDaoRemoteCassandraTest.java:404)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at com.lordofthejars.nosqlunit.core.AbstractNoSqlTestRule$1.evaluate(AbstractNoSqlTestRule.java:72)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:791)
at com.google.gson.Gson.fromJson(Gson.java:757)
at com.google.gson.Gson.fromJson(Gson.java:706)
at com.google.gson.Gson.fromJson(Gson.java:678)
at com.cisco.onplus.das.server.dao.monitoring.NosqlJsonConverter.formulateObject(NosqlJsonConverter.java:29)
at com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1009)
... 28 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:322)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)
... 34 more
from cassandra-unit.
I think that problem is in your DAO in this case because I think you are using gson as parser in com.cisco.onplus.das.server.dao.monitoring.MonitoringNoSQLDao.queryDeviceResponseDataById(MonitoringNoSQLDao.java:1017) throws an exception of invalid json entry, nothing to related with cassandraunit nor nosqlunit.
from cassandra-unit.
Thanks, I will check it
from cassandra-unit.
Ok, this afternoon I will check nosqlunit too using " approach.
from cassandra-unit.
Related Issues (20)
- Cassandra-unit, Integration test during org.springframework.boot:spring-boot-maven-plugin:X.X.X.RELEASE:start (pre-integration-test)
- “NoSuchMethodErrors” due to multiple versions of io.dropwizard.metrics:metrics-core:jar HOT 3
- Vesion bump Cassandra Server to 4.x release to support migration to JDK11. HOT 6
- Unable to check disk space available to target/embeddedCassandra/commitlog HOT 2
- Add an isRunning method to EmbeddedCassandraServerHelper
- log4j config copy fails in EmbeddedCassandraServerHelper HOT 1
- Upgrade hibernate-validator HOT 6
- InvalidQueryException: Virtual keyspace 'system_views' is not user-modifiable when using Cassandra4 with .InvalidQueryException: Virtual keyspace 'system_views' is not user-modifiable HOT 1
- cassandra-unit not working for libthrift 0.14.0 version
- [2021-06-14T14:58:06.055Z] org.apache.cassandra.exceptions.ConfigurationException: Unable to check disk space available to target/embeddedCassandra/commitlog. Perhaps the Cassandra user does not have the necessary permissions HOT 1
- com.datastax.oss.driver.api.core.servererrors.InvalidQueryException: Virtual keyspace 'system_views' is not user-modifiable
- ClassNotFoundException: org.apache.cassandra.thrift.Cassandra$Iface HOT 1
- CU hangs on CommitLog creation with Java 17 - Update cassandra-all to 4.0.1 to support Java 17 HOT 3
- Misleading error message in YamlConfigurationLoader.loadConfig(): "Invalid yaml"
- Windows 10: Expecting URI in variable
- Guava library issue post 25 jre
- Is this project still alive? HOT 2
- Version for Cassandra 3.11.11
- Using cassandra-unit with M1 (ARM64), JDK11 and cassandra v3
- Support for snakeyaml 2.0 due to various CVEs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cassandra-unit.