Skip to content

Commit

Permalink
force lazy vs eager conf switch is go after freebaseDownloader smoke …
Browse files Browse the repository at this point in the history
…test; if that succeeds, we launch instance 99.6; too bad there is no more freecode to announce it at
  • Loading branch information
paulhoule committed Jun 24, 2014
1 parent dbf6d3e commit 4ea43ed
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 145 deletions.
277 changes: 143 additions & 134 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ ApplicationContext createApplicationContext(CentipedeShellOptions centipedeOptio
if(centipedeOptions.eager && centipedeOptions.lazy)
throw new MisconfigurationException("Cannot force eager and lazy load at same time");

Boolean forcedMode=false;
// Boolean forcedMode =
// centipedeOptions.lazy ? true :
// (centipedeOptions.eager ? false : null);

forcedMode = (forcedMode==null) ? isLazyByDefault() : forcedMode;
Boolean forcedMode =
centipedeOptions.lazy ? Boolean.TRUE :
(centipedeOptions.eager ? Boolean.FALSE : isLazyByDefault());

return (forcedMode==null) ? newContext(contextPath) :
newContext(contextPath,forcedMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public List<String> getApplicationContextPath() {
return that;
}

public static void main(String[] args) {
static void main(String[] args) {
new InfovoreShell().run(args);


}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ontology2.centipede.shell;

public class NeitherLazyNorEagerShell extends InfovoreShell {
@Override
protected Boolean isLazyByDefault() {
return null;
}

static void main(String[] arguments) {
new NeitherLazyNorEagerShell().run(arguments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public static int getCreated() {

public static void reset() {
instanceCount.set(0);
totalCreated.set(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.theories.suppliers.TestedOn;

public class TestInfovoreShell {

Expand Down Expand Up @@ -62,4 +63,38 @@ public void alternateLaunchCode() throws IOException {
assertEquals("777-656-005",ShellTestApp.getLaunchCode());
}

@Test
public void evaluationIsLazyByDefault() {
String[] arguments = {"-applicationContext","classpath:com/ontology2/centipede/shell/objectCountingContext.xml","run","shellTest"};
InfovoreShell.main(arguments);
assertEquals(0,ObjectThatCountsClassInstances.getCreated());
}

@Test
public void evaluationCanBeForcedEager() {
String[] arguments = {"-applicationContext","classpath:com/ontology2/centipede/shell/objectCountingContext.xml","-eager","run","shellTest"};
InfovoreShell.main(arguments);
assertEquals(2,ObjectThatCountsClassInstances.getCreated());
}

@Test
public void defaultEvaluationBehaviorCanBeExposed() {
String[] arguments = {"-applicationContext","classpath:com/ontology2/centipede/shell/objectCountingContext.xml","run","shellTest"};
NeitherLazyNorEagerShell.main(arguments);
assertEquals(1,ObjectThatCountsClassInstances.getCreated());
}

@Test
public void defaultEvaluationBehaviorCanBeForcedLazy() {
String[] arguments = {"-applicationContext","classpath:com/ontology2/centipede/shell/objectCountingContext.xml","-lazy","run","shellTest"};
NeitherLazyNorEagerShell.main(arguments);
assertEquals(0,ObjectThatCountsClassInstances.getCreated());
}

@Test
public void defaultEvaluationBehaviorCanBeForcedEager() {
String[] arguments = {"-applicationContext","classpath:com/ontology2/centipede/shell/objectCountingContext.xml","-eager","run","shellTest"};
NeitherLazyNorEagerShell.main(arguments);
assertEquals(2,ObjectThatCountsClassInstances.getCreated());
}
}

0 comments on commit 4ea43ed

Please sign in to comment.