예제 #1
1
  @Ignore
  @Test
  public void testLegendBaseline() throws Exception {
    assertTrue("Folder", map.getLegend().get(0) instanceof Folder);

    Folder folder = (Folder) map.getLegend().get(0);

    assertSame(
        "Reference Resource 0",
        map.getLayersInternal().get(0),
        ((LayerLegendItem) folder.getItems().get(0)).getLayer());
    assertSame(
        "Reference Resource 1",
        map.getLayersInternal().get(1),
        ((LayerLegendItem) folder.getItems().get(1)).getLayer());

    assertSame(
        "Reference Resource 2",
        map.getLayersInternal().get(2),
        ((LayerLegendItem) map.getLegend().get(1)).getLayer());
    assertSame(
        "Reference Resource 3",
        map.getLayersInternal().get(3),
        ((LayerLegendItem) map.getLegend().get(2)).getLayer());
  }
예제 #2
0
  @Test
  public void testNoAdd2WithCircDep() {
    Foo.instanceCounter = 0;
    PetiteContainer pc = new PetiteContainer();
    pc.registerBean(Foo.class);
    pc.registerBean(Zoo.class);
    pc.registerBean(Boo.class);

    Boo boo = (Boo) pc.getBean("boo");
    Foo foo = (Foo) pc.getBean("foo");
    Zoo zoo = (Zoo) pc.getBean("zoo");

    assertNotNull(boo.getFoo());
    assertSame(foo, boo.getFoo());

    assertNotNull(zoo.boo);
    assertSame(boo, zoo.boo);
    assertSame(zoo, boo.zoo);

    Boo boo2 = (Boo) pc.getBean("boo");
    assertNotNull(boo2);
    assertSame(boo, boo2);
    assertFalse(boo.orders.isEmpty());
    assertNotNull(boo2.getFoo());
    assertSame(foo, boo2.getFoo());
    assertEquals(1, boo2.getFoo().hello());
    assertEquals(1, boo2.getFoo().getCounter());
    assertEquals("[first, second, third, init, beforeLast, last]", boo.orders.toString());
  }
  @Test
  public void targetIsNotNull() {
    assertNotNull(target);

    assertNotNull(target.theNameForTheMeter);
    Meter meter =
        (Meter)
            forInjectMetricField(
                metricRegistry, InjectMetricTest.Target.class, "theNameForTheMeter");
    assertSame(target.theNameForTheMeter, meter);

    assertNotNull(target.timer);
    Timer timer =
        (Timer) forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "timer");
    assertSame(target.timer, timer);

    assertNotNull(target.counter);
    Counter ctr =
        (Counter) forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "counter");
    assertSame(target.counter, ctr);

    assertNotNull(target.histogram);
    Histogram hist =
        (Histogram)
            forInjectMetricField(metricRegistry, InjectMetricTest.Target.class, "histogram");
    assertSame(target.histogram, hist);
  }
 @Test
 public void testGetConnection() throws SQLException {
   assertSame(mockConnections[0], dataSource.getConnection());
   assertSame(mockConnections[1], dataSource.getConnection());
   assertSame(mockConnections[2], dataSource.getConnection());
   assertSame(mockConnections[3], dataSource.getConnection());
 }
  @Test
  public void get_with_hashingStrategy() {
    UnifiedSetWithHashingStrategy<Person> people =
        UnifiedSetWithHashingStrategy.newSet(
                HashingStrategies.nullSafeHashingStrategy(LAST_NAME_HASHING_STRATEGY), 2)
            .withAll(PEOPLE.castToList());

    // Putting null then testing geting a null
    Verify.assertSize(3, people.with((Person) null));
    Assert.assertNull(people.get(null));

    // Testing it is getting the same reference
    Assert.assertSame(JOHNSMITH, people.get(JANESMITH));
    Assert.assertSame(JOHNSMITH, people.get(JOHNSMITH));
    Assert.assertSame(JOHNDOE, people.get(JANEDOE));
    Assert.assertSame(JOHNDOE, people.get(JOHNDOE));

    Assert.assertSame(JOHNSMITH, people.get(new Person("Anything", "Smith")));
    Assert.assertNull(people.get(new Person("John", "NotHere")));

    // Testing get throws NullPointerException if the hashingStrategy is not null safe
    Verify.assertThrows(
        NullPointerException.class,
        () -> {
          UnifiedSetWithHashingStrategy.newSet(LAST_NAME_HASHING_STRATEGY).get(null);
        });
  }
