Java Reference

Java Reference

InitTest.java
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 package com.google.ortools.init;
15 
16 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import static org.junit.jupiter.api.Assertions.assertNotNull;
18 
19 import com.google.ortools.Loader;
20 import com.google.ortools.init.CppBridge;
21 import com.google.ortools.init.CppFlags;
22 import com.google.ortools.init.OrToolsVersion;
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.Test;
25 
27 public final class InitTest {
28  @BeforeEach
29  public void setUp() {
31  }
32 
33  @Test
34  public void testLogging() {
35  CppBridge.initLogging("init");
36  CppBridge.shutdownLogging();
37  }
38 
39  @Test
40  public void testFlags() {
41  final CppFlags cppFlags = new CppFlags();
42  assertNotNull(cppFlags);
43  cppFlags.setStderrthreshold(0);
44  cppFlags.setLog_prefix(true);
45  cppFlags.setCp_model_dump_prefix("init");
46  cppFlags.setCp_model_dump_models(true);
47  cppFlags.setCp_model_dump_lns(true);
48  cppFlags.setCp_model_dump_response(true);
49  CppBridge.setFlags(cppFlags);
50  }
51 
52  @Test
53  public void testVersion() {
54  final OrToolsVersion v = new OrToolsVersion();
55  assertNotNull(v);
56  final int major = v.getMajorNumber();
57  final int minor = v.getMinorNumber();
58  final int patch = v.getPatchNumber();
59  final String version = v.getVersionString();
60  final String check = major + "." + minor + "." + patch;
61  assertEquals(check, version);
62  }
63 }
Load native libraries needed for using ortools-java.
Definition: Loader.java:33
static synchronized void loadNativeLibraries()
Definition: Loader.java:104
Tests the Init java interface.
Definition: InitTest.java:27