/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package api.testing; import com.mks.api.*; import java.util.*; import com.mks.api.response.APIException; import com.mks.api.response.Field; import com.mks.api.response.Item; import com.mks.api.response.ItemList; import com.mks.api.response.Response; import com.mks.api.response.WorkItem; import com.mks.api.response.WorkItemIterator; import com.mks.api.util.ResponseUtil; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author ascott */ public class APITesting { /** * @param args the command line arguments */ private static int majorVersion = 4; private static int minorVersion = 15; public static void main(String[] args) { try{ IntegrationPointFactory factory = IntegrationPointFactory.getInstance(); IntegrationPoint integrationPoint = factory.createLocalIntegrationPoint(majorVersion,minorVersion); integrationPoint.setAutoStartIntegrityClient(true); Session session = integrationPoint.getCommonSession(); CmdRunner cmdRunner = session.createCmdRunner(); cmdRunner.setDefaultUsername("mks"); cmdRunner.setDefaultPassword("mks"); cmdRunner.setDefaultHostname("localhost"); cmdRunner.setDefaultPort(7001); Command cmd = new Command(Command.SI,"projects"); Response response = cmdRunner.execute(cmd); if (response != null) { WorkItemIterator wis = response.getWorkItems(); while (wis.hasNext()) { WorkItem wi = wis.next(); System.err.println(wi.getId()); } } } catch (APIException e) { // TODO Auto-generated catch block e.printStackTrace(); System.err.println(e.getLocalizedMessage()); System.err.println(e.getMessage()); ResponseUtil.printAPIException(e, 0, System.out); } } }