예제 #6
0
  @Test
  public void setsUpApplicationContextBeforeCallToRequestHandler() throws Exception {
    ContainerRequest containerRequest = mockContainerRequest();
    ContainerResponse containerResponse = mockContainerResponse();
    EnvironmentContext environmentContext = mock(EnvironmentContext.class);

    ApplicationContext[] applicationContextThatRequestHandlerCalledWith = new ApplicationContext[1];
    doAnswer(
            invocation -> {
              applicationContextThatRequestHandlerCalledWith[0] = ApplicationContext.getCurrent();
              return null;
            })
        .when(requestHandler)
        .handleRequest(containerRequest, containerResponse);

    everrestProcessor.process(containerRequest, containerResponse, environmentContext);
    assertNotNull(applicationContextThatRequestHandlerCalledWith[0]);
    assertSame(
        containerRequest, applicationContextThatRequestHandlerCalledWith[0].getContainerRequest());
    assertSame(
        containerResponse,
        applicationContextThatRequestHandlerCalledWith[0].getContainerResponse());
    assertSame(
        dependencySupplier,
        applicationContextThatRequestHandlerCalledWith[0].getDependencySupplier());
  }
  @Test
  public void testPrepareResponse() throws UnknownHostException {
    HttpClientSPIAgent httpClientSPIAgent =
        new HttpClientSPIAgent(
            _spiConfiguration, new MockRegistrationReference(new MockIntraband()));

    MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();

    mockHttpServletRequest.setAttribute(WebKeys.SPI_AGENT_PORTLET, _portlet);

    MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();

    HttpServletResponse httpServletResponse =
        httpClientSPIAgent.prepareResponse(mockHttpServletRequest, mockHttpServletResponse);

    Assert.assertSame(
        mockHttpServletResponse,
        mockHttpServletRequest.getAttribute(WebKeys.SPI_AGENT_ORIGINAL_RESPONSE));
    Assert.assertNotNull(mockHttpServletRequest.getAttribute(WebKeys.SPI_AGENT_RESPONSE));

    Assert.assertSame(BufferCacheServletResponse.class, httpServletResponse.getClass());

    BufferCacheServletResponse bufferCacheServletResponse =
        (BufferCacheServletResponse) httpServletResponse;

    ServletResponse servletResponse = bufferCacheServletResponse.getResponse();

    Assert.assertSame(ReadOnlyServletResponse.class, servletResponse.getClass());

    ReadOnlyServletResponse readOnlyServletResponse = (ReadOnlyServletResponse) servletResponse;

    Assert.assertSame(mockHttpServletResponse, readOnlyServletResponse.getResponse());
  }
  @Test
  public void getPullService() {
    assertSame(null, content.getPullService());

    content.setPullService(pullService);
    assertSame(pullService, content.getPullService());
  }
  /**
   * Test the old reader is still open until all searchers using it are closed
   *
   * @throws Exception
   */
  @Test
  public void testOldReaderStillOpenTillAllSearchersClosed() throws Exception {
    final DefaultIndexEngine engine = getRamDirectory();

    final IndexSearcher oldSearcher1 = engine.getSearcher();
    final IndexSearcher oldSearcher2 = engine.getSearcher();
    final IndexSearcher oldSearcher3 = engine.getSearcher();
    final IndexReader reader = oldSearcher1.getIndexReader();
    assertSame("should be same until something is written", oldSearcher1, oldSearcher2);
    assertSame("should be same until something is written", oldSearcher1, oldSearcher3);

    writeTestDocument(engine);

    oldSearcher1.close();

    final IndexSearcher newSearcher = engine.getSearcher();
    assertNotSame(oldSearcher1, newSearcher);
    final IndexReader newReader = newSearcher.getIndexReader();
    assertNotSame(reader, newReader);
    assertReaderOpen(reader);
    assertReaderOpen(newReader);
    oldSearcher2.close();
    assertReaderOpen(reader);
    oldSearcher3.close();
    assertReaderClosed(reader);
    assertReaderOpen(newReader);
  }
