小编Chr*_*riX的帖子

AngularJS中的测试:注入函数的参考错误

我尝试测试下面的代码:

describe('myService test', function () {
    describe('when I call myService.one', function () {
        beforeEach(angular.module('TargetMarketServices'));
        it('returns 1', inject(function (imagesRepository) {
            expect(true).toEqual(true);
        }));

    });

});
Run Code Online (Sandbox Code Playgroud)

执行此代码时,我收到此错误:

TypeError: 'undefined' is not a function (evaluating 'this.func.apply(this.spec)')
    at http://localhost:8080/testacular.js:76
    at http://localhost:8080/context.html:35
ReferenceError: Can't find variable: inject
    at /home/peter/Dropbox/AngularJS/set-component/test/sets/sets-ihm.js:6
    at /home/peter/Dropbox/AngularJS/set-component/test/sets/sets-ihm.js:8
    at /home/peter/Dropbox/AngularJS/set-component/test/sets/sets-ihm.js:10
Run Code Online (Sandbox Code Playgroud)

PhantomJS 1.8:执行1 of 3(1失败)(跳过2)(0.072秒/ 0.01秒)

对于我的测试,我使用Testacular与Jasmine和PhantomJS.

javascript testing angularjs karma-runner

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

使用Tomcat 9和Java10停止SpringBoot Web应用程序时的非法反射访问

我正在尝试使用Spring Boot 2进行Java 10开发,但我遇到了一些问题.

该应用程序是一个基于Spring Boot 2的简单webapp.应用程序启动是可以的但是当我停止它时,我收到此警告:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/C:/Users/CS/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.11/tomcat-embed-core-9.0.11.jar) to field java.io.ObjectStreamClass$Caches.localDescs
WARNING: Please consider reporting this to the maintainers of org.apache.catalina.loader.WebappClassLoaderBase
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Run Code Online (Sandbox Code Playgroud)

如您所见,我已经将嵌入式Tomcat服务器从版本8切换到9.0.11以符合Java模块系统.该应用程序随选项启动--add-opens java.base/java.lang=ALL-UNNAMED

有人知道我为什么收到这条消息吗?

java spring-boot java-10 java-module tomcat9

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

定义内存中的JobRepository

我正在使用Spring启动测试Spring Batch.我需要定义在Oracle数据库上工作的作业,但我不想在此数据库中保存作业和步骤状态.我在文档中读到了我可以使用MapJobRepositoryFactoryBean的内存存储库.

然后,我实现了这个bean:

@Bean
    public JobRepository jobRepository() {
        MapJobRepositoryFactoryBean factoryBean = new MapJobRepositoryFactoryBean(new ResourcelessTransactionManager());
        try {
            JobRepository jobRepository = factoryBean.getObject();
            return jobRepository;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
Run Code Online (Sandbox Code Playgroud)

但是当我的工作开始时,Spring Batch的第一件事就是在Oracle DB中创建表并继续使用Oracle数据源.这就像我的JobRepository定义没有被考虑在内.

我错过了什么 ?

编辑:我正在使用Spring Boot 1.5.3和Spring Batch 3.0.7

spring-batch spring-boot

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

使用参数测试单个Spring Batch Tasklet步骤

我用2个tasklet实现了一个简单的工作.我想通过传递参数来测试第二个tasklet.

我已阅读Spring批处理文档并在我的测试下面:

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles({"test"})
@TestExecutionListeners( { DependencyInjectionTestExecutionListener.class,
        StepScopeTestExecutionListener.class })
public class EtudeBatchApplicationTests {
    @Autowired
    private JobLauncherTestUtils jobLauncherTestUtils;

    public StepExecution getStepExecution() {
        StepExecution execution = MetaDataInstanceFactory.createStepExecution();
        execution.getJobExecution().getExecutionContext().putString("myValue", "foo,bar,spam");
        return execution;
    }

    @Test
    public void contextLoads() {

        JobExecution jobExecution = jobLauncherTestUtils.launchStep("insertIncludedSiretsStep");
    }

}
Run Code Online (Sandbox Code Playgroud)

我的问题出在我的tasklet中,myValue总是为null.

下面是tasklet的代码:

@Component
@StepScope
@Slf4j
public class InsertIncludedSiretsTask implements Tasklet {
    @Override
    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
        Object myValue = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().get("myValue");

        log.info("INSERTINCLUDEDSIRETSTASK runnning");
        Thread.sleep(3000);
        return RepeatStatus.FINISHED;

    }
}
Run Code Online (Sandbox Code Playgroud)

unit-testing spring-batch

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

使用Couchbase Java Client进行的第一次查询不返回任何行

今天,我下载了最新版本的Couchbase CE和JDK客户端,我在啤酒样品桶上尝试了这个简单的代码(它是Groovy代码):

package couchbase.beer

import com.couchbase.client.java.Cluster
import com.couchbase.client.java.CouchbaseCluster
import com.couchbase.client.java.query.N1qlQuery
import com.couchbase.client.java.view.ViewQuery
import static com.couchbase.client.java.query.Select.select
import static com.couchbase.client.java.query.dsl.Expression.i

def cluster = CouchbaseCluster.create()

def beerBucket = cluster.openBucket('beer-sample')


def oneBeer = beerBucket.get('21st_amendment_brewery_cafe')
assert oneBeer
println oneBeer

println "==================> HERE  <=================="


def result = beerBucket
        .query(N1qlQuery.simple(select("*").from(i('beer-sample')).limit(10)))

println "SIZE: ${result.rows().size()}"

cluster.disconnect()
Run Code Online (Sandbox Code Playgroud)

按键的第一个查询效果很好.我检索一个JSON对象.但是当我编写N1QL查询代码时,我没有结果.有关信息,上面的代码来自couchbase开发人员站点.

java couchbase

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