我没有得到适当的jar文件为PowerMock模拟私人方法?

时间:2015-12-31 08:50:47

标签: java junit powermockito

我正在尝试模拟私有方法,但我无法为PowerMockito加载正确的jar文件。我曾经遇到像

这样的错误
private void setXmppConnection() {
        if (this.XMPP_CONNECTION == null) {
            this.CONN_CONFIG = new ConnectionConfiguration(MyGlobals.HOST,
                    MyGlobals.PORT, MyGlobals.SERVICE);
            this.CONN_CONFIG
                    .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
            this.CONN_CONFIG.setSASLAuthenticationEnabled(false);
            this.XMPP_CONNECTION = new XMPPConnection(this.CONN_CONFIG);
        }
    }

public void connectToChatServer() {
        new AsyncTask<String, Void, Void>() {
            @Override
            protected Void doInBackground(String... params) {

                try {
                    XMPP_CONNECTION.connect();
                    openFireUsername = String.valueOf(sharedPreferences.getInt(
                            "userID", -1));
                    openFirePassword = sharedPreferences.getString("password",null);
                    Log.d(MyGlobals.TAG, "open fire username"+ openFireUsername);
                    Log.d(MyGlobals.TAG, "open fire password"+ openFirePassword);
                    XMPP_CONNECTION.login(openFireUsername, openFirePassword);
                    Presence presence = new Presence(Presence.Type.available);
                    XMPP_CONNECTION.sendPacket(presence);
                    connectedToChatServer = true;
                } catch (XMPPException localXMPPException) {
                    localXMPPException.printStackTrace();
                } catch (Error localError) {
                }
                return null;
            }

        }.execute(null, null, null);
    }

0 个答案:

没有答案