예제 #10
0
 @Test
 public void testSameInstance() {
   // If no normalization is required we should get the same instance.
   String id = new String("Example.html");
   assertSame(id, nfn.getFileName(id));
   assertSame(id, nfn.getFileName(new String("Example.html")));
 }
  @Test
  public void testAcceptsComponentParametersForComponent() {
    Reader script =
        new StringReader(
            "A = org.picocontainer.script.testmodel.A\n"
                + "B = org.picocontainer.script.testmodel.B\n"
                + "container {\n"
                + "    component(:key => 'a1', :class => A)\n"
                + "    component(:key => 'a2', :class => A)\n"
                + "    component(:key => 'b1', :class => B, :parameters => [ key('a1') ])\n"
                + "    component(:key => 'b2', :class => B, :parameters => key('a2'))\n"
                + "}");

    PicoContainer pico = buildContainer(script, null, ASSEMBLY_SCOPE);
    A a1 = (A) pico.getComponent("a1");
    A a2 = (A) pico.getComponent("a2");
    B b1 = (B) pico.getComponent("b1");
    B b2 = (B) pico.getComponent("b2");

    assertNotNull(a1);
    assertNotNull(a2);
    assertNotNull(b1);
    assertNotNull(b2);

    assertSame(a1, b1.getA());
    assertSame(a2, b2.getA());
    assertNotSame(a1, a2);
    assertNotSame(b1, b2);
  }
  private void test(Object original, boolean same) throws IOException, ClassNotFoundException {
    try {
      Object marshalled = this.marshaller.marshal(original);

      if (original != null) {
        assertTrue(original instanceof Serializable);
      }
      if (marshalled != null) {
        assertTrue(marshalled instanceof Serializable);
      }

      if (same) {
        assertSame(original, marshalled);
      } else {
        assertNotSame(original, marshalled);
      }

      Object unmarshalled = this.marshaller.unmarshal(marshalled);

      if (same) {
        assertSame(marshalled, unmarshalled);
      } else {
        assertNotSame(marshalled, unmarshalled);
        assertEquals(original, unmarshalled);
      }
    } catch (IllegalArgumentException e) {
      assertFalse(same);
      assertFalse(original instanceof Serializable);
    }
  }
예제 #13
0
 @Test
 public void testWithNullAsKey() throws Exception {
   final T cache = getInstance(1000, 1000);
   final Object o = new Object();
   assertEquals(0, (long) cache.size());
   assertFalse(cache.contains(null));
   assertNull(cache.get(null));
   // Add entry with null as key ...
   cache.put(null, o);
   assertEquals(1, (long) cache.size());
   assertTrue(cache.contains(null));
   assertSame(o, cache.get(null));
   // Add another entry ...
   cache.put(o, o);
   assertEquals(2, (long) cache.size());
   // Remove entry with null as key ...
   assertSame(o, cache.remove(null).getValue());
   assertEquals(1, (long) cache.size());
   assertFalse(cache.contains(null));
   assertNull(cache.get(null));
   // Try to remove entry with null as key again ...
   assertNull(cache.remove(null));
   assertEquals(1, (long) cache.size());
   assertFalse(cache.contains(null));
   assertNull(cache.get(null));
 }
예제 #14
0
  /** The URL instance must be able to set and get an access token instance */
  @Test
  public void testCanSetAndGetAnAccessTokenInstance() {
    final AccessToken accessToken = new AccessToken();

    assertSame(url, url.setAccessToken(accessToken));
    assertSame(accessToken, url.getAccessToken());
  }
예제 #15
0
 /** Moo */
 @Test
 public void testGet() {
   words.add("moo");
   words.add("cow");
   assertSame("moo", words.get(0));
   assertSame("cow", words.get(1));
 }
  @Test
  public void testGetCache() throws Exception {

    // Create on missing

    IntrabandPortalCacheManager<String, String> intraBandPortalCacheManager =
        new IntrabandPortalCacheManager<String, String>(_mockRegistrationReference);

    Map<String, PortalCache<?, ?>> portalCaches = getPortalCaches(intraBandPortalCacheManager);

    Assert.assertTrue(portalCaches.isEmpty());

    String portalCacheName = "portalCacheName";

    PortalCache<?, ?> portalCache = intraBandPortalCacheManager.getCache(portalCacheName);

    Assert.assertNotNull(portalCache);
    Assert.assertEquals(portalCacheName, portalCache.getName());
    Assert.assertEquals(1, portalCaches.size());
    Assert.assertSame(portalCache, portalCaches.get(portalCacheName));

    // Get existing

    PortalCache<?, ?> portalCache2 = intraBandPortalCacheManager.getCache(portalCacheName);

    Assert.assertNotNull(portalCache2);
    Assert.assertEquals(portalCacheName, portalCache2.getName());
    Assert.assertEquals(1, portalCaches.size());
    Assert.assertSame(portalCache, portalCache2);
  }
예제 #17
0
  @Test
  public void toArray() {
    assertTrue(Arrays.equals(toTest.toArray(), new Serializable[] {}));

    toTest.add("Test1");
    toTest.add("Test2");

    assertTrue(Arrays.equals(toTest.toArray(), new String[] {"Test1", "Test2"}));

    String[] sArray = new String[2];
    String[] result = toTest.toArray(sArray);

    assertSame(sArray, result);
    assertTrue(Arrays.equals(sArray, new String[] {"Test1", "Test2"}));

    sArray = new String[3];
    result = toTest.toArray(sArray);

    assertSame(sArray, result);
    assertTrue(Arrays.equals(sArray, new String[] {"Test1", "Test2", null}));

    result = toTest.toArray(new String[] {});

    assertTrue(Arrays.equals(result, new String[] {"Test1", "Test2"}));
  }
예제 #18
0
 private void failTest(Handler<TestContext> thrower) {
   AtomicReference<Throwable> failure = new AtomicReference<>();
   TestSuite suite =
       TestSuite.create("my_suite")
           .test(
               "my_test",
               context -> {
                 try {
                   thrower.handle(context);
                 } catch (Error | RuntimeException e) {
                   failure.set(e);
                   throw e;
                 }
               });
   TestReporter reporter = new TestReporter();
   run(suite, reporter);
   reporter.await();
   assertEquals(0, reporter.exceptions.size());
   assertEquals(1, reporter.results.size());
   TestResult result = reporter.results.get(0);
   assertEquals("my_test", result.name());
   assertFalse(result.succeeded());
   assertTrue(result.failed());
   assertNotNull(result.failure());
   assertSame(failure.get().getMessage(), result.failure().message());
   assertSame(failure.get(), result.failure().cause());
 }
  @Test
  public void testLoadAndSaveAggregate() {
    UUID identifier = UUID.randomUUID();
    DomainEventMessage event1 =
        new GenericDomainEventMessage<String>(
            identifier, (long) 1, "Mock contents", MetaData.emptyInstance());
    DomainEventMessage event2 =
        new GenericDomainEventMessage<String>(
            identifier, (long) 2, "Mock contents", MetaData.emptyInstance());
    when(mockEventStore.readEvents("test", identifier))
        .thenReturn(new SimpleDomainEventStream(event1, event2));

    TestAggregate aggregate = testSubject.load(identifier, null);

    assertEquals(0, aggregate.getUncommittedEventCount());
    assertEquals(2, aggregate.getHandledEvents().size());
    assertSame(event1, aggregate.getHandledEvents().get(0));
    assertSame(event2, aggregate.getHandledEvents().get(1));

    // now the aggregate is loaded (and hopefully correctly locked)
    StubDomainEvent event3 = new StubDomainEvent();

    aggregate.apply(event3);

    CurrentUnitOfWork.commit();

    verify(mockEventBus).publish(isA(DomainEventMessage.class));
    verify(mockEventBus, never()).publish(event1);
    verify(mockEventBus, never()).publish(event2);
    verify(mockEventStore, times(1)).appendEvents(eq("test"), isA(DomainEventStream.class));
    assertEquals(0, aggregate.getUncommittedEventCount());
  }
  @Test
  public void testGetPredicate() {
    String[] data = {"a", "b", "c"};
    DynamicUserDefinedPredicateFactory dp = createDynamicPredicate();
    for (String d : data) {
      addLast(dp, d);
    }

    // test evaluate with atom as argument
    for (String d : data) {
      Term inputArg = atom(d);
      Term[] args = new Term[] {inputArg};
      Predicate e = dp.getPredicate(args);
      assertTrue(e.isRetryable());
      assertTrue(e.evaluate(args));
      assertSame(inputArg, args[0]);
      assertFalse(e.evaluate(args));
      assertSame(inputArg, args[0]);
    }

    // test evaluate with variable as argument
    Term inputArg = variable();
    Term[] args = new Term[] {inputArg};
    Predicate e = dp.getPredicate(args);
    assertTrue(e.isRetryable());
    for (String d : data) {
      assertTrue(e.evaluate(args));
      assertSame(TermType.ATOM, args[0].getType());
      assertEquals(d, args[0].getName());
    }
    assertFalse(e.evaluate(args));
    assertSame(inputArg, args[0]);
    assertSame(inputArg, args[0].getTerm());
  }
