public static void main(String[] args) { try { Project p = Project.loadProject( new File(ProjectStructure.getnCExamplesDir(), "Ex5_Networks/Ex5_Networks.ncx"), null); GeneratedElecInputs gei = new GeneratedElecInputs(p); System.out.println("Internal info: \n" + gei.toString()); // IClamp ic = new IClamp(2,3,4, true); gei.addSingleInput("Input_0", "IClamp", "cg1", 3, 3, 3, null); gei.addSingleInput("Input_0", "IClamp", "cg1", 38, 3, 3, null); gei.addSingleInput("Input_2", "IClamp", "cg3", 3, 38, 39, null); System.out.println("Internal info: \n" + gei.toString()); File f = new File("../temp/tempp.txt"); gei.saveToFile(f); GeneratedElecInputs cpr2 = new GeneratedElecInputs(null); System.out.println( "---- v1.8.1: \n" + gei.getNetworkMLElement(UnitConverter.GENESIS_SI_UNITS) .getXMLString(" ", false)); ArrayList<SimpleXMLEntity> els = gei.getNetworkMLEntities( UnitConverter.GENESIS_SI_UNITS, NeuroMLConstants.NeuroMLVersion.NEUROML_VERSION_2_ALPHA, null); System.out.println("---- v2.0 alpha: "); for (SimpleXMLEntity el : els) System.out.println(el.getXMLString(" ", false)); els = gei.getNetworkMLEntities( UnitConverter.GENESIS_SI_UNITS, NeuroMLConstants.NeuroMLVersion.getLatestVersion(), null); System.out.println("---- v2.0 beta: "); for (SimpleXMLEntity el : els) System.out.println(el.getXMLString(" ", false)); System.out.println("-------------- "); } catch (Exception ex) { ex.printStackTrace(); } }
/** @author padraig */ public class ProjectTest { static { // System.out.println("ProjectTest static: "+ProjectStructure.getCMLExamplesDir()); } String projName = "Ex5_Networks"; File projDir = new File(ProjectStructure.getnCExamplesDir() + "/" + projName); File projFile = null; Project projLoaded = null; public ProjectTest() {} @Before public void setUp() { System.out.println("--------------- setUp() ProjectTest"); projFile = ProjectStructure.findProjectFile(projDir); try { projLoaded = Project.loadProject(projFile, null); System.out.println("Proj status: " + projLoaded.getProjectStatusAsString()); } catch (ProjectFileParsingException ex) { fail("Error loading: " + projFile.getAbsolutePath()); } } @After public void tearDown() {} /** Test of createNewProject method, of class Project. */ @Test public void testCreateNewProject() throws IOException, NoProjectLoadedException { System.out.println("--- testCreateNewProject"); String projName2 = "TestingFrameworkProject"; File projDir2 = new File(MainTest.getTempProjectDirectory(), projName2); Project proj = Project.createNewProject(projDir2.getAbsolutePath(), projName2, null); System.out.println("Created project at: " + proj.getProjectFile().getCanonicalPath()); proj.saveProject(); File projFileNew = proj.getProjectFile(); assertEquals(proj.getProjectName(), projName2); assertTrue(projFileNew.exists()); } @Test public void testCopyProject() throws IOException, NoProjectLoadedException, ProjectFileParsingException, Exception { System.out.println("--- testCopyAndRunProject"); String projNameNew = "TestingGranCell"; File projDirNew = new File(MainTest.getTempProjectDirectory(), projNameNew); if (projDirNew.exists()) { GeneralUtils.removeAllFiles(projDirNew, false, true, true); } System.out.println("Ex " + projDirNew.getCanonicalFile() + ": " + projDirNew.exists()); projDirNew.mkdir(); File projFile = new File(projDirNew, projNameNew + ".ncx"); File oldProjDir = new File(ProjectStructure.getnCModelsDir(), "GranuleCell"); File oldProj = new File(oldProjDir, "GranuleCell.ncx"); ProjectManager p = new ProjectManager(); Project proj = p.copyProject(oldProj, projFile); System.out.println("Created project at: " + proj.getProjectFile().getCanonicalPath()); assertEquals(proj.getProjectName(), projNameNew); assertTrue(projFile.exists()); } /** Test of getProjectFileName method, of class Project. */ @Test public void testGetProjectFileName() { System.out.println("--- getProjectFileName"); String expResult = ProjectStructure.findProjectFile(projDir).getName(); String result = projLoaded.getProjectFileName(); assertEquals(expResult, result); } public static void main(String[] args) { ProjectTest ct = new ProjectTest(); Result r = org.junit.runner.JUnitCore.runClasses(ct.getClass()); MainTest.checkResults(r); } }