source: java/main/src/test/java/com/framsticks/model/ModelPackageTest.java @ 105

Last change on this file since 105 was 105, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File size: 2.2 KB
Line 
1package com.framsticks.model;
2
3import java.io.InputStream;
4
5import org.testng.annotations.DataProvider;
6import org.testng.annotations.Test;
7
8import com.framsticks.params.FramsClass;
9import com.framsticks.params.ReflectionAccess;
10import com.framsticks.params.Source;
11import com.framsticks.params.ValueParam;
12import com.framsticks.parsers.FileSource;
13import com.framsticks.parsers.Loaders;
14import com.framsticks.test.TestConfiguration;
15
16import static org.fest.assertions.Assertions.*;
17import static com.framsticks.params.ParamsUtil.getParam;
18
19@Test
20public class ModelPackageTest extends TestConfiguration {
21
22        @Test(dataProvider = "classesList")
23        public void testFramsClass(Class<?> javaClass, String name, int paramCount, Object[][] paramsTests) throws InstantiationException, IllegalAccessException {
24                String filename = "/info/" + name + ".info";
25                InputStream stream = ModelPackage.class.getResourceAsStream(filename);
26                assertThat(stream).describedAs("stream " + filename).isNotNull();
27
28                Source source = new FileSource(stream, filename);
29
30                assertThat(source.isClosed()).isFalse();
31                FramsClass framsClass = Loaders.loadFramsClass(source);
32                assertThat(framsClass).isNotNull();
33
34                assertThat(framsClass.getParamCount()).isEqualTo(paramCount);
35                ReflectionAccess access = new ReflectionAccess(javaClass, framsClass);
36                Object object = javaClass.newInstance();
37                access.select(object);
38
39                if (paramsTests != null) {
40                        for (Object[] args : paramsTests) {
41                                String paramName = (String )args[0];
42                                Object defaultValue = args[1];
43
44                                ValueParam param = getParam(framsClass, paramName, ValueParam.class);
45                                assertThat(param.getDef(Object.class)).isEqualTo(defaultValue);
46
47                        }
48                }
49        }
50
51        @DataProvider
52        public Object[][] classesList() {
53                return new Object[][] {
54                        { MechPart.class, "MechPart", 20 , null},
55                        { Joint.class, "Joint", 16 , null},
56                        { MechJoint.class, "MechJoint", 10 , null},
57                        { Neuro.class, "Neuro", 21, null},
58                        { NeuroDefinition.class, "NeuroDef", 9, null},
59                        { Part.class, "Part", 18, new Object[][] {{"m", 1.0}}},
60                        // { Model.class, "Model", null},
61                        { Creature.class, "Creature", 64, null},
62                        { Genotype.class, "Genotype", 37, null},
63                        { World.class, "World", 10, null}
64                };
65        }
66}
Note: See TracBrowser for help on using the repository browser.