예제 #21
0
 private void assertCalloutExceptionIsFilled(
     final CalloutException exception, final ICalloutField field) {
   Assert.assertSame(
       "Invalid executor for " + exception, calloutExecutor, exception.getCalloutExecutor());
   Assert.assertSame("Invalid field for " + exception, field, exception.getCalloutField());
   // exception.getCalloutInstance();
 }
  @Test
  public void testSetArguments()
      throws NoSuchFieldException, SecurityException, IllegalArgumentException,
          IllegalAccessException {
    TestBean bean = new TestBean();
    TestMethodProperty<String> property = new TestMethodProperty<String>(bean, "name");
    Object[] getArgs = property.getGetArgs();
    Object[] setArgs = property.getSetArgs();

    Field getArgsField = TestMethodProperty.class.getDeclaredField("getArgs");
    getArgsField.setAccessible(true);

    Field setArgsField = TestMethodProperty.class.getDeclaredField("setArgs");
    setArgsField.setAccessible(true);

    Assert.assertSame(
        "setArguments method sets non-default instance" + " of empty Object array for getArgs",
        getArgsField.get(property),
        getArgs);

    Assert.assertSame(
        "setArguments method sets non-default instance" + " of empty Object array for setArgs",
        setArgsField.get(property),
        setArgs);
  }
  @Test
  public void setKeyPreservation() {
    Key key = new Key("key");

    Key duplicateKey1 = new Key("key");
    MutableSet<Key> set1 =
        UnifiedSetWithHashingStrategy.newSet(HashingStrategies.<Key>defaultStrategy())
            .with(key, duplicateKey1);
    Verify.assertSize(1, set1);
    Verify.assertContains(key, set1);
    Assert.assertSame(key, set1.getFirst());

    Key duplicateKey2 = new Key("key");
    MutableSet<Key> set2 =
        UnifiedSetWithHashingStrategy.newSet(HashingStrategies.<Key>defaultStrategy())
            .with(key, duplicateKey1, duplicateKey2);
    Verify.assertSize(1, set2);
    Verify.assertContains(key, set2);
    Assert.assertSame(key, set2.getFirst());

    Key duplicateKey3 = new Key("key");
    MutableSet<Key> set3 =
        UnifiedSetWithHashingStrategy.newSet(HashingStrategies.<Key>defaultStrategy())
            .with(key, new Key("not a dupe"), duplicateKey3);
    Verify.assertSize(2, set3);
    Verify.assertContainsAll(set3, key, new Key("not a dupe"));
    Assert.assertSame(key, set3.detect(key::equals));
  }
  @Test
  public void testLongConstructor() {
    Rectangle node = new Rectangle(10, 10);
    node.setTranslateX(3);
    node.setTranslateY(2);
    node.setTranslateZ(50);
    Rectangle n1 = new Rectangle(10, 10);
    Rectangle n2 = new Rectangle(10, 10);

    PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);
    ContextMenuEvent e =
        new ContextMenuEvent(
            n1, n2, ContextMenuEvent.CONTEXT_MENU_REQUESTED, 10, 20, 30, 40, false, pickRes);
    assertSame(n1, e.getSource());
    assertSame(n2, e.getTarget());
    assertSame(ContextMenuEvent.CONTEXT_MENU_REQUESTED, e.getEventType());
    assertEquals(18, e.getX(), 10e-20);
    assertEquals(27, e.getY(), 10e-20);
    assertEquals(150, e.getZ(), 10e-20);
    assertEquals(10, e.getSceneX(), 10e-20);
    assertEquals(20, e.getSceneY(), 10e-20);
    assertEquals(30, e.getScreenX(), 10e-20);
    assertEquals(40, e.getScreenY(), 10e-20);
    assertFalse(e.isKeyboardTrigger());
    assertFalse(e.isConsumed());
    assertSame(pickRes, e.getPickResult());

    e = new ContextMenuEvent(ContextMenuEvent.CONTEXT_MENU_REQUESTED, 10, 20, 30, 40, true, null);
    assertTrue(e.isKeyboardTrigger());
  }
  @Test
  public void put_with_hashingStrategy() {
    UnifiedSetWithHashingStrategy<Person> people =
        UnifiedSetWithHashingStrategy.newSet(
                HashingStrategies.nullSafeHashingStrategy(LAST_NAME_HASHING_STRATEGY), 2)
            .withAll(PEOPLE.castToList());
    // Testing if element already exists, returns the instance in the set
    Assert.assertSame(JOHNSMITH, people.put(new Person("Anything", "Smith")));
    Verify.assertSize(2, people);

    // Testing if the element doesn't exist, returns the element itself
    Person notInSet = new Person("Not", "inSet");
    Assert.assertSame(notInSet, people.put(notInSet));
    Verify.assertSize(3, people);

    // Testing putting a null to force a rehash
    Assert.assertNull(people.put(null));
    Verify.assertSize(4, people);

    // Testing put throws NullPointerException if the hashingStrategy is not null safe
    Verify.assertThrows(
        NullPointerException.class,
        () -> {
          UnifiedSetWithHashingStrategy.newSet(LAST_NAME_HASHING_STRATEGY).put(null);
        });
  }
