我有以下控制器代码,我必须编写JUnit测试用例.
public class EquipmentController {
private Map<String, Equipment> equiList = new HashMap <String,Equipment>();
@RequestMapping("/rest/equipment/{Number}")
public Equipment getEquipment(@PathVariable String Number){
if(!equiList.containsKey(Number)){
lNumber = DEFAULT;
}
return equiList.get(Number);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在编写JUnit测试用例,如下所示:
import static org.springframework.test.web.ModelAndViewAssert.*;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({/* include live config here
e.g. "file:web/WEB-INF/application-context.xml",
"file:web/WEB-INF/dispatcher-servlet.xml" */})
public class EquipmentControllerTest {
@Inject
private ApplicationContext applicationContext;
private MockHttpServletRequest request;
private MockHttpServletResponse response;
private HandlerAdapter handlerAdapter;
private EquipmentController controller;
@Before
public void setUp() {
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
handlerAdapter = applicationContext.getBean(HandlerAdapter.class);
// Get …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮助我理解签名时间戳时使用的过程和Java API.
我需要使用TSA URL签名文件并对其加盖时间戳" http://timestamp.globalsign.com/scripts/timstamp.dll使用Java API ".
我能够使用java.security API对文件进行签名,但无法为其加时间戳.
我在表格中有几列,例如A,B,C,D和E列,我需要在HTML页面中显示.在某些页面中,我需要仅根据页面的一列显示排序结果,例如列"C"(表格的第3列).我可以使用以下代码执行此操作:
function Ascending(a, b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
var rows = $('#table tr').not(':first').get();
$('#table tr').slice(1).remove();
rows.sort(function(rowA, rowB) {
var keyA = $(rowA).children('td').eq(2).text().toUpperCase();
var keyB = $(rowB).children('td').eq(2).text().toUpperCase();
return Ascending(keyA, keyB);
});
Run Code Online (Sandbox Code Playgroud)
但我有另一个要求,其中我需要根据两列显示排序结果,即在上述情况下基于C列的排序,列E的结果也应该排序.例如:
排序前:
Column C Column E
2 Fish
1 Box
7 Cat
2 Dog
1 Apple
2 Box
2 Axe
7 Box
2 Answer
7 Apple
6 Year
2 Goat
Run Code Online (Sandbox Code Playgroud)
仅排序C列后:
Column C Column E
1 Box
1 …Run Code Online (Sandbox Code Playgroud) java ×2
html ×1
javascript ×1
jquery ×1
junit ×1
rfc3161 ×1
security ×1
sorting ×1
spring ×1
spring-mvc ×1
timestamping ×1