@@ -0,0 +1,2156 @@
+/*%0A * Copyright 2008-2017 by Emeric Vernat%0A *%0A *     This file is part of Java Melody.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.bull.javamelody.internal.model;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.Random;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport net.bull.javamelody.Utils;%0Aimport net.bull.javamelody.internal.common.Parameters;%0A%0A/**%0A * Test unitaire de la classe CounterStorage.%0A * @author Emeric Vernat%0A */%0Apublic class TestWebappVersions %7B%0A%09private static final String VERSIONS_FILENAME = %22versions.properties%22;%0A%0A%09/** Test. */%0A%09@Before%0A%09public void setUp() %7B%0A%09%09Utils.initialize();%0A%09%7D%0A%0A%09/** Test. %0A%09 * @throws IOException e */%0A%09@Test%0A%09public void test() throws IOException %7B%0A%09%09final String application = %22unittest%22;%0A%09%09final File storageDirectory = Parameters.getStorageDirectory(application);%0A%09%09final File versionsFile = new File(storageDirectory, VERSIONS_FILENAME);%0A%09%09versionsFile.delete();%0A%09%09WebappVersions webappVersions = new WebappVersions(application);%0A%09%09assertEquals(%220%22, 0, webappVersions.getDatesByVersions().size());%0A%09%09final Random random = new Random();%0A%09%09final String version = String.valueOf(random.nextInt());%0A%09%09webappVersions.addVersionIfNeeded(version);%0A%09%09webappVersions = new WebappVersions(application);%0A%09%09assertEquals(%221%22, 1, webappVersions.getDatesByVersions().size());%0A%09%09webappVersions.addVersionIfNeeded(version);%0A%09%09assertEquals(%221%22, 1, webappVersions.getDatesByVersions().size());%0A%09%09webappVersions.addVersionIfNeeded(version + %22b%22);%0A%09%09assertEquals(%222%22, 2, webappVersions.getDatesByVersions().size());%0A%09%7D%0A%7D%0A

improve unit tests