### Question:
PaletteFactory { public static synchronized PaletteFactory getDefault() { if (defaultFactory == null) { defaultFactory = new PaletteFactory(); scanForPlugins(null); } return defaultFactory; } protected  PaletteFactory();  PaletteFactory(final File    directory,
                          final String  extension,
                          final Charset charset,
                          final Locale  locale);  PaletteFactory(final PaletteFactory fallback,
                          final ClassLoader    loader,
                          final File           directory,
                          final String         extension,
                          final Charset        charset,
                          final Locale         locale);  PaletteFactory(final PaletteFactory fallback,
                          final Class<?>       loader,
                          final File           directory,
                          final String         extension,
                          final Charset        charset,
                          final Locale         locale); static synchronized PaletteFactory getDefault(); static synchronized void scanForPlugins(final ClassLoader loader); synchronized void setWarningLocale(final Locale warningLocale); synchronized Locale getWarningLocale(); Set<String> getAvailableNames(); Color[] getColors(final String name); Palette getPalette(final String name, final int size); Palette getPalettePadValueFirst(final String name, final int size); Palette getPalettePadValueLast(final String name, final int size); Palette getPalette(final String name, final int lower, final int upper, final int size,
                              final int numBands, final int visibleBand); Palette getContinuousPalette(final String name, final float minimum, final float maximum,
                                        final int dataType, final int numBands, final int visibleBand);  }### Answer:
@Test public void testConstructor() { final PaletteFactory factory = PaletteFactory.getDefault(); assertEquals(100, new IndexedPalette(factory, "grayscale", 0, 100, 100, 1, 0).upper); assertEquals( 50, new IndexedPalette(factory, "grayscale", -100, 50, 100, 1, 0).upper); try { new IndexedPalette(factory, "grayscale", 0, 100, -100, 1, 0); fail("Should not accept negative size."); } catch (IllegalArgumentException e) { } try { new IndexedPalette(factory, "grayscale", 100, 50, 256, 1, 0); fail("Should not accept invalid range."); } catch (IllegalArgumentException e) { } assertEquals(40000, new IndexedPalette(factory, "grayscale", 1, 40000, 0xFFFF, 1, 0).upper); try { new IndexedPalette(factory, "grayscale", -1, 40000, 0xFFFF, 1, 0); fail("Should not accept value out of range."); } catch (IllegalArgumentException e) { } try { new IndexedPalette(factory, "grayscale", 1, 70000, 0xFFFF, 1, 0); fail("Should not accept value out of range."); } catch (IllegalArgumentException e) { } try { new IndexedPalette(factory, "grayscale", -40000, 0, 0xFFFF, 1, 0); fail("Should not accept value out of range."); } catch (IllegalArgumentException e) { } }