()
| 174 | } |
| 175 | |
| 176 | private void Test() |
| 177 | { |
| 178 | // Make sure the kernel was ok |
| 179 | if (m_Kernel.HadError()) |
| 180 | throw new IllegalStateException("Error initializing kernel: " |
| 181 | + m_Kernel.GetLastErrorDescription()); |
| 182 | |
| 183 | String version = m_Kernel.GetSoarKernelVersion(); |
| 184 | System.out.println("Soar version " + version); |
| 185 | |
| 186 | // Create an agent |
| 187 | Agent agent = m_Kernel.CreateAgent("javatest"); |
| 188 | Agent pAgent = agent; // So it's easier copying existing C++ code here |
| 189 | Kernel pKernel = m_Kernel; |
| 190 | |
| 191 | // We test the kernel for an error after creating an agent as the agent |
| 192 | // object may not be properly constructed if the create call failed so |
| 193 | // we store errors in the kernel in this case. |
| 194 | if (m_Kernel.HadError()) |
| 195 | throw new IllegalStateException("Error creating agent: " |
| 196 | + m_Kernel.GetLastErrorDescription()); |
| 197 | |
| 198 | try |
| 199 | { |
| 200 | ProductionUtils.sourceAgentFromJar(agent, "/testjavasml.soar"); |
| 201 | } |
| 202 | catch (IOException e) |
| 203 | { |
| 204 | throw new IllegalStateException(e.getMessage()); |
| 205 | } |
| 206 | |
| 207 | if (agent.HadError()) |
| 208 | throw new IllegalStateException( |
| 209 | "Error loading productions from testjavasml.soar: " |
| 210 | + agent.GetLastErrorDescription()); |
| 211 | |
| 212 | Identifier pInputLink = agent.GetInputLink(); |
| 213 | |
| 214 | if (pInputLink == null) |
| 215 | throw new IllegalStateException("Error getting the input link"); |
| 216 | |
| 217 | // Some random adds |
| 218 | Identifier pID = pAgent.CreateIdWME(pInputLink, "plane"); |
| 219 | // StringElement pWME1 = |
| 220 | pAgent.CreateStringWME(pID, "type", "Boeing747"); |
| 221 | // IntElement pWME2 = |
| 222 | pAgent.CreateIntWME(pID, "speed", 200); |
| 223 | |
| 224 | // Then add some tic tac toe stuff which should trigger output |
| 225 | Identifier pSquare = pAgent.CreateIdWME(pInputLink, "square"); |
| 226 | StringElement pEmpty = pAgent.CreateStringWME(pSquare, "content", |
| 227 | "RANDOM"); |
| 228 | // IntElement pRow = |
| 229 | pAgent.CreateIntWME(pSquare, "row", 1); |
| 230 | // IntElement pCol = |
| 231 | pAgent.CreateIntWME(pSquare, "col", 2); |
| 232 | |
| 233 | // boolean ok = |
no test coverage detected