问题列表 - 第16299页

为什么我的会话在使用PerformanceTest而不是IntegrationTest时会过期?

好吧,我正在编写性能测试,并且无法像在集成测试中那样保持会话持续存在.据我所知,PerformanceTest是IntegrationTest的子代,任何集成测试都应该与性能测试一起使用.但是,当我进行集成测试并将其复制到性能时,将ActionController :: IntegrationTest更改为ActionController :: PerformanceTest,然后运行测试,它会失败.

我正在使用Authlogic并且没有遇到集成测试会话的问题.通过性能测试虽然看起来会正确创建会话但是当我访问"/ reports"页面(这是一个受保护的页面)时,它会将我重定向到登录页面,就像根本没有用户会话一样.

require 'performance_test_help'

class SimpleTest < ActionController::PerformanceTest
  setup :activate_authlogic

  test "login" do
    assert user_session = UserSession.create!(User.find_by_login("admin"))

    get "/reports"
    assert_response :success
  end
end
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?我已经尝试了多种方式来获得用户会话(创建,发布等),似乎没有任何工作.这是我第一次写性能测试,所以我可能做了一些愚蠢的事......

BTW:我在Debian Squeeze上运行Ruby 1.8.7,Rails 2.2.2.

integration-testing ruby-on-rails performance-testing authlogic

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

如何在Go中使用.Read函数?

试图使用Go的http包,我无法弄清楚语法.Read.以下标记为HERE是我唯一需要编译的东西,尽管我尝试了其他一些被编译器拒绝的东西.

package main
import "fmt";
import "http";
import "os";

func main () {
    kinopiko_flair := "http://stackoverflow.com/users/flair/181548.json";
    response, _, error := http.Get (kinopiko_flair);
    if (error != nil) {
        // I want to print out the error too.
        fmt.Printf ("Error getting %s\n", kinopiko_flair);
        os.Exit (1);
    }
    fmt.Printf ("Status is %s\n", response.Status);
    var nr int;
    var buf []byte;
    nr, error = response.Body.Read (buf); // HERE
    if (error != nil) {
        // I want to print out the error too.
        fmt.Printf ("Error …
Run Code Online (Sandbox Code Playgroud)

go

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

如何在代码中设置ServiceHostingEnvironment.AspNetCompatibilityEnabled = true(不在配置中).NET/C#

我需要从RESTful WCF服务中使用来访问HttpContext.Current.我知道我可以通过在config中添加以下内容来实现这一目的:

<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
Run Code Online (Sandbox Code Playgroud)

并在我的服务上使用以下属性:

[AspNetCompatibilityRequirements(RequirementsMode 
    = AspNetCompatibilityRequirementsMode.Required)]
Run Code Online (Sandbox Code Playgroud)

这是我的问题,我需要在代码中"旋转"一个服务实例进行单元测试,因此我不能使用配置文件来指定服务bebaviours等.目前我的代码看起来如下,但尽管在网上搜索我我一直无法弄清楚如何设置ServiceHostingEnvironment类并在不使用配置的情况下将AspNetCompatibilityEnabled属性设置为true,有人可以帮忙吗?

string serviceUrl = "http://localhost:8082/MyService.svc";

_host = new ServiceHost(typeof(MyService), new Uri[] { new Uri(serviceUrl) });

ServiceEndpoint serviceEndpoint 
    = _host.AddServiceEndpoint(typeof(IMyService), new WebHttpBinding(), string.Empty);

serviceEndpoint.Behaviors.Add(new WebHttpBehavior());

// Here's where I'm stuck, i need something like...
ServiceHostingEnvironmentSection shes = new ServiceHostingEnvironmentSection();
shes.AspNetCompatibilityEnabled = true;
_host.Add(shes);

_host.Open();
Run Code Online (Sandbox Code Playgroud)

任何帮助都非常感谢,并提前感谢.

.net c# rest wcf

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

多部分电子邮件

如何在多部分电子邮件中使用html标记.当我使用<b>它不被识别为粗体标签时.

html java email multipart

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

嵌套Div标签的PHP RegExp

我需要一个正则表达式,我可以使用PHP的preg_match_all()来匹配div-tags中的内容.div看起来像这样:

<div id="t1">Content</div>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经提出了这个正则表达式,它匹配了id ="t [number]"的所有div

/<div id="t(\\d)">(.*?)<\\/div>/
Run Code Online (Sandbox Code Playgroud)

问题是当内容包含更多div时,嵌套的div如下所示:

<div id="t1">Content <div>more stuff</div></div>
Run Code Online (Sandbox Code Playgroud)

关于如何使我的正则表达式与嵌套标签一起工作的任何想法?

谢谢

php regex tags nested

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

在托管服务器上的CakePHP应用程序?

如何在托管服务器上运行cakePHP应用程序?

我在CakePHP中创建了自己的应用程序.它在当地运行良好.但是当我将它上传到服务器时,它会给出404 Not Found错误.

谁能告诉我如何将CakePHP上传到托管服务器?

web-hosting cakephp

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

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

在SQL Server中触发之前

我有2张桌子:survey (id(PK), name)survey_to_topic (survey_id(PK,FK,not null), topic_id(PK,FK,not null)).当我尝试从调查表中删除时,我得到例外:

"DELETE语句与REFERENCE约束冲突"FK_survey _to _topic _survey".冲突发生在数据库"mydatabase",表"dbo.survey _to _topic",列'survey _id'中."

因此,首先我必须删除表survey_to_topic中的记录,然后从表调查中删除记录.我认为在桌面调查之前使用触发器更好,但我找不到任何有关此信息的信息.PL/SQL中有很多关于before触发器的文章,但我使用的是SQL Server.

sql t-sql sql-server triggers

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

是否可以在批处理文件中的回显行中添加新的行字符?

是否可以在批处理文件中的回显行中添加新的行字符?

基本上我希望能够做到相当于:

echo Hello\nWorld
Run Code Online (Sandbox Code Playgroud)

您可以在Linux中轻松完成此操作,但我无法解决如何在Windows中执行此操作.

windows batch-file

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

如何在Python中将bin系列浮点值转换为直方图?

我在float中设置了值(总是小于0).我希望将其分为直方图,即e.直方图中的每个条形包含值范围[0,0.150)

我的数据看起来像这样:

0.000
0.005
0.124
0.000
0.004
0.000
0.111
0.112
Run Code Online (Sandbox Code Playgroud)

我的代码如下,我希望得到的结果看起来像

[0, 0.005) 5
[0.005, 0.011) 0
...etc.. 
Run Code Online (Sandbox Code Playgroud)

我尝试用我的这个代码做这样的binning.但它似乎没有用.什么是正确的方法呢?

#! /usr/bin/env python


import fileinput, math

log2 = math.log(2)

def getBin(x):
    return int(math.log(x+1)/log2)

diffCounts = [0] * 5

for line in fileinput.input():
    words = line.split()
    diff = float(words[0]) * 1000;

    diffCounts[ str(getBin(diff)) ] += 1

maxdiff = [i for i, c in enumerate(diffCounts) if c > 0][-1]
print maxdiff
maxBin = max(maxdiff)


for i in range(maxBin+1):
     lo = 2**i - 1 …
Run Code Online (Sandbox Code Playgroud)

python statistics histogram binning

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