我写了Spring控制器Junits。我使用JsonPath使用来从JSON获取所有ID ["$..id"]。
我有以下作为测试方法:
mockMvc.perform(get(baseURL + "/{Id}/info", ID).session(session))
.andExpect(status().isOk()) // Success
.andExpect(jsonPath("$..id").isArray()) // Success
.andExpect(jsonPath("$..id", Matchers.arrayContainingInAnyOrder(ar))) // Failed
.andExpect(jsonPath("$", Matchers.hasSize(ar.size()))); // Success
Run Code Online (Sandbox Code Playgroud)
以下是我传递的数据:-
List<String> ar = new ArrayList<String>();
ar.add("ID1");
ar.add("ID2");
ar.add("ID3");
ar.add("ID4");
ar.add("ID5");
Run Code Online (Sandbox Code Playgroud)
我收到以下失败消息:
Expected: [<[ID1,ID2,ID3,ID4,ID5]>] in any order
but: was a net.minidev.json.JSONArray (<["ID1","ID2","ID3","ID4","ID5"]>)
Run Code Online (Sandbox Code Playgroud)
问题是:如何使用JSONArray进行处理?org.hamcrest.Matchers;有没有使用JSONPath的简单方法。
设置: - ,,hamcrest-all-1.3 jarjson-path-0.9.0.jarspring-test-4.0.9.jar
我有布尔字段作为
private boolean isCustom;
Run Code Online (Sandbox Code Playgroud)
有吸气剂和制定者
public boolean isCustom() {
return isCustom;
}
public void setCustom(boolean isCustom) {
this.isCustom = isCustom;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我的JSON将是 {"custom":false}
但我想要JSON {"isCustom":false}
所以我添加了@JsonProperty:
@JsonProperty
private boolean isCustom;
Run Code Online (Sandbox Code Playgroud)
但是现在我的JSON还有另外一个问题 {"isCustom":false,"custom":false}
问:在这种情况下,如何消除不需要的/重复的字段?
注意:我使用的是jackson-all-1.9.11.jar
我有本体论,其中有另一个本体论.我想知道如何OWLOntologyManager的loadOntologyFromOntologyDocument(OWLOntologyDocumentSource documentSource, OWLOntologyLoaderConfiguration config)内部工作原理.我已经使用OWLOntologyLoaderConfiguration类来处理Missing Imports(想知道在MissingImportListener类的帮助下哪个导入失败).
我能听到丢失的进口.但是,如果我的任何本体文件导入了WEB资源,则上面的方法从其位置获取它.有什么方法可以限制对WEB资源的调用,并要求加载我在系统中的副本吗?
例如,如果BBC的运动本体加载方法在内部加载本体:
就像在Protege中打开BBC的运动本体一样.
根据OWL DL的原始OWL定义,我们不能给一个类和一个人赋予相同的名称(这是OWL DL和OWL Full之间的明显区别)."Punning"在OWL 2中引入并删除了此限制.所以我可以为一个类和一个人(以及一个属性)赋予相同的名称.
OWL是否在语义上将它们视为相同或不同?(两者都有相同的名称,因此它们在语法上是相同的.)这些实体(具有相同的IRI)是同一个吗?[与OWL一样,一切都只与IRI有关]
我有一个项目是另一个项目的一部分。我正在使用Maven构建过程来制作项目的jar。我使用ProGuard对其进行了模糊处理。我有一些控制器可以处理UI请求。
问:我的问题是未混淆的jar正在工作。所有控制器都被命中,但是混淆的jar无法正常工作(没有控制器被命中)。混淆有什么问题?
我的Servlet.XML:
<context:component-scan base-package="myPackage.controllers" />
<mvc:annotation-driven />
Run Code Online (Sandbox Code Playgroud)
样例控制器代码:
package myPackage.controllers.information;
import myPackage.beans.InfoBean;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@RestController
@RequestMapping("/information")
public class InformationController {
@RequestMapping(method = RequestMethod.GET)
public return_bean getAllInformation() {
//some logic
}
@RequestMapping(value = "/{infoId}", method = RequestMethod.PUT)
public return_bean updateInformation(@PathVariable String InfoId, @RequestBody InfoBean info) {
// some logic
}
}
Run Code Online (Sandbox Code Playgroud)
我与ProGuard相关的POM.XML内容:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.13</version>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<goals> …Run Code Online (Sandbox Code Playgroud)