Github user imesh commented on a diff in the pull request: https://github.com/apache/stratos/pull/233#discussion_r24972772 --- Diff: components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java --- @@ -66,20 +69,77 @@ private static final String PARTITION_ID = "partition-1"; private static final String TENANT_ID = "-1234"; private static final String SERVICE_NAME = "php"; + public static final String REPO_CLONE_PATH = "/tmp/stratos-pca-test-app-path/"; private static List<ServerSocket> serverSocketList; private static Map<String, Executor> executorList; + private final ArtifactUpdatedEvent artifactUpdatedEvent; + private final Boolean expectedResult; + private boolean instanceStarted; + private boolean instanceActivated; + private ByteArrayOutputStreamLocal outputStream; + private TopologyEventReceiver topologyEventReceiver; + private InstanceStatusEventReceiver instanceStatusEventReceiver; + private boolean eventReceiverInitiated = false; + + public PythonCartridgeAgentTest(ArtifactUpdatedEvent artifactUpdatedEvent, Boolean expectedResult) { + this.artifactUpdatedEvent = artifactUpdatedEvent; + this.expectedResult = expectedResult; + } @BeforeClass - public static void setUp() { + public static void oneTimeSetUp() { // Set jndi.properties.dir system property for initializing event publishers and receivers System.setProperty("jndi.properties.dir", getResourcesFolderPath()); + } + + @Before + public void setup(){ serverSocketList = new ArrayList<ServerSocket>(); executorList = new HashMap<String, Executor>(); + + if (!this.eventReceiverInitiated) { + ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL", 5); + topologyEventReceiver = new TopologyEventReceiver(); + topologyEventReceiver.setExecutorService(executorService); + topologyEventReceiver.execute(); + + instanceStatusEventReceiver = new InstanceStatusEventReceiver(); + instanceStatusEventReceiver.setExecutorService(executorService); + instanceStatusEventReceiver.execute(); + + + this.instanceStarted = false; + instanceStatusEventReceiver.addEventListener(new InstanceStartedEventListener() { + @Override + protected void onEvent(Event event) { + log.info("Instance started event received"); + instanceStarted = true; + } + }); + + this.instanceActivated = false; + instanceStatusEventReceiver.addEventListener(new InstanceActivatedEventListener() { + @Override + protected void onEvent(Event event) { + log.info("Instance activated event received"); + instanceActivated = true; + } + }); + + this.eventReceiverInitiated = true; + } + + String agentPath = setupPythonAgent(); + log.info("Starting python cartridge agent..."); + this.outputStream = executeCommand("python " + agentPath + "/agent.py"); + + // Simulate CEP server socket + startServerSocket(7711); } - @AfterClass - public static void tearDown() { + @After --- End diff -- Can you please explain the reason for changing @AfterClass to @After?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---