Skip to content
Snippets Groups Projects
Commit a64bd712 authored by Herwin van Welbergen's avatar Herwin van Welbergen
Browse files

fixed cpp dependencies

parent f28af56b
No related branches found
No related tags found
No related merge requests found
.DS_Store .DS_Store
*/generatedsrc generatedsrc
*/*/generatedsrc build
*/build docs
*/*/build lib
*/*/*/build test/lib
*/*/*/docs report
*/*/docs dist
*/lib deps
*/test/lib privateprops
*/test/report .project
*/dist .classpath
*/deps .setting
*/privateprops .settings
*/.project .pydevproject
*/.classpath
*.pyc *.pyc
*/.*.swp *.swp
.*.sw[a-z] *.sw[a-z]
*.un~ *.un~
Session.vim Session.vim
*/manifest.mf manifest.mf
*/*/manifest.mf *.*~
*/*/*/manifest.mf
*/*/*/*/manifest.mf
*/*.*~
deps
dist
<ivy-module version="2.0"> <ivy-module version="2.0">
<info organisation="ipaaca" module="IpaacaCpp" /> <info organisation="ipaaca" module="IpaacaCpp" />
<dependencies> <dependencies>
<dependency org="google" name="protobuf" rev="latest.release"/>
<dependency org="rsb" name="rsb" rev="latest.release"/>
</dependencies> </dependencies>
</ivy-module> </ivy-module>
...@@ -25,12 +25,12 @@ public final class Initializer ...@@ -25,12 +25,12 @@ public final class Initializer
DefaultConverterRepository.getDefaultConverterRepository().addConverter( DefaultConverterRepository.getDefaultConverterRepository().addConverter(
new IUConverter(new ConverterSignature("ipaaca-iu", RemotePushIU.class))); new IUConverter(new ConverterSignature("ipaaca-iu", RemotePushIU.class)));
DefaultConverterRepository.getDefaultConverterRepository().addConverter( DefaultConverterRepository.getDefaultConverterRepository().addConverter(
new IUConverter(new ConverterSignature("ipaaca-localiu", LocalIU.class))); new IUConverter(new ConverterSignature("ipaaca-localiu", LocalIU.class)));
DefaultConverterRepository.getDefaultConverterRepository().addConverter( DefaultConverterRepository.getDefaultConverterRepository().addConverter(
new IUConverter(new ConverterSignature("ipaaca-messageiu", RemoteMessageIU.class))); new IUConverter(new ConverterSignature("ipaaca-messageiu", RemoteMessageIU.class)));
DefaultConverterRepository.getDefaultConverterRepository().addConverter( DefaultConverterRepository.getDefaultConverterRepository().addConverter(
new IUConverter(new ConverterSignature("ipaaca-localmessageiu", LocalMessageIU.class))); new IUConverter(new ConverterSignature("ipaaca-localmessageiu", LocalMessageIU.class)));
DefaultConverterRepository.getDefaultConverterRepository().addConverter(new PayloadConverter()); DefaultConverterRepository.getDefaultConverterRepository().addConverter(new PayloadConverter());
DefaultConverterRepository.getDefaultConverterRepository().addConverter(new LinkUpdateConverter()); DefaultConverterRepository.getDefaultConverterRepository().addConverter(new LinkUpdateConverter());
......
...@@ -8,6 +8,7 @@ import java.io.BufferedReader; ...@@ -8,6 +8,7 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.EnumSet;
import java.util.Set; import java.util.Set;
import org.junit.Before; import org.junit.Before;
...@@ -24,7 +25,8 @@ import com.google.common.collect.ImmutableSet; ...@@ -24,7 +25,8 @@ import com.google.common.collect.ImmutableSet;
*/ */
public class JavaPythonTest public class JavaPythonTest
{ {
private StoringEventHandler storeHandler = new StoringEventHandler();
@BeforeClass @BeforeClass
public static void setupStatic() public static void setupStatic()
{ {
...@@ -35,19 +37,20 @@ public class JavaPythonTest ...@@ -35,19 +37,20 @@ public class JavaPythonTest
private static final String PYTHON_PREAMBLE = "import sys\n" private static final String PYTHON_PREAMBLE = "import sys\n"
+ "sys.path.insert(0, '../python/build/')\n" + "sys.path.insert(0, '../python/build/')\n"
+ "sys.path.insert(0, '../python/lib/')\n" + "sys.path.insert(0, '../python/lib/')\n"
+ "sys.path.insert(0, '../../deps/python/')\n"
+ "import ipaaca, time\n"; + "import ipaaca, time\n";
@Before @Before
public void setup() public void setup()
{ {
Set<String> categories = new ImmutableSet.Builder<String>().add("JavaPythonTest").build(); Set<String> categories = new ImmutableSet.Builder<String>().add("JavaPythonTest").build();
inBuffer = new InputBuffer("javaside", categories); inBuffer = new InputBuffer("javaside", categories);
} }
private void printRuntimeErrors(Process p) throws IOException private String getRuntimeErrors(Process p) throws IOException
{ {
StringBuffer errors = new StringBuffer();
InputStream in = p.getInputStream(); InputStream in = p.getInputStream();
BufferedInputStream buf = new BufferedInputStream(in); BufferedInputStream buf = new BufferedInputStream(in);
InputStreamReader inread = new InputStreamReader(buf); InputStreamReader inread = new InputStreamReader(buf);
...@@ -63,12 +66,12 @@ public class JavaPythonTest ...@@ -63,12 +66,12 @@ public class JavaPythonTest
{ {
if (p.waitFor() != 0) if (p.waitFor() != 0)
{ {
System.err.println("exit value = " + p.exitValue()); errors.append("exit value = " + p.exitValue()+"\n");
} }
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
System.err.println(e); errors.append(e);
} }
in = p.getErrorStream(); in = p.getErrorStream();
...@@ -78,15 +81,15 @@ public class JavaPythonTest ...@@ -78,15 +81,15 @@ public class JavaPythonTest
// Read the ls output // Read the ls output
while ((line = bufferedreader.readLine()) != null) while ((line = bufferedreader.readLine()) != null)
{ {
System.out.println(line); errors.append(line);
} }
return errors.toString();
} }
private boolean runPythonProgram(String pypr) throws IOException private void runPythonProgram(String pypr) throws IOException
{ {
Process p = Runtime.getRuntime().exec(new String[] { "python", "-c", pypr }); Process p = Runtime.getRuntime().exec(new String[] { "python", "-c", pypr });
printRuntimeErrors(p); assertTrue(getRuntimeErrors(p), p.exitValue()==0);
return p.exitValue()==0;
} }
@Test @Test
...@@ -99,7 +102,7 @@ public class JavaPythonTest ...@@ -99,7 +102,7 @@ public class JavaPythonTest
+ "iu.payload = {'data':'Hello from Python!'}\n" + "iu.payload = {'data':'Hello from Python!'}\n"
+ "time.sleep(0.1)\n" + "time.sleep(0.1)\n"
+ "ob.add(iu)\n"; + "ob.add(iu)\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
...@@ -118,7 +121,7 @@ public class JavaPythonTest ...@@ -118,7 +121,7 @@ public class JavaPythonTest
+ "time.sleep(0.1)\n" + "time.sleep(0.1)\n"
+ "iu.payload = {'data':'Hello from Python!'}\n"; + "iu.payload = {'data':'Hello from Python!'}\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
...@@ -135,7 +138,7 @@ public class JavaPythonTest ...@@ -135,7 +138,7 @@ public class JavaPythonTest
+"iu.add_links('testtype',['dummy1','dummy2'])\n" +"iu.add_links('testtype',['dummy1','dummy2'])\n"
+ "time.sleep(0.1)\n" + "time.sleep(0.1)\n"
+ "ob.add(iu)\n"; + "ob.add(iu)\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
AbstractIU iu = inBuffer.getIUs().iterator().next(); AbstractIU iu = inBuffer.getIUs().iterator().next();
...@@ -153,7 +156,7 @@ public class JavaPythonTest ...@@ -153,7 +156,7 @@ public class JavaPythonTest
+ "time.sleep(0.1)\n" + "time.sleep(0.1)\n"
+"iu.add_links('testtype',['dummy1','dummy2'])\n"; +"iu.add_links('testtype',['dummy1','dummy2'])\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
AbstractIU iu = inBuffer.getIUs().iterator().next(); AbstractIU iu = inBuffer.getIUs().iterator().next();
...@@ -169,7 +172,7 @@ public class JavaPythonTest ...@@ -169,7 +172,7 @@ public class JavaPythonTest
+ "ob.add(iu)\n" + "ob.add(iu)\n"
+ "time.sleep(0.1)\n" + "time.sleep(0.1)\n"
+ "iu.commit()\n"; + "iu.commit()\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
AbstractIU iu = inBuffer.getIUs().iterator().next(); AbstractIU iu = inBuffer.getIUs().iterator().next();
...@@ -181,15 +184,31 @@ public class JavaPythonTest ...@@ -181,15 +184,31 @@ public class JavaPythonTest
{ {
String pypr = PYTHON_PREAMBLE String pypr = PYTHON_PREAMBLE
+"ob = ipaaca.OutputBuffer('pythonside')\n" +"ob = ipaaca.OutputBuffer('pythonside')\n"
+"iu = ipaaca.IU('JavaPythonTest')\n" +"iu = ipaaca.IU('JavaPythonTest')\n"
+"iu.commit()\n" +"iu.commit()\n"
+"time.sleep(0.1)\n" +"time.sleep(0.1)\n"
+"ob.add(iu)\n"; +"ob.add(iu)\n";
assertTrue(runPythonProgram(pypr)); runPythonProgram(pypr);
Thread.sleep(200); Thread.sleep(200);
assertEquals(1, inBuffer.getIUs().size()); assertEquals(1, inBuffer.getIUs().size());
AbstractIU iu = inBuffer.getIUs().iterator().next(); AbstractIU iu = inBuffer.getIUs().iterator().next();
assertTrue(iu.isCommitted()); assertTrue(iu.isCommitted());
} }
@Test
public void testMessageFromPython()throws IOException, InterruptedException
{
inBuffer.registerHandler(new IUEventHandler(storeHandler,EnumSet.of(IUEventType.ADDED),ImmutableSet.of("JavaPythonTest")));
String pypr = PYTHON_PREAMBLE
+"ob = ipaaca.OutputBuffer('pythonside')\n"
+"iu = ipaaca.Message('JavaPythonTest')\n"
+"iu.payload = {'data':'Hello from Python!'}\n"
+"time.sleep(0.1)\n"
+"ob.add(iu)\n";
runPythonProgram(pypr);
Thread.sleep(200);
assertEquals(1,storeHandler.getAddedIUs().size());
assertEquals("Hello from Python!", storeHandler.getAddedIUs().get(0).getPayload().get("data"));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment