Example #1
0
 // Constructor
 // Sets time constant to unity and the order to unity
 public LowPassPassive() {
   super("Passive Low Pass Filter");
   super.setSnumer(new ComplexPoly(1.0D));
   super.setSdenom(new ComplexPoly(1.0D, 1.0D));
   super.setZtransformMethod(1);
   super.addDeadTimeExtras();
   this.timeConstant = 1.0D;
 }
Example #2
0
 @Test
 // 语法错误2
 public void testSendInfor9() throws InterruptedException {
   // fail("Not yet implemented");
   blackbox.sendInfor("S0,0,\"hello world\",R0");
   Thread.sleep(100);
   assertEquals("Invalid arg: S0,0,\"hello world\",R0\n", outContent.toString());
 }
Example #3
0
 @Test
 // 从不存在的节点接收
 public void testSendInfor7() throws InterruptedException {
   // fail("Not yet implemented");
   blackbox.sendInfor("S0,0,\"hello world\",R2,");
   Thread.sleep(100);
   assertEquals("Error: Index out of bound: R2\n", outContent.toString());
 }
Example #4
0
 @Test
 // 孤立Sender节点
 public void testSendInfor5() throws InterruptedException {
   // fail("Not yet implemented");
   blackbox.sendInfor("S2,0,\"hello world\",R0,");
   Thread.sleep(100);
   assertEquals("", outContent.toString());
 }
Example #5
0
 public void setCapacitance(double cap) {
   this.capacitance = cap;
   this.timeConstant = cap * this.resistance;
   this.calcPolesZerosS();
   super.sDenom = ComplexPoly.rootsToPoly(this.sPoles);
   super.addDeadTimeExtras();
   this.setC = true;
 }
Example #6
0
 @Test
 // 加密情况3
 public void testSendInfor3() throws InterruptedException {
   // fail("Not yet implemented");
   Pattern pattern = Pattern.compile("R0 received: \\(S1,R0,\"hello world\",.*\\)");
   blackbox.sendInfor("S1,1,\"hello world\",R0,");
   Thread.sleep(100);
   Matcher matcher = pattern.matcher(outContent.toString());
   assertTrue(matcher.find());
 }
Example #7
0
  @Test
  public void testNoOtherInvocations() {
    // Setup mocks
    Service1 s1 = mock(Service1.class);
    Service2 s2 = mock(Service2.class);

    // Stub relevant method
    stubReturn(42L).on(s1).methodA();

    BlackBox blackBox = new BlackBox(s1, s2);

    // Execute business method
    long result = blackBox.doSomething();

    // Assert result
    assertEquals(42, result);

    // Check that method has been invoked
    // This is somewhat unnecessary as it is already tested by the alias verification below.
    verifyOnce().on(s1).methodA();

    // Any of these calls will make the verification below fail.
    // s1.methodB();
    // s2.methodB();

    // Verify that no side effects occurred (desired testing)
    SimpleAlias alias = newAlias();
    alias.bind(s1).methodA();
    alias.verifyOnce();

    Alias allMatches = AllAlias.fromMock(s1);
    Alias difference = allMatches.difference(alias);
    difference.verifyNever();

    AllAlias.fromMock(s2).verifyNever();
  }
Example #8
0
  @BeforeClass
  public static void setUp() throws Exception {
    configFile = new File("./config.ini");
    badConfigFile = new File("./badConfig.ini");
    if (configFile.exists()) {
      configFile.delete();
    }
    configFile.createNewFile();
    FileWriter fw = new FileWriter(configFile);
    fw.write("(3,3,2)\nS0\nS2\n#\nR0\n#\n(S0,T0)\n(T0,R0)\n(T0,T1)\n(T1,T0)\n(T1,R1)\n(S1,T1)\n#");
    fw.close();

    if (badConfigFile.exists()) {
      badConfigFile.delete();
    }
    badConfigFile.createNewFile();
    fw = new FileWriter(badConfigFile);
    fw.write("(3,3,2)123\nS0\nS2\n#\nR0\n#\n(S0,T0)\n(T0,R0)\n(T0,T1)\n(T1,R1)\n(S1,T1)\n#");
    fw.close();

    blackbox = BlackBox.initBlackBox(configFile);
  }
Example #9
0
 @Test(expected = NotConfigFileException.class)
 public void testInitBlackBox() throws IOException, NotConfigFileException {
   // fail("Not yet implemented");
   BlackBox.initBlackBox(badConfigFile);
 }
Example #10
0
 @Test
 public void testLs_receiver() {
   // fail("Not yet implemented");
   blackbox.ls_receiver();
   assertEquals("R0:Decipherable\nR1:DisDecipherable\n", outContent.toString());
 }
Example #11
0
 @Test
 public void testLs_transponder() {
   // fail("Not yet implemented");
   blackbox.ls_transponder();
   assertNotEquals("", outContent.toString());
 }
Example #12
0
 @Test
 public void testLs_sender() {
   // fail("Not yet implemented");
   blackbox.ls_sender();
   assertEquals("S0:Encryptable\nS1:DisEncryptable\nS2:Encryptable\n", outContent.toString());
 }
Example #13
0
 @Test
 public void testLs_n() {
   // fail("Not yet implemented");
   blackbox.ls_n();
   assertEquals("(Sender: 3,Transponder: 3,Receiver: 2)\n", outContent.toString());
 }
Example #14
0
 @Test
 public void testPing() {
   // fail("Not yet implemented");
   blackbox.ping();
   assertNotEquals("", outContent.toString());
 }
Example #15
0
 public void setTimeConstant(double tau) {
   this.timeConstant = tau;
   this.calcPolesZerosS();
   super.sDenom = ComplexPoly.rootsToPoly(this.sPoles);
   super.addDeadTimeExtras();
 }
Example #16
0
 // Calculate the zeros and poles in the s-domain
 protected void calcPolesZerosS() {
   super.sPoles[0].setReal(-this.timeConstant);
 }