小编isl*_*lon的帖子

具有会话支持的Spring mvc 3.1集成测试

我正在使用3.1版本中的新弹簧测试来运行集成测试.它工作得很好,但我不能使会话工作.我的代码:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration("src/main/webapp")
@ContextConfiguration({"classpath:applicationContext-dataSource.xml",
      "classpath:applicationContext.xml",
      "classpath:applicationContext-security-roles.xml",
      "classpath:applicationContext-security-web.xml",
      "classpath:applicationContext-web.xml"})
public class SpringTestBase {

    @Autowired
    private WebApplicationContext wac;
    @Autowired
    private FilterChainProxy springSecurityFilterChain;
    @Autowired
    private SessionFactory sessionFactory;

    protected MockMvc mock;
    protected MockHttpSession mockSession;

    @Before
    public void setUp() throws Exception {
       initDataSources("dataSource.properties");

       mock = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
       mockSession = new MockHttpSession(wac.getServletContext(), UUID.randomUUID().toString());
    }

    @Test
    public void testLogin() throws Exception {
        // this controller sets a variable in the session
        mock.perform(get("/")
            .session(mockSession))
            .andExpect(model().attributeExists("csrf"));

        // I set another variable here just to be sure
        mockSession.setAttribute(CSRFHandlerInterceptor.CSRF, csrf); …
Run Code Online (Sandbox Code Playgroud)

java testing spring spring-mvc

18
推荐指数
2
解决办法
2万
查看次数

为什么clojurescript宏不能用clojurescript写?

虽然clojure和clojurescript功能基本相同(除了明显的差异),但宏不是.当我想要一个clojurescript中的宏时,我必须在clojure中编写它并且需要它与require-macros.这是javascript的技术限制还是仅仅是设计决策?为什么不能两者都一样?

clojure clojurescript

15
推荐指数
1
解决办法
1904
查看次数

如何使用带连接的查询从jOOQ中的一个表中进行选择?

我在jOOQ中有以下查询:

factory()
.select()
.from(PERSON)
.join(ENDUSER).on(ENDUSER.PERSON_FK.equal(PERSON.ID))
.where(ENDUSER.ID.equal(userId))
.fetchOne();
Run Code Online (Sandbox Code Playgroud)

这个查询返回给我一个记录,包含PERSON和ENDUSER的所有列,但我只想要PERSON的列(这就是我放弃的原因.from(PERSON)而不是.from(PERSON, ENDUSER)).我知道这并不重要,但我不希望返回不必要的字段.

java mysql jooq

11
推荐指数
2
解决办法
4326
查看次数

HTML/Javascript从img src属性中删除数据

我的页面中有一个空的img <img ... src=""/>

当事件发生时,我将img属性设置为内联png数据:

<img ... src="data:image/png;base64,..."/>

当另一个事件发生时,我设置src到什么(删除图片):myImg.src = ""

问题是:当我将src设置为空时,img不会重新加载.如果我隐藏了img,请等一段时间然后重新显示它有效,但这是一个丑陋的黑客......

PS:我不想设置默认的"空白"图像我需要它真的是空白的(src ="").

编辑:我的javascript:

biometria.setImage = function(png) {
    if(png)
        bioCanvas.src = 'data:image/png;base64,' + png;
    else
        bioCanvas.src = '';
};
Run Code Online (Sandbox Code Playgroud)

Edit2:浏览器:谷歌浏览器18.0.1025.162 Ubuntu 12.04

html javascript image

8
推荐指数
2
解决办法
2万
查看次数

MongoDB删除不在fs.files中的fs.chunks

我在fs.chunks中有10 GB的数据,我想删除不在fs.files上的每个文件.我已经删除了我不想要的fs.files中的每个条目,因此fs.files中的每个id都是我想保留的文件.

所以,我想要类似db.fs.chunks.remove({"_id": {$nin: fs.files._id}})或"删除fs.funks中不存在的fs.files中的每个条目".

编辑:我正在寻找相当于SQL的mongo delete from fs_chunks where id not in (select id from fs_files).

mongodb

4
推荐指数
1
解决办法
3851
查看次数

标签 统计

java ×2

clojure ×1

clojurescript ×1

html ×1

image ×1

javascript ×1

jooq ×1

mongodb ×1

mysql ×1

spring ×1

spring-mvc ×1

testing ×1