From mboxrd@z Thu Jan 1 00:00:00 1970 From: santorini lysias Subject: Reporting org-babel bug for java Date: Thu, 30 Mar 2017 18:27:53 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c12fdb6f1c46d054bfcb787 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctlM4-0003h1-BZ for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 21:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctlM3-0007mQ-2V for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 21:27:56 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:33396) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctlM2-0007lr-RQ for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 21:27:55 -0400 Received: by mail-pg0-x234.google.com with SMTP id x125so55238067pgb.0 for ; Thu, 30 Mar 2017 18:27:54 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --94eb2c12fdb6f1c46d054bfcb787 Content-Type: text/plain; charset=UTF-8 Hello, I've never used a mailing list before, so bear with me if I'm not "doing this right." I found behavior that I think is a bug and not a feature. This is for org-babel Java. The content below the equals signs, below, comprise an org-mode file that I will refer to in order to report the behavior that is the topic of this post. Two Java jars are referenced in the classpaths and are needed in order to run the code. They can be obtained from the Junit download page. This code basically runs a Junit test. The concern I have is with this line: #+begin_src java :classname ParameterizedTest :cmpflag "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:." :cmdline "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:." If I press C-c C-c on this block of code, it runs fine. However, if the string after :cmpflag is written as "-cp .:~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar" the compilation of this Java class will fail because the Junit jar cannot be located! This only happens because I change the order of the jars as they appear in the classpath. This is not a Java problem, since the order of items in the classpath should not change Java behavior. I have to conclude there is something happening in the org-babel code that is causing this. Org-mode file below ============= * calculator #+begin_src java :classname Calculator :cmpflag "-cp ." :cmdline "-cp ." public class Calculator{ public double add(double number1, double number2){ return number1+number2; } } #+end_src * parameterized test #+begin_src java :classname ParameterizedTest :cmpflag "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:." :cmdline "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:." import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import java.util.Arrays; import java.util.Collection; @RunWith(value=Parameterized.class) public class ParameterizedTest{ private double expected; private double valueOne; private double valueTwo; @Parameters public static Collection getTestParameters(){ return Arrays.asList(new Integer[][]{ {2, 1, 1}, {3, 2, 1}, {4, 3, 1}, }); } public ParameterizedTest(double expected, double valueOne, double valueTwo){ this.expected = expected; this.valueOne = valueOne; this.valueTwo = valueTwo; } @Test public void sum(){ Calculator calc = new Calculator(); assertEquals(expected, calc.add(valueOne, valueTwo), 0); } } #+end_src * run test #+begin_src sh :results verbatim java -cp .:/home/ahan/Linux/rep/junit-4.12.jar:/home/ahan/Linux/rep/hamcrest-core-1.3.jar: org.junit.runner.JUnitCore ParameterizedTest #+end_src #+RESULTS: : JUnit version 4.12 : ... : Time: 0.007 : : OK (3 tests) : --94eb2c12fdb6f1c46d054bfcb787 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,

I've= never used a mailing list before, so bear with me if I'm not "doi= ng this right."

I found behavior that I think is a bug an= d not a feature. This is for org-babel Java.

The content below= the equals signs, below, comprise an org-mode file that I will refer to in= order to report the behavior that is the topic of this post. Two Java jars= are referenced in the classpaths and are needed in order to run the code. = They can be obtained from the Junit download page.

This code b= asically runs a Junit test. The concern I have is with this line:

#+= begin_src java :classname ParameterizedTest :cmpflag "-cp=20 ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:." :cmdli= ne "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar:.&q= uot;

If I press C-c C-c on this block of code, it runs fine. H= owever, if the string after :cmpflag is written as "-cp .:~/Linux/rep/= junit-4.12.jar:~/Linux/rep/hamcrest-core-1.3.jar" the compilation of t= his Java class will fail because the Junit jar cannot be located!

This only happens because I change the order of the jars as they appear= in the classpath. This is not a Java problem, since the order of items in = the classpath should not change Java behavior. I have to conclude there is = something happening in the org-babel code that is causing this.


Org-mode file below
= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
* calculator
#+begin_src java= :classname Calculator :cmpflag "-cp ." :cmdline "-cp ."= ;
public class Calculator{
=C2=A0 public double add(double number1, d= ouble number2){
=C2=A0=C2=A0=C2=A0 return number1+number2;
=C2=A0 }}
#+end_src
* parameterized test
#+begin_src java :classname Par= ameterizedTest :cmpflag "-cp ~/Linux/rep/junit-4.12.jar:~/Linux/rep/ha= mcrest-core-1.3.jar:." :cmdline "-cp ~/Linux/rep/junit-4.12.jar:~= /Linux/rep/hamcrest-core-1.3.jar:."
import static org.junit.Assert.= *;
import org.junit.Test;
import org.junit.runner.RunWith;
import = org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.= Parameters;
import java.util.Arrays;
import java.util.Collection;
=
@RunWith(value=3DParameterized.class)
public class ParameterizedTest= {
=C2=A0 private double expected;
=C2=A0 private double valueOne;
= =C2=A0 private double valueTwo;

=C2=A0 @Parameters
=C2=A0 public = static Collection<Integer[]> getTestParameters(){
=C2=A0=C2=A0=C2= =A0 return Arrays.asList(new Integer[][]{
=C2=A0=C2=A0=C2=A0 {2, 1, 1},<= br>=C2=A0=C2=A0=C2=A0 {3, 2, 1},
=C2=A0=C2=A0=C2=A0 {4, 3, 1},
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 });
=C2=A0 }

=C2=A0 public Parameterized= Test(double expected, double valueOne, double valueTwo){
=C2=A0=C2=A0=C2= =A0 this.expected =3D expected;
=C2=A0=C2=A0=C2=A0 this.valueOne =3D val= ueOne;
=C2=A0=C2=A0=C2=A0 this.valueTwo =3D valueTwo;
=C2=A0 }
=C2=A0 @Test
=C2=A0 public void sum(){
=C2=A0=C2=A0=C2=A0 Calculator= calc =3D new Calculator();
=C2=A0=C2=A0=C2=A0 assertEquals(expected, ca= lc.add(valueOne, valueTwo), 0);
=C2=A0 }
}
#+end_src
* run test=
#+begin_src sh :results verbatim
java -cp .:/home/ahan/Linux/rep/jun= it-4.12.jar:/home/ahan/Linux/rep/hamcrest-core-1.3.jar: org.junit.runner.JU= nitCore ParameterizedTest
#+end_src

#+RESULTS:
: JUnit version= 4.12
: ...
: Time: 0.007
:
: OK (3 tests)
:
--94eb2c12fdb6f1c46d054bfcb787--