Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScrpit validators are not loaded from REDPEN_HOME\js #501

Closed
so-c opened this issue Oct 18, 2015 · 2 comments
Closed

JavaScrpit validators are not loaded from REDPEN_HOME\js #501

so-c opened this issue Oct 18, 2015 · 2 comments

Comments

@so-c
Copy link

so-c commented Oct 18, 2015

I expect JavaScript validators are loaded REDPEN_HOME\js when configured JavaScriptValidator without script-path property. Actually they loaded from .\js. if .\js is not exsits, it is created.

I shows my enbironment below.

  • RedPen 1.4.0
  • Windows 10
  • Java 1.8 update 45

I tried write a unit test for JavaScriptValidator.

    @Test
    public void testLoadJSValidatorFromRedPenHomeJs() throws Exception {
        Path redPenHome = Files.createTempDirectory(null);
        System.setProperty("REDPEN_HOME", redPenHome.toString());
        Path jsDir = Files.createDirectories(Paths.get(System.getProperty("REDPEN_HOME"), "js"));
        Path jsValidator = Files.createFile(Paths.get(jsDir.toString(), "test.js"));

        ValidatorConfiguration vc = new ValidatorConfiguration("JavaScriptValidator");
        JavaScriptValidator sut = new JavaScriptValidator();
        sut.preInit(vc, null);

        assertEquals(1, sut.scripts.size());
    }

    @Test
    public void testLoadJSValidatorFromScriptPath() throws Exception {
        Path jsDir = Files.createDirectories(Paths.get(Files.createTempDirectory(null).toString(), "js"));
        Path jsValidator = Files.createFile(Paths.get(jsDir.toString(), "test.js"));

        ValidatorConfiguration vc = new ValidatorConfiguration("JavaScriptValidator").addAttribute("script-path", jsDir.toString());
        JavaScriptValidator sut = new JavaScriptValidator();
        sut.preInit(vc, null);

        assertEquals(1, sut.scripts.size());
    }

testLoadJSValidatorFromScriptPath success but testLoadJSValidatorFromRedPenHomeJs fails.

junit.framework.AssertionFailedError: expected:<1> but was:<0>
    at junit.framework.Assert.fail(Assert.java:50)
    at junit.framework.Assert.failNotEquals(Assert.java:287)
    at junit.framework.Assert.assertEquals(Assert.java:67)
    at junit.framework.Assert.assertEquals(Assert.java:199)
    at junit.framework.Assert.assertEquals(Assert.java:205)
    at cc.redpen.validator.JavaScriptValidatorTest.testLoadJSValidatorFromRedPenHomeJs(JavaScriptValidatorTest.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
@takahi-i
Copy link
Member

Thank you very much for the valuable report @so-c. We will look into the problem.

@takahi-i
Copy link
Member

Hi @so-c! #503 (merged) would fix the problem. Please let me know when you still have the problem. I will reopen this issue when the problem is not fixed in your environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants