import java.io.IOException;

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;


/*
 * TestFileStore.java
 *
 * created at 29.10.2009 by Krum Valkov <k.valkov@bg.seeburge.com>
 * 
 * $Id: eclipse-seeburger-codetemplates.xml,v 1.1 2005/03/04 15:02:28 UllrichPollaehne Exp www-data $
 *
 * Copyright (c) 2009 SEEBURGER AG, Germany. All Rights Reserved.
 */

public class TestFileStore
{
    private static final String DOMAIN = "";
    private static final String PASSWORD = "";
    private static final String USER_NAME = "";
    private static String DIRECTORY = "";


    public static void main(String[] args)
        throws IOException
    {
        int bufferSize = 1024 * 512;
        byte[] buffer = new byte[bufferSize];
        for (int i = 0; i < buffer.length; i++)
        {
            buffer[i] = (byte)(i % Byte.MAX_VALUE);
        }
        System.out.println("START");
        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(DOMAIN, USER_NAME, PASSWORD);

        SmbFile dir = new SmbFile(DIRECTORY, auth);
        if (!dir.exists())
        {
            dir.mkdirs();
        }
        SmbFile file = new SmbFile(dir.getPath() + "F" + System.currentTimeMillis(), auth);
        if (!file.exists())
        {
            file.createNewFile();
        }
        System.out.println("SMB file " + file.getPath() + " created!");
        SmbFileOutputStream out = new SmbFileOutputStream(file);
        int iterations = 2000;
        System.out.println("Start writing");
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++)
        {
            out.write(buffer, 0, buffer.length);
        }
        long endTime = System.currentTimeMillis();
        String writingTime = (endTime - startTime) / 1000 + " seconds and " + (endTime - startTime) % 1000
                             + " milliseconds";
        System.out.println("Writing finished in " + writingTime);
    }
}
