You are here: Wiki>SE Web>TeachingHome>ProgrammierPraktikum2006>ProgrammierPraktikum2006Nuetzliches (01 Mar 2007, oezbekPCPOOL.MI.FU-BERLIN.DE)Edit

Nützliche Tipps fürs ProgrammierPraktikum2006

Eclipse

  • Kein Subclipse
    • Nach-Installieren: Help -> Software Updates -> Find & Install -> New Remote Site -> Subclipse, URL: http://subclipse.tigris.org/update_1.0.x -> OK -> Finish -> Wichtig: NICHT auswählen "Show the latest Version of ..." -> Next -> Subclipse 1.0.5 auswählen -> Next ... Okay ... usw.

  • Unter Windows: Eclipse lässt sich nicht starten, wenn es Probleme mit dem Profil gibt
    • Eclipse direct aus c:\bin\eclipse...\eclipse....exe starten

Splineforge

Subversion Repository

  • Zugriff (lesend) nicht möglich
    • Lässt sich mit der URL das Repository im Browser browsen?
    • Ist der Benutzername und das Passwort für die Authentifizierung richtig?
    • Gehört der eigene Splineforge-Account zu den Mitgliedern des Projektes?

JUnit Mockserver

Mit folgendem Testcode könnt ihr einen Server lokal simulieren:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;

import junit.framework.TestCase;

public class TestWithMockServer extends TestCase {

   ServerSocket sock = new ServerSocket(42523);

   public TestWithMockServer() throws IOException {
   }

   public Thread letClientConnect(final String[] communication) throws IOException {

      Thread t;
      (t = new Thread() {
         public void run() {

            try {
               BufferedReader in;
               PrintStream out;
               Socket clientSocket;

               clientSocket = sock.accept();

               in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
               out = new PrintStream(clientSocket.getOutputStream(), true);

               for (int i = 0; i < communication.length; i++) {

                  switch (communication[i].charAt(0)) {
                  case '+':
                     String outS = communication[i].substring(1);
                     System.out.println("OUT: " + outS);
                     out.println(outS);
                     break;
                  case '-':
                     String read = in.readLine();
                     String excpected = communication[i].substring(1);
                     System.out.println("IN : " + read + " , " + excpected);

                     assertEquals(excpected, read);
                     break;
                  default:
                     out.println(communication[i]);
                  }
               }

               out.close();
               in.close();
               clientSocket.close();
               sock.close();
            } catch (Exception e) {
               throw new RuntimeException(e);
            }
         }
      }).start();
      return t;
   }

   public void testListGames() throws Exception {

      Thread t = letClientConnect(new String[] { "-PROTOCOL GASP 1.0", "+OK", "-USER Chris",
         "+OK", "-PASS SecretPass", "+OK", "-LIST PLAYERS", "+PLAYER Chris", "+OK",
         "-LIST GAMES", "+GAME Abalone", "+OK", "-LOGOUT", "+BYE" });

      Client c = new Client();
      c.connect("127.0.0.1", 42523, "Chris", "SecretPass");

      List s = c.list(Client.ListType.PLAYERS);
      assertNotNull(s);
      assertEquals(1, s.size());
      assertTrue(s.contains("Chris"));

      List s2 = c.list(Client.ListType.GAMES);
      assertEquals(1, s2.size());
      assertTrue(s2.contains("Abalone"));

      assertEquals(ResponseType.BYE, c.logOut().getResponseType());
      t.join();

   }

Comments

 
Topic revision: r4 - 01 Mar 2007, oezbekPCPOOL.MI.FU-BERLIN.DE
 
  • Printable version of this topic (p) Printable version of this topic (p)