Java Code Examples for junit.framework.TestCase#assertSame()

The following examples show how to use junit.framework.TestCase#assertSame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
@Config(interfaceClass = Greeting.class, filter = {"f1, f2"}, listener = {"l1, l2"},
        parameters = {"k1", "v1", "k2", "v2"})
public void appendAnnotation() throws Exception {
    Config config = getClass().getMethod("appendAnnotation").getAnnotation(Config.class);
    AnnotationConfig annotationConfig = new AnnotationConfig();
    annotationConfig.appendAnnotation(Config.class, config);
    TestCase.assertSame(Greeting.class, annotationConfig.getInterface());
    TestCase.assertEquals("f1, f2", annotationConfig.getFilter());
    TestCase.assertEquals("l1, l2", annotationConfig.getListener());
    TestCase.assertEquals(2, annotationConfig.getParameters().size());
    TestCase.assertEquals("v1", annotationConfig.getParameters().get("k1"));
    TestCase.assertEquals("v2", annotationConfig.getParameters().get("k2"));
    assertThat(annotationConfig.toString(), Matchers.containsString("filter=\"f1, f2\" "));
    assertThat(annotationConfig.toString(), Matchers.containsString("listener=\"l1, l2\" "));
}
 
Example 2
Source File: TestAbstractPinProvider.java    From Bulldog with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPinByName() {
	MockedBoard board = new MockedBoard();
	
	Pin availablePin = board.getPin("P4");
	TestCase.assertNotNull(availablePin);
	TestCase.assertEquals("P4", availablePin.getName());
	
	Pin nonExistentPin = board.getPin("P11");
	TestCase.assertNull(nonExistentPin);
	
	nonExistentPin = board.getPin("Chewbacca");
	TestCase.assertNull(nonExistentPin);
	
	for(Pin pin : board.getPins()) {
		Pin crossCheck = board.getPin(pin.getName());
		TestCase.assertSame(pin, crossCheck);
	}
	
	try {
		board.getPin(null);
		TestCase.fail();
	} catch(IllegalArgumentException ex) {}
}
 
Example 3
Source File: TestAbstractPinProvider.java    From Bulldog with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPinByAdress() {
	MockedBoard board = new MockedBoard();
	
	Pin availablePin = board.getPin(0);
	TestCase.assertNotNull(availablePin);
	TestCase.assertEquals(0, availablePin.getAddress());
	
	Pin nonExistentPin = board.getPin(-1);
	TestCase.assertNull(nonExistentPin);
	
	nonExistentPin = board.getPin(11);
	TestCase.assertNull(nonExistentPin);
	
	for(Pin pin : board.getPins()) {
		Pin crossCheck = board.getPin(pin.getAddress());
		TestCase.assertSame(pin, crossCheck);
	}
}
 
Example 4
Source File: AbstractInterfaceConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplication() throws Exception {
    InterfaceConfig interfaceConfig = new InterfaceConfig();
    ApplicationConfig applicationConfig = new ApplicationConfig();
    interfaceConfig.setApplication(applicationConfig);
    TestCase.assertSame(applicationConfig, interfaceConfig.getApplication());
}
 
Example 5
Source File: AbstractInterfaceConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testModule() throws Exception {
    InterfaceConfig interfaceConfig = new InterfaceConfig();
    ModuleConfig moduleConfig = new ModuleConfig();
    interfaceConfig.setModule(moduleConfig);
    TestCase.assertSame(moduleConfig, interfaceConfig.getModule());
}
 
Example 6
Source File: AbstractInterfaceConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegistry() throws Exception {
    InterfaceConfig interfaceConfig = new InterfaceConfig();
    RegistryConfig registryConfig = new RegistryConfig();
    interfaceConfig.setRegistry(registryConfig);
    TestCase.assertSame(registryConfig, interfaceConfig.getRegistry());
}
 
Example 7
Source File: AbstractInterfaceConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegistries() throws Exception {
    InterfaceConfig interfaceConfig = new InterfaceConfig();
    RegistryConfig registryConfig = new RegistryConfig();
    interfaceConfig.setRegistries(Collections.singletonList(registryConfig));
    TestCase.assertEquals(1, interfaceConfig.getRegistries().size());
    TestCase.assertSame(registryConfig, interfaceConfig.getRegistries().get(0));
}
 
Example 8
Source File: AbstractInterfaceConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testMonitor() throws Exception {
    InterfaceConfig interfaceConfig = new InterfaceConfig();
    interfaceConfig.setMonitor("monitor-addr");
    TestCase.assertEquals("monitor-addr", interfaceConfig.getMonitor().getAddress());
    MonitorConfig monitorConfig = new MonitorConfig();
    interfaceConfig.setMonitor(monitorConfig);
    TestCase.assertSame(monitorConfig, interfaceConfig.getMonitor());
}
 
Example 9
Source File: TestDFSClientUpdateNameNodeSignature.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/**
 * Test when name-node's finger-print changes, client re-fetch the
 * name-node proxy.
 */
public void testClientUpdateMethodList() throws IOException {
  InetSocketAddress addr = cluster.getNameNode().getNameNodeDNAddress();
  DFSClient client = new DFSClient(addr, cluster.getNameNode().getConf());
  ClientProtocol oldNamenode = client.namenode;
  
  // Client's name-node proxy should keep the same if the same namenode
  // sends the same fingerprint
  //
  OutputStream os = client.create("/testClientUpdateMethodList.txt", true);
  os.write(66);
  os.close();
  TestCase.assertSame(oldNamenode, client.namenode);    
  int oldFingerprint = cluster.getNameNode().getClientProtocolMethodsFingerprint();
  TestCase.assertEquals(oldFingerprint, client.namenodeProtocolProxy
      .getMethodsFingerprint());
  
  // Namenode's fingerprint will be different to client. Client is suppsoed
  // to get a new proxy.
  //
  cluster.getNameNode().setClientProtocolMethodsFingerprint(666);
  os = client.create("/testClientUpdateMethodList1.txt", true);
  os.write(88);
  os.close();
  TestCase.assertNotSame(oldNamenode, client.namenode);
  // Since we didn't change method list of name-node, the fingerprint
  // got from the new proxy should be the same as the previous one.
  TestCase.assertEquals(oldFingerprint, client.namenodeProtocolProxy
      .getMethodsFingerprint());
  
  // Client's name-node proxy should keep the same if the same namenode
  // sends the same fingerprint
  //
  ClientProtocol namenode1 = client.namenode;
  cluster.getNameNode().setClientProtocolMethodsFingerprint(oldFingerprint);
  DFSInputStream dis = client.open("/testClientUpdateMethodList.txt");
  int val = dis.read();
  TestCase.assertEquals(66, val);
  dis.close();
  TestCase.assertSame(namenode1, client.namenode);

  // Namenode's fingerprint will be different to client. Client is suppsoed
  // to get a new proxy.
  //
  cluster.getNameNode().setClientProtocolMethodsFingerprint(888);
  dis = client.open("/testClientUpdateMethodList1.txt");
  val = dis.read();
  TestCase.assertEquals(88, val);
  dis.close();
  // Since we didn't change method list of name-node, the fingerprint
  // got from the new proxy should be the same as the previous one.
  TestCase.assertNotSame(namenode1, client.namenode);
}