Revision 1233
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.scripting.swing</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.scripting</artifactId> |
|
11 |
<version>2.3.92</version> |
|
12 |
</parent> |
|
13 |
<modules> |
|
14 |
<module>org.gvsig.scripting.swing.api</module> |
|
15 |
<module>org.gvsig.scripting.swing.impl</module> |
|
16 |
</modules> |
|
17 |
</project> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/README.txt | ||
---|---|---|
1 |
#set( $symbol_pound = '#' ) |
|
2 |
#set( $symbol_dollar = '$' ) |
|
3 |
#set( $symbol_escape = '\' ) |
|
4 |
For each class you are going to test, create one Test class with the same |
|
5 |
name as the class to test, ending with Test. |
|
6 |
|
|
7 |
For example, the unit tests of the "ExampleLibrary" class are performed |
|
8 |
by the "ExampleLibraryTest" class. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/MyTestJScriptableThinlet.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.io.File; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
|
|
8 |
import org.gvsig.scripting.swing.api.JThinlet; |
|
9 |
import org.gvsig.scripting.swing.impl.DefaultJThinlet; |
|
10 |
|
|
11 |
public class MyTestJScriptableThinlet { |
|
12 |
|
|
13 |
public static void main(String[] args) { |
|
14 |
|
|
15 |
// Creamos el JPanel del thinlet y le |
|
16 |
// cargamos el xml de pruebas. |
|
17 |
JThinlet panel = new DefaultJThinlet(new File("/home/jobacas/ScriptFramework/org.gvsig.scripting/src/org/gvsig/scripting/impl/xul/thing.xml")); |
|
18 |
|
|
19 |
JFrame frame = new JFrame("TEST JScriptableThinlet"); |
|
20 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
21 |
frame.setLayout(new BorderLayout()); |
|
22 |
frame.setSize(500, 400); |
|
23 |
// Añadimos el JPanel del thinlet al frame. |
|
24 |
frame.add(panel, BorderLayout.CENTER); |
|
25 |
//frame.pack(); |
|
26 |
frame.setVisible(true); |
|
27 |
|
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
|
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/impl/MyTestDefaultJThinG.java | ||
---|---|---|
1 |
package org.gvsig.scripting.impl; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
|
|
5 |
import javax.swing.JFrame; |
|
6 |
|
|
7 |
import org.gvsig.scripting.swing.impl.DefaultJThinG; |
|
8 |
|
|
9 |
public class MyTestDefaultJThinG { |
|
10 |
|
|
11 |
public static void main(String[] args) { |
|
12 |
|
|
13 |
// Creamos el JPanel del thinlet y le |
|
14 |
// cargamos el xml de pruebas. |
|
15 |
DefaultJThinG panel = new DefaultJThinG(); |
|
16 |
|
|
17 |
JFrame frame = new JFrame("TEST JScriptableThinlet"); |
|
18 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
19 |
frame.setLayout(new BorderLayout()); |
|
20 |
frame.setSize(500, 400); |
|
21 |
// Añadimos el JPanel del thinlet al frame. |
|
22 |
frame.add(panel, BorderLayout.CENTER); |
|
23 |
frame.pack(); |
|
24 |
frame.setVisible(true); |
|
25 |
|
|
26 |
} |
|
27 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/MyTestJScriptableThinG.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
|
|
5 |
import javax.swing.JFrame; |
|
6 |
|
|
7 |
import org.gvsig.scripting.swing.impl.DefaultJThinG; |
|
8 |
|
|
9 |
public class MyTestJScriptableThinG { |
|
10 |
|
|
11 |
public static void main(String[] args) { |
|
12 |
|
|
13 |
// Creamos el JPanel del thinlet y le |
|
14 |
// cargamos el xml de pruebas. |
|
15 |
DefaultJThinG panel = new DefaultJThinG(); |
|
16 |
|
|
17 |
JFrame frame = new JFrame("TEST JScriptableThinlet"); |
|
18 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
19 |
frame.setLayout(new BorderLayout()); |
|
20 |
frame.setSize(500, 400); |
|
21 |
// Añadimos el JPanel del thinlet al frame. |
|
22 |
frame.add(panel, BorderLayout.CENTER); |
|
23 |
//frame.pack(); |
|
24 |
frame.setVisible(true); |
|
25 |
|
|
26 |
} |
|
27 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/MyTestJScriptingBrowser.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
import javax.swing.JPanel; |
|
8 |
|
|
9 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
10 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
11 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingBrowser; |
|
12 |
|
|
13 |
public class MyTestJScriptingBrowser extends JPanel { |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
*/ |
|
18 |
private static final long serialVersionUID = 1L; |
|
19 |
private DefaultJScriptingBrowser treePanel; |
|
20 |
|
|
21 |
public MyTestJScriptingBrowser() { |
|
22 |
super(new BorderLayout()); |
|
23 |
|
|
24 |
// Inicializamos las librerías |
|
25 |
ScriptingLibrary lib = new ScriptingLibrary(); |
|
26 |
lib.initialize(); |
|
27 |
|
|
28 |
|
|
29 |
// Asignamos el locator e iniciamos la instancia |
|
30 |
|
|
31 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
32 |
ScriptingManager manager = uimanager.getManager(); |
|
33 |
treePanel = new DefaultJScriptingBrowser(uimanager, manager.getUserFolder()); |
|
34 |
|
|
35 |
// Establecemos algunas características del JPanel |
|
36 |
treePanel.setPreferredSize(new Dimension(500, 800)); |
|
37 |
add(treePanel, BorderLayout.CENTER); |
|
38 |
; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Create the GUI and show it. For thread safety, |
|
43 |
* this method should be invoked from the |
|
44 |
* event-dispatching thread. |
|
45 |
*/ |
|
46 |
private static void createAndShowGUI() { |
|
47 |
//Create and set up the window. |
|
48 |
JFrame frame = new JFrame("TEST ScriptUserBrowser"); |
|
49 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
50 |
|
|
51 |
//Create and set up the content pane. |
|
52 |
MyTestJScriptingBrowser newContentPane = new MyTestJScriptingBrowser(); |
|
53 |
newContentPane.setOpaque(true); //content panes must be opaque |
|
54 |
frame.getContentPane().add(newContentPane, BorderLayout.CENTER); |
|
55 |
|
|
56 |
//Display the window. |
|
57 |
frame.pack(); |
|
58 |
frame.setVisible(true); |
|
59 |
} |
|
60 |
|
|
61 |
public static void main(String[] args) { |
|
62 |
|
|
63 |
//Iniciamos el test |
|
64 |
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
|
65 |
public void run() { |
|
66 |
createAndShowGUI(); |
|
67 |
} |
|
68 |
}); |
|
69 |
} |
|
70 |
|
|
71 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/MyTestLauncher.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import javax.swing.JFrame; |
|
4 |
import javax.swing.JPanel; |
|
5 |
|
|
6 |
|
|
7 |
public class MyTestLauncher extends JPanel { |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
*/ |
|
12 |
private static final long serialVersionUID = 1L; |
|
13 |
|
|
14 |
|
|
15 |
public static void main( String args[] ) { |
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
// Inicializamos las librerías |
|
20 |
/* |
|
21 |
ScriptingLibrary lib = new ScriptingLibrary(); |
|
22 |
lib.initialize(); |
|
23 |
|
|
24 |
// Asignamos el locator e iniciamos la instancia |
|
25 |
ScriptingUIManager uimanager = ScriptingLocator.getUIManager(); |
|
26 |
ScriptingManager manager = uimanager.getManager(); |
|
27 |
|
|
28 |
URL u = TestLauncher.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts/"); |
|
29 |
File f = new File(u.getPath()); |
|
30 |
manager.registerSystemFolder("Tests", f); |
|
31 |
*/ |
|
32 |
|
|
33 |
JFrame frame = new JFrame("TEST Launcher"); |
|
34 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
35 |
|
|
36 |
//Create and set up the content pane. |
|
37 |
// JScriptingLauncher newContentPane = new JScriptingLauncher(uimanager); |
|
38 |
// newContentPane.setOpaque(true); //content panes must be opaque |
|
39 |
// frame.setContentPane(newContentPane); |
|
40 |
|
|
41 |
//Display the window. |
|
42 |
frame.pack(); |
|
43 |
frame.setSize( 250,400 ); |
|
44 |
frame.setVisible(true); |
|
45 |
|
|
46 |
} |
|
47 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/TestComposer.java | ||
---|---|---|
1 |
package org.gvsig.scripting; |
|
2 |
|
|
3 |
import javax.swing.JPanel; |
|
4 |
|
|
5 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
6 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
7 |
|
|
8 |
public class TestComposer extends JPanel { |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
*/ |
|
13 |
private static final long serialVersionUID = 1L; |
|
14 |
|
|
15 |
|
|
16 |
public static void main( String args[] ) { |
|
17 |
// Asignamos el locator e iniciamos la instancia |
|
18 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
19 |
ScriptingManager manager = uimanager.getManager(); |
|
20 |
|
|
21 |
/* URL u = TestLauncher.class.getClassLoader().getResource("org/gvsig/scripting/impl/scripts/"); |
|
22 |
File f = new File(u.getPath()); |
|
23 |
manager.registerSystemFolder("Tests", f); |
|
24 |
*/ |
|
25 |
|
|
26 |
uimanager.createComposer(); |
|
27 |
|
|
28 |
} |
|
29 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/swing/syntaxhighlight/MyTest.java | ||
---|---|---|
1 |
package org.gvsig.scripting.swing.syntaxhighlight; |
|
2 |
|
|
3 |
import javax.swing.JEditorPane; |
|
4 |
import javax.swing.JFrame; |
|
5 |
import javax.swing.JScrollPane; |
|
6 |
|
|
7 |
|
|
8 |
public class MyTest { |
|
9 |
public static void main(String a[]) |
|
10 |
{ |
|
11 |
|
|
12 |
/* final JEditorPane edit = new JEditorPaneSyntaxHighlighting(); |
|
13 |
edit.setContentType("text/java"); |
|
14 |
|
|
15 |
JFrame frame = new JFrame("Syntax Highlighting"); |
|
16 |
frame.getContentPane().add( new JScrollPane(edit) ); |
|
17 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
18 |
frame.setSize(800,300); |
|
19 |
frame.setVisible(true);*/ |
|
20 |
} |
|
21 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/swing/impl/composer/TestJRemoveHelpModel.java | ||
---|---|---|
1 |
package org.gvsig.scripting.swing.impl.composer; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import org.gvsig.scripting.ScriptingLocator; |
|
6 |
import org.gvsig.scripting.ScriptingManager; |
|
7 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
8 |
|
|
9 |
public class TestJRemoveHelpModel extends AbstractLibraryAutoInitTestCase { |
|
10 |
|
|
11 |
protected ScriptingManager manager; |
|
12 |
protected JMoveScriptModel model; |
|
13 |
|
|
14 |
@Override |
|
15 |
protected void doSetUp() throws Exception { |
|
16 |
manager = ScriptingLocator.getManager(); |
|
17 |
} |
|
18 |
|
|
19 |
public void setWorkingHelpFolder(){ |
|
20 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home/help").getFile()); |
|
21 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
22 |
// manager.getHelpManager().setFolder(file.getAbsolutePath()); |
|
23 |
} |
|
24 |
|
|
25 |
public void testMove() { |
|
26 |
setWorkingHelpFolder(); |
|
27 |
|
|
28 |
} |
|
29 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/swing/impl/composer/TestJRenameModel.java | ||
---|---|---|
1 |
package org.gvsig.scripting.swing.impl.composer; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import junit.framework.Assert; |
|
6 |
|
|
7 |
import org.gvsig.scripting.ScriptingLocator; |
|
8 |
import org.gvsig.scripting.ScriptingManager; |
|
9 |
import org.gvsig.scripting.ScriptingScript; |
|
10 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
11 |
|
|
12 |
public class TestJRenameModel extends AbstractLibraryAutoInitTestCase { |
|
13 |
|
|
14 |
protected ScriptingManager manager; |
|
15 |
protected JRenameModel model; |
|
16 |
|
|
17 |
@Override |
|
18 |
protected void doSetUp() throws Exception { |
|
19 |
manager = ScriptingLocator.getManager(); |
|
20 |
} |
|
21 |
|
|
22 |
public void setWorkingFolder(){ |
|
23 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
24 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
25 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
26 |
} |
|
27 |
|
|
28 |
public File getFile(String name){ |
|
29 |
return new File(manager.getRootUserFolder()+File.separator+name); |
|
30 |
} |
|
31 |
|
|
32 |
public void checkExistsFile(String fName){ |
|
33 |
File fscript = getFile(fName); |
|
34 |
Assert.assertTrue(fscript.exists()); |
|
35 |
} |
|
36 |
|
|
37 |
public void checkDoesntExistFile(String fName){ |
|
38 |
File fscript = getFile(fName); |
|
39 |
Assert.assertFalse(fscript.exists()); |
|
40 |
} |
|
41 |
|
|
42 |
public void testRename() { |
|
43 |
setWorkingFolder(); |
|
44 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
45 |
checkExistsFile("testScript01.py"); |
|
46 |
checkExistsFile("testScript01.inf"); |
|
47 |
|
|
48 |
model = new JRenameModel(manager,script); |
|
49 |
model.setNewName("testScript"); |
|
50 |
try { |
|
51 |
model.validate(); |
|
52 |
} catch (Exception e) { |
|
53 |
Assert.fail("The data model is correct. Validation couldn't fail"); |
|
54 |
} |
|
55 |
Assert.assertTrue(script.rename("testScript")); |
|
56 |
|
|
57 |
//Comprobamos que existen los ficheros con el nuevo nombre |
|
58 |
checkExistsFile("testScript.py"); |
|
59 |
checkExistsFile("testScript.inf"); |
|
60 |
|
|
61 |
//Confirmamos que han sido renombrados y no copiados |
|
62 |
checkDoesntExistFile("testScript01.py"); |
|
63 |
checkDoesntExistFile("testScript01.inf"); |
|
64 |
} |
|
65 |
|
|
66 |
public void testRenameSameName() { |
|
67 |
setWorkingFolder(); |
|
68 |
ScriptingScript script1 = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
69 |
ScriptingScript script2 = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript02"); |
|
70 |
|
|
71 |
checkExistsFile(script2.getId()+".py"); |
|
72 |
checkExistsFile(script2.getId()+".inf"); |
|
73 |
|
|
74 |
model = new JRenameModel(manager,script1); |
|
75 |
model.setNewName(script2.getId()); |
|
76 |
try { |
|
77 |
model.validate(); |
|
78 |
} catch (Exception e) { |
|
79 |
Assert.assertEquals("This file already exists.\nWrite another name for the script",e.getMessage()); |
|
80 |
} |
|
81 |
Assert.assertFalse(script1.rename(script2.getId())); |
|
82 |
|
|
83 |
} |
|
84 |
|
|
85 |
public void testRenameWithEmptyNewName() { |
|
86 |
setWorkingFolder(); |
|
87 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
88 |
checkExistsFile("testScript01.py"); |
|
89 |
checkExistsFile("testScript01.inf"); |
|
90 |
|
|
91 |
model = new JRenameModel(manager,script); |
|
92 |
model.setNewName(""); |
|
93 |
try { |
|
94 |
model.validate(); |
|
95 |
} catch (Exception e) { |
|
96 |
Assert.assertEquals("Name must not be empty.",e.getMessage()); |
|
97 |
} |
|
98 |
|
|
99 |
checkExistsFile("testScript01.py"); |
|
100 |
checkExistsFile("testScript01.inf"); |
|
101 |
} |
|
102 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/swing/impl/composer/TestJMoveScriptModel.java | ||
---|---|---|
1 |
package org.gvsig.scripting.swing.impl.composer; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import junit.framework.Assert; |
|
6 |
|
|
7 |
import org.gvsig.scripting.ScriptingFolder; |
|
8 |
import org.gvsig.scripting.ScriptingLocator; |
|
9 |
import org.gvsig.scripting.ScriptingManager; |
|
10 |
import org.gvsig.scripting.ScriptingScript; |
|
11 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
12 |
|
|
13 |
public class TestJMoveScriptModel extends AbstractLibraryAutoInitTestCase { |
|
14 |
|
|
15 |
protected ScriptingManager manager; |
|
16 |
protected JMoveScriptModel model; |
|
17 |
|
|
18 |
@Override |
|
19 |
protected void doSetUp() throws Exception { |
|
20 |
manager = ScriptingLocator.getManager(); |
|
21 |
} |
|
22 |
|
|
23 |
public void setWorkingFolder(){ |
|
24 |
File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
25 |
// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
26 |
// manager.setRootUserFolder(file.getAbsolutePath()); |
|
27 |
} |
|
28 |
|
|
29 |
public void testMove() { |
|
30 |
setWorkingFolder(); |
|
31 |
ScriptingFolder folder = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER, manager.getUserFolder(), "test"); |
|
32 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
33 |
model = new JMoveScriptModel(manager,script); |
|
34 |
model.setMoveTo(folder.getFile()); |
|
35 |
try { |
|
36 |
model.validate(); |
|
37 |
} catch (Exception e) { |
|
38 |
Assert.fail("The data model is correct. Validation couldn't fail"); |
|
39 |
} |
|
40 |
script.move(folder); |
|
41 |
Assert.assertEquals(folder.getFile().getAbsolutePath(), model.getUnit().getParent().getFile().getAbsolutePath()); |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
public void testMoveWithSameName() { |
|
46 |
setWorkingFolder(); |
|
47 |
ScriptingFolder folder = (ScriptingFolder) manager.createUnit(ScriptingManager.UNIT_FOLDER, manager.getUserFolder(), "test"); |
|
48 |
ScriptingScript script1 = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
49 |
manager.createUnit(ScriptingManager.UNIT_SCRIPT, folder, "testScript01"); |
|
50 |
model = new JMoveScriptModel(manager,script1); |
|
51 |
model.setMoveTo(folder.getFile()); |
|
52 |
try { |
|
53 |
model.validate(); |
|
54 |
} catch (Exception e) { |
|
55 |
Assert.assertEquals("This file already exists.\nWrite another name for the script",e.getMessage()); |
|
56 |
} |
|
57 |
Assert.assertFalse(script1.move(folder)); |
|
58 |
} |
|
59 |
|
|
60 |
public void testMoveToAnInvalidDestination() { |
|
61 |
setWorkingFolder(); |
|
62 |
ScriptingScript script = (ScriptingScript) manager.createUnit(ScriptingManager.UNIT_SCRIPT, manager.getUserFolder(), "testScript01"); |
|
63 |
model = new JMoveScriptModel(manager,script); |
|
64 |
|
|
65 |
model.setMoveTo(""); |
|
66 |
try { |
|
67 |
model.validate(); |
|
68 |
} catch (Exception e) { |
|
69 |
Assert.assertEquals("Destination must not be empty.",e.getMessage()); |
|
70 |
} |
|
71 |
|
|
72 |
model.setMoveTo("/not/a/valid/path"); |
|
73 |
try { |
|
74 |
model.validate(); |
|
75 |
} catch (Exception e) { |
|
76 |
Assert.assertEquals("Not a valid destination.",e.getMessage()); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/java/org/gvsig/scripting/swing/impl/composer/TestJNewScriptModel.java | ||
---|---|---|
1 |
package org.gvsig.scripting.swing.impl.composer; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import junit.framework.Assert; |
|
6 |
|
|
7 |
import org.gvsig.scripting.ScriptingFolder; |
|
8 |
import org.gvsig.scripting.ScriptingLocator; |
|
9 |
import org.gvsig.scripting.ScriptingManager; |
|
10 |
import org.gvsig.scripting.ScriptingUnit; |
|
11 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
12 |
|
|
13 |
public class TestJNewScriptModel extends AbstractLibraryAutoInitTestCase { |
|
14 |
|
|
15 |
protected ScriptingManager manager; |
|
16 |
// protected JNewScriptModel model; |
|
17 |
// protected JNewScriptModel model2; |
|
18 |
// |
|
19 |
@Override |
|
20 |
protected void doSetUp() throws Exception { |
|
21 |
manager = ScriptingLocator.getManager(); |
|
22 |
} |
|
23 |
|
|
24 |
// public void setWorkingFolder(){ |
|
25 |
// File file =new File(this.getClass().getClassLoader().getResource("org/gvsig/scripting/home").getFile()); |
|
26 |
// if (!file.exists()) { |
|
27 |
// file.mkdir(); |
|
28 |
// } |
|
29 |
//// FIXME: hay que sustituirlo por manager.setHomeFolder(home) |
|
30 |
//// manager.setRootUserFolder(file.getAbsolutePath()); |
|
31 |
// } |
|
32 |
// |
|
33 |
// public void testCreate(){ |
|
34 |
// setWorkingFolder(); |
|
35 |
// model.setType(ScriptingManager.UNIT_SCRIPT); |
|
36 |
// model.setName("TestScript01"); |
|
37 |
// model.setDescription("Test Script 01"); |
|
38 |
// model.setCreatedBy("Anonymus"); |
|
39 |
// model.setVersion("v0.1"); |
|
40 |
// model.setPath(manager.getRootUserFolder()); |
|
41 |
// try { |
|
42 |
// model.validate(); |
|
43 |
// } catch (Exception e) { |
|
44 |
// Assert.fail("The data model is correct. Validation couldn't fail"); |
|
45 |
// } |
|
46 |
// } |
|
47 |
// |
|
48 |
// public void testCreateWithEmptyName() { |
|
49 |
// testCreate(); |
|
50 |
// model.setType(ScriptingManager.UNIT_SCRIPT); |
|
51 |
// model.setName(""); |
|
52 |
// model.setDescription("Test Script 01"); |
|
53 |
// model.setCreatedBy("Anonymus"); |
|
54 |
// model.setVersion("v0.1"); |
|
55 |
// model.setPath(manager.getRootUserFolder()); |
|
56 |
// try { |
|
57 |
// model.validate(); |
|
58 |
// } catch (Exception e) { |
|
59 |
// Assert.assertEquals(e.getMessage(), "Name must not be empty."); |
|
60 |
// } |
|
61 |
// } |
|
62 |
// |
|
63 |
// public void testCreateWithSameName() { |
|
64 |
// testCreate(); |
|
65 |
// this.manager.createUnit( |
|
66 |
// model.getType(), |
|
67 |
// manager.getFolder(new File(model.getPath())), |
|
68 |
// model.getName()+model.getExtension() |
|
69 |
// ); |
|
70 |
// |
|
71 |
// model.setType(ScriptingManager.UNIT_SCRIPT); |
|
72 |
// model.setName("TestScript01"); |
|
73 |
// model.setDescription("Test Script 01"); |
|
74 |
// model.setCreatedBy("Anonymus"); |
|
75 |
// model.setVersion("v0.1"); |
|
76 |
// model.setPath(manager.getRootUserFolder()); |
|
77 |
// try { |
|
78 |
// model.validate(); |
|
79 |
// } catch (Exception e) { |
|
80 |
// Assert.assertEquals(e.getMessage(), "This file already exists.\nWrite another name for the script"); |
|
81 |
// |
|
82 |
// } |
|
83 |
// ScriptingUnit newFolder= this.manager.createUnit( |
|
84 |
// ScriptingManager.UNIT_FOLDER, |
|
85 |
// manager.getFolder(new File(model.getPath())), |
|
86 |
// "scripts" |
|
87 |
// ); |
|
88 |
// model.setPath(((ScriptingFolder) newFolder).getPath()); |
|
89 |
// try { |
|
90 |
// model.validate(); |
|
91 |
// } catch (Exception e) { |
|
92 |
// Assert.fail("The data model is correct. Validation couldn't fail"); |
|
93 |
// } |
|
94 |
// |
|
95 |
// } |
|
96 |
// |
|
97 |
// public void testCreateProjects() { |
|
98 |
// testCreate(); |
|
99 |
// |
|
100 |
// model.setType(ScriptingManager.UNIT_PROJECT); |
|
101 |
// model.setName("TestScript01"); |
|
102 |
// model.setDescription("Test Script 01"); |
|
103 |
// model.setCreatedBy("Anonymus"); |
|
104 |
// model.setVersion("v0.1"); |
|
105 |
// model.setPath(manager.getRootUserFolder()); |
|
106 |
// try { |
|
107 |
// model.validate(); |
|
108 |
// } catch (Exception e) { |
|
109 |
// Assert.assertEquals(e.getMessage(), "Projects will be supported in future versions"); |
|
110 |
// |
|
111 |
// } |
|
112 |
// } |
|
113 |
|
|
114 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
DefaultExampleManager class. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.scripting.impl.DefaultExampleManager"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
|
|
26 |
<!-- |
|
27 |
By default, show only logging messages of INFO level or higher, |
|
28 |
through the previously configured CONSOLE appender. |
|
29 |
--> |
|
30 |
<root> |
|
31 |
<priority value="INFO" /> |
|
32 |
<appender-ref ref="CONSOLE" /> |
|
33 |
</root> |
|
34 |
</log4j:configuration> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
#set( $symbol_pound = '#' ) |
|
2 |
#set( $symbol_dollar = '$' ) |
|
3 |
#set( $symbol_escape = '\' ) |
|
4 |
Put into this folder the resources needed by your test classes. |
|
5 |
|
|
6 |
This folder is added to the Tests classpath, so you can load any resources |
|
7 |
through the ClassLoader. |
|
8 |
|
|
9 |
By default, in this folder you can find an example of log4j configuration, |
|
10 |
prepared to log messages through the console, so logging works when you |
|
11 |
run your tests classes. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/javadoc/overview.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.scripting package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>TODO: Example library overview.</p> |
|
11 |
|
|
12 |
<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#overviewcomment">Javadoc Tool documentation about the overview file</a></p> |
|
13 |
|
|
14 |
</body> |
|
15 |
</html> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your library classes. |
|
2 |
|
|
3 |
This folder is added to the runtime classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, into this folder you can find some examples of resource bundle |
|
7 |
property files that may be used by your library classes. |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.92/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.scripting.swing.impl.ScriptingSwingDefaultSwingLibrary |
Also available in: Unified diff