package servidor;

import java.util.ArrayList;

import org.junit.Assert;
import org.junit.Test;

// obtenido de https://andrejserafim.wordpress.com/2010/10/07/testing-threads-with-junit/s
public class ServidorTest {

	@Test
	public void pruebaThreadServidor() throws InterruptedException{
		 Servidor s = new Servidor() {
		     @Override 
		     public void run() {
		    	 Assert.fail();
		      }           
	     };
		Thread t1 = new Thread(s);
		t1.start();
		t1.join();
	}

	@Test public void testCase2Threads() throws InterruptedException {
        final ArrayList<Integer> threadsCompleted = new ArrayList< Integer >();
        Runnable runnable1 = new Runnable() {
            @Override 
            public void run() {
                Assert.fail();
                threadsCompleted.add(1);
            }
        };
         
        Runnable runnable2 = new Runnable() {
            @Override 
            public void run() {
                Assert.assertTrue( true );
                threadsCompleted.add(2);
            }
        };
         
        Thread t1 = new Thread( runnable1 );
        Thread t2 = new Thread( runnable2 );
         
        t1.start();
        t2.start();
        t1.join();
        t2.join();
         
        System.out.println( "Threads completed: " + threadsCompleted );
        Assert.assertEquals(2, threadsCompleted.size());
    }
	
	
	
}

@@ -28,71 +28,293 @@
 ava.
-util.ArrayList;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test
+sql.PreparedStatement;%0Aimport java.sql.SQLException;%0Aimport java.util.ArrayList;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport cliente.Cliente;%0Aimport cliente.Mensaje;%0Aimport cliente.MensajePersonaje;%0Aimport cliente.Usuario;%0Aimport dominio.Personaje;%0Aimport utilities.Loggin
 ;%0A%0A/
@@ -698,16 +698,18 @@
 %0A%09%7D%0A
+%09
 %0A%09@Test
- 
+%0A%09
 publ
@@ -720,891 +720,699 @@
 oid 
-testCase2Threads() throws InterruptedException %7B%0A        final ArrayList%3CInteger%3E threadsCompleted = new ArrayList%3C Integer %3E();%0A        Runnable runnable1 = new Runnable() %7B%0A            @Override %0A            public void run() %7B%0A                Assert.fail();%0A                threadsCompleted.add(1);%0A            %7D%0A        %7D;%0A         %0A        Runnable runnable2 = new Runnable() %7B%0A            @Override %0A            public void run() %7B%0A                Assert.assertTrue( true );%0A                threadsCompleted.add(2);%0A            %7D%0A        %7D;%0A         %0A        Thread t1 = new Thread( runnable1 );%0A        Thread t2 = new Thread( runnable2 );%0A         %0A        t1.start();%0A        t2.start();%0A        t1.join();%0A        t2.join();%0A         %0A        System.out.println( %22Threads completed: %22 + threadsCompleted );%0A        Assert.assertEquals(2, threadsCompleted.size());%0A    %7D%0A%09%0A%09
+actualizarRaza()%7B%0A%09%09Usuario user = new Usuario();%0A%09%09user.setNombre_usuario(%22GUS%22);%0A%09%09%0A%09%09DBControlador db = new DBControlador();%0A%09%09db.connect();%0A%09%09MensajePersonaje pp = db.getPersonaje(user);%0A%09%09Assert.assertEquals(%22ORCO%22, pp.getRaza());%0A%09%09%0A%09%09MensajePersonaje msj = new MensajePersonaje();%0A%09%09msj.setIdPersonaje(3);%0A%09%09msj.setRaza(%22HUMANO%22);%0A%09%09msj.setCasta(%22HECHICERO%22);%0A%09%09db.actualizarElPersonaje(msj);%0A%09%09pp = db.getPersonaje(user);%0A%09%09Assert.assertEquals(%22HUMANO%22, pp.getRaza());%0A%09%09%0A%09%09MensajePersonaje dejarOriginal = new MensajePersonaje();%0A%09%09dejarOriginal.setIdPersonaje(3);%0A%09%09dejarOriginal.setRaza(%22ORCO%22);%0A%09%09dejarOriginal.setCasta(%22HECHICERO%22);%0A%09%09db.actualizarElPersonaje(dejarOriginal);%0A%09%7D
 %0A%09%0A%7D

Test de Servidor