@@ -0,0 +1,2541 @@
+/*%0A * Hivemall: Hive scalable Machine Learning Library%0A *%0A * Copyright (C) 2013-2014%0A *   National Institute of Advanced Industrial Science and Technology (AIST)%0A *   Registration Number: H25PRO-1520%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA%0A */%0Apackage hivemall.mix.server;%0A%0Aimport hivemall.io.DenseModel;%0Aimport hivemall.io.PredictionModel;%0Aimport hivemall.io.WeightValue;%0Aimport hivemall.mix.MixMessage.MixEventName;%0Aimport hivemall.mix.client.MixClient;%0Aimport hivemall.utils.lang.CommandLineUtils;%0A%0Aimport java.util.Random;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.apache.commons.cli.CommandLine;%0Aimport org.junit.Test;%0A%0Apublic class MixServerTest %7B%0A%0A    @Test%0A    public void testScenario1() throws InterruptedException %7B%0A        CommandLine cl = CommandLineUtils.parseOptions(new String%5B%5D %7B %22-port%22, %2211212%22,%0A                %22-sync_threshold%22, %223%22 %7D, MixServer.getOptions());%0A        MixServer server = new MixServer(cl);%0A        ExecutorService serverExec = Executors.newSingleThreadExecutor();%0A        serverExec.submit(server);%0A%0A        PredictionModel model = new DenseModel(16777216, false);%0A        model.configureClock();%0A        MixClient client = new MixClient(MixEventName.average, %22scenario1%22, %22localhost:11212%22, false, 2, model);%0A        model.setUpdateHandler(client);%0A%0A        final Random rand = new Random(43);%0A        for(int i = 0; i %3C 100000; i++) %7B%0A            Integer feature = Integer.valueOf(rand.nextInt(100));%0A            float weight = (float) rand.nextGaussian();%0A            model.set(feature, new WeightValue(weight));%0A        %7D%0A%0A        Thread.sleep(10 * 1000);%0A        int numMixed = model.getNumMixed();%0A        //System.out.println(%22number of mix events: %22 + numMixed);%0A        Assert.assertTrue(%22number of mix events: %22 + numMixed, numMixed %3E 0);%0A%0A        serverExec.shutdown();%0A    %7D%0A%0A%7D%0A

Add a unit test for MixServer