|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.arrow.adapter.jdbc; |
| 19 | + |
| 20 | +import static org.junit.Assert.*; |
| 21 | + |
| 22 | +import java.util.Calendar; |
| 23 | +import java.util.Locale; |
| 24 | +import java.util.TimeZone; |
| 25 | + |
| 26 | +import org.apache.arrow.memory.BaseAllocator; |
| 27 | +import org.apache.arrow.memory.RootAllocator; |
| 28 | +import org.junit.Test; |
| 29 | + |
| 30 | +public class JdbcToArrowConfigTest { |
| 31 | + |
| 32 | + private static final RootAllocator allocator = new RootAllocator(Integer.MAX_VALUE); |
| 33 | + private static final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT); |
| 34 | + |
| 35 | + @Test(expected = NullPointerException.class) |
| 36 | + public void testNullArguments() { |
| 37 | + new JdbcToArrowConfig(null, null); |
| 38 | + } |
| 39 | + |
| 40 | + @Test(expected = NullPointerException.class) |
| 41 | + public void testNullCalendar() { |
| 42 | + new JdbcToArrowConfig(allocator, null); |
| 43 | + } |
| 44 | + |
| 45 | + @Test(expected = NullPointerException.class) |
| 46 | + public void testNullAllocator() { |
| 47 | + new JdbcToArrowConfig(null, calendar); |
| 48 | + } |
| 49 | + |
| 50 | + @Test(expected = NullPointerException.class) |
| 51 | + public void testSetNullAllocator() { |
| 52 | + JdbcToArrowConfig config = new JdbcToArrowConfig(allocator, calendar); |
| 53 | + config.setAllocator(null); |
| 54 | + } |
| 55 | + |
| 56 | + @Test(expected = NullPointerException.class) |
| 57 | + public void testSetNullCalendar() { |
| 58 | + JdbcToArrowConfig config = new JdbcToArrowConfig(allocator, calendar); |
| 59 | + config.setCalendar(null); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void testConfig() { |
| 64 | + JdbcToArrowConfig config = new JdbcToArrowConfig(allocator, calendar); |
| 65 | + assertTrue(config.isValid()); |
| 66 | + assertTrue(allocator == config.getAllocator()); |
| 67 | + assertTrue(calendar == config.getCalendar()); |
| 68 | + |
| 69 | + Calendar newCalendar = Calendar.getInstance(); |
| 70 | + BaseAllocator newAllocator = new RootAllocator(Integer.SIZE); |
| 71 | + |
| 72 | + config.setAllocator(newAllocator).setCalendar(newCalendar); |
| 73 | + |
| 74 | + assertTrue(config.isValid()); |
| 75 | + assertTrue(newAllocator == config.getAllocator()); |
| 76 | + assertTrue(newCalendar == config.getCalendar()); |
| 77 | + } |
| 78 | +} |
0 commit comments