예제 #26
0
 @Test
 public void shouldHaveSameByteOrder() {
   ByteBuf buf = Unpooled.buffer(1);
   assertSame(Unpooled.BIG_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
   buf = buf.order(LITTLE_ENDIAN);
   assertSame(Unpooled.LITTLE_ENDIAN, Unpooled.unmodifiableBuffer(buf).order());
 }
  /** Tests nextElement() method. */
  @Test
  public void testNextElement() {
    List<TransactionJobDescriptorEntry> entries = new ArrayList<TransactionJobDescriptorEntry>();
    final TransactionJobDescriptorEntryImpl jobDescriptorEntry1 =
        new TransactionJobDescriptorEntryImpl();
    final TransactionJobDescriptorEntryImpl jobDescriptorEntry2 =
        new TransactionJobDescriptorEntryImpl();
    final TransactionJobDescriptorEntryImpl jobDescriptorEntry3 =
        new TransactionJobDescriptorEntryImpl();
    entries.add(jobDescriptorEntry1);
    entries.add(jobDescriptorEntry2);
    entries.add(jobDescriptorEntry3);

    entryIterator.initialize(entries, Arrays.asList(("2")));
    Assert.assertTrue(entryIterator.hasNextElement());

    final List<TransactionJobDescriptorEntry> nextElement1 = entryIterator.nextElement();
    Assert.assertEquals(2, nextElement1.size());
    Assert.assertSame(jobDescriptorEntry1, nextElement1.get(0));
    Assert.assertSame(jobDescriptorEntry2, nextElement1.get(1));
    Assert.assertTrue(entryIterator.hasNextElement());

    final List<TransactionJobDescriptorEntry> nextElement2 = entryIterator.nextElement();
    Assert.assertEquals(1, nextElement2.size());
    Assert.assertSame(jobDescriptorEntry3, nextElement2.get(0));

    Assert.assertFalse(entryIterator.hasNextElement());
  }
  @Test
  public void testRemoveAndClear() throws Exception {
    IntrabandPortalCacheManager<String, String> intraBandPortalCacheManager =
        new IntrabandPortalCacheManager<String, String>(_mockRegistrationReference);

    String portalCacheName1 = "portalCacheName1";

    PortalCache<?, ?> portalCache1 = intraBandPortalCacheManager.getCache(portalCacheName1);

    String portalCacheName2 = "portalCacheName2";

    PortalCache<?, ?> portalCache2 = intraBandPortalCacheManager.getCache(portalCacheName2);

    Map<String, PortalCache<?, ?>> portalCaches = getPortalCaches(intraBandPortalCacheManager);

    Assert.assertEquals(2, portalCaches.size());
    Assert.assertSame(portalCache1, portalCaches.get(portalCacheName1));
    Assert.assertSame(portalCache2, portalCaches.get(portalCacheName2));

    intraBandPortalCacheManager.removeCache(portalCacheName1);

    Assert.assertEquals(1, portalCaches.size());
    Assert.assertSame(portalCache2, portalCaches.get(portalCacheName2));

    intraBandPortalCacheManager.clearAll();

    Assert.assertTrue(portalCaches.isEmpty());
  }
예제 #29
0
  @Test
  public void extend_overrideField() throws Exception {
    field3.setName("field1"); // group2.field1 overrides group1.field1

    group1 = new GroupConfigImpl();
    group1.setName("group1");
    group1.setFieldConfigImplList(createFieldList(field1));
    group1.afterPropertiesSet();

    group2 = new GroupConfigImpl();
    group2.setName("group2");
    group2.setFieldConfigImplList(createFieldList(field2, field3));
    group2.setParentGroup("group1");
    group2.afterPropertiesSet();

    formConfig.setGroupConfigImplList(createGroupList(group1, group2));
    formConfig.afterPropertiesSet();

    assertEquals(1, group1.getFieldConfigList().size());
    assertSame(field1, group1.getFieldConfig("field1"));

    assertEquals(2, group2.getFieldConfigList().size());
    assertSame(field3, group2.getFieldConfig("field1"));
    assertSame(field2, group2.getFieldConfig("field2"));
  }
  /** Test of constructors of class CategoryBalancedBaggingLearner. */
  @Test
  public void testConstructors() {
    Perceptron learner = null;
    double percentToSample = BaggingCategorizerLearner.DEFAULT_PERCENT_TO_SAMPLE;
    int maxIterations = BaggingCategorizerLearner.DEFAULT_MAX_ITERATIONS;
    CategoryBalancedBaggingLearner<Vector, Boolean> instance =
        new CategoryBalancedBaggingLearner<Vector, Boolean>();
    assertSame(learner, instance.getLearner());
    assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
    assertEquals(maxIterations, instance.getMaxIterations());
    assertNotNull(instance.getRandom());

    learner = new Perceptron();
    instance = new CategoryBalancedBaggingLearner<Vector, Boolean>(learner);
    assertSame(learner, instance.getLearner());
    assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
    assertEquals(maxIterations, instance.getMaxIterations());
    assertNotNull(instance.getRandom());

    percentToSample = percentToSample / 3.4;
    maxIterations = maxIterations * 9;
    instance =
        new CategoryBalancedBaggingLearner<Vector, Boolean>(
            learner, maxIterations, percentToSample, random);
    assertSame(learner, instance.getLearner());
    assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
    assertEquals(maxIterations, instance.getMaxIterations());
    assertSame(random, instance.getRandom());
  }