小编Dom*_*Dom的帖子

Mockito 替换方法

我有一个班级:

    public class ProductComercialOrderDAO  extends BaseDao implements ProductComercialOrderDAOLocal  {

    private final static Logger log = UtilsBusiness.getLog4J(ProductComercialOrderDAO.class);

    public Session getSession() throws DAOServiceException{
        return super.getSession();
    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void createProductComertialOrder(ProductComertialOrder pcom) throws DAOServiceException, DAOSQLException {

        log.debug("== Init createProductComertialOrder/ProductComercialOrderDAO ==");
        Session session = this.getSession();
        try {
            session.save(pcom);
            this.doFlush(session);
        } catch (Throwable ex) {
            log.error("== Exception in ProductComertialOrder ==");
            throw super.manageException(ex);
        } finally {
            log.debug("== createProductComertialOrder/ProductComercialOrderDAO End ==");
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

我需要模拟该方法:

public Session getSession() throws DAOServiceException{
    return super.getSession();
}
Run Code Online (Sandbox Code Playgroud)

用于在 jUnit 测试阶段替换 …

java hibernate mockito

5
推荐指数
1
解决办法
9033
查看次数

尝试卸载Anaconda时权限被拒绝错误

我的电脑:Mac Book Pro,OS X Yosemite

我正在尝试使用以下命令卸载anaconda。

rm -rf ~/anaconda
Run Code Online (Sandbox Code Playgroud)

但是我得到了很多类似这样的权限被拒绝的行

rm: /Users/myname/anaconda/lib/python2.7/site-packages/oauthlib/__init__.py: Permission denied
Run Code Online (Sandbox Code Playgroud)

非常感谢您的建议。

permission-denied anaconda

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

在Nose中从time.time()伪造时间戳

我正在构建一个设备对象来从python中连接设备轮询数据,我正在尝试使用nose测试对象及其所有功能的交互操作.我在编写时间戳时遇到问题,time.time()因为每次调用函数时结果值都不同,这严重搞砸了一些测试,例如这个数据收集函数:

def getData(self, data):
    if type(data) is not type({}):
        #print "Bad Type!"
        raise TypeError
    else:
        #print "Good Type!"
        self.outD = {}
        datastr = ""
        for key, value in data.iteritems():
            self.outD[key] = value
        self.outD["timestamp"] = time.time()
        self.outD["id"] = self.id
        self._writeCSV()
Run Code Online (Sandbox Code Playgroud)

当我测试此函数的输出并比较生成的CSV文件时,它总是因时间戳而失败.我可以通过添加测试标志在我的设备对象中将其分出来,但我想知道是否有一个内置的方法来处理这样的问题,其中函数的结果可以用给定的值替换或本地函数伪造的time.time()通话.这可能吗?

python unit-testing timestamp nose

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

Git 分支 vs Git fork

我有一个普遍的疑问。假设有一个以 master 分支为开发分支的 git repo,你想在不影响 master 分支的情况下进行一些更改,然后你想稍后合并它。什么是更好的方法?

  1. 在同一个 repo 中创建新分支,然后将其合并到 master。
  2. 通过分叉创建新的 repo,然后将其合并到 master。

git git-branch

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

java.io.FileNotFoundException:无法打开[WEB-INF/spring-servlet.xml],因为它不存在

/src/main/java/com/application/myGoogleAppEngine/controller/AddressController.java,我想使用此说明在以下后面使用bean:

ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/WEB-INF/spring-servlet.xml");
Run Code Online (Sandbox Code Playgroud)

我的spring-servlet.xml文件位于/src/main/webapp/WEB-INF/目录中.

当我执行我的spring应用程序时,我遇到以下错误:

java.io.FileNotFoundException: class path resource [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)

在我的记忆中,我知道我们可以使用函数来获取项目的当前目录,但我不记得了.

否则,你有什么解决方案吗?

谢谢

java spring spring-mvc

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

git clone x as"y" - (在本地重命名repo)

这是git clone的文档

https://git-scm.com/docs/git-clone

通常我们会像这样克隆一个回购

git clone x
Run Code Online (Sandbox Code Playgroud)

但是,我想在本地重命名存储库,所以它将类似于

git clone x as y
Run Code Online (Sandbox Code Playgroud)

看看文档,目前尚不清楚这是可能的还是犹太教的,是否有人知道如何做到这一点?

它看起来像这样:

git clone x y
Run Code Online (Sandbox Code Playgroud)

根据文件:

<repository>

    The (possibly remote) repository to clone from. See the URLS section below for more information on specifying repositories.
<directory>

    The name of a new directory to clone into. The "humanish" part of the source repository is used if no directory is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning into an existing directory is only allowed if …
Run Code Online (Sandbox Code Playgroud)

git git-clone

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