小编SOL*_*OLO的帖子

使用Mockito在JUnit中使用PowerMock和PowerRule获取javassist.NotFoundException

我已经将JUnit中的PowerMock和PowerRule与Mockito集成在一起.

这是我的依赖项:

<dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.0.GA</version>
      </dependency>
<dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
</dependency>

 <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
 </dependency>
 <dependency>
        <groupId>org.powermoc</groupId>
    <artifactId>powermock-module-junit4</artifactId>
    <version>1.4.12</version>
    <scope>test</scope>
    </dependency>
 <dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito</artifactId>
    <version>1.4.12</version>
    <scope>test</scope>
 </dependency>
 <dependency>
       <groupId>org.powermock</groupId>
       <artifactId>powermock-module-junit4-rule</artifactId>
       <version>1.4.12</version>
       <scope>test</scope>
 </dependency>
 <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-classloading-objenesis</artifactId>
        <version>1.4.12</version>
        <scope>test</scope>
 </dependency>
Run Code Online (Sandbox Code Playgroud)

我的测试类是:

public class TestClass extends AbstractShiroTest{
    @Rule
    public PowerMockRule rule = new PowerMockRule();
    @Autowired
    SomeService someService;
    @Before

    public void setUp(){
    Map<String, Object> newMap = new HashMap<String, Object>();
    newMap.put("userTimeZone", "Asia/Calcutta");
    Subject subjectUnderTest = mock(Subject.class);
             when(subjectUnderTest.getPrincipal()).thenReturn(LMPTestConstants.USER_NAME);
    Session session = mock(Session.class);
    when(session.getAttribute(LMPCoreConstants.USER_DETAILS_MAP)).thenReturn(newMap); …
Run Code Online (Sandbox Code Playgroud)

java junit4 mockito powermock maven

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

YUI Compressor Maven插件不压缩JS文件

我正在使用YUI Compressor压缩我的Web应用程序中的JS文件.

我已经按照插件的网站说明配置了插件.

这是POM插件conf:

   <plugin>
    <groupId>net.sf.alchim</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>0.7.1</version>  
    <executions>
      <execution>
     <phase>compile</phase>
        <goals>
         <goal>jslint</goal>
          <goal>compress</goal>
        </goals>
      </execution>
    </executions>        
    <configuration>
    <failOnWarning>true</failOnWarning>
      <nosuffix>true</nosuffix>
      <force>true</force>
      <aggregations>
       <aggregation>
          <!-- remove files after aggregation (default: false) -->
          <removeIncluded>false</removeIncluded>
          <!-- insert new line after each concatenation (default: false) -->
          <insertNewLine>false</insertNewLine>
          <output>${project.basedir}/${webcontent.dir}/js/compressedAll.js</output>
          <!-- files to include, path relative to output's directory or absolute path-->
          <!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
          <includes>                
            <include>**/autocomplete.js</include>
            <include>**/calendar.js</include>
            <include>**/dialogs.js</include>
            <include>**/download.js</include>
            <include>**/folding.js</include>
            <include>**/jquery-1.4.2.min.js</include>
            <include>**/jquery.bgiframe.min.js</include> …
Run Code Online (Sandbox Code Playgroud)

maven-2 yui-compressor

6
推荐指数
2
解决办法
9849
查看次数

org.hibernate.exception.SQLGrammarException: could not prepare statement

I have created two entities and am trying to fill one with data after loading it, to show it as a drop down list.

I got the error

org.hibernate.exception.SQLGrammarException: could not prepare statement

The Group entity that must be in the drop down list is:

@Entity
@Table(name="GROUP")
public class Group implements Serializable,Lifecycle{

    /**
     * 
     */
    private static final long serialVersionUID = 5551707547269388327L;
    @Id
    @Column(name="ID")
    @GeneratedValue
    private int id;
    @Column(name="E_NAME")
    private String eName;
    @Column(name="A_NAME")
    private String aName;

    public int getId() { …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa

6
推荐指数
3
解决办法
4万
查看次数

JAWS Screen Reader读取页面标题两次

我有一个简单的ASPX页面,如下所示:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test JAWS</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divBody">
        <div id="header">
            <h1>Simple ASPX page</h1>
        </div>
    </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在使用JAWS测试页面时,我注意到页面标题被读取了两次(主要是在Firefox中).在其他浏览器中,例如IE和Chrome,它会以不同的方式读取.

有没有人有同样的问题?我的代码出了什么问题?

jaws-screen-reader

5
推荐指数
0
解决办法
855
查看次数

React JSX在不导入React的情况下工作

我正在尝试运行我的第一个React JSX文件,它可以工作!但是,我的JSX中没有这两个import语句:

import React from 'react';
import ReactDOM from 'react-dom';
Run Code Online (Sandbox Code Playgroud)

我以为我需要这两个导入,以便当JSX被编译为JS(由React.createElement)时,React组件将在范围内。但是,即使没有两个进口,它似乎也能正常工作。

没有进口商品怎么办?

这是我的代码:

script.jsx:

var Main = React.createClass({
    getIntialState: function () {
        return {
            counter: 0
        };
    },
    clickHandler: function () {
        return {
            counter: this.state.counter + 1
        };
    },
    render: function () {
        return (
            <button onClick={this.clickHandler}>+2</button>
        )
    }
});
Run Code Online (Sandbox Code Playgroud)

package.json

{
  "name": "reactjs",
  "version": "1.0.0",
  "description": "",
  "main": "react.js",
  "dependencies": {
    "webpack": "^1.13.3"
  },
  "devDependencies": {
    "babel-cli": "^6.18.0",
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.8",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0", …
Run Code Online (Sandbox Code Playgroud)

reactjs

5
推荐指数
0
解决办法
6954
查看次数

C#或Java中是否存在格式化字符串漏洞?

我已经了解了C++中的格式字符串漏洞,但C++是一种古老的语言.我想知道格式字符串漏洞是否仍然存在于现代语言中,如C#和Java.

security

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

JUnit5 tests work fine with maven but not when run through Eclipse, "No tests found with test runner 'JUnit 5'."

I'm getting a pop-up window with title "Could not run test" and message "No tests found with test runner 'JUnit 5'." when I try to run JUnit 5 tests with Eclipse via Run As > JUnit Test.

I have two test-related files. One is a test suite:

...

import org.junit.jupiter.api.BeforeAll;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.runner.RunWith;

@RunWith(JUnitPlatform.class)
@SelectPackages("com.foo.stufftotest")

public class TestSuite {
    @BeforeAll
    public static void setup() {
        ...
Run Code Online (Sandbox Code Playgroud)

The other contains the "actual" tests:

package com.foo.stufftotest;

import static …
Run Code Online (Sandbox Code Playgroud)

eclipse maven junit5

4
推荐指数
2
解决办法
2476
查看次数

IntelliJ IDEA中的“同步”有什么作用?

在IntelliJ IDEA的,有一个叫做动作同步,下File > Synchronize

它到底是做什么的?它与VCS或IntelliJ的编辑历史有关吗?我如何使用此动作> _ <

“同步”作为动作列表中的条目出现

intellij-idea

3
推荐指数
1
解决办法
947
查看次数

为什么带有Spring Boot的Keycloak教程不起作用?

我一直在尝试遵循DZone的Keycloak教程(编辑:这似乎是官方Keycloak博客上的教程,几乎是同一作者的逐字逐句转贴),但是我遇到了以下问题:

  • index.html 找不到

  • 单击内部页面的链接时,错误

    我们很抱歉...

    找不到网页

  • 在同一页面上,错误

    javax.servlet.ServletException:循环视图路径[products]:将再次分派回当前的处理程序URL [/ products]。

  • 出现Keycloak管理面板,而不是示例应用程序

我究竟做错了什么?

keycloak

3
推荐指数
1
解决办法
367
查看次数

在本地调试两个 Azure Functions 项目

我有两个 Azure Functions 项目。

我有一个项目 A 正在运行 localhost:7071/api/....

项目 A 的控制台输出,显示端口 7071

我已经更改了另一个项目 B 来运行 localhost:8888/api/...

项目 B 的控制台输出,显示端口 8888

我正在从项目 B 中的函数调用在项目 A 上运行的函数!如何在本地调试两个 Azure Functions 项目?我找不到任何文档来帮助我。

azure azure-web-app-service azure-functions azure-functions-runtime azure-functions-core-tools

3
推荐指数
1
解决办法
1613
查看次数