GlueGen: src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java Source File

GlueGen v2.6.0-rc-20250722 GlueGen, Native Binding Generator for Java™ (public API).

Test1p2DynamicLibraryBundle.java
Go to the documentation of this file.
1/**
2 * Copyright 2019 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.gluegen.test.junit.generation;
30
31import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p1Impl;
32import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl;
33import com.jogamp.common.os.DynamicLibraryBundle;
34import com.jogamp.common.os.DynamicLibraryBundleInfo;
35import com.jogamp.common.os.NativeLibrary;
36import com.jogamp.common.util.RunnableExecutor;
37import com.jogamp.common.util.TestIOUtil01;
38
39import java.util.ArrayList;
40import java.util.Arrays;
41import java.util.List;
42
43import org.junit.AfterClass;
44import org.junit.Assert;
45import org.junit.BeforeClass;
46import org.junit.Test;
47import org.junit.FixMethodOrder;
48import org.junit.runners.MethodSorters;
49
50@FixMethodOrder(MethodSorters.NAME_ASCENDING)
51public class Test1p2DynamicLibraryBundle extends BaseClass {
52
53 static DynamicLibraryBundle dlb;
54
55 /**
56 * Verifies loading of the new library.
57 */
58 @BeforeClass
59 public static void chapter__TestLoadLibrary() throws Exception {
60 dlb = new DynamicLibraryBundle(new Test1DynLibBundleInfo());
61 Assert.assertTrue("DynamicLibraryBundle failed", dlb.isLibComplete());
62 System.err.println("Loaded: "+dlb.getToolLibraries());
63
64 Bindingtest1p2Impl.resetProcAddressTable(dlb);
65 }
66
67 /**
68 * Verifies the existence and creation of the generated class.
69 */
70 @Test
71 public void chapter00TestClassExist() throws Exception {
72 testClassExist("test1p2");
73 }
74
75 /**
76 * Verifies if all generated method signatures are completed,
77 * ie a compilation only coverage test without functional tests.
78 */
79 public void chapter__TestCoverageSignature() throws Exception {
80 chapter__TestCoverageSignature(new Bindingtest1p2Impl());
81 }
82
83 /**
84 * Verifies if all generated static constant values are completed,
85 * and whether their value is as expected!
86 * <p>
87 * Covers all enumerates and defines.
88 * </p>
89 */
90 @Test
91 public void chapter01TestStaticConstants() throws Exception {
92 chapter01TestStaticConstants(new Bindingtest1p2Impl());
93 }
94
95 /**
96 * Verifies if all methods / signatures are properly generated,
97 * can be invoked and functions.
98 * This is a compilation (coverage) and runtime time (semantic) test.
99 * This covers indirect primitive arrays and direct NIO buffers.
100 */
101 @Test
102 public void chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception {
103 chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p2Impl(), true);
104 }
105
106 /**
107 * Verifies if all methods / signatures are properly generated,
108 * can be invoked and functions.
109 * This is a compilation (coverage) and runtime time (semantic) test.
110 * This covers indirect primitive arrays and indirect NIO buffers (nio using arrays).
111 */
112 @Test
113 public void chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray() throws Exception {
114 chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p2Impl(), false);
115 }
116
117 /**
118 * This covers direct / indirect pointer buffers
119 */
120 @Test
121 public void chapter04TestPointerBuffer() throws Exception {
122 this.chapter04TestPointerBuffer(new Bindingtest1p2Impl());
123 }
124
125 /**
126 * This covers indirect primitive arrays and indirect NIO buffers.
127 */
128 @Test
129 public void chapter05TestSomeFunctionsAllIndirect() throws Exception {
130 chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p2Impl());
131 }
132
133 /**
134 * This covers compounds (structs) data alignment
135 */
136 @Test
137 public void chapter09TestCompoundAlignment() throws Exception {
138 chapter09TestCompoundAlignment(new Bindingtest1p2Impl());
139 }
140
141 /**
142 * This covers compounds (structs) call-by-reference
143 */
144 @Test
145 public void chapter10TestCompoundCallByReference() throws Exception {
146 chapter10TestCompoundCallByReference(new Bindingtest1p2Impl());
147 }
148
149 /**
150 * This covers compounds (structs) call-by-value
151 */
152 @Test
153 public void chapter11TestCompoundCallByValue() throws Exception {
154 chapter11TestCompoundCallByValue(new Bindingtest1p2Impl());
155 }
156
157 /**
158 * Test compound access read-write
159 */
160 @Test
161 public void chapter12TestTKField() throws Exception {
162 chapter12TestTKField(new Bindingtest1p2Impl());
163 }
164
165 /**
166 * Test compound access read-only
167 */
168 @Test
169 public void chapter13TestTKFieldImmutable() throws Exception {
170 chapter13TestTKFieldImmutable(new Bindingtest1p2Impl());
171 }
172
173 @Test
174 public void chapter14TestTKMixed() throws Exception {
175 chapter14TestTKMixed(new Bindingtest1p2Impl());
176 }
177
178 /**
179 * Test Custom JNI Code invocation
180 */
181 @Test
182 public void chapter15TestCustomJNICode() throws Exception {
183 chapter15TestCustomJNICode(new Bindingtest1p2Impl());
184 }
185
186 @Test
187 public void chapter16TestPascalString() throws Exception {
188 chapter16TestPascalString(new Bindingtest1p2Impl());
189 }
190
191 /**
192 * Verifies unloading of the new library.
193 */
194 @AfterClass
195 public static void chapter0XTestUnloadLibrary() throws Exception {
196 Assert.assertNotNull(dlb);
197 dlb.destroy();
198 dlb = null;
199 }
200
201 @SuppressWarnings("unused")
202 public static void main(final String args[]) throws Exception {
203 if( false ) {
204 chapter__TestLoadLibrary();
205 final Test1p2DynamicLibraryBundle tst = new Test1p2DynamicLibraryBundle();
206 tst.chapter00TestClassExist();
207 } else {
208 final String tstname = Test1p2DynamicLibraryBundle.class.getName();
209 org.junit.runner.JUnitCore.main(tstname);
210 }
211 }
212
213 public static class Test1DynLibBundleInfo implements DynamicLibraryBundleInfo {
214 private static final List<String> glueLibNames;
215 static {
216 glueLibNames = new ArrayList<String>();
217 glueLibNames.add("Bindingtest1p2");
218 }
219
220 protected Test1DynLibBundleInfo() {
221 }
222
223 /**
224 * <p>
225 * Returns <code>true</code>,
226 * since we might load the library and allow symbol access to subsequent libs.
227 * </p>
228 */
229 @Override
230 public final boolean shallLinkGlobal() { return true; }
231
232 /**
233 * {@inheritDoc}
234 * <p>
235 * Returns <code>false</code>.
236 * </p>
237 */
238 @Override
239 public final boolean shallLookupGlobal() { return false; }
240
241 @Override
242 public final List<String> getGlueLibNames() {
243 return glueLibNames;
244 }
245
246 @Override
247 public final boolean searchToolLibInSystemPath() {
248 return true;
249 }
250
251 @Override
252 public final boolean searchToolLibSystemPathFirst() {
253 return true;
254 }
255
256 @Override
257 public final List<List<String>> getToolLibNames() {
258 final List<List<String>> libNamesList = new ArrayList<List<String>>();
259
260 final List<String> libNames = new ArrayList<String>();
261 {
262 // this is the default AL lib name, according to the spec
263 // libNames.add("libtest1.so"); // unix
264 libNames.add("test1"); // windows, OSX
265 }
266 libNamesList.add(libNames);
267
268 return libNamesList;
269 }
270
271 @Override
272 public List<String> getSymbolForToolLibPath() { return Arrays.asList("testXID"); }
273
274 @Override
275 public final List<String> getToolGetProcAddressFuncNameList() {
276 return null;
277 }
278
279 @Override
280 public final long toolGetProcAddress(final long toolGetProcAddressHandle, final String funcName) {
281 return 0;
282 }
283
284 @Override
285 public final boolean useToolGetProcAdressFirst(final String funcName) {
286 return false;
287 }
288
289 @Override
290 public final RunnableExecutor getLibLoaderExecutor() {
291 return DynamicLibraryBundle.getDefaultRunnableExecutor();
292 }
293 }
294
295}
com.jogamp.common.os.DynamicLibraryBundle
Provides bundling of:
Definition: DynamicLibraryBundle.java:61
com.jogamp.common.os.DynamicLibraryBundle.getToolLibraries
final List< NativeLibrary > getToolLibraries()
Returns list of NativeLibrarys for each DynamicLibraryBundleInfo#getToolLibNames() in the same size a...
Definition: DynamicLibraryBundle.java:223
com.jogamp.common.os.DynamicLibraryBundle.destroy
final void destroy()
Unload all NativeLibrarys, and remove all references.
Definition: DynamicLibraryBundle.java:159
com.jogamp.common.os.DynamicLibraryBundle.isLibComplete
final boolean isLibComplete()
Definition: DynamicLibraryBundle.java:180
com.jogamp.common.os.DynamicLibraryBundle.getDefaultRunnableExecutor
static RunnableExecutor getDefaultRunnableExecutor()
Returns an AWT-EDT RunnableExecutor implementation if AWT is available, otherwise RunnableExecutor#cu...
Definition: DynamicLibraryBundle.java:82
com.jogamp.gluegen.test.junit.generation.BaseClass
Definition: BaseClass.java:51
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo
Definition: Test1p2DynamicLibraryBundle.java:213
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.getToolGetProcAddressFuncNameList
final List< String > getToolGetProcAddressFuncNameList()
May return the native libraries.
Definition: Test1p2DynamicLibraryBundle.java:275
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.Test1DynLibBundleInfo
Test1DynLibBundleInfo()
Definition: Test1p2DynamicLibraryBundle.java:220
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.getToolLibNames
final List< List< String > > getToolLibNames()
If a SecurityManager is installed, user needs link permissions for the named libraries.
Definition: Test1p2DynamicLibraryBundle.java:257
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.useToolGetProcAdressFirst
final boolean useToolGetProcAdressFirst(final String funcName)
Definition: Test1p2DynamicLibraryBundle.java:285
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.getLibLoaderExecutor
final RunnableExecutor getLibLoaderExecutor()
Returns a suitable RunnableExecutor implementation, which is being used to load the tool and glue nat...
Definition: Test1p2DynamicLibraryBundle.java:290
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.searchToolLibSystemPathFirst
final boolean searchToolLibSystemPathFirst()
Returns true if system path shall be searched first (default), rather than searching it last.
Definition: Test1p2DynamicLibraryBundle.java:252
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.toolGetProcAddress
final long toolGetProcAddress(final long toolGetProcAddressHandle, final String funcName)
May implement the lookup function using the Tools facility.
Definition: Test1p2DynamicLibraryBundle.java:280
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.getGlueLibNames
final List< String > getGlueLibNames()
If a SecurityManager is installed, user needs link permissions for the named libraries.
Definition: Test1p2DynamicLibraryBundle.java:242
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.shallLookupGlobal
final boolean shallLookupGlobal()
If method returns true and if a SecurityManager is installed, user needs link permissions for all lib...
Definition: Test1p2DynamicLibraryBundle.java:239
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.searchToolLibInSystemPath
final boolean searchToolLibInSystemPath()
Returns true if tool libraries shall be searched in the system path (default), otherwise false.
Definition: Test1p2DynamicLibraryBundle.java:247
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.getSymbolForToolLibPath
List< String > getSymbolForToolLibPath()
Returns optional list of optional symbol names per getToolLibNames() in same order for an OS which re...
Definition: Test1p2DynamicLibraryBundle.java:272
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.Test1DynLibBundleInfo.shallLinkGlobal
final boolean shallLinkGlobal()
Definition: Test1p2DynamicLibraryBundle.java:230
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle
Definition: Test1p2DynamicLibraryBundle.java:51
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter14TestTKMixed
void chapter14TestTKMixed()
Definition: Test1p2DynamicLibraryBundle.java:174
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter05TestSomeFunctionsAllIndirect
void chapter05TestSomeFunctionsAllIndirect()
This covers indirect primitive arrays and indirect NIO buffers.
Definition: Test1p2DynamicLibraryBundle.java:129
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter01TestStaticConstants
void chapter01TestStaticConstants()
Verifies if all generated static constant values are completed, and whether their value is as expecte...
Definition: Test1p2DynamicLibraryBundle.java:91
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter__TestLoadLibrary
static void chapter__TestLoadLibrary()
Verifies loading of the new library.
Definition: Test1p2DynamicLibraryBundle.java:59
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter0XTestUnloadLibrary
static void chapter0XTestUnloadLibrary()
Verifies unloading of the new library.
Definition: Test1p2DynamicLibraryBundle.java:195
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray
void chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray()
Verifies if all methods / signatures are properly generated, can be invoked and functions.
Definition: Test1p2DynamicLibraryBundle.java:113
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter04TestPointerBuffer
void chapter04TestPointerBuffer()
This covers direct / indirect pointer buffers.
Definition: Test1p2DynamicLibraryBundle.java:121
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter11TestCompoundCallByValue
void chapter11TestCompoundCallByValue()
This covers compounds (structs) call-by-value.
Definition: Test1p2DynamicLibraryBundle.java:153
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.main
static void main(final String args[])
Definition: Test1p2DynamicLibraryBundle.java:202
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter12TestTKField
void chapter12TestTKField()
Test compound access read-write.
Definition: Test1p2DynamicLibraryBundle.java:161
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter16TestPascalString
void chapter16TestPascalString()
Definition: Test1p2DynamicLibraryBundle.java:187
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter__TestCoverageSignature
void chapter__TestCoverageSignature()
Verifies if all generated method signatures are completed, ie a compilation only coverage test withou...
Definition: Test1p2DynamicLibraryBundle.java:79
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter09TestCompoundAlignment
void chapter09TestCompoundAlignment()
This covers compounds (structs) data alignment.
Definition: Test1p2DynamicLibraryBundle.java:137
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter00TestClassExist
void chapter00TestClassExist()
Verifies the existence and creation of the generated class.
Definition: Test1p2DynamicLibraryBundle.java:71
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray
void chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray()
Verifies if all methods / signatures are properly generated, can be invoked and functions.
Definition: Test1p2DynamicLibraryBundle.java:102
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter10TestCompoundCallByReference
void chapter10TestCompoundCallByReference()
This covers compounds (structs) call-by-reference.
Definition: Test1p2DynamicLibraryBundle.java:145
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter13TestTKFieldImmutable
void chapter13TestTKFieldImmutable()
Test compound access read-only.
Definition: Test1p2DynamicLibraryBundle.java:169
com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle.chapter15TestCustomJNICode
void chapter15TestCustomJNICode()
Test Custom JNI Code invocation.
Definition: Test1p2DynamicLibraryBundle.java:182
com.jogamp.common.os.DynamicLibraryBundleInfo
Definition: DynamicLibraryBundleInfo.java:36
com.jogamp.common.util.RunnableExecutor
Definition: RunnableExecutor.java:30