1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.incubator.jpackage.internal; 24 25 import java.util.List; 26 import java.util.stream.Collectors; 27 import java.util.stream.Stream; 28 import org.junit.Rule; 29 import org.junit.Test; 30 import org.junit.rules.ExpectedException; 31 import org.junit.runner.RunWith; 32 import org.junit.runners.Parameterized; 33 import org.junit.runners.Parameterized.Parameters; 34 35 @RunWith(Parameterized.class) 36 public class InvalidDottedVersionTest { 37 38 public InvalidDottedVersionTest(String version) { 39 this.version = version; 40 } 41 42 @Parameters 43 public static List<Object[]> data() { 44 return Stream.of( 45 "1.-1", 46 "5.", 47 "4.2.", 48 "3..2", 49 "2.a", 50 "0a", 51 ".", 52 " ", 53 " 1", 54 "1. 2", 55 "+1", 56 "-1", 57 "-0", 58 "1234567890123456789012345678901234567890" 59 ).map(version -> new Object[] { version }).collect(Collectors.toList()); 60 } 61 62 @Rule 63 public ExpectedException exceptionRule = ExpectedException.none(); 64 65 @Test 66 public void testIt() { 67 exceptionRule.expect(IllegalArgumentException.class); 68 new DottedVersion(version); 69 } 70 71 private final String version; 72 }