如果我使用如下所述的/ testmetadata标志,我可以使用MSTest从命令行一次性在解决方案中运行我的所有测试:http://msdn.microsoft.com/en-us/library/ms182487. ASPX
我在Visual Studio 2013中运行SQL Server数据库单元测试,其中我似乎根本没有vsmdi文件,我也找不到添加方法的方法.我尝试创建一个testsettings文件,但是当我调用MSTest时它没有发现任何测试(显示"没有运行测试").
有没有办法让MSTest在VS2013解决方案中运行我的所有测试?
自从HttpClient 4.3以来,我一直在使用HttpClientBuilder.我正在连接到具有基本身份验证的REST服务.我正在设置凭据如下:
HttpClientBuilder builder = HttpClientBuilder.create();
// Get the client credentials
String username = Config.get(Constants.CONFIG_USERNAME);
String password = Config.get(Constants.CONFIG_PASSWORD);
// If username and password was found, inject the credentials
if (username != null && password != null)
{
CredentialsProvider provider = new BasicCredentialsProvider();
// Create the authentication scope
AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);
// Create credential pair
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
// Inject the credentials
provider.setCredentials(scope, credentials);
// Set the default credentials provider
builder.setDefaultCredentialsProvider(provider);
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用(我正在使用的REST服务返回401).出了什么问题?
我正在使用apache的HttpClient(通过Fluent API).当我收到响应对象时,我首先做:
response.returnResponse().getStatusLine().getStatusCode()
Run Code Online (Sandbox Code Playgroud)
如果状态代码是4xx或5xx,我抛出异常,或者我返回内容:
response.returnContent().asBytes();
Run Code Online (Sandbox Code Playgroud)
这response是一个类型的对象Response.但是,当我运行这个时,我得到:
java.lang.IllegalStateException: Response content has been already consumed.
Run Code Online (Sandbox Code Playgroud)
我怎么能绕过这个?
我正在尝试在我的应用程序中编写一个通用路由,并根据路径参数动态解析视图和控制器名称.
我有以下代码:
$stateProvider.state('default', angularAMD.route({
url: '/:module/:action?id',
templateUrl: function (params) {
var module = params.module;
var action = module + params.action.charAt(0).toUpperCase()
+ params.action.substr(1);
return 'app/views/' + module + '/' + action + 'View.html';
},
controller: 'userController',
}));
Run Code Online (Sandbox Code Playgroud)
但是,我无法找到一种动态解析控制器名称的方法.我尝试使用这里resolve描述的,但ui-router似乎处理不同于angular-route的解决方案.
有什么指针吗?
编辑:我已经尝试过使用controllerProvider但它对我不起作用(例如,下面的代码只返回一个硬编码的控制器名称来测试它是否真的有效):
controllerProvider: function () {
return 'userController';
}
Run Code Online (Sandbox Code Playgroud)
给我以下错误:
错误:[ng:areq]参数'userController'不是函数,未定义
http://errors.angularjs.org/1.3.3/ng/areq?p0=userController&p1=not%20aNaNunction%2C%20got%20undefined
我们有一个角度1 + 2混合应用程序(因此使用角度1基础应用程序).
在使用适配器引导应用程序之前,我们使用升级适配器降级我们的angular2组件.这按预期工作.
但是,我们预计会有大量的angular2组件(150+),因此在引导之前加载所有组件意味着初始负载非常慢.我试图找到延迟加载angular2组件的方法,以便我们可以根据需要加载它们.有没有办法实现这一目标?
这是我的代码的一部分.
main.ts
import baseRouter from './lib/routing/baseRouter';
import router from './lib/routing/router'
import futureRoutes from './futureRoutes'
import { Adapter } from './lib/framework/upgradeAdapter';
import { Http, Headers, Response } from '@angular/http';
import { DashboardComponent } from './2x/Dashboard/dashboard.component';
var app = angular.module('myApp', [
'ui.router',
'ngStorage'
]);
app.config(router(app, futureRoutes))
.config(baseRouter)
.directive('dashboard', Adapter.downgradeNg2Component(DashboardComponent));
Adapter.bootstrap(document.body, ['myApp'], { strictDi: true });
export default app;
Run Code Online (Sandbox Code Playgroud)
module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { DashboardComponent } from '../../2x/Dashboard/dashboard.component'; …Run Code Online (Sandbox Code Playgroud) 我有一个PHP应用程序,有一个相当不错的用户群.现在不幸的是,这些年来它一直在使用sha1($ password.$ salt),我真的想放弃支持bcrypt.我找到了一些获得Blowfish哈希的好方法,但我仍然不确定我应该使用的转换方法.以下是我的选择:
每次用户登录时,我都会检查哈希是否以$ 2开头.如果没有,我认为它是sha1,取用户输入的密码,获取它的bcrypt哈希并替换数据库中的旧哈希.
我替换我的auth类来执行此操作:
$hash = password_hash("rasmuslerdorf", sha1($password . $salt));
Run Code Online (Sandbox Code Playgroud)
这样,转换更快.
但老实说,我真的不喜欢这两种选择.两者都表明我仍然在代码库中保留遗留检查,我想摆脱它.
从编码标准的角度来看,上述哪两个更好?或者有人有更好的解决方案吗?
我有一个文本框和一个列表框.列表框显示文本框的搜索建议.当文本框聚焦时,我想在用户按下箭头时突出显示第一个列表框项.同样,当用户作为列表框中的第一个元素并按下向上箭头时,应该将文本框聚焦回来.
我在KeyBindings中使用以下代码:
<KeyBinding Key="Down" Command="{x:Static local:SearchView.ApplicationShortCutsCommand}" CommandParameter="{x:Static common:SearchViewCommands.MoveToSuggestions}" />
<KeyBinding Key="Up" Command="{x:Static local:SearchView.ApplicationShortCutsCommand}" CommandParameter="{x:Static common:SearchViewCommands.MoveToQuery}" />
Run Code Online (Sandbox Code Playgroud)
其他键,如Esc和Enter工作正常,虽然这一个根本不起作用(相关事件不会被触发).
有什么建议?
这个问题适用于我用PHP编写的pastebin应用程序.
我做了一些研究,虽然我找不到符合我需求的解决方案.我有一个这种结构的表:
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| id | int(12) unsigned | NO | PRI | NULL | auto_increment |
| author | varchar(50) | YES | | | |
| authorid | int(12) unsigned | YES | | NULL | |
| project | varchar(50) | YES | | | |
| timestamp | int(11) unsigned | NO | | NULL | |
| expire | int(11) unsigned …Run Code Online (Sandbox Code Playgroud) 我有一个 DAO,它使用 JPA/Hibernate 从 SQL Server 2008 R2 获取数据。在我的特定用例中,我正在执行一个简单的 SELECT 查询,该查询返回大约 100000 条记录,但需要超过 35 分钟。
我通过手动加载 sql server 驱动程序创建了一个基本的 JDBC 连接,并且相同的查询在 15 秒内返回了 100k 条记录。所以我的配置有些问题。
这是我的 springDataContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<property name="persistenceXmlLocation" value="classpath:persistence.xml"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</prop>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.use_sql_comments">false</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql:false}</prop>
<prop key="jadira.usertype.autoRegisterUserTypes">true</prop>
<prop key="jadira.usertype.javaZone">America/Chicago</prop>
<prop key="jadira.usertype.databaseZone">America/Chicago</prop> …Run Code Online (Sandbox Code Playgroud) 我有一个 UITableView,其框架设置为父视图的框架大小。表格视图在 iPhone 上显示得很好。但是,在 iPad 上,它的两侧都有这么厚的边距。
如果我选择单元格,它会显示表格确实跨越了整个宽度。然而,分隔符似乎更小。我曾尝试将 layoutMargins 设置为零,但没有效果。这是我将它添加到我的视图的方法:
self.optionsView = UITableView()
self.optionsView.delegate = self
self.optionsView.dataSource = self
self.optionsView.hidden = true
self.optionsView.frame.origin = CGPoint(x: view.frame.size.width + 30, y: 0)
self.optionsView.frame.size = view.frame.size
self.optionsView.layer.shadowColor = Palette.shadowColor.CGColor
self.optionsView.layer.shadowRadius = 10.0
self.optionsView.layer.shadowOpacity = 0.3
self.optionsView.clipsToBounds = false
view.addSubview(optionsView)
Run Code Online (Sandbox Code Playgroud)
知道这里出了什么问题吗?
我在Laravel上看过很多关于全文搜索的文章,用户建议使用whereRaw(...)或DB :: query(...),但我的目标是保持数据库不可知.我明白一个地方('col','like','%foo%')是糟糕的表现.
所以我相信我只剩下创建自己的数据库索引了.有没有我可以用Laravel开箱即用的东西,或者我可以设置一些表格结构来构建更快的搜索机制?
目前,我有一个'主'表,其中有一个文本列'data',我打算在其上运行搜索.这是我正在进行查找的唯一列.
java ×3
php ×3
angularjs ×2
laravel ×2
angular ×1
angular-amd ×1
apache ×1
bcrypt ×1
c# ×1
eloquent ×1
fluent ×1
hibernate ×1
ios ×1
javascript ×1
jpa ×1
key-bindings ×1
mstest ×1
mysql ×1
passwords ×1
revisionable ×1
search ×1
sha1 ×1
spring ×1
sql ×1
sql-server ×1
swift ×1
uitableview ×1
unit-testing ×1
wpf ×1