|
From: <de...@us...> - 2003-03-18 14:05:55
|
Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/test/reflux
In directory sc8-pr-cvs1:/tmp/cvs-serv8811/dodico/src/org/fudaa/dodico/test/reflux
Modified Files:
TestDunes.java
Log Message:
ajout des tests pour la lecture et ecriture des fichiers telemac/reflux
Index: TestDunes.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/test/reflux/TestDunes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestDunes.java 21 Feb 2003 16:27:59 -0000 1.1
--- TestDunes.java 18 Mar 2003 14:05:21 -0000 1.2
***************
*** 18,28 ****
import junit.framework.TestCase;
! import org.fudaa.dodico.commun.DodicoIOAnalyse;
import org.fudaa.dodico.commun.DodicoLib;
import org.fudaa.dodico.commun.ProgressionBuAdapter;
import org.fudaa.dodico.corba.geometrie.SPoint;
! import org.fudaa.dodico.tr.reflux.DunesInterface;
! import org.fudaa.dodico.tr.reflux.DunesReader;
! import org.fudaa.dodico.tr.reflux.DunesWriter;
import com.memoire.bu.BuTask;
--- 18,28 ----
import junit.framework.TestCase;
! import org.fudaa.dodico.commun.DodicoIOAnalyze;
import org.fudaa.dodico.commun.DodicoLib;
import org.fudaa.dodico.commun.ProgressionBuAdapter;
import org.fudaa.dodico.corba.geometrie.SPoint;
! import org.fudaa.dodico.dunes.io.DunesInterface;
! import org.fudaa.dodico.dunes.io.DunesReader;
! import org.fudaa.dodico.dunes.io.DunesWriter;
import com.memoire.bu.BuTask;
***************
*** 37,60 ****
double eps_;
DunesInterface t_;
!
public TestDunes()
{
! eps_=1E-15;
! t_=lecture(getFile("mesh.mail"));
}
!
private final static synchronized DunesInterface lecture(File _f)
{
DunesInterface t = null;
! FileReader in=null;
try
{
assertNotNull(_f);
! in=new FileReader(_f);
! DodicoIOAnalyse a = new DunesReader(in).read();
! assertNull(a.getErrors());
! assertNull(a.getWarnings());
! assertNull(a.getInfos());
! t=(DunesInterface)a.getSource();
}
catch (IOException _e)
--- 37,61 ----
double eps_;
DunesInterface t_;
!
public TestDunes()
{
! eps_ = 1E-15;
! t_ = lecture(getFile("mesh.mail"));
}
!
private final static synchronized DunesInterface lecture(File _f)
{
DunesInterface t = null;
! FileReader in = null;
try
{
assertNotNull(_f);
! in = new FileReader(_f);
! DunesReader r = new DunesReader();
! r.setIn(in);
! r.read();
! t = r.getDunesInterface();
! DodicoIOAnalyze a = r.getAnalyze();
! assertNull(a);
}
catch (IOException _e)
***************
*** 66,142 ****
try
{
! if(in!=null) in.close();
}
! catch(IOException e)
{
System.err.println("Impossible de fermer le flux");
e.printStackTrace();
}
!
}
return t;
}
!
private synchronized void communTest(DunesInterface _t)
{
assertNotNull(_t);
! double[] adapt=_t.getAdaptatifValeur();
! int temp=adapt.length;
assertEquals(temp, 9);
! assertEquals(adapt[0] , 0.1d,eps_);
! assertEquals(adapt[1] , 1d,eps_);
! assertEquals(adapt[2] , 1d,eps_);
! assertEquals(adapt[3] , 1d,eps_);
! assertEquals(adapt[4] , 0.1d,eps_);
! assertEquals(adapt[5] , 0.01d,eps_);
! assertEquals(adapt[6] , 0.01d,eps_);
! assertEquals(adapt[7] , 1d,eps_);
! assertEquals(adapt[8] , 1d,eps_);
assertNotNull(_t.getMaillage());
! SPoint[] pts=_t.getMaillage().points;
! temp=pts.length;
assertEquals(temp, 9);
! SPoint pt=pts[0];
! assertEquals(pt.x, 0d,eps_);
! assertEquals(pt.y, 0d,eps_);
! assertEquals(pt.z, 0.25,eps_);
! pt=pts[4];
! assertEquals(pt.x, 0d,eps_);
! assertEquals(pt.y, 3d,eps_);
! assertEquals(pt.z, 0.25,eps_);
! pt=pts[8];
! assertEquals(pt.x, 2d,eps_);
! assertEquals(pt.y, 1d,eps_);
! assertEquals(pt.z, 0.1,eps_);
! int[][] elems=_t.getMaillage().elements;
! temp=elems.length;
assertEquals(temp, 9);
! int[] indices=elems[1];
! temp=indices.length;
assertEquals(temp, 3);
! assertEquals(indices[0],5);
! assertEquals(indices[1],1);
! assertEquals(indices[2],6);
! indices=elems[6];
! temp=indices.length;
assertEquals(temp, 3);
! assertEquals(indices[0],5);
! assertEquals(indices[1],6);
! assertEquals(indices[2],7);
}
public void testLecture()
{
! communTest(t_);
}
!
public void testEcriture()
{
! File tFile=null;
try
{
! tFile=File.createTempFile("temp", ".mail");
}
! catch(IOException e)
{
e.printStackTrace();
--- 67,144 ----
try
{
! if (in != null)
! in.close();
}
! catch (IOException e)
{
System.err.println("Impossible de fermer le flux");
e.printStackTrace();
}
!
}
return t;
}
!
private synchronized void communTest(DunesInterface _t)
{
assertNotNull(_t);
! double[] adapt = _t.getAdaptatifValeur();
! int temp = adapt.length;
assertEquals(temp, 9);
! assertEquals(adapt[0], 0.1d, eps_);
! assertEquals(adapt[1], 1d, eps_);
! assertEquals(adapt[2], 1d, eps_);
! assertEquals(adapt[3], 1d, eps_);
! assertEquals(adapt[4], 0.1d, eps_);
! assertEquals(adapt[5], 0.01d, eps_);
! assertEquals(adapt[6], 0.01d, eps_);
! assertEquals(adapt[7], 1d, eps_);
! assertEquals(adapt[8], 1d, eps_);
assertNotNull(_t.getMaillage());
! SPoint[] pts = _t.getMaillage().points;
! temp = pts.length;
assertEquals(temp, 9);
! SPoint pt = pts[0];
! assertEquals(pt.x, 0d, eps_);
! assertEquals(pt.y, 0d, eps_);
! assertEquals(pt.z, 0.25, eps_);
! pt = pts[4];
! assertEquals(pt.x, 0d, eps_);
! assertEquals(pt.y, 3d, eps_);
! assertEquals(pt.z, 0.25, eps_);
! pt = pts[8];
! assertEquals(pt.x, 2d, eps_);
! assertEquals(pt.y, 1d, eps_);
! assertEquals(pt.z, 0.1, eps_);
! int[][] elems = _t.getMaillage().elements;
! temp = elems.length;
assertEquals(temp, 9);
! int[] indices = elems[1];
! temp = indices.length;
assertEquals(temp, 3);
! assertEquals(indices[0], 5);
! assertEquals(indices[1], 1);
! assertEquals(indices[2], 6);
! indices = elems[6];
! temp = indices.length;
assertEquals(temp, 3);
! assertEquals(indices[0], 5);
! assertEquals(indices[1], 6);
! assertEquals(indices[2], 7);
}
public void testLecture()
{
! communTest(t_);
}
!
public void testEcriture()
{
! File tFile = null;
try
{
! tFile = File.createTempFile("temp", ".mail");
}
! catch (IOException e)
{
e.printStackTrace();
***************
*** 144,156 ****
assertNotNull(tFile);
tFile.deleteOnExit();
! DunesWriter out=null;
! boolean ecrit=false;
try
{
! out=new DunesWriter(new FileWriter(tFile),t_);
out.write();
! ecrit=true;
}
! catch(IOException io)
{
io.printStackTrace();
--- 146,160 ----
assertNotNull(tFile);
tFile.deleteOnExit();
! DunesWriter out = null;
! boolean ecrit = false;
try
{
! out = new DunesWriter();
! out.setOut(new FileWriter(tFile));
! out.setDunesInterface(t_);
out.write();
! ecrit = true;
}
! catch (IOException io)
{
io.printStackTrace();
***************
*** 158,177 ****
finally
{
! try
! {
! if(out!=null) out.close();
! }
! catch(IOException io)
{
! System.err.println("Impossible de fermer le flux");
! io.printStackTrace();
}
}
assertTrue(ecrit);
! communTest(lecture(tFile));
}
!
!
!
private File getFile(String _f)
{
--- 162,178 ----
finally
{
!
! if (out != null)
{
! IOException[] exs = out.close();
! if (exs != null)
! System.err.println("Impossible de fermer le flux");
}
+
}
assertTrue(ecrit);
! communTest(lecture(tFile));
}
!
private File getFile(String _f)
{
***************
*** 192,235 ****
{
System.err.println("Usage: -file=monFichier.mail -out=monFichierReecrit");
}
File f = new File(fileName);
if (!f.exists())
System.err.println("Fichier inexistant " + f.getAbsolutePath());
! DunesReader r=null;
! DunesInterface inter=null;
! ProgressionBuAdapter progress=new ProgressionBuAdapter(new BuTask());
try
{
! r = new DunesReader(new FileReader(f));
r.setProgressReceiver(progress);
! DodicoIOAnalyse infos = r.read();
! if(infos.isError())
{
System.err.println("Attention erreur");
}
! DodicoIOAnalyse.Field[] t=infos.getErrors();
! if(t!=null)
{
System.out.println("+ erreurs");
DodicoLib.printObject(t, true);
}
!
! t=infos.getWarnings();
! if(t!=null)
{
System.out.println("+ warnings");
DodicoLib.printObject(t, true);
}
!
! t=infos.getInfos();
! if(t!=null)
{
System.out.println("+ infos");
DodicoLib.printObject(t, true);
}
!
! if(infos.getSource()!=null)
{
! inter=(DunesInterface)infos.getSource();
System.out.println("+ source");
DodicoLib.printFields(inter, true);
--- 193,243 ----
{
System.err.println("Usage: -file=monFichier.mail -out=monFichierReecrit");
+ return;
}
File f = new File(fileName);
if (!f.exists())
+ {
System.err.println("Fichier inexistant " + f.getAbsolutePath());
! return;
! }
! DunesReader r = null;
! DunesInterface inter = null;
! ProgressionBuAdapter progress = new ProgressionBuAdapter(new BuTask());
try
{
! r = new DunesReader();
! r.setIn(new FileReader(f));
r.setProgressReceiver(progress);
! r.read();
! inter = r.getDunesInterface();
! DodicoIOAnalyze infos = r.getAnalyze();
! if (infos.containsErrors())
{
System.err.println("Attention erreur");
}
! DodicoIOAnalyze.Field[] t = infos.getErrors();
! if (t != null)
{
System.out.println("+ erreurs");
DodicoLib.printObject(t, true);
}
!
! t = infos.getWarnings();
! if (t != null)
{
System.out.println("+ warnings");
DodicoLib.printObject(t, true);
}
!
! t = infos.getInfos();
! if (t != null)
{
System.out.println("+ infos");
DodicoLib.printObject(t, true);
}
!
! if (inter != null)
{
!
System.out.println("+ source");
DodicoLib.printFields(inter, true);
***************
*** 237,241 ****
}
else
! System.out.println("Attention Pas de source");
}
catch (IOException e)
--- 245,249 ----
}
else
! System.out.println("Attention Pas de source");
}
catch (IOException e)
***************
*** 243,279 ****
e.printStackTrace();
}
!
finally
{
! try
! {
! if (r != null)
! r.close();
! }
! catch (IOException e)
{
! System.err.println("Impossible de fermer le flux");
! e.printStackTrace();
}
}
fileName = (String) arg.get("-out");
! if(fileName==null)
{
System.err.println("pas de sortie");
! return;
}
! File out=new File(fileName);
! if(out.exists())
{
System.err.println("Le fichier existe déja :opération annulée");
return;
}
! DunesWriter w=null;
try
{
! w=new DunesWriter(new FileWriter(out),inter,progress);
w.write();
}
! catch(IOException io)
{
io.printStackTrace();
--- 251,286 ----
e.printStackTrace();
}
!
finally
{
! if (r != null)
{
! IOException[] exs = r.close();
! if (exs != null)
! System.err.println("Impossible de fermer le flux");
}
}
fileName = (String) arg.get("-out");
! if (fileName == null)
{
System.err.println("pas de sortie");
! return;
}
! File out = new File(fileName);
! if (out.exists())
{
System.err.println("Le fichier existe déja :opération annulée");
return;
}
! DunesWriter w = null;
try
{
! w = new DunesWriter();
! w.setOut(new FileWriter(out));
! w.setProgressReceiver(progress);
! w.setDunesInterface(inter);
w.write();
}
! catch (IOException io)
{
io.printStackTrace();
***************
*** 281,298 ****
finally
{
! try
! {
! if(w!=null) w.close();
! }
! catch(IOException io)
{
! System.err.println("Impossible de fermer le flux");
! io.printStackTrace();
}
}
-
-
-
-
}
--- 288,298 ----
finally
{
! if (w != null)
{
! IOException[] exs = w.close();
! if (exs != null)
! System.err.println("Impossible de fermer le flux");
}
}
}
|